From 85ffdc73b32e747ba0517bfc0e8403299f539b03 Mon Sep 17 00:00:00 2001 From: graemeg Date: Mon, 23 Jul 2007 21:53:15 +0000 Subject: X11: Modal forms are now working correctly. You cannot kill the parent of a modal form by clicking the top right X button anymore. --- src/corelib/x11/gfx_x11.pas | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/corelib/x11') diff --git a/src/corelib/x11/gfx_x11.pas b/src/corelib/x11/gfx_x11.pas index 99411c18..66722790 100644 --- a/src/corelib/x11/gfx_x11.pas +++ b/src/corelib/x11/gfx_x11.pas @@ -689,7 +689,6 @@ begin msgp.mouse.shiftstate := ConvertShiftState(ev.xbutton.state); w := FindWindowByHandle(ev.xbutton.window); - if fpgTopModalForm <> nil then begin // This is ugly!!!!!!!!!!!!!!! @@ -756,6 +755,15 @@ begin // until not XCheckTypedWindowEvent(display, ev.xbutton.window, X.MotionNotify, @ev); + w := FindWindowByHandle(ev.xany.window); + if fpgTopModalForm <> nil then + begin + // This is ugly!!!!!!!!!!!!!!! + ew := TfpgWindowImpl(WidgetParentForm(TfpgWidget(w))); + if (ew <> nil) and (fpgTopModalForm <> ew) then + blockmsg := true; + end; + if not blockmsg then begin msgp.mouse.x := ev.xmotion.x; @@ -768,8 +776,19 @@ begin // message blockings for modal windows X.ClientMessage: - if not blockmsg then - fpgPostMessage(nil, FindWindowByHandle(ev.xany.window), FPGM_CLOSE); + begin + w := FindWindowByHandle(ev.xany.window); + if fpgTopModalForm <> nil then + begin + // This is ugly!!!!!!!!!!!!!!! + ew := TfpgWindowImpl(WidgetParentForm(TfpgWidget(w))); + if (ew <> nil) and (fpgTopModalForm <> ew) then + blockmsg := true; + end; + + if not blockmsg then + fpgPostMessage(nil, FindWindowByHandle(ev.xany.window), FPGM_CLOSE); + end; X.ConfigureNotify: -- cgit v1.2.3-70-g09d2