From f425574373900f9b1bf77674cbf26b40a0c54035 Mon Sep 17 00:00:00 2001 From: Rich Walsh Date: Tue, 23 Jun 2009 11:26:45 +0200 Subject: [PATCH] [OS/2] Bug 430163: Implement GetToggledKeyState, r=pweilbacher --- widget/src/os2/nsWindow.cpp | 27 +++++++++++++++++++++++++++ widget/src/os2/nsWindow.h | 1 + 2 files changed, 28 insertions(+) diff --git a/widget/src/os2/nsWindow.cpp b/widget/src/os2/nsWindow.cpp index 135160d9677..f75e0a5b7a4 100644 --- a/widget/src/os2/nsWindow.cpp +++ b/widget/src/os2/nsWindow.cpp @@ -3448,6 +3448,33 @@ void nsWindow::RemoveFromStyle( ULONG style) } } +// -------------------------------------------------------------------------- + +NS_IMETHODIMP nsWindow::GetToggledKeyState(PRUint32 aKeyCode, PRBool* aLEDState) +{ + PRUint32 vkey; + + NS_ENSURE_ARG_POINTER(aLEDState); + + switch (aKeyCode) { + case NS_VK_CAPS_LOCK: + vkey = VK_CAPSLOCK; + break; + case NS_VK_NUM_LOCK: + vkey = VK_NUMLOCK; + break; + case NS_VK_SCROLL_LOCK: + vkey = VK_SCRLLOCK; + break; + default: + *aLEDState = PR_FALSE; + return NS_OK; + } + + *aLEDState = (::WinGetKeyState(HWND_DESKTOP, vkey) & 1) != 0; + return NS_OK; +} + // -------------------------------------------------------------------------- // Drag & Drop - Target methods // -------------------------------------------------------------------------- diff --git a/widget/src/os2/nsWindow.h b/widget/src/os2/nsWindow.h index 153cf3188f9..077f10b7a1e 100644 --- a/widget/src/os2/nsWindow.h +++ b/widget/src/os2/nsWindow.h @@ -173,6 +173,7 @@ class nsWindow : public nsBaseWidget, NS_IMETHOD Invalidate( const nsIntRect & aRect, PRBool aIsSynchronous); NS_IMETHOD Update(); NS_IMETHOD Scroll( PRInt32 aDx, PRInt32 aDy, nsIntRect *aClipRect); + NS_IMETHOD GetToggledKeyState(PRUint32 aKeyCode, PRBool* aLEDState); // Get a HWND or a HPS. virtual void *GetNativeData( PRUint32 aDataType);