From: Michael D. Lowis Date: Fri, 16 Jun 2017 02:12:24 +0000 (-0400) Subject: tweaked mouse handling for gutter and out of bounds X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=0b1df521266fea4319ef656c7d58960e87b0d6fe;p=projs%2Ftide.git tweaked mouse handling for gutter and out of bounds --- diff --git a/TODO.md b/TODO.md index 204268b..ace4a9f 100644 --- 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 diff --git a/lib/win.c b/lib/win.c index 9b48588..7c5297e 100644 --- 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);