aboutsummaryrefslogtreecommitdiff
path: root/terminal.c
diff options
context:
space:
mode:
Diffstat (limited to 'terminal.c')
-rw-r--r--terminal.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/terminal.c b/terminal.c
index a1641063..c49c34df 100644
--- a/terminal.c
+++ b/terminal.c
@@ -1322,8 +1322,7 @@ term_mouse_grabbed(const struct terminal *term)
}
void
-term_mouse_down(struct terminal *term, int button, int row, int col,
- bool shift, bool alt, bool ctrl)
+term_mouse_down(struct terminal *term, int button, int row, int col)
{
if (term_mouse_grabbed(term))
return;
@@ -1337,6 +1336,12 @@ term_mouse_down(struct terminal *term, int button, int row, int col,
if (encoded == -1)
return;
+
+ bool has_focus = term->wl->focused == term;
+ bool shift = has_focus ? term->wl->kbd.shift : false;
+ bool alt = has_focus ? term->wl->kbd.alt : false;
+ bool ctrl = has_focus ? term->wl->kbd.ctrl : false;
+
encoded += (shift ? 4 : 0) + (alt ? 8 : 0) + (ctrl ? 16 : 0);
switch (term->mouse_tracking) {
@@ -1357,8 +1362,7 @@ term_mouse_down(struct terminal *term, int button, int row, int col,
}
void
-term_mouse_up(struct terminal *term, int button, int row, int col,
- bool shift, bool alt, bool ctrl)
+term_mouse_up(struct terminal *term, int button, int row, int col)
{
if (term_mouse_grabbed(term))
return;
@@ -1377,6 +1381,11 @@ term_mouse_up(struct terminal *term, int button, int row, int col,
if (encoded == -1)
return;
+ bool has_focus = term->wl->focused == term;
+ bool shift = has_focus ? term->wl->kbd.shift : false;
+ bool alt = has_focus ? term->wl->kbd.alt : false;
+ bool ctrl = has_focus ? term->wl->kbd.ctrl : false;
+
encoded += (shift ? 4 : 0) + (alt ? 8 : 0) + (ctrl ? 16 : 0);
switch (term->mouse_tracking) {
@@ -1397,8 +1406,7 @@ term_mouse_up(struct terminal *term, int button, int row, int col,
}
void
-term_mouse_motion(struct terminal *term, int button, int row, int col,
- bool shift, bool alt, bool ctrl)
+term_mouse_motion(struct terminal *term, int button, int row, int col)
{
if (term_mouse_grabbed(term))
return;
@@ -1417,6 +1425,11 @@ term_mouse_motion(struct terminal *term, int button, int row, int col,
} else
encoded = 3; /* "released" */
+ bool has_focus = term->wl->focused == term;
+ bool shift = has_focus ? term->wl->kbd.shift : false;
+ bool alt = has_focus ? term->wl->kbd.alt : false;
+ bool ctrl = has_focus ? term->wl->kbd.ctrl : false;
+
encoded += 32; /* Motion event */
encoded += (shift ? 4 : 0) + (alt ? 8 : 0) + (ctrl ? 16 : 0);