From 5105db37ab0f822b61e25db79f0f6e78fb6114df Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Tue, 31 Jan 2012 17:41:21 +0000 Subject: [PATCH] implement wxGetMousePosition without using X-specific code git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70489 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/window.cpp | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 671258b..e88d441 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -4425,31 +4425,18 @@ wxWindow* wxFindWindowAtPointer(wxPoint& pt) // Get the current mouse position. wxPoint wxGetMousePosition() { - /* This crashes when used within wxHelpContext, - so we have to use the X-specific implementation below. - gint x, y; - GdkModifierType *mask; - (void) gdk_window_get_pointer(NULL, &x, &y, mask); - - return wxPoint(x, y); - */ + wxWindow* tlw = NULL; + if (!wxTopLevelWindows.empty()) + tlw = wxTopLevelWindows.front(); + GdkDisplay* display; + if (tlw && tlw->m_widget) + display = gtk_widget_get_display(tlw->m_widget); + else + display = gdk_display_get_default(); int x, y; - GdkWindow* windowAtPtr = gdk_window_at_pointer(& x, & y); - - Display *display = windowAtPtr ? GDK_WINDOW_XDISPLAY(windowAtPtr) : GDK_DISPLAY(); - Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display)); - Window rootReturn, childReturn; - int rootX, rootY, winX, winY; - unsigned int maskReturn; - - XQueryPointer (display, - rootWindow, - &rootReturn, - &childReturn, - &rootX, &rootY, &winX, &winY, &maskReturn); - return wxPoint(rootX, rootY); - + gdk_display_get_pointer(display, NULL, &x, &y, NULL); + return wxPoint(x, y); } GdkWindow* wxWindowGTK::GTKGetDrawingWindow() const -- 2.7.4