зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1903418 - Properly use the wayland code path when running under wayland. r=timhuang
Differential Revision: https://phabricator.services.mozilla.com/D214209
This commit is contained in:
Родитель
5a798245ea
Коммит
0b5aa260ab
|
@ -62,6 +62,7 @@
|
|||
# include "nsMacUtilsImpl.h"
|
||||
# include <CoreFoundation/CoreFoundation.h>
|
||||
#elif defined(XP_LINUX)
|
||||
# include "mozilla/WidgetUtilsGtk.h"
|
||||
# include <gtk/gtk.h>
|
||||
# ifdef MOZ_X11
|
||||
# include <X11/XKBlib.h>
|
||||
|
@ -308,56 +309,60 @@ void PopulateKeyboardLayout() {
|
|||
TISGetInputSourceProperty(source, kTISPropertyInputSourceID));
|
||||
CFStringGetCString(layoutID, layout, sizeof(layout), kCFStringEncodingUTF8);
|
||||
layoutName.Assign(layout);
|
||||
#elif defined(XP_LINUX)
|
||||
#elif defined(XP_LINUX) && !defined(ANDROID)
|
||||
if (mozilla::widget::GdkIsX11Display()) {
|
||||
# if defined(MOZ_X11)
|
||||
Display* display = XOpenDisplay(nullptr);
|
||||
if (!display) {
|
||||
return;
|
||||
}
|
||||
XkbDescRec* kbdDesc = XkbAllocKeyboard();
|
||||
if (!kbdDesc) {
|
||||
Display* display = XOpenDisplay(nullptr);
|
||||
if (!display) {
|
||||
return;
|
||||
}
|
||||
XkbDescRec* kbdDesc = XkbAllocKeyboard();
|
||||
if (!kbdDesc) {
|
||||
XCloseDisplay(display);
|
||||
return;
|
||||
}
|
||||
|
||||
XkbStateRec state;
|
||||
XkbGetState(display, XkbUseCoreKbd, &state);
|
||||
uint32_t group = state.group;
|
||||
|
||||
XkbGetNames(display, XkbGroupNamesMask, kbdDesc);
|
||||
|
||||
if (!kbdDesc->names || !kbdDesc->names->groups[group]) {
|
||||
return;
|
||||
}
|
||||
|
||||
char* layout = XGetAtomName(display, kbdDesc->names->groups[group]);
|
||||
|
||||
XkbFreeKeyboard(kbdDesc, 0, True);
|
||||
XCloseDisplay(display);
|
||||
return;
|
||||
}
|
||||
|
||||
XkbStateRec state;
|
||||
XkbGetState(display, XkbUseCoreKbd, &state);
|
||||
uint32_t group = state.group;
|
||||
|
||||
XkbGetNames(display, XkbGroupNamesMask, kbdDesc);
|
||||
|
||||
if (!kbdDesc->names || !kbdDesc->names->groups[group]) {
|
||||
return;
|
||||
}
|
||||
|
||||
char* layout = XGetAtomName(display, kbdDesc->names->groups[group]);
|
||||
|
||||
XkbFreeKeyboard(kbdDesc, 0, True);
|
||||
XCloseDisplay(display);
|
||||
|
||||
layoutName.Assign(layout);
|
||||
# elif defined(MOZ_WAYLAND)
|
||||
struct xkb_context* context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||
if (!context) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct xkb_keymap* keymap =
|
||||
xkb_keymap_new_from_names(context, NULL, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||
if (!keymap) {
|
||||
xkb_context_unref(context);
|
||||
return;
|
||||
}
|
||||
|
||||
const char* layout = xkb_keymap_layout_get_name(keymap, 0);
|
||||
|
||||
if (layout) {
|
||||
layoutName.Assign(layout);
|
||||
}
|
||||
|
||||
xkb_keymap_unref(keymap);
|
||||
xkb_context_unref(context);
|
||||
# endif
|
||||
} else {
|
||||
# if defined(MOZ_WAYLAND)
|
||||
struct xkb_context* context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||
if (!context) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct xkb_keymap* keymap = xkb_keymap_new_from_names(
|
||||
context, nullptr, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||
if (!keymap) {
|
||||
xkb_context_unref(context);
|
||||
return;
|
||||
}
|
||||
|
||||
const char* layout = xkb_keymap_layout_get_name(keymap, 0);
|
||||
|
||||
if (layout) {
|
||||
layoutName.Assign(layout);
|
||||
}
|
||||
|
||||
xkb_keymap_unref(keymap);
|
||||
xkb_context_unref(context);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (layoutName.IsEmpty()) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче