mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1170522 - expose whether or not we're in tablet mode to xul/js/css, r=jimm,ted
This commit is contained in:
parent
e92dee7e2f
commit
92cbb6df9d
@ -2,7 +2,7 @@ _VSPATH="/c/tools/vs2013"
|
||||
export WIN32_REDIST_DIR=${_VSPATH}/VC/redist/x86/Microsoft.VC120.CRT
|
||||
|
||||
## includes: win8.1 sdk includes, msvc std library, directx sdk for d3d9 ##
|
||||
export INCLUDE=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/shared:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/um:${_VSPATH}/vc/include:${_VSPATH}/vc/atlmfc/include:/c/tools/sdks/dx10/include
|
||||
export INCLUDE=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/shared:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/um:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/winrt:${_VSPATH}/vc/include:${_VSPATH}/vc/atlmfc/include:/c/tools/sdks/dx10/include
|
||||
|
||||
## libs: win8.1 sdk x86 (32-bit) libs, msvc (32-bit) std library, msvc atl libs, directx sdk (32-bit) for d3d9 ##
|
||||
export LIBPATH=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/Lib/winv6.3/um/x86:${_VSPATH}/vc/lib:${_VSPATH}/vc/atlmfc/lib:/c/tools/sdks/dx10/lib
|
||||
|
@ -2,7 +2,7 @@ _VSPATH="/c/tools/vs2013"
|
||||
export WIN32_REDIST_DIR=${_VSPATH}/VC/redist/x64/Microsoft.VC120.CRT
|
||||
|
||||
## includes: win8.1 sdk includes, msvc std library, directx sdk for d3d9 ##
|
||||
export INCLUDE=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/shared:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/um:${_VSPATH}/vc/include:${_VSPATH}/vc/atlmfc/include:/c/tools/sdks/dx10/include
|
||||
export INCLUDE=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/shared:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/um:/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/include/winrt:${_VSPATH}/vc/include:${_VSPATH}/vc/atlmfc/include:/c/tools/sdks/dx10/include
|
||||
|
||||
## libs: win8.1 sdk x64 (64-bit) libs, msvc (64-bit) std library, msvc atl libs, directx sdk (64-bit) for d3d9 ##
|
||||
export LIBPATH=/c/Program\ Files\ \(x86\)/Windows\ Kits/8.1/Lib/winv6.3/um/x64:${_VSPATH}/vc/lib/amd64:${_VSPATH}/vc/atlmfc/lib/amd64:/c/tools/sdks/dx10/lib/x64
|
||||
|
@ -32,6 +32,12 @@ def Libxul(name):
|
||||
if CONFIG['MOZ_WEBRTC']:
|
||||
DELAYLOAD_DLLS += ['msdmo.dll']
|
||||
|
||||
if CONFIG['OS_ARCH'] == 'WINNT':
|
||||
DELAYLOAD_DLLS += [
|
||||
'api-ms-win-core-winrt-l1-1-0.dll',
|
||||
'api-ms-win-core-winrt-string-l1-1-0.dll',
|
||||
]
|
||||
|
||||
if CONFIG['OS_ARCH'] == 'WINNT' and not CONFIG['GNU_CC']:
|
||||
LOCAL_INCLUDES += [
|
||||
'/widget/windows',
|
||||
|
@ -26,6 +26,7 @@ if toolkit == 'windows':
|
||||
'nsITaskbarProgress.idl',
|
||||
'nsITaskbarTabPreview.idl',
|
||||
'nsITaskbarWindowPreview.idl',
|
||||
'nsIWindowsUIUtils.idl',
|
||||
'nsIWinTaskbar.idl',
|
||||
]
|
||||
elif toolkit == 'cocoa':
|
||||
|
24
widget/nsIWindowsUIUtils.idl
Normal file
24
widget/nsIWindowsUIUtils.idl
Normal file
@ -0,0 +1,24 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
|
||||
[scriptable, uuid(aa8a0ecf-96a1-418c-b80e-f24ae18bbedc)]
|
||||
interface nsIWindowsUIUtils : nsISupports
|
||||
{
|
||||
/**
|
||||
* Whether the OS is currently in tablet mode. Always false on
|
||||
* non-Windows and on versions of Windows before win10
|
||||
*/
|
||||
readonly attribute boolean inTabletMode;
|
||||
|
||||
/**
|
||||
* Update the tablet mode state
|
||||
*/
|
||||
void updateTabletModeState();
|
||||
};
|
||||
|
@ -185,3 +185,7 @@
|
||||
#define NS_IMEPICKER_CID \
|
||||
{ 0x8e5c35ef, 0xb65b, 0x47aa, \
|
||||
{ 0xbb, 0x90, 0x5b, 0x89, 0x6d, 0x88, 0x24, 0x18 } }
|
||||
|
||||
#define NS_WINDOWS_UIUTILS_CID \
|
||||
{ 0xe04a55e8, 0xfee3, 0x4ea2, \
|
||||
{ 0xa9, 0x8b, 0x41, 0xd2, 0x62, 0x1a, 0xdc, 0x3c } }
|
||||
|
174
widget/windows/WindowsUIUtils.cpp
Normal file
174
widget/windows/WindowsUIUtils.cpp
Normal file
@ -0,0 +1,174 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include <windows.h>
|
||||
#include "mozwrlbase.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
|
||||
#include "WindowsUIUtils.h"
|
||||
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsIDocshell.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsAppShellCID.h"
|
||||
#include "nsIXULWindow.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/WindowsVersion.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIWidget.h"
|
||||
|
||||
#include <windows.ui.viewmanagement.h>
|
||||
|
||||
#pragma comment(lib, "runtimeobject.lib")
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace ABI::Windows::UI;
|
||||
using namespace ABI::Windows::UI::ViewManagement;
|
||||
using namespace Microsoft::WRL;
|
||||
using namespace Microsoft::WRL::Wrappers;
|
||||
using namespace ABI::Windows::Foundation;
|
||||
|
||||
/* All of this is win10 stuff and we're compiling against win81 headers
|
||||
* for now, so we may need to do some legwork: */
|
||||
#ifndef UserInteractionMode
|
||||
namespace ABI {
|
||||
namespace Windows {
|
||||
namespace UI {
|
||||
namespace ViewManagement {
|
||||
enum UserInteractionMode {
|
||||
UserInteractionMode_Mouse = 0,
|
||||
UserInteractionMode_Touch = 1
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef RuntimeClass_Windows_UI_ViewManagement_UIViewSettings
|
||||
#define RuntimeClass_Windows_UI_ViewManagement_UIViewSettings L"Windows.UI.ViewManagement.UIViewSettings"
|
||||
#endif
|
||||
|
||||
#ifndef IUIViewSettings
|
||||
namespace ABI {
|
||||
namespace Windows {
|
||||
namespace UI {
|
||||
namespace ViewManagement {
|
||||
interface IUIViewSettings;
|
||||
MIDL_INTERFACE("C63657F6-8850-470D-88F8-455E16EA2C26")
|
||||
IUIViewSettings : public IInspectable
|
||||
{
|
||||
public:
|
||||
virtual HRESULT STDMETHODCALLTYPE get_UserInteractionMode(UserInteractionMode *value) = 0;
|
||||
};
|
||||
|
||||
extern const __declspec(selectany) IID & IID_IUIViewSettings = __uuidof(IUIViewSettings);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef IUIViewSettingsInterop
|
||||
|
||||
typedef interface IUIViewSettingsInterop IUIViewSettingsInterop;
|
||||
|
||||
MIDL_INTERFACE("3694dbf9-8f68-44be-8ff5-195c98ede8a6")
|
||||
IUIViewSettingsInterop : public IInspectable
|
||||
{
|
||||
public:
|
||||
virtual HRESULT STDMETHODCALLTYPE GetForWindow(HWND hwnd, REFIID riid, void **ppv) = 0;
|
||||
};
|
||||
#endif
|
||||
|
||||
WindowsUIUtils::WindowsUIUtils() :
|
||||
mInTabletMode(eTabletModeUnknown)
|
||||
{
|
||||
}
|
||||
|
||||
WindowsUIUtils::~WindowsUIUtils()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Implement the nsISupports methods...
|
||||
*/
|
||||
NS_IMPL_ISUPPORTS(WindowsUIUtils,
|
||||
nsIWindowsUIUtils)
|
||||
|
||||
NS_IMETHODIMP
|
||||
WindowsUIUtils::GetInTabletMode(bool* aResult)
|
||||
{
|
||||
if (mInTabletMode == eTabletModeUnknown) {
|
||||
UpdateTabletModeState();
|
||||
}
|
||||
*aResult = mInTabletMode == eTabletModeOn;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WindowsUIUtils::UpdateTabletModeState()
|
||||
{
|
||||
if (!IsWin10OrLater()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShell(do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
|
||||
nsCOMPtr<nsIXULWindow> hiddenWindow;
|
||||
|
||||
nsresult rv = appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
rv = hiddenWindow->GetDocShell(getter_AddRefs(docShell));
|
||||
if (NS_FAILED(rv) || !docShell) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIBaseWindow> baseWindow(do_QueryInterface(docShell));
|
||||
|
||||
if (!baseWindow)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIWidget> widget;
|
||||
baseWindow->GetMainWidget(getter_AddRefs(widget));
|
||||
|
||||
if (!widget)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
HWND winPtr = (HWND)widget->GetNativeData(NS_NATIVE_WINDOW);
|
||||
ComPtr<IUIViewSettingsInterop> uiViewSettingsInterop;
|
||||
|
||||
HRESULT hr = GetActivationFactory(
|
||||
HStringReference(RuntimeClass_Windows_UI_ViewManagement_UIViewSettings).Get(),
|
||||
&uiViewSettingsInterop);
|
||||
if (SUCCEEDED(hr)) {
|
||||
ComPtr<IUIViewSettings> uiViewSettings;
|
||||
hr = uiViewSettingsInterop->GetForWindow(winPtr, IID_PPV_ARGS(&uiViewSettings));
|
||||
if (SUCCEEDED(hr)) {
|
||||
UserInteractionMode mode;
|
||||
hr = uiViewSettings->get_UserInteractionMode(&mode);
|
||||
if (SUCCEEDED(hr)) {
|
||||
TabletModeState oldTabletModeState = mInTabletMode;
|
||||
mInTabletMode = (mode == UserInteractionMode_Touch) ? eTabletModeOn : eTabletModeOff;
|
||||
if (mInTabletMode != oldTabletModeState) {
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
mozilla::services::GetObserverService();
|
||||
NS_NAMED_LITERAL_STRING(tabletMode, "tablet-mode");
|
||||
NS_NAMED_LITERAL_STRING(normalMode, "normal-mode");
|
||||
observerService->NotifyObservers(nullptr, "tablet-mode-change",
|
||||
((mInTabletMode == eTabletModeOn) ? tabletMode.get() : normalMode.get()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
29
widget/windows/WindowsUIUtils.h
Normal file
29
widget/windows/WindowsUIUtils.h
Normal file
@ -0,0 +1,29 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_widget_WindowsUIUtils_h__
|
||||
#define mozilla_widget_WindowsUIUtils_h__
|
||||
|
||||
#include "nsIWindowsUIUtils.h"
|
||||
|
||||
enum TabletModeState {
|
||||
eTabletModeUnknown = 0,
|
||||
eTabletModeOff,
|
||||
eTabletModeOn
|
||||
};
|
||||
|
||||
class WindowsUIUtils final : public nsIWindowsUIUtils {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWINDOWSUIUTILS
|
||||
|
||||
WindowsUIUtils();
|
||||
protected:
|
||||
~WindowsUIUtils();
|
||||
|
||||
TabletModeState mInTabletMode;
|
||||
};
|
||||
|
||||
#endif // mozilla_widget_WindowsUIUtils_h__
|
@ -63,6 +63,7 @@ SOURCES += [
|
||||
'nsBidiKeyboard.cpp',
|
||||
'nsFilePicker.cpp',
|
||||
'nsWidgetFactory.cpp',
|
||||
'WindowsUIUtils.cpp',
|
||||
'WinMouseScrollHandler.cpp',
|
||||
]
|
||||
|
||||
|
77
widget/windows/mozwrlbase.h
Normal file
77
widget/windows/mozwrlbase.h
Normal file
@ -0,0 +1,77 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
* Includes <wrl.h> and it's children. Defines imports needed by
|
||||
* corewrappers.h in the case where windows.h has already been
|
||||
* included w/WINVER < 0x600. Also ups WINVER/_WIN32_WINNT prior
|
||||
* to including wrl.h. Mozilla's build currently has WINVER set to
|
||||
* 0x502 for XP support.
|
||||
*/
|
||||
|
||||
#if _WIN32_WINNT < 0x600
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
VOID
|
||||
WINAPI
|
||||
ReleaseSRWLockExclusive(
|
||||
_Inout_ PSRWLOCK SRWLock
|
||||
);
|
||||
|
||||
VOID
|
||||
WINAPI
|
||||
ReleaseSRWLockShared(
|
||||
_Inout_ PSRWLOCK SRWLock
|
||||
);
|
||||
|
||||
BOOL
|
||||
WINAPI
|
||||
InitializeCriticalSectionEx(
|
||||
_Out_ LPCRITICAL_SECTION lpCriticalSection,
|
||||
_In_ DWORD dwSpinCount,
|
||||
_In_ DWORD Flags
|
||||
);
|
||||
|
||||
VOID
|
||||
WINAPI
|
||||
InitializeSRWLock(
|
||||
_Out_ PSRWLOCK SRWLock
|
||||
);
|
||||
|
||||
VOID
|
||||
WINAPI
|
||||
AcquireSRWLockExclusive(
|
||||
_Inout_ PSRWLOCK SRWLock
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
WINAPI
|
||||
TryAcquireSRWLockExclusive(
|
||||
_Inout_ PSRWLOCK SRWLock
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
WINAPI
|
||||
TryAcquireSRWLockShared(
|
||||
_Inout_ PSRWLOCK SRWLock
|
||||
);
|
||||
|
||||
VOID
|
||||
WINAPI
|
||||
AcquireSRWLockShared(
|
||||
_Inout_ PSRWLOCK SRWLock
|
||||
);
|
||||
|
||||
#undef WINVER
|
||||
#undef _WIN32_WINNT
|
||||
#define WINVER 0x600
|
||||
#define _WIN32_WINNT 0x600
|
||||
|
||||
#endif // _WIN32_WINNT < 0x600
|
||||
|
||||
#include <wrl.h>
|
@ -44,6 +44,8 @@
|
||||
#include "JumpListBuilder.h"
|
||||
#include "JumpListItem.h"
|
||||
|
||||
#include "WindowsUIUtils.h"
|
||||
|
||||
#ifdef NS_PRINTING
|
||||
#include "nsDeviceContextSpecWin.h"
|
||||
#include "nsPrintOptionsWin.h"
|
||||
@ -112,6 +114,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(JumpListItem)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(JumpListSeparator)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(JumpListLink)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(JumpListShortcut)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(WindowsUIUtils)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
|
||||
@ -150,6 +153,7 @@ NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTITEM_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTSEPARATOR_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTLINK_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_WIN_JUMPLISTSHORTCUT_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_WINDOWS_UIUTILS_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_BIDIKEYBOARD_CID);
|
||||
#ifdef NS_PRINTING
|
||||
@ -182,6 +186,7 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
|
||||
{ &kNS_WIN_JUMPLISTSEPARATOR_CID, false, nullptr, JumpListSeparatorConstructor },
|
||||
{ &kNS_WIN_JUMPLISTLINK_CID, false, nullptr, JumpListLinkConstructor },
|
||||
{ &kNS_WIN_JUMPLISTSHORTCUT_CID, false, nullptr, JumpListShortcutConstructor },
|
||||
{ &kNS_WINDOWS_UIUTILS_CID, false, nullptr, WindowsUIUtilsConstructor },
|
||||
{ &kNS_DRAGSERVICE_CID, false, nullptr, nsDragServiceConstructor, Module::MAIN_PROCESS_ONLY },
|
||||
{ &kNS_BIDIKEYBOARD_CID, false, nullptr, nsBidiKeyboardConstructor },
|
||||
#ifdef NS_PRINTING
|
||||
@ -214,6 +219,7 @@ static const mozilla::Module::ContractIDEntry kWidgetContracts[] = {
|
||||
{ "@mozilla.org/windows-jumplistseparator;1", &kNS_WIN_JUMPLISTSEPARATOR_CID },
|
||||
{ "@mozilla.org/windows-jumplistlink;1", &kNS_WIN_JUMPLISTLINK_CID },
|
||||
{ "@mozilla.org/windows-jumplistshortcut;1", &kNS_WIN_JUMPLISTSHORTCUT_CID },
|
||||
{ "@mozilla.org/windows-ui-utils;1", &kNS_WINDOWS_UIUTILS_CID },
|
||||
{ "@mozilla.org/widget/dragservice;1", &kNS_DRAGSERVICE_CID, Module::MAIN_PROCESS_ONLY },
|
||||
{ "@mozilla.org/widget/bidikeyboard;1", &kNS_BIDIKEYBOARD_CID },
|
||||
#ifdef NS_PRINTING
|
||||
|
@ -161,6 +161,8 @@
|
||||
#include "nsIWinTaskbar.h"
|
||||
#define NS_TASKBAR_CONTRACTID "@mozilla.org/windows-taskbar;1"
|
||||
|
||||
#include "nsIWindowsUIUtils.h"
|
||||
|
||||
#include "nsWindowDefs.h"
|
||||
|
||||
#include "nsCrashOnException.h"
|
||||
@ -4656,6 +4658,20 @@ nsWindow::ProcessMessage(UINT msg, WPARAM& wParam, LPARAM& lParam,
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_SETTINGCHANGE:
|
||||
{
|
||||
if (IsWin10OrLater() && mWindowType == eWindowType_invisible && lParam) {
|
||||
auto lParamString = reinterpret_cast<const wchar_t*>(lParam);
|
||||
if (!wcscmp(lParamString, L"UserInteractionMode")) {
|
||||
nsCOMPtr<nsIWindowsUIUtils> uiUtils(do_GetService("@mozilla.org/windows-ui-utils;1"));
|
||||
if (uiUtils) {
|
||||
uiUtils->UpdateTabletModeState();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_NCCALCSIZE:
|
||||
{
|
||||
if (mCustomNonClient) {
|
||||
|
Loading…
Reference in New Issue
Block a user