aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sway/input/seatop_default.c41
-rw-r--r--sway/input/seatop_move_floating.c26
2 files changed, 52 insertions, 15 deletions
diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c
index b8265441..46595fdd 100644
--- a/sway/input/seatop_default.c
+++ b/sway/input/seatop_default.c
@@ -194,9 +194,9 @@ static void state_add_button(struct seatop_default_event *e, uint32_t button) {
194 e->pressed_button_count++; 194 e->pressed_button_count++;
195} 195}
196 196
197/*----------------------------------\ 197/*-------------------------------------------\
198 * Functions used by handle_button / 198 * Functions used by handle_tablet_tool_tip /
199 *--------------------------------*/ 199 *-----------------------------------------*/
200 200
201static void handle_tablet_tool_tip(struct sway_seat *seat, 201static void handle_tablet_tool_tip(struct sway_seat *seat,
202 struct sway_tablet_tool *tool, uint32_t time_msec, 202 struct sway_tablet_tool *tool, uint32_t time_msec,
@@ -204,23 +204,48 @@ static void handle_tablet_tool_tip(struct sway_seat *seat,
204 if (state == WLR_TABLET_TOOL_TIP_UP) { 204 if (state == WLR_TABLET_TOOL_TIP_UP) {
205 wlr_tablet_v2_tablet_tool_notify_up(tool->tablet_v2_tool); 205 wlr_tablet_v2_tablet_tool_notify_up(tool->tablet_v2_tool);
206 return; 206 return;
207 } else if (state == WLR_TABLET_TOOL_TIP_DOWN) {
208 wlr_tablet_v2_tablet_tool_notify_down(tool->tablet_v2_tool);
209 wlr_tablet_tool_v2_start_implicit_grab(tool->tablet_v2_tool);
210 } 207 }
211 208
212 struct sway_cursor *cursor = seat->cursor; 209 struct sway_cursor *cursor = seat->cursor;
213
214 struct wlr_surface *surface = NULL; 210 struct wlr_surface *surface = NULL;
215 double sx, sy; 211 double sx, sy;
216 struct sway_node *node = node_at_coords(seat, 212 struct sway_node *node = node_at_coords(seat,
217 cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); 213 cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy);
218 214
219 if (surface && node && node->type == N_CONTAINER) { 215 if (!sway_assert(surface,
216 "Expected null-surface tablet input to route through pointer emulation")) {
217 return;
218 }
219
220 struct sway_container *cont = node && node->type == N_CONTAINER ?
221 node->sway_container : NULL;
222
223 if (cont) {
224 bool is_floating_or_child = container_is_floating_or_child(cont);
225 bool is_fullscreen_or_child = container_is_fullscreen_or_child(cont);
226 struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->wlr_seat);
227 bool mod_pressed = keyboard &&
228 (wlr_keyboard_get_modifiers(keyboard) & config->floating_mod);
229
230 // Handle beginning floating move
231 if (is_floating_or_child && !is_fullscreen_or_child && mod_pressed) {
232 seat_set_focus_container(seat,
233 seat_get_focus_inactive_view(seat, &cont->node));
234 seatop_begin_move_floating(seat, container_toplevel_ancestor(cont));
235 return;
236 }
237
220 seatop_begin_down(seat, node->sway_container, time_msec, sx, sy); 238 seatop_begin_down(seat, node->sway_container, time_msec, sx, sy);
221 } 239 }
240
241 wlr_tablet_v2_tablet_tool_notify_down(tool->tablet_v2_tool);
242 wlr_tablet_tool_v2_start_implicit_grab(tool->tablet_v2_tool);
222} 243}
223 244
245/*----------------------------------\
246 * Functions used by handle_button /
247 *--------------------------------*/
248
224static void handle_button(struct sway_seat *seat, uint32_t time_msec, 249static void handle_button(struct sway_seat *seat, uint32_t time_msec,
225 struct wlr_input_device *device, uint32_t button, 250 struct wlr_input_device *device, uint32_t button,
226 enum wlr_button_state state) { 251 enum wlr_button_state state) {
diff --git a/sway/input/seatop_move_floating.c b/sway/input/seatop_move_floating.c
index 21a2a966..b9a20402 100644
--- a/sway/input/seatop_move_floating.c
+++ b/sway/input/seatop_move_floating.c
@@ -9,20 +9,31 @@ struct seatop_move_floating_event {
9 double dx, dy; // cursor offset in container 9 double dx, dy; // cursor offset in container
10}; 10};
11 11
12static void finalize_move(struct sway_seat *seat) {
13 struct seatop_move_floating_event *e = seat->seatop_data;
14
15 // We "move" the container to its own location
16 // so it discovers its output again.
17 container_floating_move_to(e->con, e->con->x, e->con->y);
18
19 seatop_begin_default(seat);
20}
21
12static void handle_button(struct sway_seat *seat, uint32_t time_msec, 22static void handle_button(struct sway_seat *seat, uint32_t time_msec,
13 struct wlr_input_device *device, uint32_t button, 23 struct wlr_input_device *device, uint32_t button,
14 enum wlr_button_state state) { 24 enum wlr_button_state state) {
15 if (seat->cursor->pressed_button_count == 0) { 25 if (seat->cursor->pressed_button_count == 0) {
16 struct seatop_move_floating_event *e = seat->seatop_data; 26 finalize_move(seat);
17
18 // We "move" the container to its own location
19 // so it discovers its output again.
20 container_floating_move_to(e->con, e->con->x, e->con->y);
21
22 seatop_begin_default(seat);
23 } 27 }
24} 28}
25 29
30static void handle_tablet_tool_tip(struct sway_seat *seat,
31 struct sway_tablet_tool *tool, uint32_t time_msec,
32 enum wlr_tablet_tool_tip_state state) {
33 if (state == WLR_TABLET_TOOL_TIP_UP) {
34 finalize_move(seat);
35 }
36}
26static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec, 37static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec,
27 double dx, double dy) { 38 double dx, double dy) {
28 struct seatop_move_floating_event *e = seat->seatop_data; 39 struct seatop_move_floating_event *e = seat->seatop_data;
@@ -42,6 +53,7 @@ static void handle_unref(struct sway_seat *seat, struct sway_container *con) {
42static const struct sway_seatop_impl seatop_impl = { 53static const struct sway_seatop_impl seatop_impl = {
43 .button = handle_button, 54 .button = handle_button,
44 .pointer_motion = handle_pointer_motion, 55 .pointer_motion = handle_pointer_motion,
56 .tablet_tool_tip = handle_tablet_tool_tip,
45 .unref = handle_unref, 57 .unref = handle_unref,
46}; 58};
47 59