Bug 935178 - Support broadcast message for switching between Metro and Desktop. r=jimm
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -120,16 +120,18 @@
#include "mozilla/Preferences.h"
#include "nsISound.h"
#include "WinTaskbar.h"
#include "WinUtils.h"
#include "WidgetUtils.h"
#include "nsIWidgetListener.h"
#include "mozilla/dom/Touch.h"
#include "mozilla/gfx/2D.h"
+#include "nsToolkitCompsCID.h"
+#include "nsIAppStartup.h"
#include "mozilla/WindowsVersion.h"
#ifdef MOZ_ENABLE_D3D9_LAYER
#include "LayerManagerD3D9.h"
#endif
#ifdef MOZ_ENABLE_D3D10_LAYER
#include "LayerManagerD3D10.h"
@@ -169,16 +171,20 @@
#include "nsIContent.h"
#include "mozilla/HangMonitor.h"
#include "WinIMEHandler.h"
#include "npapi.h"
+#if !defined(SM_CONVERTIBLESLATEMODE)
+#define SM_CONVERTIBLESLATEMODE 0x2003
+#endif
+
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::layers;
using namespace mozilla::widget;
/**************************************************************
**************************************************************
**
@@ -5457,16 +5463,31 @@ nsWindow::ProcessMessage(UINT msg, WPARA
// WM_KILLFOCUS was received by the child process.
if (sJustGotDeactivate) {
DispatchFocusToTopLevelWindow(false);
}
}
}
}
break;
+ case WM_SETTINGCHANGE:
+ if (IsWin8OrLater() && lParam &&
+ !wcsicmp(L"ConvertibleSlateMode", (wchar_t*)lParam)) {
+ // If we're switching into slate mode, switch to Metro for hardware
+ // that supports this feature.
+ if (GetSystemMetrics(SM_CONVERTIBLESLATEMODE) == 0) {
+ nsCOMPtr<nsIAppStartup> appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID));
+ if (appStartup) {
+ appStartup->Quit(nsIAppStartup::eForceQuit |
+ nsIAppStartup::eRestartTouchEnvironment);
+ }
+ }
+ }
+ break;
+
}
//*aRetValue = result;
if (mWnd) {
return result;
}
else {
//Events which caused mWnd destruction and aren't consumed
--- a/widget/windows/winrt/MetroWidget.cpp
+++ b/widget/windows/winrt/MetroWidget.cpp
@@ -55,16 +55,20 @@ using namespace ABI::Windows::UI::Core;
using namespace ABI::Windows::System;
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::Graphics::Display;
#ifdef PR_LOGGING
extern PRLogModuleInfo* gWindowsLog;
#endif
+#if !defined(SM_CONVERTIBLESLATEMODE)
+#define SM_CONVERTIBLESLATEMODE 0x2003
+#endif
+
static uint32_t gInstanceCount = 0;
const PRUnichar* kMetroSubclassThisProp = L"MetroSubclassThisProp";
HWND MetroWidget::sICoreHwnd = nullptr;
namespace mozilla {
namespace widget {
UINT sDefaultBrowserMsgId = RegisterWindowMessageW(L"DefaultBrowserClosing");
} }
@@ -705,16 +709,27 @@ MetroWidget::StaticWindowProcedure(HWND
return self->WindowProcedure(aWnd, aMsg, aWParam, aLParam);
}
LRESULT
MetroWidget::WindowProcedure(HWND aWnd, UINT aMsg, WPARAM aWParam, LPARAM aLParam)
{
if(sDefaultBrowserMsgId == aMsg) {
CloseGesture();
+ } else if (WM_SETTINGCHANGE == aMsg) {
+ if (aLParam && !wcsicmp(L"ConvertibleSlateMode", (wchar_t*)aLParam)) {
+ // If we're switching away from slate mode, switch to Desktop for
+ // hardware that supports this feature.
+ if (GetSystemMetrics(SM_CONVERTIBLESLATEMODE) != 0) {
+ nsCOMPtr<nsIAppStartup> appStartup(do_GetService(NS_APPSTARTUP_CONTRACTID));
+ if (appStartup) {
+ appStartup->Quit(nsIAppStartup::eForceQuit | nsIAppStartup::eRestart);
+ }
+ }
+ }
}
// Indicates if we should hand messages to the default windows
// procedure for processing.
bool processDefault = true;
// The result returned if we do not do default processing.
LRESULT processResult = 0;