mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-06 04:57:12 +01:00
implement calling event for handle activity in main loop for gtk
git-svn-id: trunk@8169 -
This commit is contained in:
parent
ed60dffb71
commit
a02ab953ca
@ -81,8 +81,8 @@ uses
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
// LCL
|
// LCL
|
||||||
ExtDlgs, Dialogs, Controls, Forms, LCLStrConsts, LMessages,
|
ExtDlgs, Dialogs, Controls, Forms, LCLStrConsts, LMessages,
|
||||||
LCLProc, LCLIntf, LCLType, gtkDef, DynHashArray, gtkMsgQueue,
|
LCLProc, LCLIntf, LCLType, gtkDef, GtkProc, DynHashArray,
|
||||||
GraphType, GraphMath, Graphics, Menus;
|
gtkMsgQueue, GraphType, GraphMath, Graphics, Menus;
|
||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -113,6 +113,8 @@ type
|
|||||||
FStockBlackPen: HPEN;
|
FStockBlackPen: HPEN;
|
||||||
FStockWhitePen: HPEN;
|
FStockWhitePen: HPEN;
|
||||||
|
|
||||||
|
FWaitHandles: PWaitHandleEventHandler;
|
||||||
|
|
||||||
{$Ifdef GTK2}
|
{$Ifdef GTK2}
|
||||||
FDefaultFontDesc: PPangoFontDescription;
|
FDefaultFontDesc: PPangoFontDescription;
|
||||||
{$Else}
|
{$Else}
|
||||||
@ -338,7 +340,7 @@ uses
|
|||||||
////////////////////////////////////////////////////
|
////////////////////////////////////////////////////
|
||||||
Buttons, StdCtrls, PairSplitter, Math,
|
Buttons, StdCtrls, PairSplitter, Math,
|
||||||
GTKWinApiWindow, ComCtrls, CListBox, Calendar, Arrow, Spin, CommCtrl,
|
GTKWinApiWindow, ComCtrls, CListBox, Calendar, Arrow, Spin, CommCtrl,
|
||||||
ExtCtrls, FileCtrl, LResources, gtkglobals, gtkproc;
|
ExtCtrls, FileCtrl, LResources, gtkglobals;
|
||||||
|
|
||||||
const
|
const
|
||||||
GtkNil = nil;
|
GtkNil = nil;
|
||||||
|
|||||||
@ -29,6 +29,48 @@
|
|||||||
|
|
||||||
//##apiwiz##sps## // Do not remove
|
//##apiwiz##sps## // Do not remove
|
||||||
|
|
||||||
|
function waithandle_iocallback(source: PGIOChannel; condition: TGIOCondition;
|
||||||
|
data: gpointer): gboolean; cdecl;
|
||||||
|
begin
|
||||||
|
TNotifyEvent(data^)(WidgetSet);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TGtkWidgetSet.AddEventHandler(AHandle: THandle; AEventHandler: TNotifyEvent);
|
||||||
|
var
|
||||||
|
giochannel: pgiochannel;
|
||||||
|
lEventHandler: PWaitHandleEventHandler;
|
||||||
|
begin
|
||||||
|
New(lEventHandler);
|
||||||
|
giochannel := g_io_channel_unix_new(AHandle);
|
||||||
|
lEventHandler^.Handle := AHandle;
|
||||||
|
lEventHandler^.GIOChannel := giochannel;
|
||||||
|
lEventHandler^.OnEvent := AEventHandler;
|
||||||
|
lEventHandler^.GSourceID := g_io_add_watch(giochannel,
|
||||||
|
G_IO_IN, @waithandle_iocallback, @lEventHandler^.OnEvent);
|
||||||
|
lEventHandler^.NextHandler := FWaitHandles;
|
||||||
|
FWaitHandles := lEventHandler;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TGtkWidgetSet.RemoveEventHandler(AHandle: THandle);
|
||||||
|
var
|
||||||
|
lEventHandler: PWaitHandleEventHandler;
|
||||||
|
lPrevEventHandler: PPWaitHandleEventHandler;
|
||||||
|
begin
|
||||||
|
lPrevEventHandler := @FWaitHandles;
|
||||||
|
while lPrevEventHandler^ <> nil do
|
||||||
|
begin
|
||||||
|
lEventHandler := lPrevEventHandler^;
|
||||||
|
if lEventHandler^.Handle = AHandle then
|
||||||
|
begin
|
||||||
|
g_source_remove(lEventHandler^.GSourceID);
|
||||||
|
lPrevEventHandler^ := lEventHandler^.NextHandler;
|
||||||
|
Dispose(lEventHandler);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
lPrevEventHandler := @lEventHandler^.NextHandler;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
function TGtkWidgetSet.DrawSplitter(DC: HDC; const ARect: TRect;
|
function TGtkWidgetSet.DrawSplitter(DC: HDC; const ARect: TRect;
|
||||||
Horizontal: boolean): Integer;
|
Horizontal: boolean): Integer;
|
||||||
|
|||||||
@ -29,6 +29,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//##apiwiz##sps## // Do not remove
|
//##apiwiz##sps## // Do not remove
|
||||||
|
procedure AddEventHandler(AHandle: THandle; AEventHandler: TNotifyEvent); override;
|
||||||
function DrawSplitter(DC: HDC; const ARect: TRect; Horizontal: boolean): boolean; override;
|
function DrawSplitter(DC: HDC; const ARect: TRect; Horizontal: boolean): boolean; override;
|
||||||
|
|
||||||
function ExtUTF8Out(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect;
|
function ExtUTF8Out(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect;
|
||||||
@ -44,6 +45,7 @@ function GetListBoxItemRect(ListBox: TComponent; Index: integer; var ARect: TRec
|
|||||||
|
|
||||||
function IntfSendsUTF8KeyPress: boolean; override;
|
function IntfSendsUTF8KeyPress: boolean; override;
|
||||||
|
|
||||||
|
procedure RemoveEventHandler(AHandle: THandle); override;
|
||||||
function ReplaceBitmapMask(var Image, Mask: HBitmap; NewMask: HBitmap): boolean; override;
|
function ReplaceBitmapMask(var Image, Mask: HBitmap; NewMask: HBitmap): boolean; override;
|
||||||
|
|
||||||
//##apiwiz##eps## // Do not remove, no wizard declaration after this line
|
//##apiwiz##eps## // Do not remove, no wizard declaration after this line
|
||||||
|
|||||||
@ -57,6 +57,17 @@ uses
|
|||||||
FileUtil, ImgList, GTKGlobals, gtkDef;
|
FileUtil, ImgList, GTKGlobals, gtkDef;
|
||||||
|
|
||||||
|
|
||||||
|
type
|
||||||
|
PPWaitHandleEventHandler = ^PWaitHandleEventHandler;
|
||||||
|
PWaitHandleEventHandler = ^TWaitHandleEventHandler;
|
||||||
|
TWaitHandleEventHandler = record
|
||||||
|
Handle: THandle;
|
||||||
|
GIOChannel: pgiochannel;
|
||||||
|
GSourceID: guint;
|
||||||
|
OnEvent: TNotifyEvent;
|
||||||
|
NextHandler: PWaitHandleEventHandler;
|
||||||
|
end;
|
||||||
|
|
||||||
{$IFDEF gtk2}
|
{$IFDEF gtk2}
|
||||||
const
|
const
|
||||||
gdkdll = gdklib;
|
gdkdll = gdklib;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user