From 9aa35c9c0a5220af1bdc7493d4caf418664d8af7 Mon Sep 17 00:00:00 2001 From: graemeg Date: Fri, 11 Jul 2008 13:59:56 +0000 Subject: Applied mousevents patch from Vladimir. --- src/corelib/gdi/gfx_gdi.pas | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/corelib/gdi') diff --git a/src/corelib/gdi/gfx_gdi.pas b/src/corelib/gdi/gfx_gdi.pas index e912de95..74bb1b60 100644 --- a/src/corelib/gdi/gfx_gdi.pas +++ b/src/corelib/gdi/gfx_gdi.pas @@ -1056,8 +1056,9 @@ var msgp: TfpgMessageParams; CursorInDifferentWindow: boolean; CurrentWindowHndl: TfpgWinHandle; + MouseCaptureWHndl: TfpgWinHandle; LastWindow: TfpgWindowImpl; - + CurrentWindow: TfpgWindowImpl; begin // vvzh: this method currently cannot receive mouse events when mouse pointer // is outside of the application window. We could try to play with @@ -1071,9 +1072,9 @@ begin // tme.dwFlags := TME_LEAVE or TME_HOVER; // tme.dwHoverTime := 1; // TrackMouseEvent(tme); - - pt.x := LoWord(lParam); - pt.y := HiWord(lParam); + + pt.x := GET_X_LPARAM(lParam); + pt.y := GET_Y_LPARAM(lParam); spt := pt; // only WM_MOUSEWHEEL uses screen coordinates!!! if uMsg = WM_MOUSEWHEEL then @@ -1092,14 +1093,18 @@ begin LastWindow := GetMyWidgetFromHandle(uLastWindowHndl); // check if last window still exits. eg: Dialog window could be closed. if LastWindow <> nil then - begin -// writeln('GFX: MouseExit detected'); fpgSendMessage(nil, LastWindow, FPGM_MOUSEEXIT, msgp); + + // if some window captured mouse input, we should not send mouse events to other windows + MouseCaptureWHndl := GetCapture; + if (MouseCaptureWHndl = 0) or (MouseCaptureWHndl = CurrentWindowHndl) then + begin + CurrentWindow := GetMyWidgetFromHandle(CurrentWindowHndl); + if (CurrentWindow <> nil) then + fpgSendMessage(nil, CurrentWindow, FPGM_MOUSEENTER, msgp); end; -// writeln('GFX: MouseEnter detected'); - fpgSendMessage(nil, AWindow, FPGM_MOUSEENTER, msgp); end; - + uLastWindowHndl := CurrentWindowHndl; end; -- cgit v1.2.3-70-g09d2