Skip to content

Commit 6fc1a10

Browse files
author
Sandor Molnar
committed
Backed out changeset b06f19b95b94 (bug 1784438) for causing build bustages CLOSED TREE
1 parent fae34b6 commit 6fc1a10

File tree

4 files changed

+11
-165
lines changed

4 files changed

+11
-165
lines changed

widget/gtk/mozwayland/mozwayland.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,6 @@ MOZ_EXPORT struct xkb_keymap* xkb_keymap_new_from_string(
251251
return NULL;
252252
}
253253

254-
MOZ_EXPORT struct xkb_keymap* xkb_keymap_ref(struct xkb_keymap* keymap) {
255-
return NULL;
256-
}
257-
258254
MOZ_EXPORT void xkb_keymap_unref(struct xkb_keymap* keymap) {}
259255

260256
MOZ_EXPORT const char* xkb_keymap_layout_get_name(struct xkb_keymap* keymap,
@@ -266,8 +262,3 @@ MOZ_EXPORT xkb_mod_index_t xkb_keymap_mod_get_index(struct xkb_keymap* keymap,
266262
const char* name) {
267263
return XKB_MOD_INVALID;
268264
}
269-
270-
MOZ_EXPORT int xkb_keymap_key_repeats(struct xkb_keymap* keymap,
271-
xkb_keycode_t kc) {
272-
return 0;
273-
}

widget/gtk/nsGtkKeyUtils.cpp

Lines changed: 7 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ Time KeymapWrapper::sLastRepeatableKeyTime = 0;
6565
KeymapWrapper::RepeatState KeymapWrapper::sRepeatState =
6666
KeymapWrapper::NOT_PRESSED;
6767

68-
#ifdef MOZ_WAYLAND
69-
uint32_t KeymapWrapper::sLastRepeatableSerial = 0;
70-
#endif
71-
7268
static const char* GetBoolName(bool aBool) { return aBool ? "TRUE" : "FALSE"; }
7369

7470
static const char* GetStatusName(nsEventStatus aStatus) {
@@ -669,8 +665,6 @@ void KeymapWrapper::SetModifierMasks(xkb_keymap* aKeymap) {
669665
keymapWrapper->SetModifierMask(aKeymap, INDEX_LEVEL3, "Level3");
670666
keymapWrapper->SetModifierMask(aKeymap, INDEX_LEVEL5, "Level5");
671667

672-
keymapWrapper->SetKeymap(aKeymap);
673-
674668
MOZ_LOG(gKeyLog, LogLevel::Info,
675669
("%p KeymapWrapper::SetModifierMasks, CapsLock=0x%X, NumLock=0x%X, "
676670
"ScrollLock=0x%X, Level3=0x%X, Level5=0x%X, "
@@ -713,13 +707,6 @@ void KeymapWrapper::HandleKeymap(uint32_t format, int fd, uint32_t size) {
713707
}
714708

715709
struct xkb_context* xkb_context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
716-
if (!xkb_context) {
717-
MOZ_LOG(gKeyLog, LogLevel::Info,
718-
("KeymapWrapper::HandleKeymap(): failed to get xkb_context!"));
719-
close(fd);
720-
return;
721-
}
722-
723710
struct xkb_keymap* keymap = xkb_keymap_new_from_string(
724711
xkb_context, mapString, XKB_KEYMAP_FORMAT_TEXT_V1,
725712
XKB_KEYMAP_COMPILE_NO_FLAGS);
@@ -730,7 +717,6 @@ void KeymapWrapper::HandleKeymap(uint32_t format, int fd, uint32_t size) {
730717
if (!keymap) {
731718
MOZ_LOG(gKeyLog, LogLevel::Info,
732719
("KeymapWrapper::HandleKeymap(): Failed to compile keymap!"));
733-
xkb_context_unref(xkb_context);
734720
return;
735721
}
736722

@@ -745,11 +731,6 @@ void KeymapWrapper::HandleKeymap(uint32_t format, int fd, uint32_t size) {
745731
KeymapWrapper::~KeymapWrapper() {
746732
#ifdef MOZ_X11
747733
gdk_window_remove_filter(nullptr, FilterEvents, this);
748-
#endif
749-
#ifdef MOZ_WAYLAND
750-
if (mXkbKeymap) {
751-
xkb_keymap_unref(mXkbKeymap);
752-
}
753734
#endif
754735
if (mOnKeysChangedSignalHandle) {
755736
g_signal_handler_disconnect(mGdkKeymap, mOnKeysChangedSignalHandle);
@@ -877,87 +858,6 @@ GdkFilterReturn KeymapWrapper::FilterEvents(GdkXEvent* aXEvent,
877858
}
878859
#endif
879860

880-
#ifdef MOZ_WAYLAND
881-
// static
882-
void KeymapWrapper::KeyboardHandlerForWayland(uint32_t aSerial,
883-
uint32_t aHardwareKeycode,
884-
uint32_t aState) {
885-
KeymapWrapper* keymapWrapper = GetInstance();
886-
if (!keymapWrapper->IsAutoRepeatableKey(aHardwareKeycode)) {
887-
MOZ_LOG(gKeyLog, LogLevel::Info,
888-
("KeyboardHandlerForWayland(aSerial=%u, aHardwareKeycode=0x%08X, "
889-
"aState=%s), no repeat key",
890-
aSerial, aHardwareKeycode,
891-
aState == WL_KEYBOARD_KEY_STATE_PRESSED
892-
? "WL_KEYBOARD_KEY_STATE_PRESSED"
893-
: "WL_KEYBOARD_KEY_STATE_RELEASED"));
894-
return;
895-
}
896-
897-
if (aState == WL_KEYBOARD_KEY_STATE_PRESSED) {
898-
MOZ_LOG(gKeyLog, LogLevel::Info,
899-
("KeyboardHandlerForWayland(aSerial=%u, aHardwareKeycode=0x%08X, "
900-
"aState=WL_KEYBOARD_KEY_STATE_PRESSED), first key pressed",
901-
aSerial, aHardwareKeycode));
902-
903-
sLastRepeatableSerial = aSerial;
904-
sLastRepeatableHardwareKeyCode = aHardwareKeycode;
905-
sRepeatState = FIRST_PRESS;
906-
907-
// This runnable will be run after GDK's key event.
908-
//
909-
// Next key press of GDK will be after repeat's delay ms.
910-
// But event time in next key press wonn't updated.
911-
//
912-
// The delay's default is 400ms in GTK/wayland. Even if we can get this
913-
// information from repeat_info, if we wait for this time, it is too late.
914-
// We guess that 10ms will be enough durration to set repeat state.
915-
916-
NS_DelayedDispatchToCurrentThread(
917-
NS_NewRunnableFunction(
918-
__func__,
919-
[aSerial] {
920-
if (sLastRepeatableSerial != aSerial) {
921-
// We already receive newer key event. Don't set repeat state.
922-
return;
923-
}
924-
925-
MOZ_LOG(gKeyLog, LogLevel::Info,
926-
("KeyboardHandlerForWayland(aSerial=%u, "
927-
"aState=WL_KEYBOARD_KEY_STATE_PRESSED), repeating",
928-
aSerial));
929-
sRepeatState = REPEATING;
930-
}),
931-
10);
932-
return;
933-
}
934-
935-
if (sLastRepeatableHardwareKeyCode != aHardwareKeycode) {
936-
MOZ_LOG(gKeyLog, LogLevel::Info,
937-
("KeyboardHandlerForWayland(aSerial=%u, aHardwareKeycode=0x%08X "
938-
"aState=WL_KEYBOARD_KEY_STATE_RELEASED), released key isn't "
939-
"matched",
940-
aSerial, aHardwareKeycode));
941-
return;
942-
}
943-
944-
MOZ_LOG(gKeyLog, LogLevel::Info,
945-
("KeyboardHandlerForWayland(aSerial=%u, aHardwareKeycode=0x%08X"
946-
"aState=WL_KEYBOARD_KEY_STATE_RELEASED), not pressed",
947-
aSerial, aHardwareKeycode));
948-
949-
sLastRepeatableSerial = aSerial;
950-
sRepeatState = NOT_PRESSED;
951-
}
952-
953-
void KeymapWrapper::SetKeymap(xkb_keymap* aKeymap) {
954-
if (mXkbKeymap) {
955-
xkb_keymap_unref(mXkbKeymap);
956-
}
957-
mXkbKeymap = xkb_keymap_ref(aKeymap);
958-
}
959-
#endif
960-
961861
static void ResetBidiKeyboard() {
962862
// Reset the bidi keyboard settings for the new GdkKeymap
963863
nsCOMPtr<nsIBidiKeyboard> bidiKeyboard = nsContentUtils::GetBidiKeyboard();
@@ -2133,28 +2033,15 @@ bool KeymapWrapper::IsLatinGroup(guint8 aGroup) {
21332033
}
21342034

21352035
bool KeymapWrapper::IsAutoRepeatableKey(guint aHardwareKeyCode) {
2136-
GdkDisplay* gdkDisplay = gdk_display_get_default();
21372036
#ifdef MOZ_X11
2138-
if (GdkIsX11Display(gdkDisplay)) {
2139-
uint8_t indexOfArray = aHardwareKeyCode / 8;
2140-
MOZ_ASSERT(indexOfArray < std::size(mKeyboardState.auto_repeats),
2141-
"invalid index");
2142-
char bitMask = 1 << (aHardwareKeyCode % 8);
2143-
return (mKeyboardState.auto_repeats[indexOfArray] & bitMask) != 0;
2144-
}
2145-
#endif
2146-
#ifdef MOZ_WAYLAND
2147-
if (GdkIsWaylandDisplay(gdkDisplay)) {
2148-
if (MOZ_UNLIKELY(!mXkbKeymap)) {
2149-
static bool sWarned = false;
2150-
NS_WARNING_ASSERTION(sWarned, "no keymap!");
2151-
sWarned = true;
2152-
return false;
2153-
}
2154-
return !!xkb_keymap_key_repeats(mXkbKeymap, aHardwareKeyCode);
2155-
}
2156-
#endif
2037+
uint8_t indexOfArray = aHardwareKeyCode / 8;
2038+
MOZ_ASSERT(indexOfArray < std::size(mKeyboardState.auto_repeats),
2039+
"invalid index");
2040+
char bitMask = 1 << (aHardwareKeyCode % 8);
2041+
return (mKeyboardState.auto_repeats[indexOfArray] & bitMask) != 0;
2042+
#else
21572043
return false;
2044+
#endif
21582045
}
21592046

21602047
/* static */
@@ -2759,8 +2646,6 @@ void KeymapWrapper::SetFocusOut(wl_surface* aFocusSurface) {
27592646

27602647
keymapWrapper->mFocusSurface = nullptr;
27612648
keymapWrapper->mFocusSerial = 0;
2762-
2763-
sRepeatState = NOT_PRESSED;
27642649
}
27652650

27662651
void KeymapWrapper::GetFocusInfo(wl_surface** aFocusSurface,
@@ -2769,14 +2654,6 @@ void KeymapWrapper::GetFocusInfo(wl_surface** aFocusSurface,
27692654
*aFocusSurface = keymapWrapper->mFocusSurface;
27702655
*aFocusSerial = keymapWrapper->mFocusSerial;
27712656
}
2772-
2773-
void KeymapWrapper::ClearKeymap() {
2774-
KeymapWrapper* keymapWrapper = KeymapWrapper::GetInstance();
2775-
if (keymapWrapper->mXkbKeymap) {
2776-
xkb_keymap_unref(keymapWrapper->mXkbKeymap);
2777-
keymapWrapper->mXkbKeymap = nullptr;
2778-
}
2779-
}
27802657
#endif
27812658

27822659
} // namespace widget

widget/gtk/nsGtkKeyUtils.h

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,9 @@ class KeymapWrapper {
207207
static void SetFocusOut(wl_surface* aFocusSurface);
208208
static void GetFocusInfo(wl_surface** aFocusSurface, uint32_t* aFocusSerial);
209209

210-
/**
211-
* Key repeat helpers for Wayland
212-
*/
213-
static void KeyboardHandlerForWayland(uint32_t aSerial,
214-
uint32_t aHardwareKeycode,
215-
uint32_t aState);
216-
static void ClearKeymap();
210+
static void SetKeyboard(wl_keyboard* aKeyboard);
211+
static wl_keyboard* GetKeyboard();
212+
static void ClearKeyboard();
217213

218214
/**
219215
* EnsureInstance() is provided on Wayland to register Wayland callbacks
@@ -354,24 +350,12 @@ class KeymapWrapper {
354350
enum RepeatState { NOT_PRESSED, FIRST_PRESS, REPEATING };
355351
static RepeatState sRepeatState;
356352

357-
#ifdef MOZ_WAYLAND
358-
xkb_keymap* mXkbKeymap = nullptr;
359-
static uint32_t sLastRepeatableSerial;
360-
#endif
361-
362353
/**
363354
* IsAutoRepeatableKey() returns true if the key supports auto repeat.
364355
* Otherwise, false.
365356
*/
366357
bool IsAutoRepeatableKey(guint aHardwareKeyCode);
367358

368-
#ifdef MOZ_WAYLAND
369-
/**
370-
* Set current xkb_keymap to detect auto repeat key on Wayland.
371-
*/
372-
void SetKeymap(xkb_keymap* aKeymap);
373-
#endif
374-
375359
/**
376360
* Signal handlers.
377361
*/

widget/gtk/nsWaylandDisplay.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -342,12 +342,7 @@ static void keyboard_handle_leave(void* data, struct wl_keyboard* keyboard,
342342

343343
static void keyboard_handle_key(void* data, struct wl_keyboard* keyboard,
344344
uint32_t serial, uint32_t time, uint32_t key,
345-
uint32_t state) {
346-
// hardware key code is +8.
347-
// https://gitlab.gnome.org/GNOME/gtk/-/blob/3.24.41/gdk/wayland/gdkdevice-wayland.c#L2341
348-
KeymapWrapper::KeyboardHandlerForWayland(serial, key + 8, state);
349-
}
350-
345+
uint32_t state) {}
351346
static void keyboard_handle_modifiers(void* data, struct wl_keyboard* keyboard,
352347
uint32_t serial, uint32_t mods_depressed,
353348
uint32_t mods_latched,
@@ -372,7 +367,6 @@ void nsWaylandDisplay::ClearKeyboard() {
372367
if (mKeyboard) {
373368
wl_keyboard_destroy(mKeyboard);
374369
mKeyboard = nullptr;
375-
KeymapWrapper::ClearKeymap();
376370
}
377371
}
378372

0 commit comments

Comments
 (0)