aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--input.c22
-rw-r--r--terminal.c51
-rw-r--r--terminal.h12
3 files changed, 47 insertions, 38 deletions
diff --git a/input.c b/input.c
index 176d9809..67d28102 100644
--- a/input.c
+++ b/input.c
@@ -1020,7 +1020,8 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer,
selection_update(term, col, row);
term_mouse_motion(
- term, seat->mouse.button, seat->mouse.row, seat->mouse.col);
+ term, seat->mouse.button, seat->mouse.row, seat->mouse.col,
+ seat->kbd.shift, seat->kbd.alt, seat->kbd.ctrl);
break;
}
}
@@ -1232,7 +1233,9 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
}
}
- term_mouse_down(term, button, seat->mouse.row, seat->mouse.col);
+ term_mouse_down(
+ term, button, seat->mouse.row, seat->mouse.col,
+ seat->kbd.shift, seat->kbd.alt, seat->kbd.ctrl);
break;
}
@@ -1240,7 +1243,9 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
if (button == BTN_LEFT && term->selection.end.col != -1)
selection_finalize(term, serial);
- term_mouse_up(term, button, seat->mouse.row, seat->mouse.col);
+ term_mouse_up(
+ term, button, seat->mouse.row, seat->mouse.col,
+ seat->kbd.shift, seat->kbd.alt, seat->kbd.ctrl);
break;
}
break;
@@ -1288,9 +1293,14 @@ mouse_scroll(struct seat *seat, int amount)
keyboard_key(seat, NULL, seat->input_serial, 0, key - 8, XKB_KEY_DOWN);
keyboard_key(seat, NULL, seat->input_serial, 0, key - 8, XKB_KEY_UP);
} else {
- for (int i = 0; i < amount; i++)
- term_mouse_down(term, button, seat->mouse.row, seat->mouse.col);
- term_mouse_up(term, button, seat->mouse.row, seat->mouse.col);
+ for (int i = 0; i < amount; i++) {
+ term_mouse_down(
+ term, button, seat->mouse.row, seat->mouse.col,
+ seat->kbd.shift, seat->kbd.alt, seat->kbd.ctrl);
+ }
+ term_mouse_up(
+ term, button, seat->mouse.row, seat->mouse.col,
+ seat->kbd.shift, seat->kbd.alt, seat->kbd.ctrl);
scrollback(term, amount);
}
diff --git a/terminal.c b/terminal.c
index add0d199..e4197a2a 100644
--- a/terminal.c
+++ b/terminal.c
@@ -1975,7 +1975,6 @@ term_kbd_focus_out(struct terminal *term)
term_to_slave(term, "\033[O", 3);
}
-#if 0
static int
linux_mouse_button_to_x(int button)
{
@@ -1994,8 +1993,7 @@ linux_mouse_button_to_x(int button)
return -1;
}
}
-#endif
-#if 0
+
static int
encode_xbutton(int xbutton)
{
@@ -2020,8 +2018,7 @@ encode_xbutton(int xbutton)
return -1;
}
}
-#endif
-#if 0
+
static void
report_mouse_click(struct terminal *term, int encoded_button, int row, int col,
bool release)
@@ -2057,14 +2054,13 @@ report_mouse_click(struct terminal *term, int encoded_button, int row, int col,
term_to_slave(term, response, strlen(response));
}
-#endif
-#if 0
+
static void
report_mouse_motion(struct terminal *term, int encoded_button, int row, int col)
{
report_mouse_click(term, encoded_button, row, col, false);
}
-#endif
+
bool
term_mouse_grabbed(const struct terminal *term)
{
@@ -2085,9 +2081,9 @@ term_mouse_grabbed(const struct terminal *term)
}
void
-term_mouse_down(struct terminal *term, int button, int row, int col)
+term_mouse_down(struct terminal *term, int button, int row, int col,
+ bool _shift, bool _alt, bool _ctrl)
{
-#if 0
if (term_mouse_grabbed(term))
return;
@@ -2101,10 +2097,10 @@ term_mouse_down(struct terminal *term, int button, int row, int col)
return;
- bool has_focus = term->wl->kbd_focus == 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;
+ bool has_focus = term_has_kbd_focus(term);
+ bool shift = has_focus ? _shift : false;
+ bool alt = has_focus ? _alt : false;
+ bool ctrl = has_focus ? _ctrl : false;
encoded += (shift ? 4 : 0) + (alt ? 8 : 0) + (ctrl ? 16 : 0);
@@ -2123,13 +2119,12 @@ term_mouse_down(struct terminal *term, int button, int row, int col)
assert(false && "unimplemented");
break;
}
-#endif
}
void
-term_mouse_up(struct terminal *term, int button, int row, int col)
+term_mouse_up(struct terminal *term, int button, int row, int col,
+ bool _shift, bool _alt, bool _ctrl)
{
-#if 0
if (term_mouse_grabbed(term))
return;
@@ -2147,10 +2142,10 @@ term_mouse_up(struct terminal *term, int button, int row, int col)
if (encoded == -1)
return;
- bool has_focus = term->wl->kbd_focus == 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;
+ bool has_focus = term_has_kbd_focus(term);
+ bool shift = has_focus ? _shift : false;
+ bool alt = has_focus ? _alt : false;
+ bool ctrl = has_focus ? _ctrl : false;
encoded += (shift ? 4 : 0) + (alt ? 8 : 0) + (ctrl ? 16 : 0);
@@ -2169,13 +2164,12 @@ term_mouse_up(struct terminal *term, int button, int row, int col)
assert(false && "unimplemented");
break;
}
-#endif
}
void
-term_mouse_motion(struct terminal *term, int button, int row, int col)
+term_mouse_motion(struct terminal *term, int button, int row, int col,
+ bool _shift, bool _alt, bool _ctrl)
{
-#if 0
if (term_mouse_grabbed(term))
return;
@@ -2193,10 +2187,10 @@ term_mouse_motion(struct terminal *term, int button, int row, int col)
} else
encoded = 3; /* "released" */
- bool has_focus = term->wl->kbd_focus == 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;
+ bool has_focus = term_has_kbd_focus(term);
+ bool shift = has_focus ? _shift : false;
+ bool alt = has_focus ? _alt : false;
+ bool ctrl = has_focus ? _ctrl : false;
encoded += 32; /* Motion event */
encoded += (shift ? 4 : 0) + (alt ? 8 : 0) + (ctrl ? 16 : 0);
@@ -2220,7 +2214,6 @@ term_mouse_motion(struct terminal *term, int button, int row, int col)
assert(false && "unimplemented");
break;
}
-#endif
}
void
diff --git a/terminal.h b/terminal.h
index e28e3af7..604511da 100644
--- a/terminal.h
+++ b/terminal.h
@@ -509,9 +509,15 @@ void term_visual_focus_out(struct terminal *term);
bool term_has_kbd_focus(struct terminal *term);
void term_kbd_focus_in(struct terminal *term);
void term_kbd_focus_out(struct terminal *term);
-void 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);
-void term_mouse_motion(struct terminal *term, int button, int row, int col);
+void term_mouse_down(
+ struct terminal *term, int button, int row, int col,
+ bool shift, bool alt, bool ctrl);
+void term_mouse_up(
+ struct terminal *term, int button, int row, int col,
+ bool shift, bool alt, bool ctrl);
+void term_mouse_motion(
+ struct terminal *term, int button, int row, int col,
+ bool shift, bool alt, bool ctrl);
bool term_mouse_grabbed(const struct terminal *term);
void term_xcursor_update(struct terminal *term);