idle
This commit is contained in:
JianjunLiu 2022-11-24 14:14:16 +08:00
parent af29344e72
commit efe547e628
4 changed files with 103 additions and 94 deletions

View File

@ -215,10 +215,10 @@ type tapplication=class(tcomponent)
**} **}
initialize(); initialize();
{$ifdef linuxgtk} {$ifdef linuxgtk}
idledata :=(new tcbytearray(4))._getptr_(); //idledata :=(new tcbytearray(4))._getptr_();
id := tsl_gtk_idle_interface(idledata);//_wapi.tsl_gtk_idle_interface(idledata); //¹¹Ôìidle //id := tsl_gtk_idle_interface(idledata);//_wapi.tsl_gtk_idle_interface(idledata); //¹¹Ôìidle
_wapi.gtk_main(); _wapi.gtk_main();
_Wapi.g_idle_remove_by_data(idledata); //ɾ³ýidle //_Wapi.g_idle_remove_by_data(idledata); //ɾ³ýidle
return 1; return 1;
{$endif} {$endif}
if not FMessageObj then FMessageObj := new TTagMSG(); if not FMessageObj then FMessageObj := new TTagMSG();

View File

@ -6630,8 +6630,6 @@ type tGtkMessageQueue = class //
@ignore(忽略) @ignore(忽略)
gtk消息队列 gtk消息队列
**} **}
private
public public
function Create(); function Create();
begin begin
@ -6643,26 +6641,28 @@ type tGtkMessageQueue = class //
function Add(h,m,l,w,obj); function Add(h,m,l,w,obj);
begin begin
lock(); lock();
FLen++;
FData[FLen]:= array(h,m,l,w,obj); FData[FLen]:= array(h,m,l,w,obj);
if FCurrent=FLen then
begin
createidle();
end
FLen++;
unlock(); unlock();
end end
function Feach(); function Feach();
begin begin
lock(); lock();
if FCurrent<FLen then if FCurrent<FLen then
begin begin
FCurrent++;
r := FData[FCurrent]; r := FData[FCurrent];
if (FCurrent+1<FLen) and FCurrent>100 then FCurrent++;
if(FCurrent<FLen)and FCurrent>100 then
begin begin
FData := FData[FCurrent+1:];//min(FLen-1,FCurrent+100)]; FData := FData[FCurrent:]; //min(FLen-1,FCurrent+100)];
FCurrent := -1; FCurrent :=0;
FLen := length(FData); FLen := length(FData);
end end
end end else
else
begin begin
Clean(); Clean();
end end
@ -6675,11 +6675,11 @@ type tGtkMessageQueue = class //
lock(); lock();
while idx<FLen do while idx<FLen do
begin begin
idx++;
if FData[idx][0]=h and FData[idx][0]=m then if FData[idx][0]=h and FData[idx][0]=m then
begin begin
FData[idx][0]:= 0; FData[idx][0]:= 0;
end end
idx++;
end end
unlock(); unlock();
end end
@ -6688,21 +6688,19 @@ type tGtkMessageQueue = class //
idx := FCurrent; idx := FCurrent;
if idx<FLen then if idx<FLen then
begin begin
idx++;
if((h=-1)or(FData[idx][0]=h))and FData[idx][0]=m then if((h=-1)or(FData[idx][0]=h))and FData[idx][0]=m then
begin begin
return 1; return 1;
end end
idx++;
end end
end end
private private
function Clean(); function Clean();
begin begin
FData := array(); FData := array();
FLen := 0; FLen := 0;
FCurrent := -1; FCurrent :=0;
end end
FData; FData;
FCurrent; FCurrent;
@ -6731,6 +6729,7 @@ type tGtkMessageQueue = class //
end end
end end
end end
function _gtkeventcall_();//消息回调 function _gtkeventcall_();//消息回调
begin begin
r := class(tgtk_ctl_object).DispatchGtkEventCall(params); r := class(tgtk_ctl_object).DispatchGtkEventCall(params);
@ -6839,6 +6838,11 @@ begin
_wapi.cairo_destroy(cr); _wapi.cairo_destroy(cr);
_wapi.gtk_object_set_data(cr); _wapi.gtk_object_set_data(cr);
end end
function createidle();
begin
idledata :=(new tcbytearray(4))._getptr_();
id := tsl_gtk_idle_interface(idledata);
end
function _gtkidledo_(); //回调 function _gtkidledo_(); //回调
begin begin
d := FeachMessageFromGtkMessageQueue(); d := FeachMessageFromGtkMessageQueue();
@ -6873,19 +6877,22 @@ begin
return 1; return 1;
end end
return r; return 1; //r
end end
else else
begin begin
tslprocessmessages(false); tslprocessmessages(false);
//sleep(10); //sleep(10);
end end
r := 1;
end else end else
begin begin
r := 0;
tslprocessmessages(false); tslprocessmessages(false);
//sleep(10);//休息一下 //sleep(10);//休息一下
end end
unit(uvclthreadworker).RunThreadWorkerHost(); unit(uvclthreadworker).RunThreadWorkerHost();
return r;
end end
procedure tslprocessmessages()begin end; procedure tslprocessmessages()begin end;
function InitGtkWindowClass(); //初始化窗口类 function InitGtkWindowClass(); //初始化窗口类

View File

@ -5566,6 +5566,7 @@ type TcustomStatusBar=class(TCustomControl)
if nv<>FItemOder then if nv<>FItemOder then
begin begin
FItemOder := nv; FItemOder := nv;
if FItems then
InvalidateRect(nil,false); InvalidateRect(nil,false);
end end
end end
@ -6769,6 +6770,7 @@ end
initialization initialization
{$ifdef linux} {$ifdef linux}
class(tUIglobalData).uisetdata("G_T_TTIMER_",class(TCustomTimer)); class(tUIglobalData).uisetdata("G_T_TTIMER_",class(TCustomTimer));
class(TCustomTimer)._wapi.SetTimer(nil,10000,100,getwinprocptr(2));
{$endif} {$endif}
end. end.