Bug 1700029 - Part 3. Move VR's software keyboard code to own class. r=masayuki

Differential Revision: https://phabricator.services.mozilla.com/D109261
This commit is contained in:
Makoto Kato 2021-03-26 05:42:47 +00:00
parent 9361d2cfbc
commit 84efb6b5bb
4 changed files with 61 additions and 7 deletions

View File

@ -0,0 +1,35 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sts=2 sw=2 et cin: */
/* 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 "OSKVRManager.h"
#include "FxRWindowManager.h"
#include "VRShMem.h"
#include "moz_external_vr.h"
namespace mozilla {
namespace widget {
// static
void OSKVRManager::ShowOnScreenKeyboard() {
#ifdef NIGHTLY_BUILD
mozilla::gfx::VRShMem shmem(nullptr, true /*aRequiresMutex*/);
shmem.SendIMEState(FxRWindowManager::GetInstance()->GetWindowID(),
mozilla::gfx::VRFxEventState::FOCUS);
#endif // NIGHTLY_BUILD
}
// static
void OSKVRManager::DismissOnScreenKeyboard() {
#ifdef NIGHTLY_BUILD
mozilla::gfx::VRShMem shmem(nullptr, true /*aRequiresMutex*/);
shmem.SendIMEState(FxRWindowManager::GetInstance()->GetWindowID(),
mozilla::gfx::VRFxEventState::BLUR);
#endif // NIGHTLY_BUILD
}
} // namespace widget
} // namespace mozilla

View File

@ -0,0 +1,22 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sts=2 sw=2 et cin: */
/* 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 OSKVRManager_h
#define OSKVRManager_h
namespace mozilla {
namespace widget {
class OSKVRManager final {
public:
static void ShowOnScreenKeyboard();
static void DismissOnScreenKeyboard();
};
} // namespace widget
} // namespace mozilla
#endif // OSKVRManager_h

View File

@ -16,6 +16,7 @@
#include "OSKInputPaneManager.h" #include "OSKInputPaneManager.h"
#include "OSKTabTipManager.h" #include "OSKTabTipManager.h"
#include "OSKVRManager.h"
#include "nsLookAndFeel.h" #include "nsLookAndFeel.h"
#include "nsWindow.h" #include "nsWindow.h"
#include "WinUtils.h" #include "WinUtils.h"
@ -33,7 +34,6 @@
#include "cfgmgr32.h" #include "cfgmgr32.h"
#include "FxRWindowManager.h" #include "FxRWindowManager.h"
#include "VRShMem.h"
#include "moz_external_vr.h" #include "moz_external_vr.h"
const char* kOskEnabled = "ui.osk.enabled"; const char* kOskEnabled = "ui.osk.enabled";
@ -759,9 +759,7 @@ void IMEHandler::MaybeShowOnScreenKeyboard(nsWindow* aWindow,
void IMEHandler::MaybeDismissOnScreenKeyboard(nsWindow* aWindow, Sync aSync) { void IMEHandler::MaybeDismissOnScreenKeyboard(nsWindow* aWindow, Sync aSync) {
#ifdef NIGHTLY_BUILD #ifdef NIGHTLY_BUILD
if (FxRWindowManager::GetInstance()->IsFxRWindow(aWindow)) { if (FxRWindowManager::GetInstance()->IsFxRWindow(aWindow)) {
mozilla::gfx::VRShMem shmem(nullptr, true /*aRequiresMutex*/); OSKVRManager::DismissOnScreenKeyboard();
shmem.SendIMEState(FxRWindowManager::GetInstance()->GetWindowID(),
mozilla::gfx::VRFxEventState::BLUR);
} }
#endif // NIGHTLY_BUILD #endif // NIGHTLY_BUILD
if (!IsWin8OrLater()) { if (!IsWin8OrLater()) {
@ -1010,9 +1008,7 @@ bool IMEHandler::AutoInvokeOnScreenKeyboardInDesktopMode() {
void IMEHandler::ShowOnScreenKeyboard(nsWindow* aWindow) { void IMEHandler::ShowOnScreenKeyboard(nsWindow* aWindow) {
#ifdef NIGHTLY_BUILD #ifdef NIGHTLY_BUILD
if (FxRWindowManager::GetInstance()->IsFxRWindow(sFocusedWindow)) { if (FxRWindowManager::GetInstance()->IsFxRWindow(sFocusedWindow)) {
mozilla::gfx::VRShMem shmem(nullptr, true /*aRequiresMutex*/); OSKVRManager::ShowOnScreenKeyboard();
shmem.SendIMEState(FxRWindowManager::GetInstance()->GetWindowID(),
mozilla::gfx::VRFxEventState::FOCUS);
return; return;
} }
#endif // NIGHTLY_BUILD #endif // NIGHTLY_BUILD

View File

@ -87,6 +87,7 @@ UNIFIED_SOURCES += [
"nsWindowGfx.cpp", "nsWindowGfx.cpp",
"nsWinGesture.cpp", "nsWinGesture.cpp",
"OSKTabTipManager.cpp", "OSKTabTipManager.cpp",
"OSKVRManager.cpp",
"RemoteBackbuffer.cpp", "RemoteBackbuffer.cpp",
"ScreenHelperWin.cpp", "ScreenHelperWin.cpp",
"ScrollbarUtil.cpp", "ScrollbarUtil.cpp",