From 2cfbb51fdadc0ae70c78455b373b33421dbbf8d5 Mon Sep 17 00:00:00 2001 From: Brad Lassey Date: Tue, 14 Apr 2009 01:27:39 -0400 Subject: [PATCH] bug 481914 - dialogs shouldn't be larger than available screen space. Send notification and adjust avail screen size for soft keyboard r=dougt, sr=vlad --- widget/src/windows/nsScreenWin.cpp | 16 ++++++++++++++++ widget/src/windows/nsWindow.cpp | 26 +++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/widget/src/windows/nsScreenWin.cpp b/widget/src/windows/nsScreenWin.cpp index 62f3d0af8b28..481b24477f9c 100644 --- a/widget/src/windows/nsScreenWin.cpp +++ b/widget/src/windows/nsScreenWin.cpp @@ -48,6 +48,9 @@ #include "nsScreenWin.h" #ifdef WINCE +#ifdef WINCE_WINDOWS_MOBILE +#include "sipapi.h" +#endif #define GetMonitorInfoW GetMonitorInfo #endif @@ -114,6 +117,19 @@ NS_IMETHODIMP nsScreenWin :: GetAvailRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight) { BOOL success = FALSE; +#ifdef WINCE_WINDOWS_MOBILE + SIPINFO sipInfo; + memset(&sipInfo, 0, sizeof(SIPINFO)); + sipInfo.cbSize = sizeof(SIPINFO); + if (SipGetInfo(&sipInfo) && !(sipInfo.fdwFlags & SIPF_OFF)) { + *outLeft = sipInfo.rcVisibleDesktop.left; + *outTop = sipInfo.rcVisibleDesktop.top; + *outWidth = sipInfo.rcVisibleDesktop.right - sipInfo.rcVisibleDesktop.left; + *outHeight = sipInfo.rcVisibleDesktop.bottom - sipInfo.rcVisibleDesktop.top; + return NS_OK; + } +#endif + #if _MSC_VER >= 1200 if ( mScreen ) { MONITORINFO info; diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index c0b6b6dc5d00..72e24a21c899 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -208,6 +208,25 @@ static gfxIntSize gSharedSurfaceSize; static PRBool gSoftKeyMenuBar = PR_FALSE; static PRBool gSoftKeyboardState = PR_FALSE; +static void NotifySoftKbObservers() { + nsCOMPtr observerService = do_GetService("@mozilla.org/observer-service;1"); + if (observerService) { + SIPINFO sipInfo; + wchar_t rectBuf[256]; + memset(&sipInfo, 0, sizeof(SIPINFO)); + sipInfo.cbSize = sizeof(SIPINFO); + if (SipGetInfo(&sipInfo)) { + _snwprintf(rectBuf, 256, L"{\"left\": %d, \"top\": %d," + L" \"right\": %d, \"bottom\": %d}", + sipInfo.rcVisibleDesktop.left, + sipInfo.rcVisibleDesktop.top, + sipInfo.rcVisibleDesktop.right, + sipInfo.rcVisibleDesktop.bottom); + observerService->NotifyObservers(nsnull, "softkb-change", rectBuf); + } + } +} + static void ToggleSoftKB(PRBool show) { HWND hWndSIP = FindWindowW(L"SipWndClass", NULL ); @@ -218,7 +237,8 @@ static void ToggleSoftKB(PRBool show) if (hWndSIP) ShowWindow(hWndSIP, show ? SW_SHOW: SW_HIDE); - SHSipPreference(NULL, show ? SIP_UP: SIP_DOWN); + SipShowIM(show ? SIPF_ON : SIPF_OFF); + NotifySoftKbObservers(); } static void CreateSoftKeyMenuBar(HWND wnd) @@ -4829,6 +4849,10 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam, case WM_SETTINGCHANGE: getWheelInfo = PR_TRUE; +#ifdef WINCE_WINDOWS_MOBILE + if (wParam == SPI_SETSIPINFO) + NotifySoftKbObservers(); +#endif break; case WM_PALETTECHANGED: