aboutsummaryrefslogtreecommitdiff
path: root/x.c
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly@gmail.com>2018-02-21 23:54:29 -0600
committerDevin J. Pohly <djpohly@gmail.com>2018-02-25 21:53:24 -0600
commitcfc7acdfd923924ae150a32061fb95987697b159 (patch)
tree81b6e86f3f21c1263c58880ccc0e45ac885cf627 /x.c
parentbcb5d3adbe57ead05a829e5144c2ba1dc465865f (diff)
downloadst-cfc7acdfd923924ae150a32061fb95987697b159.tar.gz
st-cfc7acdfd923924ae150a32061fb95987697b159.tar.bz2
st-cfc7acdfd923924ae150a32061fb95987697b159.zip
Move remaining selection mode logic into selextend
The "done" parameter indicates a change which finalizes the selection (e.g. a mouse button release as opposed to motion). Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
Diffstat (limited to 'x.c')
-rw-r--r--x.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/x.c b/x.c
index ddae6b6..a7f619e 100644
--- a/x.c
+++ b/x.c
@@ -157,7 +157,7 @@ static void selnotify(XEvent *);
static void selclear_(XEvent *);
static void selrequest(XEvent *);
static void setsel(char *, Time);
-static void mousesel(XEvent *);
+static void mousesel(XEvent *, int);
static void mousereport(XEvent *);
static char *kmap(KeySym, uint);
static int match(uint, uint);
@@ -313,7 +313,7 @@ y2row(int y)
}
void
-mousesel(XEvent *e)
+mousesel(XEvent *e, int done)
{
int type, seltype = SEL_REGULAR;
uint state = e->xbutton.state & ~(Button1Mask | forceselmod);
@@ -324,8 +324,9 @@ mousesel(XEvent *e)
break;
}
}
-
- selextend(x2col(e->xbutton.x), y2row(e->xbutton.y), seltype);
+ selextend(x2col(e->xbutton.x), y2row(e->xbutton.y), seltype, done);
+ if (done)
+ setsel(getsel(), e->xbutton.time);
}
void
@@ -630,16 +631,10 @@ brelease(XEvent *e)
return;
}
- if (e->xbutton.button == Button2) {
+ if (e->xbutton.button == Button2)
selpaste(NULL);
- } else if (e->xbutton.button == Button1) {
- if (sel.mode == SEL_READY) {
- mousesel(e);
- setsel(getsel(), e->xbutton.time);
- } else
- selclear_(NULL);
- sel.mode = SEL_IDLE;
- }
+ else if (e->xbutton.button == Button1)
+ mousesel(e, 1);
}
void
@@ -650,11 +645,7 @@ bmotion(XEvent *e)
return;
}
- if (!sel.mode)
- return;
-
- sel.mode = SEL_READY;
- mousesel(e);
+ mousesel(e, 0);
}
void