[dev] [st] Selection should take BORDER into account

From: Petr Sabata <psabata_AT_redhat.com>
Date: Sun, 3 Apr 2011 13:27:23 +0200

I use 10px BORDER and it's been quite annoying to start and end my selection
a row and a few columns off. The selection code should respect BORDER.

The patch below should do the thing.

-- Petr

---
 st.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/st.c b/st.c
index ed750e6..b1e74a6 100644
--- a/st.c
+++ b/st.c
@@ -392,8 +392,8 @@ getbuttoninfo(XEvent *e, int *b, int *x, int *y) {
 	if(b) 
 		*b = e->xbutton.button;
 
-	*x = e->xbutton.x/xw.cw;
-	*y = e->xbutton.y/xw.ch;
+	*x = (e->xbutton.x - BORDER)/xw.cw;
+	*y = (e->xbutton.y - BORDER)/xw.ch;
 	sel.b.x = sel.by < sel.ey ? sel.bx : sel.ex;
 	sel.b.y = MIN(sel.by, sel.ey);
 	sel.e.x = sel.by < sel.ey ? sel.ex : sel.bx;
@@ -403,8 +403,8 @@ getbuttoninfo(XEvent *e, int *b, int *x, int *y) {
 void
 bpress(XEvent *e) {
 	sel.mode = 1;
-	sel.ex = sel.bx = e->xbutton.x/xw.cw;
-	sel.ey = sel.by = e->xbutton.y/xw.ch;
+	sel.ex = sel.bx = (e->xbutton.x - BORDER)/xw.cw;
+	sel.ey = sel.by = (e->xbutton.y - BORDER)/xw.ch;
 }
 
 void
-- 
1.7.4
Received on Sun Apr 03 2011 - 13:27:23 CEST

This archive was generated by hypermail 2.2.0 : Sun Apr 03 2011 - 13:36:02 CEST