зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1077515 - part 11 - Remap arrow keys for vertical writing mode in the Gtk widget code. r=roc
This commit is contained in:
Родитель
28077f9d67
Коммит
6a598abe4a
|
@ -6005,12 +6005,79 @@ nsWindow::GetIMEUpdatePreference()
|
|||
return updatePreference;
|
||||
}
|
||||
|
||||
bool
|
||||
nsWindow::ExecuteNativeKeyBindingRemapped(NativeKeyBindingsType aType,
|
||||
const WidgetKeyboardEvent& aEvent,
|
||||
DoCommandCallback aCallback,
|
||||
void* aCallbackData,
|
||||
uint32_t aGeckoKeyCode,
|
||||
uint32_t aNativeKeyCode)
|
||||
{
|
||||
WidgetKeyboardEvent modifiedEvent(aEvent);
|
||||
modifiedEvent.keyCode = aGeckoKeyCode;
|
||||
static_cast<GdkEventKey*>(modifiedEvent.mNativeKeyEvent)->keyval =
|
||||
aNativeKeyCode;
|
||||
|
||||
NativeKeyBindings* keyBindings = NativeKeyBindings::GetInstance(aType);
|
||||
return keyBindings->Execute(modifiedEvent, aCallback, aCallbackData);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP_(bool)
|
||||
nsWindow::ExecuteNativeKeyBinding(NativeKeyBindingsType aType,
|
||||
const WidgetKeyboardEvent& aEvent,
|
||||
DoCommandCallback aCallback,
|
||||
void* aCallbackData)
|
||||
{
|
||||
if (aEvent.keyCode >= nsIDOMKeyEvent::DOM_VK_LEFT &&
|
||||
aEvent.keyCode <= nsIDOMKeyEvent::DOM_VK_DOWN) {
|
||||
|
||||
// Check if we're targeting content with vertical writing mode,
|
||||
// and if so remap the arrow keys.
|
||||
WidgetQueryContentEvent query(true, NS_QUERY_SELECTED_TEXT, this);
|
||||
nsEventStatus status;
|
||||
DispatchEvent(&query, status);
|
||||
|
||||
if (query.mSucceeded && query.mReply.mWritingMode.IsVertical()) {
|
||||
uint32_t geckoCode = 0;
|
||||
uint32_t gdkCode = 0;
|
||||
switch (aEvent.keyCode) {
|
||||
case nsIDOMKeyEvent::DOM_VK_LEFT:
|
||||
if (query.mReply.mWritingMode.IsVerticalLR()) {
|
||||
geckoCode = nsIDOMKeyEvent::DOM_VK_UP;
|
||||
gdkCode = GDK_Up;
|
||||
} else {
|
||||
geckoCode = nsIDOMKeyEvent::DOM_VK_DOWN;
|
||||
gdkCode = GDK_Down;
|
||||
}
|
||||
break;
|
||||
|
||||
case nsIDOMKeyEvent::DOM_VK_RIGHT:
|
||||
if (query.mReply.mWritingMode.IsVerticalLR()) {
|
||||
geckoCode = nsIDOMKeyEvent::DOM_VK_DOWN;
|
||||
gdkCode = GDK_Down;
|
||||
} else {
|
||||
geckoCode = nsIDOMKeyEvent::DOM_VK_UP;
|
||||
gdkCode = GDK_Up;
|
||||
}
|
||||
break;
|
||||
|
||||
case nsIDOMKeyEvent::DOM_VK_UP:
|
||||
geckoCode = nsIDOMKeyEvent::DOM_VK_LEFT;
|
||||
gdkCode = GDK_Left;
|
||||
break;
|
||||
|
||||
case nsIDOMKeyEvent::DOM_VK_DOWN:
|
||||
geckoCode = nsIDOMKeyEvent::DOM_VK_RIGHT;
|
||||
gdkCode = GDK_Right;
|
||||
break;
|
||||
}
|
||||
|
||||
return ExecuteNativeKeyBindingRemapped(aType, aEvent, aCallback,
|
||||
aCallbackData,
|
||||
geckoCode, gdkCode);
|
||||
}
|
||||
}
|
||||
|
||||
NativeKeyBindings* keyBindings = NativeKeyBindings::GetInstance(aType);
|
||||
return keyBindings->Execute(aEvent, aCallback, aCallbackData);
|
||||
}
|
||||
|
|
|
@ -263,6 +263,13 @@ public:
|
|||
const InputContextAction& aAction);
|
||||
NS_IMETHOD_(InputContext) GetInputContext();
|
||||
virtual nsIMEUpdatePreference GetIMEUpdatePreference();
|
||||
bool ExecuteNativeKeyBindingRemapped(
|
||||
NativeKeyBindingsType aType,
|
||||
const mozilla::WidgetKeyboardEvent& aEvent,
|
||||
DoCommandCallback aCallback,
|
||||
void* aCallbackData,
|
||||
uint32_t aGeckoKeyCode,
|
||||
uint32_t aNativeKeyCode);
|
||||
NS_IMETHOD_(bool) ExecuteNativeKeyBinding(
|
||||
NativeKeyBindingsType aType,
|
||||
const mozilla::WidgetKeyboardEvent& aEvent,
|
||||
|
|
Загрузка…
Ссылка в новой задаче