diff options
-rw-r--r-- | include/sway/input/seat.h | 3 | ||||
-rw-r--r-- | sway/input/seatop_default.c | 3 | ||||
-rw-r--r-- | sway/input/seatop_down.c | 30 |
3 files changed, 31 insertions, 5 deletions
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index a2b5d2a1..78dbda6f 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -241,6 +241,9 @@ void seatop_begin_default(struct sway_seat *seat); | |||
241 | void seatop_begin_down(struct sway_seat *seat, struct sway_container *con, | 241 | void seatop_begin_down(struct sway_seat *seat, struct sway_container *con, |
242 | uint32_t time_msec, double sx, double sy); | 242 | uint32_t time_msec, double sx, double sy); |
243 | 243 | ||
244 | void seatop_begin_down_on_layer_surface(struct sway_seat *seat, | ||
245 | struct wlr_surface *surface, uint32_t time_msec, double sx, double sy); | ||
246 | |||
244 | void seatop_begin_move_floating(struct sway_seat *seat, | 247 | void seatop_begin_move_floating(struct sway_seat *seat, |
245 | struct sway_container *con); | 248 | struct sway_container *con); |
246 | 249 | ||
diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c index f9eb8c8a..7a3745d2 100644 --- a/sway/input/seatop_default.c +++ b/sway/input/seatop_default.c | |||
@@ -373,6 +373,9 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, | |||
373 | seat_set_focus_layer(seat, layer); | 373 | seat_set_focus_layer(seat, layer); |
374 | transaction_commit_dirty(); | 374 | transaction_commit_dirty(); |
375 | } | 375 | } |
376 | if (state == WLR_BUTTON_PRESSED) { | ||
377 | seatop_begin_down_on_layer_surface(seat, surface, time_msec, sx, sy); | ||
378 | } | ||
376 | seat_pointer_notify_button(seat, time_msec, button, state); | 379 | seat_pointer_notify_button(seat, time_msec, button, state); |
377 | return; | 380 | return; |
378 | } | 381 | } |
diff --git a/sway/input/seatop_down.c b/sway/input/seatop_down.c index 7607a598..cc54b90b 100644 --- a/sway/input/seatop_down.c +++ b/sway/input/seatop_down.c | |||
@@ -10,7 +10,8 @@ | |||
10 | 10 | ||
11 | struct seatop_down_event { | 11 | struct seatop_down_event { |
12 | struct sway_container *con; | 12 | struct sway_container *con; |
13 | double ref_lx, ref_ly; // cursor's x/y at start of op | 13 | struct wlr_surface *surface; |
14 | double ref_lx, ref_ly; // cursor's x/y at start of op | ||
14 | double ref_con_lx, ref_con_ly; // container's x/y at start of op | 15 | double ref_con_lx, ref_con_ly; // container's x/y at start of op |
15 | }; | 16 | }; |
16 | 17 | ||
@@ -40,8 +41,7 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, | |||
40 | 41 | ||
41 | static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec) { | 42 | static void handle_pointer_motion(struct sway_seat *seat, uint32_t time_msec) { |
42 | struct seatop_down_event *e = seat->seatop_data; | 43 | struct seatop_down_event *e = seat->seatop_data; |
43 | struct sway_container *con = e->con; | 44 | if (seat_is_input_allowed(seat, e->surface)) { |
44 | if (seat_is_input_allowed(seat, con->view->surface)) { | ||
45 | double moved_x = seat->cursor->cursor->x - e->ref_lx; | 45 | double moved_x = seat->cursor->cursor->x - e->ref_lx; |
46 | double moved_y = seat->cursor->cursor->y - e->ref_ly; | 46 | double moved_y = seat->cursor->cursor->y - e->ref_ly; |
47 | double sx = e->ref_con_lx + moved_x; | 47 | double sx = e->ref_con_lx + moved_x; |
@@ -62,8 +62,7 @@ static void handle_tablet_tool_tip(struct sway_seat *seat, | |||
62 | static void handle_tablet_tool_motion(struct sway_seat *seat, | 62 | static void handle_tablet_tool_motion(struct sway_seat *seat, |
63 | struct sway_tablet_tool *tool, uint32_t time_msec) { | 63 | struct sway_tablet_tool *tool, uint32_t time_msec) { |
64 | struct seatop_down_event *e = seat->seatop_data; | 64 | struct seatop_down_event *e = seat->seatop_data; |
65 | struct sway_container *con = e->con; | 65 | if (seat_is_input_allowed(seat, e->surface)) { |
66 | if (seat_is_input_allowed(seat, con->view->surface)) { | ||
67 | double moved_x = seat->cursor->cursor->x - e->ref_lx; | 66 | double moved_x = seat->cursor->cursor->x - e->ref_lx; |
68 | double moved_y = seat->cursor->cursor->y - e->ref_ly; | 67 | double moved_y = seat->cursor->cursor->y - e->ref_ly; |
69 | double sx = e->ref_con_lx + moved_x; | 68 | double sx = e->ref_con_lx + moved_x; |
@@ -99,6 +98,7 @@ void seatop_begin_down(struct sway_seat *seat, struct sway_container *con, | |||
99 | return; | 98 | return; |
100 | } | 99 | } |
101 | e->con = con; | 100 | e->con = con; |
101 | e->surface = con->view->surface; | ||
102 | e->ref_lx = seat->cursor->cursor->x; | 102 | e->ref_lx = seat->cursor->cursor->x; |
103 | e->ref_ly = seat->cursor->cursor->y; | 103 | e->ref_ly = seat->cursor->cursor->y; |
104 | e->ref_con_lx = sx; | 104 | e->ref_con_lx = sx; |
@@ -110,3 +110,23 @@ void seatop_begin_down(struct sway_seat *seat, struct sway_container *con, | |||
110 | container_raise_floating(con); | 110 | container_raise_floating(con); |
111 | transaction_commit_dirty(); | 111 | transaction_commit_dirty(); |
112 | } | 112 | } |
113 | |||
114 | void seatop_begin_down_on_layer_surface(struct sway_seat *seat, | ||
115 | struct wlr_surface *surface, uint32_t time_msec, double sx, double sy) { | ||
116 | seatop_end(seat); | ||
117 | |||
118 | struct seatop_down_event *e = | ||
119 | calloc(1, sizeof(struct seatop_down_event)); | ||
120 | if (!e) { | ||
121 | return; | ||
122 | } | ||
123 | e->con = NULL; | ||
124 | e->surface = surface; | ||
125 | e->ref_lx = seat->cursor->cursor->x; | ||
126 | e->ref_ly = seat->cursor->cursor->y; | ||
127 | e->ref_con_lx = sx; | ||
128 | e->ref_con_ly = sy; | ||
129 | |||
130 | seat->seatop_impl = &seatop_impl; | ||
131 | seat->seatop_data = e; | ||
132 | } | ||