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

@ -40,7 +40,7 @@ type TVclDesignerStart = class(TVclDesigner) //ʵ
_wapi.bringWindowToTop(self.Handle);
end
inherited;
end
end
function CreateParams(p);override;
begin
inherited;

View File

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

View File

@ -6625,112 +6625,111 @@ function g_main_context_new():pointer;cdecl;external "libgtk-3.so";
function g_main_context_ref(m:pointer):pointer;cdecl;external "libgtk-3.so";
function g_main_context_acquire(m:pointer):integer;cdecl;external "libgtk-3.so";
procedure g_main_context_release(m:pointer);cdecl;external "libgtk-3.so";
type tGtkMessageQueue = class //ÏûÏ¢¶ÓÁÐ
{**
type tGtkMessageQueue=class //ÏûÏ¢¶ÓÁÐ
{**
@ignore(忽略)
gtk消息队列
**}
private
public
function Create();
begin
Clean();
FMainContext := g_main_context_new();
g_main_context_ref(FMainContext);
fLock := 0;
end
function Add(h,m,l,w,obj);
begin
lock();
FLen++;
FData[FLen] := array(h,m,l,w,obj);
unlock();
end
function Feach();
begin
lock();
if FCurrent<FLen then
begin
FCurrent++;
r := FData[FCurrent];
if (FCurrent+1<FLen) and FCurrent>100 then
begin
FData := FData[FCurrent+1:];//min(FLen-1,FCurrent+100)];
FCurrent := -1;
FLen := length(FData);
end
end
else
begin
Clean();
end
unlock();
return r;
end
function cleaneasyLostMessage(h,m);
begin
idx := FCurrent;
lock();
while idx<FLen do
begin
idx++;
if FData[idx][0]=h and FData[idx][0]=m then
begin
FData[idx][0] := 0;
end
end
unlock();
end
function haseasyLostMessage(h,m);
begin
idx := FCurrent;
if idx<FLen then
begin
idx++;
if ((h=-1) or (FData[idx][0]=h)) and FData[idx][0]=m then
begin
return 1;
end
end
end
private
function Clean();
begin
FData := array();
FLen := 0;
FCurrent := -1;
end
FData;
FCurrent;
FLen;
FLock ;
FMainContext;
**}
public
function Create();
begin
Clean();
FMainContext := g_main_context_new();
g_main_context_ref(FMainContext);
fLock := 0;
end
function Add(h,m,l,w,obj);
begin
lock();
FData[FLen]:= array(h,m,l,w,obj);
if FCurrent=FLen then
begin
createidle();
end
FLen++;
unlock();
end
function Feach();
begin
lock();
if FCurrent<FLen then
begin
r := FData[FCurrent];
FCurrent++;
if(FCurrent<FLen)and FCurrent>100 then
begin
FData := FData[FCurrent:]; //min(FLen-1,FCurrent+100)];
FCurrent :=0;
FLen := length(FData);
end
end else
begin
Clean();
end
unlock();
return r;
end
function cleaneasyLostMessage(h,m);
begin
idx := FCurrent;
lock();
while idx<FLen do
begin
if FData[idx][0]=h and FData[idx][0]=m then
begin
FData[idx][0]:= 0;
end
idx++;
end
unlock();
end
function haseasyLostMessage(h,m);
begin
idx := FCurrent;
if idx<FLen then
begin
if((h=-1)or(FData[idx][0]=h))and FData[idx][0]=m then
begin
return 1;
end
idx++;
end
end
private
function Clean();
begin
FData := array();
FLen := 0;
FCurrent :=0;
end
FData;
FCurrent;
FLen;
FLock;
FMainContext;
function lock()
begin
return ;
return;
fLock++;
if (fLock=1 )then
if(fLock=1)then
begin
g_main_context_acquire(FMainContext);
end
end
function unlock()
begin
return ;
if (fLock>0) then
return;
if(fLock>0)then
begin
fLock--;
if (fLock=0) then
if(fLock=0)then
begin
g_main_context_release(FMainContext);
end
end
end
end
end
function _gtkeventcall_();//消息回调
begin
r := class(tgtk_ctl_object).DispatchGtkEventCall(params);
@ -6839,6 +6838,11 @@ begin
_wapi.cairo_destroy(cr);
_wapi.gtk_object_set_data(cr);
end
function createidle();
begin
idledata :=(new tcbytearray(4))._getptr_();
id := tsl_gtk_idle_interface(idledata);
end
function _gtkidledo_(); //回调
begin
d := FeachMessageFromGtkMessageQueue();
@ -6873,19 +6877,22 @@ begin
return 1;
end
return r;
return 1; //r
end
else
begin
tslprocessmessages(false);
//sleep(10);
end
r := 1;
end else
begin
r := 0;
tslprocessmessages(false);
//sleep(10);//休息一下
end
unit(uvclthreadworker).RunThreadWorkerHost();
return r;
end
procedure tslprocessmessages()begin end;
function InitGtkWindowClass(); //初始化窗口类

View File

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