diff --git a/mozilla/widget/src/windows/nsWindow.cpp b/mozilla/widget/src/windows/nsWindow.cpp index dc38a237c9d..aa81ce2c782 100644 --- a/mozilla/widget/src/windows/nsWindow.cpp +++ b/mozilla/widget/src/windows/nsWindow.cpp @@ -200,7 +200,6 @@ static inline PRBool IsAlphaTranslucencySupported() { return pUpdateLayeredWindo #ifdef WINCE -static PRBool gSoftKeyMenuBar = PR_FALSE; static PRBool gUseOkayButton = PR_FALSE; static PRBool gOverrideHWKeys = PR_TRUE; @@ -246,37 +245,18 @@ static void MapHardwareButtons(HWND window) gProcUnregisterFunc = (UnregisterFunc1Proc)GetProcAddress( gCoreDll, _T("UnregisterFunc1")); } - if (!gProcUnregisterFunc) - return; - - for (int i=0; gHardwareKeys[i][0]; i++) - { - UINT mod = gHardwareKeys[i][1]; - UINT kc = gHardwareKeys[i][0]; - - gProcUnregisterFunc(mod, kc); - RegisterHotKey(window, kc, mod, kc); + if (gProcUnregisterFunc) + { + for (int i=0; gHardwareKeys[i][0]; i++) + { + UINT mod = gHardwareKeys[i][1]; + UINT kc = gHardwareKeys[i][0]; + + gProcUnregisterFunc(mod, kc); + RegisterHotKey(window, kc, mod, kc); + } } } - - HWND mb = SHFindMenuBar (window); - - if (!mb) - return; - - SendMessage(mb, SHCMBM_OVERRIDEKEY, VK_TBACK, - MAKELPARAM(SHMBOF_NODEFAULT | SHMBOF_NOTIFY, - SHMBOF_NODEFAULT | SHMBOF_NOTIFY)); - - SendMessage(mb, SHCMBM_OVERRIDEKEY, VK_TSOFT1, - MAKELPARAM (SHMBOF_NODEFAULT | SHMBOF_NOTIFY, - SHMBOF_NODEFAULT | SHMBOF_NOTIFY)); - - - SendMessage(mb, SHCMBM_OVERRIDEKEY, VK_TSOFT2, - MAKELPARAM (SHMBOF_NODEFAULT | SHMBOF_NOTIFY, - SHMBOF_NODEFAULT | SHMBOF_NOTIFY)); - } static void UnmapHardwareButtons() @@ -293,25 +273,42 @@ static void UnmapHardwareButtons() } } -void CreateSoftKeyMenuBar(HWND wnd) +HWND CreateSoftKeyMenuBar(HWND wnd) { - if (gSoftKeyMenuBar) - return; - - gSoftKeyMenuBar = PR_TRUE; + if (!wnd) + return nsnull; SHMENUBARINFO mbi; ZeroMemory(&mbi, sizeof(SHMENUBARINFO)); mbi.cbSize = sizeof(SHMENUBARINFO); mbi.hwndParent = wnd; - mbi.dwFlags = SHCMBF_EMPTYBAR; - mbi.hInstRes = GetModuleHandle(NULL); - - SHCreateMenuBar(&mbi); - HWND mb = SHFindMenuBar(wnd); - if (mb) - SetWindowPos(mb, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE); + // On windows ce smartphone, events never occur if the + // menubar is empty. This doesn't work: + // mbi.dwFlags = SHCMBF_EMPTYBAR; + + mbi.nToolBarId = IDC_DUMMY_CE_MENUBAR; + mbi.hInstRes = GetModuleHandle(NULL); + + if (!SHCreateMenuBar(&mbi)) + return nsnull; + + SetWindowPos(mbi.hwndMB, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE); + + SendMessage(mbi.hwndMB, SHCMBM_OVERRIDEKEY, VK_TBACK, + MAKELPARAM(SHMBOF_NODEFAULT | SHMBOF_NOTIFY, + SHMBOF_NODEFAULT | SHMBOF_NOTIFY)); + + SendMessage(mbi.hwndMB, SHCMBM_OVERRIDEKEY, VK_TSOFT1, + MAKELPARAM (SHMBOF_NODEFAULT | SHMBOF_NOTIFY, + SHMBOF_NODEFAULT | SHMBOF_NOTIFY)); + + + SendMessage(mbi.hwndMB, SHCMBM_OVERRIDEKEY, VK_TSOFT2, + MAKELPARAM (SHMBOF_NODEFAULT | SHMBOF_NOTIFY, + SHMBOF_NODEFAULT | SHMBOF_NOTIFY)); + + return mbi.hwndMB; } #endif @@ -896,6 +893,9 @@ nsWindow::nsWindow() : nsBaseWidget() prefBranch->GetBoolPref("config.wince.overrideHWKeys", &gOverrideHWKeys); } } + + mSoftKeyMenuBar = nsnull; + #endif } @@ -955,6 +955,10 @@ nsWindow::~nsWindow() } NS_IF_RELEASE(mNativeDragTarget); + +#ifdef WINCE + // XXX do we free mSoftKeyMenuBar. MSDN isn't sure. +#endif } @@ -1567,7 +1571,8 @@ nsWindow::StandardWindowCreate(nsIWidget *aParent, } #ifdef WINCE if (mWindowType == eWindowType_dialog || mWindowType == eWindowType_toplevel ) - CreateSoftKeyMenuBar(mWnd); + mSoftKeyMenuBar = CreateSoftKeyMenuBar(mWnd); + MapHardwareButtons(mWnd); #endif @@ -2222,9 +2227,11 @@ NS_METHOD nsWindow::SetFocus(PRBool aRaise) if (::IsIconic(toplevelWnd)) ::OpenIcon(toplevelWnd); ::SetFocus(mWnd); + #ifdef WINCE MapHardwareButtons(mWnd); #endif + } return NS_OK; } @@ -4302,7 +4309,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT // fire hotkey events. See // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/win_ce/html/pwc_TheBackButtonandOtherInterestingButtons.asp - if (VK_TSOFT1 == HIWORD(lParam) && (0 != (MOD_KEYUP & LOWORD(lParam)))) + if (VK_TSOFT1 == HIWORD(lParam) && (0 != (MOD_KEYUP & LOWORD(lParam)))) { keybd_event(VK_F23, 0, 0, 0); keybd_event(VK_F23, 0, KEYEVENTF_KEYUP, 0); @@ -4310,7 +4317,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT break; } - if (VK_TSOFT2 == HIWORD(lParam) && (0 != (MOD_KEYUP & LOWORD(lParam)))) + if (VK_TSOFT2 == HIWORD(lParam) && (0 != (MOD_KEYUP & LOWORD(lParam)))) { keybd_event(VK_F24, 0, 0, 0); keybd_event(VK_F24, 0, KEYEVENTF_KEYUP, 0); diff --git a/mozilla/widget/src/windows/nsWindow.h b/mozilla/widget/src/windows/nsWindow.h index dbdd0972427..6115cc008e3 100644 --- a/mozilla/widget/src/windows/nsWindow.h +++ b/mozilla/widget/src/windows/nsWindow.h @@ -263,7 +263,6 @@ protected: static void RegisterSpecialDropdownHooks(); static void UnregisterSpecialDropdownHooks(); - #endif static BOOL DealWithPopups (HWND inWnd, UINT inMsg, WPARAM inWParam, LPARAM inLParam, LRESULT* outResult); @@ -449,6 +448,10 @@ protected: // Drag & Drop nsNativeDragTarget * mNativeDragTarget; +#ifdef WINCE + HWND mSoftKeyMenuBar; +#endif + // Enumeration of the methods which are accessible on the "main GUI thread" // via the CallMethod(...) mechanism... // see nsSwitchToUIThread diff --git a/mozilla/widget/src/windows/resource.h b/mozilla/widget/src/windows/resource.h index 5b15ec4e6ba..91a9dafaf22 100644 --- a/mozilla/widget/src/windows/resource.h +++ b/mozilla/widget/src/windows/resource.h @@ -45,3 +45,5 @@ #define IDC_COLRESIZE 4108 #define IDC_ROWRESIZE 4109 #define IDC_VERTICALTEXT 4110 +#define IDC_DUMMY_CE_MENUBAR 4111 +