From e22fcf204ea0e86a0a125896627f84f414e5d09b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 14 Feb 2015 15:04:55 +0000 Subject: [PATCH] Fix coordinates of wxSetCursorEvent in wxGTK. The event coordinates remained in the client coordinates of the window the initial event had been sent to, even when the event was propagated to its parent. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@78488 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/gtk/window.cpp | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index fad051e735..eb8774adcb 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -589,6 +589,7 @@ wxGTK: - Fix infinite sizing loop with GTK3 when using wxScrolled with a non-default target window. - Fix crashes in wxGTK3 when running with non-X11 backend (Marco Trevisan). +- Fix coordinates of wxSetCursorEvent propagated to parent windows. wxMSW: diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 388da76cee..6cc60836e8 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1552,9 +1552,13 @@ static const wxCursor* gs_overrideCursor; static void SendSetCursorEvent(wxWindowGTK* win, int x, int y) { - wxSetCursorEvent event(x, y); + wxPoint posClient(x, y); + const wxPoint posScreen = win->ClientToScreen(posClient); + wxWindowGTK* w = win; - do { + for ( ;; ) + { + wxSetCursorEvent event(posClient.x, posClient.y); if (w->GTKProcessEvent(event)) { gs_overrideCursor = &event.GetCursor(); @@ -1566,8 +1570,12 @@ static void SendSetCursorEvent(wxWindowGTK* win, int x, int y) // this is how wxMSW works... if (w->GetCursor().IsOk()) break; + w = w->GetParent(); - } while (w); + if ( !w ) + break; + posClient = w->ScreenToClient(posScreen); + } if (gs_needCursorResetMap[win]) win->GTKUpdateCursor(); }