diff options
author | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-03-19 21:09:55 +0000 |
---|---|---|
committer | graemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2008-03-19 21:09:55 +0000 |
commit | 1f7bbc75ab6a277868fe9ef7594e015db6295a45 (patch) | |
tree | cb81b1987c80ae5f24f475aec53682354dce9878 | |
parent | 9e654476e33a447d04e056e6a16c5d5fca3ab654 (diff) | |
download | fpGUI-1f7bbc75ab6a277868fe9ef7594e015db6295a45.tar.xz |
* X11: Implemented an Application.OnIdle event.
* X11: Implemented an experimental EventFilter hook.
-rw-r--r-- | src/corelib/gfxbase.pas | 2 | ||||
-rw-r--r-- | src/corelib/x11/gfx_x11.pas | 24 |
2 files changed, 21 insertions, 5 deletions
diff --git a/src/corelib/gfxbase.pas b/src/corelib/gfxbase.pas index fadde046..5129fbb3 100644 --- a/src/corelib/gfxbase.pas +++ b/src/corelib/gfxbase.pas @@ -386,6 +386,7 @@ type FTerminated: boolean; function GetTopModalForm: TfpgWindowBase; protected + FOnIdle: TNotifyEvent; FIsInitialized: Boolean; FModalFormStack: TList; function DoGetFontFaceList: TStringList; virtual; abstract; @@ -408,6 +409,7 @@ type { TODO : Implement these two properties in the near future. } // property FormCount... // property Forms[]... + property OnIdle: TNotifyEvent read FOnIdle write FOnIdle; end; diff --git a/src/corelib/x11/gfx_x11.pas b/src/corelib/x11/gfx_x11.pas index adc1df8f..49b58825 100644 --- a/src/corelib/x11/gfx_x11.pas +++ b/src/corelib/x11/gfx_x11.pas @@ -27,34 +27,37 @@ const $b4, $24, $a4, $24, $18, $73, $00, $00); type - TfpgGContext = Xlib.TGc; -type + TfpgGContext = Xlib.TGc; PInt = ^integer; + TXIC = record dummy: Pointer; end; PXIC = ^TXIC; + TXIM = record dummy: Pointer; end; PXIM = ^TXIM; - PXdbeSwapInfo = ^TXdbeSwapInfo; TXdbeSwapInfo = record Window: TfpgWinHandle; SwapAction: PChar; end; + PXdbeSwapInfo = ^TXdbeSwapInfo; -type TXWindowStateFlag = (xwsfMapped); - TXWindowStateFlags = set of TXWindowStateFlag; + // Returns True if it 'ate' the event + TX11EventFilter = function(const AEvent: TXEvent): Boolean of object; + + // forward declaration TfpgWindowImpl = class; @@ -160,10 +163,13 @@ type end; + { TfpgApplicationImpl } + TfpgApplicationImpl = class(TfpgApplicationBase) private FComposeBuffer: String[32]; FComposeStatus: TStatus; + FEventFilter: TX11EventFilter; function ConvertShiftState(AState: Cardinal): TShiftState; function KeySymToKeycode(KeySym: TKeySym): Word; function StartComposing(const Event: TXEvent): TKeySym; @@ -201,6 +207,7 @@ type function Screen_dpi: integer; override; property Display: PXDisplay read FDisplay; property RootWindow: TfpgWinHandle read FRootWindow; + property EventFilter: TX11EventFilter read FEventFilter write FEventFilter; end; @@ -817,6 +824,8 @@ begin repeat if (atimeoutms >= 0) and (XPending(display) <= 0) then begin + if Assigned(FOnIdle) then + OnIdle(self); // Some event is waiting for the given timeout. // This Select handles only the first 256 file descriptors. // Poll would be better but FPC has no official poll interface (if I'm right) @@ -829,6 +838,11 @@ begin end; XNextEvent(display, @ev); until (not XFilterEvent(@ev, X.None)); + + // if the event filter returns true then it ate the message + if Assigned(FEventFilter) and FEventFilter(ev) then + exit; // no more processing required for that event + blockmsg := False; fillchar(msgp, sizeof(msgp), 0); |