]> git.mdlowis.com Git - projs/tide.git/commitdiff
tweaked mouse handling for gutter and out of bounds
authorMichael D. Lowis <mike@mdlowis.com>
Fri, 16 Jun 2017 02:12:24 +0000 (22:12 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Fri, 16 Jun 2017 02:12:24 +0000 (22:12 -0400)
TODO.md
lib/win.c

diff --git a/TODO.md b/TODO.md
index 204268b643f23f781ef5e00e81096fd823e78822..ace4a9f73e7e64a951d873f9ac888583552212fe 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -5,7 +5,6 @@ Up Next:
 * add a cap to the distance from last span to first char on screen
 * Ctrl+/ shortcut to comment/uncomment based on syntax
 * ignore the menu key or map it to control
-* clicking or dragging the mouse out of bounds should still update the selection
 * implement transaction control in buf.c
 * implement X resources config file
 * highlight classes of identifiers
index 9b485884aafcfd7e852dd06f1ed4aa07ca486678..7c5297ec93da1e75b856abb124863c8254ddc693 100644 (file)
--- a/lib/win.c
+++ b/lib/win.c
@@ -334,14 +334,17 @@ static void scroll_actions(int btn, bool pressed, int x, int y) {
 }
 
 static void onmousedrag(int state, int x, int y) {
-    WinRegion id = getregion(x, y);
-    size_t row = (y-Regions[id].y) / x11_font_height(Font);
-    size_t col = (x-Regions[id].x) / x11_font_width(Font);
-    if (id == Focused && win_btnpressed(MouseLeft))
-        view_selext(win_view(id), row, col);
+    if (x < Regions[Focused].x) x = Regions[Focused].x;
+    if (y < Regions[Focused].y) y = Regions[Focused].y;
+    size_t row = (y-Regions[Focused].y) / x11_font_height(Font);
+    size_t col = (x-Regions[Focused].x) / x11_font_width(Font);
+    if (win_btnpressed(MouseLeft))
+        view_selext(win_view(Focused), row, col);
 }
 
 static void onmousebtn(int btn, bool pressed, int x, int y) {
+    if (x < Regions[Focused].x)
+        x = Regions[Focused].x;
     WinRegion id = getregion(x, y);
     size_t row = (y-Regions[id].y) / x11_font_height(Font);
     size_t col = (x-Regions[id].x) / x11_font_width(Font);