This patch also prevents sel.mode from increasing beyond 2. It is almost
impossible, but sel.mode may overflow if mouse is moved around for too
long while selecting.
+enum selection_mode {
+ SEL_IDLE = 0,
+ SEL_EMPTY = 1,
+ SEL_READY = 2
+};
+
enum selection_type {
SEL_REGULAR = 1,
SEL_RECTANGULAR = 2
enum selection_type {
SEL_REGULAR = 1,
SEL_RECTANGULAR = 2
selinit(void) {
memset(&sel.tclick1, 0, sizeof(sel.tclick1));
memset(&sel.tclick2, 0, sizeof(sel.tclick2));
selinit(void) {
memset(&sel.tclick1, 0, sizeof(sel.tclick1));
memset(&sel.tclick2, 0, sizeof(sel.tclick2));
sel.ob.x = -1;
sel.primary = NULL;
sel.clipboard = NULL;
sel.ob.x = -1;
sel.primary = NULL;
sel.clipboard = NULL;
/* Clear previous selection, logically and visually. */
selclear(NULL);
/* Clear previous selection, logically and visually. */
selclear(NULL);
sel.type = SEL_REGULAR;
sel.oe.x = sel.ob.x = x2col(e->xbutton.x);
sel.oe.y = sel.ob.y = y2row(e->xbutton.y);
sel.type = SEL_REGULAR;
sel.oe.x = sel.ob.x = x2col(e->xbutton.x);
sel.oe.y = sel.ob.y = y2row(e->xbutton.y);
* make clicks visible
*/
if(sel.snap != 0) {
* make clicks visible
*/
if(sel.snap != 0) {
tsetdirt(sel.nb.y, sel.ne.y);
}
sel.tclick2 = sel.tclick1;
tsetdirt(sel.nb.y, sel.ne.y);
}
sel.tclick2 = sel.tclick1;
if(e->xbutton.button == Button2) {
selpaste(NULL);
} else if(e->xbutton.button == Button1) {
if(e->xbutton.button == Button2) {
selpaste(NULL);
} else if(e->xbutton.button == Button1) {
- if(sel.mode < 2) {
- selclear(NULL);
- } else {
+ if(sel.mode == SEL_READY) {
getbuttoninfo(e);
selcopy(e->xbutton.time);
getbuttoninfo(e);
selcopy(e->xbutton.time);
+ } else
+ selclear(NULL);
+ sel.mode = SEL_IDLE;
tsetdirt(sel.nb.y, sel.ne.y);
}
}
tsetdirt(sel.nb.y, sel.ne.y);
}
}
oldey = sel.oe.y;
oldex = sel.oe.x;
oldsby = sel.nb.y;
oldey = sel.oe.y;
oldex = sel.oe.x;
oldsby = sel.nb.y;