]> git.mdlowis.com Git - projs/tide.git/commitdiff
add logic to warp pointer when opening windows or jumping to lines
authorMichael D. Lowis <mike.lowis@gentex.com>
Fri, 18 Jan 2019 19:19:01 +0000 (14:19 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Fri, 18 Jan 2019 19:19:01 +0000 (14:19 -0500)
TODO.md
inc/win.h
src/lib/draw.c
src/lib/x11_gc.c
src/tide.c

diff --git a/TODO.md b/TODO.md
index 1588a2e84dcc0cd8b7d083a346f991c413595a6a..e117cf41ed03be41e2dd0e6bc66d939fcf2193ea 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -6,8 +6,9 @@
 
 * registrar: doesnt match open windows when new file created and is then opened for edit or line number
 * registrar: group by hostname or group env var in registrar
-* tide: gap buffer does not handle UTF-8 currently
 * registrar: should cleanup invalid windows
+* tide: gap buffer does not handle UTF-8 currently
+* tide: search should not warp pointer when nothing found
 
 ## BACKLOG
 
index e37567fd799939fa71cb6f0d9aa406b1637dcfe5..28a718431c04ec00aa0cee9b1e7700a0c0aa24b7 100644 (file)
--- a/inc/win.h
+++ b/inc/win.h
@@ -130,3 +130,4 @@ void win_togglefocus(void);
 View* win_view(WinRegion id);
 Buf* win_buf(WinRegion id);
 bool win_keymodsset(int mask);
+void win_setln(int line_num);
index 94233f5d640c71463e072c1364c06e2b57c4cac8..36cb1503b1b6156329e8fea947632072a6201b12 100644 (file)
@@ -46,7 +46,7 @@ void draw_view(XConf* x, View* view, XftFont* font, size_t nrows, drawcsr* csr,
             if (row->cols[i].off == view->buffer.selection.end) {
                 csr_drawn = draw_csr(x, view, fg, fheight, posx, y, csr_drawn);
                 if (csrsync) {
-                    XWarpPointer(x->display, x->self, x->self, 0, 0, x->width, x->height, posx-4, y + fheight/2);
+                    XWarpPointer(x->display, None, x->self, 0, 0, x->width, x->height, posx-4, y + fheight/2);
                     csrsync = false;
                 }
             }
index 93b3000a367f1e58703a2b61981644651c353ec1..b08ef0979d678a17a2e7d21dc8ae91417ebc74f1 100644 (file)
@@ -70,6 +70,7 @@ void x11_show(XConf* x) {
             continue;
         xresize(x, &ev);
     } while (ev.type != MapNotify);
+    XWarpPointer(x->display, None, x->self, 0, 0, x->width, x->height, x->width/2, x->height/2);
 }
 
 XftFont* x11_font_load(XConf* x, char* name) {
index c541880012b35c671cf6b2a40e0cdc44a1b8ba5f..53d769825a35ca69070171a9261e856a8ac5e40b 100644 (file)
@@ -247,7 +247,7 @@ static void xclientmsg(XConf* x, XEvent* e) {
     if ((Atom)(e->xclient.data.l[0]) == XInternAtom(x->display, "WM_DELETE_WINDOW", False))
         win_quit();
     else if (e->xclient.message_type == XInternAtom(x->display, "GOTO", False))
-        view_setln(win_view(EDIT), e->xclient.data.l[0]);
+        win_setln(e->xclient.data.l[0]);
 }
 
 static void xupdate(Job* job) {
@@ -389,6 +389,11 @@ bool win_keymodsset(int mask) {
     return ((KeyBtnState & mask) == mask);
 }
 
+void win_setln(int line_num) {
+    view_setln(win_view(EDIT), line_num);
+    SyncMouse = true;
+}
+
 /* Tag/Cmd Execution
  ******************************************************************************/
 static Tag* tag_lookup(char* cmd) {
@@ -717,12 +722,10 @@ static void fcomplete(char* arg) {
 static void jump_to(char* arg) {
     if (arg) {
         size_t line = strtoul(arg, NULL, 0);
-        if (line) {
-            view_setln(win_view(EDIT), line);
-            SyncMouse = true;
-        } else {
+        if (line)
+            win_setln(line);
+        else
             pick_symbol(arg);
-        }
     }
 }
 
@@ -926,7 +929,7 @@ int main(int argc, char** argv) {
         char* path = realpath(*argv, NULL);
         if (!path) path = strdup(*argv); /* if file doesnt exist, use the original name */
         view_init(win_view(EDIT), path);
-        view_setln(win_view(EDIT), line_num);
+        win_setln(line_num);
         win_title(path);
         win_prop_set("FILE", "file", path);
         free(path);