summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Carbonneaux2014-07-16 14:34:11 -0400
committerQuentin Carbonneaux2014-07-16 14:34:11 -0400
commit3d270e7b19513d773e112bc8069de9f7c39cc766 (patch)
tree88673205d5d40eba5f65c9e5e041fec248776093
parent2462b94decf44621c999fcdbd3ff64e849bdbbfb (diff)
add x11 code for mouse selection
-rw-r--r--gui.h3
-rw-r--r--main.c2
-rw-r--r--x11.c11
3 files changed, 12 insertions, 4 deletions
diff --git a/gui.h b/gui.h
index 05f7320..8a787fb 100644
--- a/gui.h
+++ b/gui.h
@@ -39,7 +39,8 @@ struct gevent {
enum {
GResize,
GKey,
- GMouse,
+ GMouseClick,
+ GMouseSelect,
} type;
union {
diff --git a/main.c b/main.c
index 423b312..0b0d174 100644
--- a/main.c
+++ b/main.c
@@ -51,7 +51,7 @@ main(int ac, char *av[])
}
scrolling = 0;
break;
- case GMouse:
+ case GMouseClick:
if (e.mouse.button == GBLeft)
win_set_cursor(curwin, e.mouse.x, e.mouse.y);
break;
diff --git a/x11.c b/x11.c
index b447f4c..4c69110 100644
--- a/x11.c
+++ b/x11.c
@@ -56,7 +56,7 @@ init()
swa.bit_gravity = NorthWestGravity;
XChangeWindowAttributes(d, win, CWBackingStore|CWBitGravity, &swa);
XStoreName(d, win, "ED");
- XSelectInput(d, win, StructureNotifyMask|ButtonPressMask|KeyPressMask|ExposureMask);
+ XSelectInput(d, win, StructureNotifyMask|ButtonPressMask|Button1MotionMask|KeyPressMask|ExposureMask);
/* simulate an initial resize and map the window */
ce.type = ConfigureNotify;
@@ -193,8 +193,15 @@ nextevent(GEvent *gev)
gev->resize.height = h;
break;
+ case MotionNotify:
+ gev->type = GMouseSelect;
+ gev->mouse.button = GBLeft;
+ gev->mouse.x = e.xmotion.x;
+ gev->mouse.y = e.xmotion.y;
+ break;
+
case ButtonPress:
- gev->type = GMouse;
+ gev->type = GMouseClick;
switch (e.xbutton.button) {
case Button1: