firefox/mozilla-1468670.patch
2018-07-17 08:56:42 +02:00

103 lines
2.9 KiB
Diff

diff --git a/widget/gtk/nsGtkKeyUtils.h b/widget/gtk/nsGtkKeyUtils.h
--- a/widget/gtk/nsGtkKeyUtils.h
+++ b/widget/gtk/nsGtkKeyUtils.h
@@ -169,17 +169,20 @@ protected:
bool mInitialized;
/**
* Initializing methods.
*/
void Init();
void InitXKBExtension();
- void InitBySystemSettings();
+ void InitBySystemSettingsX11();
+#ifdef MOZ_WAYLAND
+ void InitBySystemSettingsWayland();
+#endif
/**
* mModifierKeys stores each hardware key information.
*/
struct ModifierKey {
guint mHardwareKeycode;
guint mMask;
diff --git a/widget/gtk/nsGtkKeyUtils.cpp b/widget/gtk/nsGtkKeyUtils.cpp
--- a/widget/gtk/nsGtkKeyUtils.cpp
+++ b/widget/gtk/nsGtkKeyUtils.cpp
@@ -190,17 +190,21 @@ KeymapWrapper::Init()
MOZ_LOG(gKeymapWrapperLog, LogLevel::Info,
("%p Init, mGdkKeymap=%p",
this, mGdkKeymap));
mModifierKeys.Clear();
memset(mModifierMasks, 0, sizeof(mModifierMasks));
if (GDK_IS_X11_DISPLAY(gdk_display_get_default()))
- InitBySystemSettings();
+ InitBySystemSettingsX11();
+#ifdef MOZ_WAYLAND
+ else
+ InitBySystemSettingsWayland();
+#endif
gdk_window_add_filter(nullptr, FilterEvents, this);
MOZ_LOG(gKeymapWrapperLog, LogLevel::Info,
("%p Init, CapsLock=0x%X, NumLock=0x%X, "
"ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, "
"Shift=0x%X, Ctrl=0x%X, Alt=0x%X, Meta=0x%X, Super=0x%X, Hyper=0x%X",
this,
@@ -270,20 +274,20 @@ KeymapWrapper::InitXKBExtension()
return;
}
MOZ_LOG(gKeymapWrapperLog, LogLevel::Info,
("%p InitXKBExtension, Succeeded", this));
}
void
-KeymapWrapper::InitBySystemSettings()
+KeymapWrapper::InitBySystemSettingsX11()
{
MOZ_LOG(gKeymapWrapperLog, LogLevel::Info,
- ("%p InitBySystemSettings, mGdkKeymap=%p",
+ ("%p InitBySystemSettingsX11, mGdkKeymap=%p",
this, mGdkKeymap));
Display* display =
gdk_x11_display_get_xdisplay(gdk_display_get_default());
int min_keycode = 0;
int max_keycode = 0;
XDisplayKeycodes(display, &min_keycode, &max_keycode);
@@ -434,16 +438,26 @@ KeymapWrapper::InitBySystemSettings()
}
}
}
XFreeModifiermap(xmodmap);
XFree(xkeymap);
}
+#ifdef MOZ_WAYLAND
+void
+KeymapWrapper::InitBySystemSettingsWayland()
+{
+ // Not implemented yet, but at least Alt modifier should be handled to save
+ // popular usage.
+ mModifierMasks[INDEX_ALT] = 1 << 3;
+}
+#endif
+
KeymapWrapper::~KeymapWrapper()
{
gdk_window_remove_filter(nullptr, FilterEvents, this);
g_signal_handlers_disconnect_by_func(mGdkKeymap,
FuncToGpointer(OnKeysChanged), this);
g_signal_handlers_disconnect_by_func(mGdkKeymap,
FuncToGpointer(OnDirectionChanged), this);
g_object_unref(mGdkKeymap);