implement wxGetMousePosition without using X-specific code

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70489 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Paul Cornett
2012-01-31 17:41:21 +00:00
parent 7dc941e3c5
commit 5105db37ab

View File

@@ -4425,31 +4425,18 @@ wxWindow* wxFindWindowAtPointer(wxPoint& pt)
// Get the current mouse position. // Get the current mouse position.
wxPoint wxGetMousePosition() wxPoint wxGetMousePosition()
{ {
/* This crashes when used within wxHelpContext, wxWindow* tlw = NULL;
so we have to use the X-specific implementation below. if (!wxTopLevelWindows.empty())
gint x, y; tlw = wxTopLevelWindows.front();
GdkModifierType *mask; GdkDisplay* display;
(void) gdk_window_get_pointer(NULL, &x, &y, mask); if (tlw && tlw->m_widget)
display = gtk_widget_get_display(tlw->m_widget);
return wxPoint(x, y); else
*/ display = gdk_display_get_default();
int x, y; int x, y;
GdkWindow* windowAtPtr = gdk_window_at_pointer(& x, & y); gdk_display_get_pointer(display, NULL, &x, &y, NULL);
return wxPoint(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);
} }
GdkWindow* wxWindowGTK::GTKGetDrawingWindow() const GdkWindow* wxWindowGTK::GTKGetDrawingWindow() const