]> git.mdlowis.com Git - projs/tide.git/commitdiff
updated logic for focus follows mouse to not override a change of focus from keyboard...
authorMichael D. Lowis <mike@mdlowis.com>
Tue, 2 May 2017 01:10:26 +0000 (21:10 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Tue, 2 May 2017 01:10:26 +0000 (21:10 -0400)
lib/win.c
lib/x11.c

index ca7d2417aaa1370e49acdc51633fbf322f512b26..674b6a4c62692c56ed0acd6cef7fafe09b0b8705 100644 (file)
--- a/lib/win.c
+++ b/lib/win.c
@@ -63,15 +63,24 @@ void win_dialog(char* name) {
     x11_dialog(name, Width, Height);
 }
 
-void win_loop(void) {
+static bool update_focus(void) {
+    static int prev_x = 0, prev_y = 0;
     int ptr_x, ptr_y;
+    bool changed = true;
+    x11_mouse_get(&ptr_x, &ptr_y);
+    if (prev_x != ptr_x || prev_y != ptr_y)
+        changed = win_setregion(getregion(ptr_x, ptr_y));
+    prev_x = ptr_x, prev_y = ptr_y;
+    return changed;
+}
+
+void win_loop(void) {
     x11_show();
+    x11_flip();
     while (x11_running()) {
         bool pending = x11_events_await(200 /* ms */);
         x11_flush();
-        x11_mouse_get(&ptr_x, &ptr_y);
-        win_setregion(getregion(ptr_x, ptr_y));
-        if (win_setregion(getregion(ptr_x, ptr_y)) || pending) {
+        if (update_focus() || pending) {
             x11_events_take();
             x11_flip();
         }
@@ -295,8 +304,6 @@ static void onmouse(MouseAct act, MouseBtn btn, int x, int y) {
             } else {
                 view_selext(win_view(selid), row, col);
             }
-        } else if (id == TAGS || id == EDIT) {
-            Focused = id;
         }
     } else {
         MouseBtns[btn].pressed = (act == MOUSE_ACT_DOWN);
index 90c8f4439159e1ab7311b0f9cc2ef476b25b8cf1..532ddac3b415ca2873f674975b36f9f26aad0aa8 100644 (file)
--- a/lib/x11.c
+++ b/lib/x11.c
@@ -135,8 +135,6 @@ void x11_window(char* name, int width, int height) {
         | ButtonPressMask
         | ButtonReleaseMask
         | ButtonMotionMask
-//        | PointerMotionMask
-//        | PointerMotionHintMask
         | KeyPressMask
     );