浏览代码

Wayland: Control key repeat via timerfd state

The key repeat logic is now controlled only via the key repeat timerfd.
Camilla Löwy 3 年之前
父节点
当前提交
850893a39f
共有 2 个文件被更改,包括 9 次插入12 次删除
  1. 3 3
      src/wl_init.c
  2. 6 9
      src/wl_window.c

+ 3 - 3
src/wl_init.c

@@ -504,12 +504,12 @@ static void keyboardHandleLeave(void* data,
     if (!window)
         return;
 
+    struct itimerspec timer = {};
+    timerfd_settime(_glfw.wl.timerfd, 0, &timer, NULL);
+
     _glfw.wl.serial = serial;
     _glfw.wl.keyboardFocus = NULL;
     _glfwInputWindowFocus(window, GLFW_FALSE);
-
-    struct itimerspec timer = {};
-    timerfd_settime(_glfw.wl.timerfd, 0, &timer, NULL);
 }
 
 static int toGLFWKeyCode(uint32_t key)

+ 6 - 9
src/wl_window.c

@@ -749,16 +749,13 @@ static void handleEvents(int timeout)
 
             if (read(_glfw.wl.timerfd, &repeats, sizeof(repeats)) == 8)
             {
-                if (_glfw.wl.keyboardFocus)
+                for (uint64_t i = 0; i < repeats; i++)
                 {
-                    for (uint64_t i = 0; i < repeats; i++)
-                    {
-                        _glfwInputKey(_glfw.wl.keyboardFocus,
-                                      _glfw.wl.keyboardLastKey,
-                                      _glfw.wl.keyboardLastScancode,
-                                      GLFW_REPEAT,
-                                      _glfw.wl.xkb.modifiers);
-                    }
+                    _glfwInputKey(_glfw.wl.keyboardFocus,
+                                  _glfw.wl.keyboardLastKey,
+                                  _glfw.wl.keyboardLastScancode,
+                                  GLFW_REPEAT,
+                                  _glfw.wl.xkb.modifiers);
                 }
             }
         }