mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-23 14:49:10 +02: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}
|
||||
// LCL
|
||||
ExtDlgs, Dialogs, Controls, Forms, LCLStrConsts, LMessages,
|
||||
LCLProc, LCLIntf, LCLType, gtkDef, DynHashArray, gtkMsgQueue,
|
||||
GraphType, GraphMath, Graphics, Menus;
|
||||
LCLProc, LCLIntf, LCLType, gtkDef, GtkProc, DynHashArray,
|
||||
gtkMsgQueue, GraphType, GraphMath, Graphics, Menus;
|
||||
|
||||
|
||||
type
|
||||
@ -113,6 +113,8 @@ type
|
||||
FStockBlackPen: HPEN;
|
||||
FStockWhitePen: HPEN;
|
||||
|
||||
FWaitHandles: PWaitHandleEventHandler;
|
||||
|
||||
{$Ifdef GTK2}
|
||||
FDefaultFontDesc: PPangoFontDescription;
|
||||
{$Else}
|
||||
@ -338,7 +340,7 @@ uses
|
||||
////////////////////////////////////////////////////
|
||||
Buttons, StdCtrls, PairSplitter, Math,
|
||||
GTKWinApiWindow, ComCtrls, CListBox, Calendar, Arrow, Spin, CommCtrl,
|
||||
ExtCtrls, FileCtrl, LResources, gtkglobals, gtkproc;
|
||||
ExtCtrls, FileCtrl, LResources, gtkglobals;
|
||||
|
||||
const
|
||||
GtkNil = nil;
|
||||
|
@ -29,6 +29,48 @@
|
||||
|
||||
//##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;
|
||||
Horizontal: boolean): Integer;
|
||||
|
@ -29,6 +29,7 @@
|
||||
}
|
||||
|
||||
//##apiwiz##sps## // Do not remove
|
||||
procedure AddEventHandler(AHandle: THandle; AEventHandler: TNotifyEvent); override;
|
||||
function DrawSplitter(DC: HDC; const ARect: TRect; Horizontal: boolean): boolean; override;
|
||||
|
||||
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;
|
||||
|
||||
procedure RemoveEventHandler(AHandle: THandle); override;
|
||||
function ReplaceBitmapMask(var Image, Mask: HBitmap; NewMask: HBitmap): boolean; override;
|
||||
|
||||
//##apiwiz##eps## // Do not remove, no wizard declaration after this line
|
||||
|
@ -57,6 +57,17 @@ uses
|
||||
FileUtil, ImgList, GTKGlobals, gtkDef;
|
||||
|
||||
|
||||
type
|
||||
PPWaitHandleEventHandler = ^PWaitHandleEventHandler;
|
||||
PWaitHandleEventHandler = ^TWaitHandleEventHandler;
|
||||
TWaitHandleEventHandler = record
|
||||
Handle: THandle;
|
||||
GIOChannel: pgiochannel;
|
||||
GSourceID: guint;
|
||||
OnEvent: TNotifyEvent;
|
||||
NextHandler: PWaitHandleEventHandler;
|
||||
end;
|
||||
|
||||
{$IFDEF gtk2}
|
||||
const
|
||||
gdkdll = gdklib;
|
||||
|
Loading…
Reference in New Issue
Block a user