Implement wxGetMouseState
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39741 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -2526,21 +2526,51 @@ wxWindow* wxFindWindowAtPointer(wxPoint& pt)
|
|||||||
return wxFindWindowAtPoint(pt);
|
return wxFindWindowAtPoint(pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the current mouse position.
|
void wxGetMouseState(int& rootX, int& rootY, unsigned& maskReturn)
|
||||||
wxPoint wxGetMousePosition()
|
|
||||||
{
|
{
|
||||||
Display *display = wxGlobalDisplay();
|
Display *display = wxGlobalDisplay();
|
||||||
Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display));
|
Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display));
|
||||||
Window rootReturn, childReturn;
|
Window rootReturn, childReturn;
|
||||||
int rootX, rootY, winX, winY;
|
int winX, winY;
|
||||||
unsigned int maskReturn;
|
|
||||||
|
|
||||||
XQueryPointer (display,
|
XQueryPointer (display,
|
||||||
rootWindow,
|
rootWindow,
|
||||||
&rootReturn,
|
&rootReturn,
|
||||||
&childReturn,
|
&childReturn,
|
||||||
&rootX, &rootY, &winX, &winY, &maskReturn);
|
&rootX, &rootY, &winX, &winY, &maskReturn);
|
||||||
return wxPoint(rootX, rootY);
|
}
|
||||||
|
|
||||||
|
// Get the current mouse position.
|
||||||
|
wxPoint wxGetMousePosition()
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
unsigned mask;
|
||||||
|
|
||||||
|
wxGetMouseState(x, y, mask);
|
||||||
|
return wxPoint(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxMouseState wxGetMouseState()
|
||||||
|
{
|
||||||
|
wxMouseState ms;
|
||||||
|
int x, y;
|
||||||
|
unsigned mask;
|
||||||
|
|
||||||
|
wxGetMouseState(x, y, mask);
|
||||||
|
|
||||||
|
ms.SetX(x);
|
||||||
|
ms.SetY(y);
|
||||||
|
|
||||||
|
ms.SetLeftDown(mask & Button1Mask);
|
||||||
|
ms.SetMiddleDown(mask & Button2Mask);
|
||||||
|
ms.SetRightDown(mask & Button3Mask);
|
||||||
|
|
||||||
|
ms.SetControlDown(mask & ControlMask);
|
||||||
|
ms.SetShiftDown(mask & ShiftMask);
|
||||||
|
ms.SetAltDown(mask & Mod1Mask);
|
||||||
|
ms.SetMetaDown(mask & Mod2Mask);
|
||||||
|
|
||||||
|
return ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1626,28 +1626,59 @@ wxWindow* wxFindWindowAtPointer(wxPoint& pt)
|
|||||||
return wxFindWindowAtPoint(wxGetMousePosition());
|
return wxFindWindowAtPoint(wxGetMousePosition());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the current mouse position.
|
void wxGetMouseState(int& rootX, int& rootY, unsigned& maskReturn)
|
||||||
wxPoint wxGetMousePosition()
|
|
||||||
{
|
{
|
||||||
#if wxUSE_NANOX
|
#if wxUSE_NANOX
|
||||||
/* TODO */
|
/* TODO */
|
||||||
return wxPoint(0, 0);
|
rootX = rootY = 0;
|
||||||
|
maskReturn = 0;
|
||||||
#else
|
#else
|
||||||
Display *display = wxGlobalDisplay();
|
Display *display = wxGlobalDisplay();
|
||||||
Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display));
|
Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display));
|
||||||
Window rootReturn, childReturn;
|
Window rootReturn, childReturn;
|
||||||
int rootX, rootY, winX, winY;
|
int winX, winY;
|
||||||
unsigned int maskReturn;
|
|
||||||
|
|
||||||
XQueryPointer (display,
|
XQueryPointer (display,
|
||||||
rootWindow,
|
rootWindow,
|
||||||
&rootReturn,
|
&rootReturn,
|
||||||
&childReturn,
|
&childReturn,
|
||||||
&rootX, &rootY, &winX, &winY, &maskReturn);
|
&rootX, &rootY, &winX, &winY, &maskReturn);
|
||||||
return wxPoint(rootX, rootY);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the current mouse position.
|
||||||
|
wxPoint wxGetMousePosition()
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
unsigned mask;
|
||||||
|
|
||||||
|
wxGetMouseState(x, y, mask);
|
||||||
|
return wxPoint(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxMouseState wxGetMouseState()
|
||||||
|
{
|
||||||
|
wxMouseState ms;
|
||||||
|
int x, y;
|
||||||
|
unsigned mask;
|
||||||
|
|
||||||
|
wxGetMouseState(x, y, mask);
|
||||||
|
|
||||||
|
ms.SetX(x);
|
||||||
|
ms.SetY(y);
|
||||||
|
|
||||||
|
ms.SetLeftDown(mask & Button1Mask);
|
||||||
|
ms.SetMiddleDown(mask & Button2Mask);
|
||||||
|
ms.SetRightDown(mask & Button3Mask);
|
||||||
|
|
||||||
|
ms.SetControlDown(mask & ControlMask);
|
||||||
|
ms.SetShiftDown(mask & ShiftMask);
|
||||||
|
ms.SetAltDown(mask & Mod1Mask);
|
||||||
|
ms.SetMetaDown(mask & Mod2Mask);
|
||||||
|
|
||||||
|
return ms;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxNoOptimize: switch off size optimization
|
// wxNoOptimize: switch off size optimization
|
||||||
|
Reference in New Issue
Block a user