static char* SearchTerm = NULL;
static int ExecRequest = 0;
-#define PRESSED(btn) \
- ((KeyBtnState & (1 << (btn + 7))) == (1 << (btn + 7)))
+#define PRESSED(mods, btn) \
+ ((mods & (1 << (btn + 7))) == (1 << (btn + 7)))
/* X11 Window Code
******************************************************************************/
}
}
-static void mouse_left(WinRegion id, bool pressed, size_t row, size_t col) {
+static void mouse_left(WinRegion id, int state, bool pressed, size_t row, size_t col) {
static int count = 0;
static Time before = 0;
if (!pressed) return;
count = ((X.now - before) <= (uint64_t)ClickTime ? count+1 : 1);
before = X.now;
- if (PRESSED(MouseRight)) {
+ if (PRESSED(state, MouseRight)) {
puts("fetch tag");
- } else if (PRESSED(MouseMiddle)) {
+ } else if (PRESSED(state, MouseMiddle)) {
/* if we didnt get an arg, find one in the selection */
char* arg = NULL;
if (!arg || !*arg) arg = view_getstr(win_view(EDIT));
}
}
-static void mouse_middle(WinRegion id, bool pressed, size_t row, size_t col) {
+static void mouse_middle(WinRegion id, int state, bool pressed, size_t row, size_t col) {
if (pressed) { ExecRequest = 1; return; }
- if (PRESSED(MouseLeft)) {
+ if (PRESSED(state, MouseLeft)) {
cut(NULL);
} else if (ExecRequest) {
char* str = view_fetch(win_view(id), row, col, riscmd);
}
}
-static void mouse_right(WinRegion id, bool pressed, size_t row, size_t col) {
+static void mouse_right(WinRegion id, int state, bool pressed, size_t row, size_t col) {
if (pressed) return;
- if (PRESSED(MouseLeft)) {
+ if (PRESSED(state, MouseLeft)) {
paste(NULL);
} else {
FetchCmd[2] = view_fetch(win_view(id), row, col, risfile);
view_scroll(win_view(id), amount);
}
-static void mouse_click(int btn, bool pressed, int x, int y) {
+static void mouse_click(int btn, int mods, bool pressed, int x, int y) {
size_t row, col;
Focused = (y <= Divider ? TAGS : EDIT);
get_position(Focused, x, y, &row, &col);
switch(btn) {
- case MouseLeft: mouse_left(Focused, pressed, row, col); break;
- case MouseMiddle: mouse_middle(Focused, pressed, row, col); break;
- case MouseRight: mouse_right(Focused, pressed, row, col); break;
+ case MouseLeft: mouse_left(Focused, mods, pressed, row, col); break;
+ case MouseMiddle: mouse_middle(Focused, mods, pressed, row, col); break;
+ case MouseRight: mouse_right(Focused, mods, pressed, row, col); break;
case MouseWheelUp: mouse_scroll(Focused, pressed, -ScrollBy); break;
case MouseWheelDn: mouse_scroll(Focused, pressed, +ScrollBy); break;
}
static void xbtnpress(XConf* x, XEvent* e) {
(void)x;
KeyBtnState = (e->xbutton.state | (1 << (e->xbutton.button + 7)));
- mouse_click(e->xbutton.button, true, e->xbutton.x, e->xbutton.y);
+ mouse_click(e->xbutton.button, e->xbutton.state, true, e->xbutton.x, e->xbutton.y);
}
static void xbtnrelease(XConf* x, XEvent* e) {
(void)x;
KeyBtnState = (KeyBtnState & ~(1 << (e->xbutton.button + 7)));
- mouse_click(e->xbutton.button, false, e->xbutton.x, e->xbutton.y);
+ mouse_click(e->xbutton.button, e->xbutton.state, false, e->xbutton.x, e->xbutton.y);
}
static void xbtnmotion(XConf* x, XEvent* e) {
KeyBtnState = e->xbutton.state;
int xpos = e->xbutton.x, ypos = e->xbutton.y;
get_position(Focused, xpos, ypos, &row, &col);
- if (PRESSED(MouseLeft))
+ if (PRESSED(e->xbutton.state, MouseLeft))
view_setcursor(win_view(Focused), row, col, true);
}