]> git.mdlowis.com Git - projs/tide.git/commitdiff
more refactoring
authorMichael D. Lowis <mike@mdlowis.com>
Thu, 12 Apr 2018 02:14:45 +0000 (22:14 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Thu, 12 Apr 2018 02:14:45 +0000 (22:14 -0400)
inc/win.h
lib/x11.c
tide.c

index c7573b15fac8ac0f997a32bc0fc8f9fa9938a7cb..e4a532ad69051176ac67d6cfab7c163040565c6b 100644 (file)
--- a/inc/win.h
+++ b/inc/win.h
@@ -142,8 +142,6 @@ void win_loop(void);
 void win_quit(void);
 View* win_view(WinRegion id);
 Buf* win_buf(WinRegion id);
-WinRegion win_getregion(void);
-void win_setregion(WinRegion id);
 
 /* move these to x11.c when possible */
 extern int SearchDir;
index 75ed919b78b08977050c7bcf623b8a56b1e82424..45409a010df14d9f23321f641f200021a9c26c32 100644 (file)
--- a/lib/x11.c
+++ b/lib/x11.c
@@ -26,6 +26,7 @@ struct XFont {
     ((KeyBtnState & (1 << (btn + 7))) == (1 << (btn + 7)))
 
 /******************************************************************************/
+
 static void die(const char* msg);
 
 static XFont x11_font_load(char* name);
@@ -156,14 +157,6 @@ void win_loop(void) {
     while (1) job_poll(Timeout);
 }
 
-WinRegion win_getregion(void) {
-    return Focused;
-}
-
-void win_setregion(WinRegion id) {
-    Focused = id;
-}
-
 View* win_view(WinRegion id) {
     return &(Regions[id == FOCUSED ? Focused : id]);
 }
@@ -272,7 +265,7 @@ XFont x11_font_load(char* name) {
     FcResult result;
     FcPattern* match = XftFontMatch(X.display, X.screen, pattern, &result);
     if (!match || !(font->match = XftFontOpenPattern(X.display, match)))
-        die("could not load base font");
+        die("could not load base font\n");
     font->height = font->match->ascent + font->match->descent;
     return font;
 }
@@ -431,7 +424,7 @@ static void xfocus(XEvent* e) {
 
 static void xkeypress(XEvent* e) {
     X.now = e->xkey.time;
-    win_setregion(getregion(e->xkey.x, e->xkey.y));
+    Focused = getregion(e->xkey.x, e->xkey.y);
     uint32_t key = getkey(e);
     if (key == RUNE_ERR) return;
     KeyBtnState = e->xkey.state, LastKey = key;
@@ -587,15 +580,14 @@ static uint32_t getkey(XEvent* e) {
 
 static void mouse_click(int btn, bool pressed, int x, int y) {
     size_t row, col;
-    WinRegion id = getregion(x, y);
-    win_setregion(id);
-    get_position(id, x, y, &row, &col);
+    Focused = getregion(x, y);
+    get_position(Focused, x, y, &row, &col);
     switch(btn) {
-        case MouseLeft:    mouse_left(id, pressed, row, col);    break;
-        case MouseMiddle:  mouse_middle(id, pressed, row, col);  break;
-        case MouseRight:   mouse_right(id, pressed, row, col);   break;
-        case MouseWheelUp: view_scroll(win_view(id), -ScrollBy); break;
-        case MouseWheelDn: view_scroll(win_view(id), +ScrollBy); break;
+        case MouseLeft:    mouse_left(Focused, pressed, row, col);    break;
+        case MouseMiddle:  mouse_middle(Focused, pressed, row, col);  break;
+        case MouseRight:   mouse_right(Focused, pressed, row, col);   break;
+        case MouseWheelUp: view_scroll(win_view(Focused), -ScrollBy); break;
+        case MouseWheelDn: view_scroll(win_view(Focused), +ScrollBy); break;
     }
 }
 
diff --git a/tide.c b/tide.c
index 96da7d80db8cc0c0d2d5112c63c572c9f893399a..88b0ed3d58e62269487b649e02363de6bbb8dae4 100644 (file)
--- a/tide.c
+++ b/tide.c
@@ -263,7 +263,7 @@ static void select_prev(char* arg) {
 }
 
 static void change_focus(char* arg) {
-    win_setregion(win_getregion() == TAGS ? EDIT : TAGS);
+    /* move the mouse to the region */
 }
 
 static void undo(char* arg) {
@@ -347,7 +347,7 @@ static void jump_to(char* arg) {
         size_t line = strtoul(arg, NULL, 0);
         if (line) {
             view_setln(win_view(EDIT), line);
-            win_setregion(EDIT);
+            /* move mouse to edit region */
         } else {
             pick_symbol(arg);
         }