mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 855975 part.4 Move nsWindow::InitKeyEvent() to widget::NativeKey::InitKeyEvent() r=jimm
This commit is contained in:
parent
daf9f3cb8e
commit
06784d3861
@ -6,7 +6,6 @@
|
||||
#include "mozilla/Util.h"
|
||||
|
||||
#include "KeyboardLayout.h"
|
||||
#include "nsWindow.h"
|
||||
#include "nsIMM32Handler.h"
|
||||
|
||||
#include "nsMemory.h"
|
||||
@ -17,6 +16,7 @@
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "WidgetUtils.h"
|
||||
#include "WinUtils.h"
|
||||
#include "nsWindowDbg.h"
|
||||
|
||||
#include "nsIDOMKeyEvent.h"
|
||||
|
||||
@ -381,12 +381,13 @@ VirtualKey::FillKbdState(PBYTE aKbdState,
|
||||
* mozilla::widget::NativeKey
|
||||
*****************************************************************************/
|
||||
|
||||
NativeKey::NativeKey(nsWindow* aWindow,
|
||||
NativeKey::NativeKey(nsWindowBase* aWidget,
|
||||
const MSG& aKeyOrCharMessage,
|
||||
const ModifierKeyState& aModKeyState) :
|
||||
mDOMKeyCode(0), mMessage(aKeyOrCharMessage.message),
|
||||
mVirtualKeyCode(0), mOriginalVirtualKeyCode(0)
|
||||
mWidget(aWidget), mDOMKeyCode(0), mMessage(aKeyOrCharMessage.message),
|
||||
mModKeyState(aModKeyState), mVirtualKeyCode(0), mOriginalVirtualKeyCode(0)
|
||||
{
|
||||
MOZ_ASSERT(aWidget);
|
||||
KeyboardLayout* keyboardLayout = KeyboardLayout::GetInstance();
|
||||
mKeyboardLayout = keyboardLayout->GetLayout();
|
||||
mScanCode = WinUtils::GetScanCode(aKeyOrCharMessage.lParam);
|
||||
@ -404,7 +405,7 @@ NativeKey::NativeKey(nsWindow* aWindow,
|
||||
// keycode.
|
||||
if (aKeyOrCharMessage.wParam == VK_PROCESSKEY) {
|
||||
mOriginalVirtualKeyCode = static_cast<uint8_t>(
|
||||
::ImmGetVirtualKey(aWindow->GetWindowHandle()));
|
||||
::ImmGetVirtualKey(mWidget->GetWindowHandle()));
|
||||
} else {
|
||||
mOriginalVirtualKeyCode =
|
||||
static_cast<uint8_t>(aKeyOrCharMessage.wParam);
|
||||
@ -543,7 +544,7 @@ NativeKey::NativeKey(nsWindow* aWindow,
|
||||
mKeyNameIndex =
|
||||
keyboardLayout->ConvertNativeKeyCodeToKeyNameIndex(mOriginalVirtualKeyCode);
|
||||
|
||||
keyboardLayout->InitNativeKey(*this, aModKeyState);
|
||||
keyboardLayout->InitNativeKey(*this, mModKeyState);
|
||||
}
|
||||
|
||||
UINT
|
||||
@ -653,6 +654,17 @@ NativeKey::ComputeUnicharFromScanCode() const
|
||||
MAPVK_VK_TO_CHAR, mKeyboardLayout));
|
||||
}
|
||||
|
||||
void
|
||||
NativeKey::InitKeyEvent(nsKeyEvent& aKeyEvent,
|
||||
const ModifierKeyState& aModKeyState) const
|
||||
{
|
||||
nsIntPoint point(0, 0);
|
||||
mWidget->InitEvent(aKeyEvent, &point);
|
||||
aKeyEvent.mKeyNameIndex = mKeyNameIndex;
|
||||
aKeyEvent.location = GetKeyLocation();
|
||||
aModKeyState.InitInputEvent(aKeyEvent);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
* mozilla::widget::KeyboardLayout
|
||||
*****************************************************************************/
|
||||
|
@ -7,8 +7,10 @@
|
||||
#define KeyboardLayout_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsEvent.h"
|
||||
#include "nsString.h"
|
||||
#include "nsWindowBase.h"
|
||||
#include <windows.h>
|
||||
|
||||
#define NS_NUM_OF_KEYS 68
|
||||
@ -32,7 +34,6 @@
|
||||
#define VK_OEM_102 0xE2
|
||||
#define VK_OEM_CLEAR 0xFE
|
||||
|
||||
class nsWindow;
|
||||
struct nsModifierKeyState;
|
||||
|
||||
namespace mozilla {
|
||||
@ -277,7 +278,7 @@ class MOZ_STACK_CLASS NativeKey
|
||||
friend class KeyboardLayout;
|
||||
|
||||
public:
|
||||
NativeKey(nsWindow* aWindow,
|
||||
NativeKey(nsWindowBase* aWidget,
|
||||
const MSG& aKeyOrCharMessage,
|
||||
const ModifierKeyState& aModKeyState);
|
||||
|
||||
@ -288,8 +289,6 @@ public:
|
||||
return mCommittedCharsAndModifiers;
|
||||
}
|
||||
|
||||
// The result is one of nsIDOMKeyEvent::DOM_KEY_LOCATION_*.
|
||||
uint32_t GetKeyLocation() const;
|
||||
UINT GetMessage() const { return mMessage; }
|
||||
bool IsKeyDownMessage() const
|
||||
{
|
||||
@ -314,7 +313,18 @@ public:
|
||||
*/
|
||||
PRUnichar ComputeUnicharFromScanCode() const;
|
||||
|
||||
/**
|
||||
* Initializes the aKeyEvent with the information stored in the instance.
|
||||
*/
|
||||
void InitKeyEvent(nsKeyEvent& aKeyEvent,
|
||||
const ModifierKeyState& aModKeyState) const;
|
||||
void InitKeyEvent(nsKeyEvent& aKeyEvent) const
|
||||
{
|
||||
InitKeyEvent(aKeyEvent, mModKeyState);
|
||||
}
|
||||
|
||||
private:
|
||||
nsRefPtr<nsWindowBase> mWidget;
|
||||
HKL mKeyboardLayout;
|
||||
uint32_t mDOMKeyCode;
|
||||
KeyNameIndex mKeyNameIndex;
|
||||
@ -322,6 +332,8 @@ private:
|
||||
// The message which the instance was initialized with.
|
||||
UINT mMessage;
|
||||
|
||||
ModifierKeyState mModKeyState;
|
||||
|
||||
// mVirtualKeyCode distinguishes left key or right key of modifier key.
|
||||
uint8_t mVirtualKeyCode;
|
||||
// mOriginalVirtualKeyCode doesn't distinguish left key or right key of
|
||||
@ -343,6 +355,9 @@ private:
|
||||
}
|
||||
|
||||
UINT GetScanCodeWithExtendedFlag() const;
|
||||
|
||||
// The result is one of nsIDOMKeyEvent::DOM_KEY_LOCATION_*.
|
||||
uint32_t GetKeyLocation() const;
|
||||
};
|
||||
|
||||
class KeyboardLayout
|
||||
|
@ -3615,17 +3615,6 @@ bool nsWindow::DispatchWindowEvent(nsGUIEvent* event, nsEventStatus &aStatus) {
|
||||
return ConvertStatus(aStatus);
|
||||
}
|
||||
|
||||
void nsWindow::InitKeyEvent(nsKeyEvent& aKeyEvent,
|
||||
const NativeKey& aNativeKey,
|
||||
const ModifierKeyState &aModKeyState)
|
||||
{
|
||||
nsIntPoint point(0, 0);
|
||||
InitEvent(aKeyEvent, &point);
|
||||
aKeyEvent.mKeyNameIndex = aNativeKey.GetKeyNameIndex();
|
||||
aKeyEvent.location = aNativeKey.GetKeyLocation();
|
||||
aModKeyState.InitInputEvent(aKeyEvent);
|
||||
}
|
||||
|
||||
bool nsWindow::DispatchKeyEvent(nsKeyEvent& aKeyEvent,
|
||||
const MSG *aMsgSentToPlugin)
|
||||
{
|
||||
@ -6468,7 +6457,7 @@ LRESULT nsWindow::OnKeyDown(const MSG &aMsg,
|
||||
bool isIMEEnabled = IMEHandler::IsIMEEnabled(mInputContext);
|
||||
nsKeyEvent keydownEvent(true, NS_KEY_DOWN, this);
|
||||
keydownEvent.keyCode = DOMKeyCode;
|
||||
InitKeyEvent(keydownEvent, nativeKey, aModKeyState);
|
||||
nativeKey.InitKeyEvent(keydownEvent);
|
||||
noDefault = DispatchKeyEvent(keydownEvent, &aMsg);
|
||||
if (aEventDispatched) {
|
||||
*aEventDispatched = true;
|
||||
@ -6793,14 +6782,14 @@ LRESULT nsWindow::OnKeyDown(const MSG &aMsg,
|
||||
keypressEvent.mFlags.Union(extraFlags);
|
||||
keypressEvent.charCode = uniChar;
|
||||
keypressEvent.alternativeCharCodes.AppendElements(altArray);
|
||||
InitKeyEvent(keypressEvent, nativeKey, modKeyState);
|
||||
nativeKey.InitKeyEvent(keypressEvent, modKeyState);
|
||||
DispatchKeyEvent(keypressEvent, nullptr);
|
||||
}
|
||||
} else {
|
||||
nsKeyEvent keypressEvent(true, NS_KEY_PRESS, this);
|
||||
keypressEvent.mFlags.Union(extraFlags);
|
||||
keypressEvent.keyCode = DOMKeyCode;
|
||||
InitKeyEvent(keypressEvent, nativeKey, aModKeyState);
|
||||
nativeKey.InitKeyEvent(keypressEvent, aModKeyState);
|
||||
DispatchKeyEvent(keypressEvent, nullptr);
|
||||
}
|
||||
|
||||
@ -6821,7 +6810,7 @@ LRESULT nsWindow::OnKeyUp(const MSG &aMsg,
|
||||
nsKeyEvent keyupEvent(true, NS_KEY_UP, this);
|
||||
NativeKey nativeKey(this, aMsg, aModKeyState);
|
||||
keyupEvent.keyCode = nativeKey.GetDOMKeyCode();
|
||||
InitKeyEvent(keyupEvent, nativeKey, aModKeyState);
|
||||
nativeKey.InitKeyEvent(keyupEvent);
|
||||
// Set defaultPrevented of the key event if the VK_MENU is not a system key
|
||||
// release, so that the menu bar does not trigger. This helps avoid
|
||||
// triggering the menu bar for ALT key accelerators used in assistive
|
||||
@ -6913,7 +6902,7 @@ LRESULT nsWindow::OnChar(const MSG &aMsg,
|
||||
if (!keypressEvent.charCode) {
|
||||
keypressEvent.keyCode = aNativeKey.GetDOMKeyCode();
|
||||
}
|
||||
InitKeyEvent(keypressEvent, aNativeKey, modKeyState);
|
||||
aNativeKey.InitKeyEvent(keypressEvent, modKeyState);
|
||||
bool result = DispatchKeyEvent(keypressEvent, &aMsg);
|
||||
if (aEventDispatched)
|
||||
*aEventDispatched = true;
|
||||
|
@ -195,9 +195,6 @@ public:
|
||||
int16_t aButton = nsMouseEvent::eLeftButton,
|
||||
uint16_t aInputSource = nsIDOMMouseEvent::MOZ_SOURCE_MOUSE);
|
||||
virtual bool DispatchWindowEvent(nsGUIEvent*event, nsEventStatus &aStatus);
|
||||
void InitKeyEvent(nsKeyEvent& aKeyEvent,
|
||||
const NativeKey& aNativeKey,
|
||||
const mozilla::widget::ModifierKeyState &aModKeyState);
|
||||
virtual bool DispatchKeyEvent(nsKeyEvent& aKeyEvent,
|
||||
const MSG *aMsgSentToPlugin);
|
||||
void DispatchPendingEvents();
|
||||
|
@ -7,6 +7,7 @@
|
||||
#define nsWindowBase_h_
|
||||
|
||||
#include "nsBaseWidget.h"
|
||||
#include <windows.h>
|
||||
|
||||
/*
|
||||
* nsWindowBase - Base class of common methods other classes need to access
|
||||
|
Loading…
Reference in New Issue
Block a user