diff options
-rw-r--r-- | include/sway/input/seat.h | 20 | ||||
-rw-r--r-- | include/sway/tree/layout.h | 1 | ||||
-rw-r--r-- | sway/desktop/output.c | 34 | ||||
-rw-r--r-- | sway/input/cursor.c | 62 | ||||
-rw-r--r-- | sway/input/seat.c | 98 | ||||
-rw-r--r-- | sway/tree/layout.c | 1 |
6 files changed, 193 insertions, 23 deletions
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index 2e4da438..1f7792ba 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -21,6 +21,19 @@ struct sway_seat_container { | |||
21 | struct wl_listener destroy; | 21 | struct wl_listener destroy; |
22 | }; | 22 | }; |
23 | 23 | ||
24 | struct sway_drag_icon { | ||
25 | struct sway_seat *seat; | ||
26 | struct wlr_drag_icon *wlr_drag_icon; | ||
27 | struct wl_list link; // sway_root::drag_icons | ||
28 | |||
29 | double x, y; // in layout-local coordinates | ||
30 | |||
31 | struct wl_listener surface_commit; | ||
32 | struct wl_listener map; | ||
33 | struct wl_listener unmap; | ||
34 | struct wl_listener destroy; | ||
35 | }; | ||
36 | |||
24 | struct sway_seat { | 37 | struct sway_seat { |
25 | struct wlr_seat *wlr_seat; | 38 | struct wlr_seat *wlr_seat; |
26 | struct sway_cursor *cursor; | 39 | struct sway_cursor *cursor; |
@@ -35,8 +48,13 @@ struct sway_seat { | |||
35 | // If exclusive_client is set, no other clients will receive input events | 48 | // If exclusive_client is set, no other clients will receive input events |
36 | struct wl_client *exclusive_client; | 49 | struct wl_client *exclusive_client; |
37 | 50 | ||
51 | // Last touch point | ||
52 | int32_t touch_id; | ||
53 | double touch_x, touch_y; | ||
54 | |||
38 | struct wl_listener focus_destroy; | 55 | struct wl_listener focus_destroy; |
39 | struct wl_listener new_container; | 56 | struct wl_listener new_container; |
57 | struct wl_listener new_drag_icon; | ||
40 | 58 | ||
41 | struct wl_list devices; // sway_seat_device::link | 59 | struct wl_list devices; // sway_seat_device::link |
42 | 60 | ||
@@ -114,4 +132,6 @@ struct seat_config *seat_get_config(struct sway_seat *seat); | |||
114 | 132 | ||
115 | bool seat_is_input_allowed(struct sway_seat *seat, struct wlr_surface *surface); | 133 | bool seat_is_input_allowed(struct sway_seat *seat, struct wlr_surface *surface); |
116 | 134 | ||
135 | void drag_icon_update_position(struct sway_drag_icon *icon); | ||
136 | |||
117 | #endif | 137 | #endif |
diff --git a/include/sway/tree/layout.h b/include/sway/tree/layout.h index cd131056..ba265623 100644 --- a/include/sway/tree/layout.h +++ b/include/sway/tree/layout.h | |||
@@ -28,6 +28,7 @@ struct sway_root { | |||
28 | struct wl_listener output_layout_change; | 28 | struct wl_listener output_layout_change; |
29 | 29 | ||
30 | struct wl_list xwayland_unmanaged; // sway_xwayland_unmanaged::link | 30 | struct wl_list xwayland_unmanaged; // sway_xwayland_unmanaged::link |
31 | struct wl_list drag_icons; // sway_drag_icon::link | ||
31 | 32 | ||
32 | struct wlr_texture *debug_tree; | 33 | struct wlr_texture *debug_tree; |
33 | 34 | ||
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index bd1d760d..29666c00 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -161,6 +161,21 @@ static void unmanaged_for_each_surface(struct wl_list *unmanaged, | |||
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
164 | static void drag_icons_for_each_surface(struct wl_list *drag_icons, | ||
165 | struct sway_output *output, struct root_geometry *geo, | ||
166 | wlr_surface_iterator_func_t iterator, void *user_data) { | ||
167 | struct sway_drag_icon *drag_icon; | ||
168 | wl_list_for_each(drag_icon, drag_icons, link) { | ||
169 | double ox = drag_icon->x - output->swayc->x; | ||
170 | double oy = drag_icon->y - output->swayc->y; | ||
171 | |||
172 | if (drag_icon->wlr_drag_icon->mapped) { | ||
173 | surface_for_each_surface(drag_icon->wlr_drag_icon->surface, | ||
174 | ox, oy, geo, iterator, user_data); | ||
175 | } | ||
176 | } | ||
177 | } | ||
178 | |||
164 | static void scale_box(struct wlr_box *box, float scale) { | 179 | static void scale_box(struct wlr_box *box, float scale) { |
165 | box->x *= scale; | 180 | box->x *= scale; |
166 | box->y *= scale; | 181 | box->y *= scale; |
@@ -270,6 +285,17 @@ static void render_unmanaged(struct sway_output *output, | |||
270 | render_surface_iterator, &data); | 285 | render_surface_iterator, &data); |
271 | } | 286 | } |
272 | 287 | ||
288 | static void render_drag_icons(struct sway_output *output, | ||
289 | pixman_region32_t *damage, struct wl_list *drag_icons) { | ||
290 | struct render_data data = { | ||
291 | .output = output, | ||
292 | .damage = damage, | ||
293 | .alpha = 1.0f, | ||
294 | }; | ||
295 | drag_icons_for_each_surface(drag_icons, output, &data.root_geo, | ||
296 | render_surface_iterator, &data); | ||
297 | } | ||
298 | |||
273 | static void render_rect(struct wlr_output *wlr_output, | 299 | static void render_rect(struct wlr_output *wlr_output, |
274 | pixman_region32_t *output_damage, const struct wlr_box *_box, | 300 | pixman_region32_t *output_damage, const struct wlr_box *_box, |
275 | float color[static 4]) { | 301 | float color[static 4]) { |
@@ -911,6 +937,7 @@ static void render_output(struct sway_output *output, struct timespec *when, | |||
911 | } | 937 | } |
912 | render_layer(output, damage, | 938 | render_layer(output, damage, |
913 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); | 939 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); |
940 | render_drag_icons(output, damage, &root_container.sway_root->drag_icons); | ||
914 | 941 | ||
915 | renderer_end: | 942 | renderer_end: |
916 | if (root_container.sway_root->debug_tree) { | 943 | if (root_container.sway_root->debug_tree) { |
@@ -961,6 +988,12 @@ static void send_frame_done_unmanaged(struct send_frame_done_data *data, | |||
961 | send_frame_done_iterator, data); | 988 | send_frame_done_iterator, data); |
962 | } | 989 | } |
963 | 990 | ||
991 | static void send_frame_done_drag_icons(struct send_frame_done_data *data, | ||
992 | struct wl_list *drag_icons) { | ||
993 | drag_icons_for_each_surface(drag_icons, data->output, &data->root_geo, | ||
994 | send_frame_done_iterator, data); | ||
995 | } | ||
996 | |||
964 | static void send_frame_done_container_iterator(struct sway_container *con, | 997 | static void send_frame_done_container_iterator(struct sway_container *con, |
965 | void *_data) { | 998 | void *_data) { |
966 | struct send_frame_done_data *data = _data; | 999 | struct send_frame_done_data *data = _data; |
@@ -1014,6 +1047,7 @@ static void send_frame_done(struct sway_output *output, struct timespec *when) { | |||
1014 | 1047 | ||
1015 | send_frame_done_layer(&data, | 1048 | send_frame_done_layer(&data, |
1016 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); | 1049 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); |
1050 | send_frame_done_drag_icons(&data, &root_container.sway_root->drag_icons); | ||
1017 | } | 1051 | } |
1018 | 1052 | ||
1019 | static void damage_handle_frame(struct wl_listener *listener, void *data) { | 1053 | static void damage_handle_frame(struct wl_listener *listener, void *data) { |
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 4100479c..37a87756 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -144,21 +144,22 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, | |||
144 | time_msec = get_current_time_msec(); | 144 | time_msec = get_current_time_msec(); |
145 | } | 145 | } |
146 | 146 | ||
147 | struct wlr_seat *seat = cursor->seat->wlr_seat; | 147 | struct sway_seat *seat = cursor->seat; |
148 | struct wlr_seat *wlr_seat = seat->wlr_seat; | ||
148 | struct wlr_surface *surface = NULL; | 149 | struct wlr_surface *surface = NULL; |
149 | double sx, sy; | 150 | double sx, sy; |
150 | 151 | ||
151 | // Find the container beneath the pointer's previous position | 152 | // Find the container beneath the pointer's previous position |
152 | struct sway_container *prev_c = container_at_coords(cursor->seat, | 153 | struct sway_container *prev_c = container_at_coords(seat, |
153 | cursor->previous.x, cursor->previous.y, &surface, &sx, &sy); | 154 | cursor->previous.x, cursor->previous.y, &surface, &sx, &sy); |
154 | // Update the stored previous position | 155 | // Update the stored previous position |
155 | cursor->previous.x = cursor->cursor->x; | 156 | cursor->previous.x = cursor->cursor->x; |
156 | cursor->previous.y = cursor->cursor->y; | 157 | cursor->previous.y = cursor->cursor->y; |
157 | 158 | ||
158 | struct sway_container *c = container_at_coords(cursor->seat, | 159 | struct sway_container *c = container_at_coords(seat, |
159 | cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); | 160 | cursor->cursor->x, cursor->cursor->y, &surface, &sx, &sy); |
160 | if (c && config->focus_follows_mouse && allow_refocusing) { | 161 | if (c && config->focus_follows_mouse && allow_refocusing) { |
161 | struct sway_container *focus = seat_get_focus(cursor->seat); | 162 | struct sway_container *focus = seat_get_focus(seat); |
162 | if (focus && c->type == C_WORKSPACE) { | 163 | if (focus && c->type == C_WORKSPACE) { |
163 | // Only follow the mouse if it would move to a new output | 164 | // Only follow the mouse if it would move to a new output |
164 | // Otherwise we'll focus the workspace, which is probably wrong | 165 | // Otherwise we'll focus the workspace, which is probably wrong |
@@ -170,20 +171,20 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, | |||
170 | output = container_parent(c, C_OUTPUT); | 171 | output = container_parent(c, C_OUTPUT); |
171 | } | 172 | } |
172 | if (output != focus) { | 173 | if (output != focus) { |
173 | seat_set_focus_warp(cursor->seat, c, false); | 174 | seat_set_focus_warp(seat, c, false); |
174 | } | 175 | } |
175 | } else if (c->type == C_VIEW) { | 176 | } else if (c->type == C_VIEW) { |
176 | // Focus c if both of the following are true: | 177 | // Focus c if both of the following are true: |
177 | // - cursor is over a new view, i.e. entered a new window; and | 178 | // - cursor is over a new view, i.e. entered a new window; and |
178 | // - the new view is visible, i.e. not hidden in a stack or tab. | 179 | // - the new view is visible, i.e. not hidden in a stack or tab. |
179 | if (c != prev_c && view_is_visible(c->sway_view)) { | 180 | if (c != prev_c && view_is_visible(c->sway_view)) { |
180 | seat_set_focus_warp(cursor->seat, c, false); | 181 | seat_set_focus_warp(seat, c, false); |
181 | } else { | 182 | } else { |
182 | struct sway_container *next_focus = | 183 | struct sway_container *next_focus = |
183 | seat_get_focus_inactive(cursor->seat, &root_container); | 184 | seat_get_focus_inactive(seat, &root_container); |
184 | if (next_focus && next_focus->type == C_VIEW && | 185 | if (next_focus && next_focus->type == C_VIEW && |
185 | view_is_visible(next_focus->sway_view)) { | 186 | view_is_visible(next_focus->sway_view)) { |
186 | seat_set_focus_warp(cursor->seat, next_focus, false); | 187 | seat_set_focus_warp(seat, next_focus, false); |
187 | } | 188 | } |
188 | } | 189 | } |
189 | } | 190 | } |
@@ -202,12 +203,18 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor, uint32_t time_msec, | |||
202 | 203 | ||
203 | // send pointer enter/leave | 204 | // send pointer enter/leave |
204 | if (surface != NULL) { | 205 | if (surface != NULL) { |
205 | if (seat_is_input_allowed(cursor->seat, surface)) { | 206 | if (seat_is_input_allowed(seat, surface)) { |
206 | wlr_seat_pointer_notify_enter(seat, surface, sx, sy); | 207 | wlr_seat_pointer_notify_enter(wlr_seat, surface, sx, sy); |
207 | wlr_seat_pointer_notify_motion(seat, time_msec, sx, sy); | 208 | wlr_seat_pointer_notify_motion(wlr_seat, time_msec, sx, sy); |
208 | } | 209 | } |
209 | } else { | 210 | } else { |
210 | wlr_seat_pointer_clear_focus(seat); | 211 | wlr_seat_pointer_clear_focus(wlr_seat); |
212 | } | ||
213 | |||
214 | struct wlr_drag_icon *wlr_drag_icon; | ||
215 | wl_list_for_each(wlr_drag_icon, &wlr_seat->drag_icons, link) { | ||
216 | struct sway_drag_icon *drag_icon = wlr_drag_icon->data; | ||
217 | drag_icon_update_position(drag_icon); | ||
211 | } | 218 | } |
212 | } | 219 | } |
213 | 220 | ||
@@ -293,22 +300,27 @@ static void handle_touch_down(struct wl_listener *listener, void *data) { | |||
293 | wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); | 300 | wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); |
294 | struct wlr_event_touch_down *event = data; | 301 | struct wlr_event_touch_down *event = data; |
295 | 302 | ||
296 | struct wlr_seat *seat = cursor->seat->wlr_seat; | 303 | struct sway_seat *seat = cursor->seat; |
304 | struct wlr_seat *wlr_seat = seat->wlr_seat; | ||
297 | struct wlr_surface *surface = NULL; | 305 | struct wlr_surface *surface = NULL; |
298 | 306 | ||
299 | double lx, ly; | 307 | double lx, ly; |
300 | wlr_cursor_absolute_to_layout_coords(cursor->cursor, event->device, | 308 | wlr_cursor_absolute_to_layout_coords(cursor->cursor, event->device, |
301 | event->x, event->y, &lx, &ly); | 309 | event->x, event->y, &lx, &ly); |
302 | double sx, sy; | 310 | double sx, sy; |
303 | container_at_coords(cursor->seat, lx, ly, &surface, &sx, &sy); | 311 | container_at_coords(seat, lx, ly, &surface, &sx, &sy); |
312 | |||
313 | seat->touch_id = event->touch_id; | ||
314 | seat->touch_x = lx; | ||
315 | seat->touch_y = ly; | ||
304 | 316 | ||
305 | if (!surface) { | 317 | if (!surface) { |
306 | return; | 318 | return; |
307 | } | 319 | } |
308 | 320 | ||
309 | // TODO: fall back to cursor simulation if client has not bound to touch | 321 | // TODO: fall back to cursor simulation if client has not bound to touch |
310 | if (seat_is_input_allowed(cursor->seat, surface)) { | 322 | if (seat_is_input_allowed(seat, surface)) { |
311 | wlr_seat_touch_notify_down(seat, surface, event->time_msec, | 323 | wlr_seat_touch_notify_down(wlr_seat, surface, event->time_msec, |
312 | event->touch_id, sx, sy); | 324 | event->touch_id, sx, sy); |
313 | cursor->image_client = NULL; | 325 | cursor->image_client = NULL; |
314 | wlr_cursor_set_image(cursor->cursor, NULL, 0, 0, 0, 0, 0, 0); | 326 | wlr_cursor_set_image(cursor->cursor, NULL, 0, 0, 0, 0, 0, 0); |
@@ -330,7 +342,8 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) { | |||
330 | wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); | 342 | wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); |
331 | struct wlr_event_touch_motion *event = data; | 343 | struct wlr_event_touch_motion *event = data; |
332 | 344 | ||
333 | struct wlr_seat *seat = cursor->seat->wlr_seat; | 345 | struct sway_seat *seat = cursor->seat; |
346 | struct wlr_seat *wlr_seat = seat->wlr_seat; | ||
334 | struct wlr_surface *surface = NULL; | 347 | struct wlr_surface *surface = NULL; |
335 | 348 | ||
336 | double lx, ly; | 349 | double lx, ly; |
@@ -339,14 +352,25 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) { | |||
339 | double sx, sy; | 352 | double sx, sy; |
340 | container_at_coords(cursor->seat, lx, ly, &surface, &sx, &sy); | 353 | container_at_coords(cursor->seat, lx, ly, &surface, &sx, &sy); |
341 | 354 | ||
355 | if (seat->touch_id == event->touch_id) { | ||
356 | seat->touch_x = lx; | ||
357 | seat->touch_y = ly; | ||
358 | |||
359 | struct wlr_drag_icon *wlr_drag_icon; | ||
360 | wl_list_for_each(wlr_drag_icon, &wlr_seat->drag_icons, link) { | ||
361 | struct sway_drag_icon *drag_icon = wlr_drag_icon->data; | ||
362 | drag_icon_update_position(drag_icon); | ||
363 | } | ||
364 | } | ||
365 | |||
342 | if (!surface) { | 366 | if (!surface) { |
343 | return; | 367 | return; |
344 | } | 368 | } |
345 | 369 | ||
346 | // TODO: fall back to cursor simulation if client has not bound to touch | 370 | // TODO: fall back to cursor simulation if client has not bound to touch |
347 | if (seat_is_input_allowed(cursor->seat, surface)) { | 371 | if (seat_is_input_allowed(cursor->seat, surface)) { |
348 | wlr_seat_touch_notify_motion( | 372 | wlr_seat_touch_notify_motion(wlr_seat, event->time_msec, |
349 | seat, event->time_msec, event->touch_id, sx, sy); | 373 | event->touch_id, sx, sy); |
350 | } | 374 | } |
351 | } | 375 | } |
352 | 376 | ||
diff --git a/sway/input/seat.c b/sway/input/seat.c index 071ef020..1ea36466 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -6,21 +6,22 @@ | |||
6 | #include <wlr/types/wlr_cursor.h> | 6 | #include <wlr/types/wlr_cursor.h> |
7 | #include <wlr/types/wlr_output_layout.h> | 7 | #include <wlr/types/wlr_output_layout.h> |
8 | #include <wlr/types/wlr_xcursor_manager.h> | 8 | #include <wlr/types/wlr_xcursor_manager.h> |
9 | #include "log.h" | ||
9 | #include "sway/debug.h" | 10 | #include "sway/debug.h" |
10 | #include "sway/tree/container.h" | 11 | #include "sway/desktop.h" |
11 | #include "sway/tree/workspace.h" | ||
12 | #include "sway/input/seat.h" | ||
13 | #include "sway/input/cursor.h" | 12 | #include "sway/input/cursor.h" |
14 | #include "sway/input/input-manager.h" | 13 | #include "sway/input/input-manager.h" |
15 | #include "sway/input/keyboard.h" | 14 | #include "sway/input/keyboard.h" |
15 | #include "sway/input/seat.h" | ||
16 | #include "sway/ipc-server.h" | 16 | #include "sway/ipc-server.h" |
17 | #include "sway/layers.h" | 17 | #include "sway/layers.h" |
18 | #include "sway/output.h" | 18 | #include "sway/output.h" |
19 | #include "sway/tree/arrange.h" | 19 | #include "sway/tree/arrange.h" |
20 | #include "sway/tree/container.h" | 20 | #include "sway/tree/container.h" |
21 | #include "sway/tree/container.h" | ||
21 | #include "sway/tree/view.h" | 22 | #include "sway/tree/view.h" |
22 | #include "sway/tree/workspace.h" | 23 | #include "sway/tree/workspace.h" |
23 | #include "log.h" | 24 | #include "sway/tree/workspace.h" |
24 | 25 | ||
25 | static void seat_device_destroy(struct sway_seat_device *seat_device) { | 26 | static void seat_device_destroy(struct sway_seat_device *seat_device) { |
26 | if (!seat_device) { | 27 | if (!seat_device) { |
@@ -40,6 +41,8 @@ void seat_destroy(struct sway_seat *seat) { | |||
40 | seat_device_destroy(seat_device); | 41 | seat_device_destroy(seat_device); |
41 | } | 42 | } |
42 | sway_cursor_destroy(seat->cursor); | 43 | sway_cursor_destroy(seat->cursor); |
44 | wl_list_remove(&seat->new_container.link); | ||
45 | wl_list_remove(&seat->new_drag_icon.link); | ||
43 | wl_list_remove(&seat->link); | 46 | wl_list_remove(&seat->link); |
44 | wlr_seat_destroy(seat->wlr_seat); | 47 | wlr_seat_destroy(seat->wlr_seat); |
45 | } | 48 | } |
@@ -234,6 +237,90 @@ static void handle_new_container(struct wl_listener *listener, void *data) { | |||
234 | seat_container_from_container(seat, con); | 237 | seat_container_from_container(seat, con); |
235 | } | 238 | } |
236 | 239 | ||
240 | static void drag_icon_damage_whole(struct sway_drag_icon *icon) { | ||
241 | if (!icon->wlr_drag_icon->mapped) { | ||
242 | return; | ||
243 | } | ||
244 | desktop_damage_surface(icon->wlr_drag_icon->surface, icon->x, icon->y, true); | ||
245 | } | ||
246 | |||
247 | void drag_icon_update_position(struct sway_drag_icon *icon) { | ||
248 | drag_icon_damage_whole(icon); | ||
249 | |||
250 | struct wlr_drag_icon *wlr_icon = icon->wlr_drag_icon; | ||
251 | struct sway_seat *seat = icon->seat; | ||
252 | struct wlr_cursor *cursor = seat->cursor->cursor; | ||
253 | if (wlr_icon->is_pointer) { | ||
254 | icon->x = cursor->x + wlr_icon->sx; | ||
255 | icon->y = cursor->y + wlr_icon->sy; | ||
256 | } else { | ||
257 | struct wlr_touch_point *point = | ||
258 | wlr_seat_touch_get_point(seat->wlr_seat, wlr_icon->touch_id); | ||
259 | if (point == NULL) { | ||
260 | return; | ||
261 | } | ||
262 | icon->x = seat->touch_x + wlr_icon->sx; | ||
263 | icon->y = seat->touch_y + wlr_icon->sy; | ||
264 | } | ||
265 | |||
266 | drag_icon_damage_whole(icon); | ||
267 | } | ||
268 | |||
269 | static void drag_icon_handle_surface_commit(struct wl_listener *listener, | ||
270 | void *data) { | ||
271 | struct sway_drag_icon *icon = | ||
272 | wl_container_of(listener, icon, surface_commit); | ||
273 | drag_icon_update_position(icon); | ||
274 | } | ||
275 | |||
276 | static void drag_icon_handle_map(struct wl_listener *listener, void *data) { | ||
277 | struct sway_drag_icon *icon = wl_container_of(listener, icon, map); | ||
278 | drag_icon_damage_whole(icon); | ||
279 | } | ||
280 | |||
281 | static void drag_icon_handle_unmap(struct wl_listener *listener, void *data) { | ||
282 | struct sway_drag_icon *icon = wl_container_of(listener, icon, unmap); | ||
283 | drag_icon_damage_whole(icon); | ||
284 | } | ||
285 | |||
286 | static void drag_icon_handle_destroy(struct wl_listener *listener, | ||
287 | void *data) { | ||
288 | struct sway_drag_icon *icon = wl_container_of(listener, icon, destroy); | ||
289 | icon->wlr_drag_icon->data = NULL; | ||
290 | wl_list_remove(&icon->link); | ||
291 | wl_list_remove(&icon->surface_commit.link); | ||
292 | wl_list_remove(&icon->unmap.link); | ||
293 | wl_list_remove(&icon->destroy.link); | ||
294 | free(icon); | ||
295 | } | ||
296 | |||
297 | static void handle_new_drag_icon(struct wl_listener *listener, void *data) { | ||
298 | struct sway_seat *seat = wl_container_of(listener, seat, new_drag_icon); | ||
299 | struct wlr_drag_icon *wlr_drag_icon = data; | ||
300 | |||
301 | struct sway_drag_icon *icon = calloc(1, sizeof(struct sway_drag_icon)); | ||
302 | if (icon == NULL) { | ||
303 | wlr_log(L_ERROR, "Allocation failed"); | ||
304 | return; | ||
305 | } | ||
306 | icon->seat = seat; | ||
307 | icon->wlr_drag_icon = wlr_drag_icon; | ||
308 | wlr_drag_icon->data = icon; | ||
309 | |||
310 | icon->surface_commit.notify = drag_icon_handle_surface_commit; | ||
311 | wl_signal_add(&wlr_drag_icon->surface->events.commit, &icon->surface_commit); | ||
312 | icon->unmap.notify = drag_icon_handle_unmap; | ||
313 | wl_signal_add(&wlr_drag_icon->events.unmap, &icon->unmap); | ||
314 | icon->map.notify = drag_icon_handle_map; | ||
315 | wl_signal_add(&wlr_drag_icon->events.map, &icon->map); | ||
316 | icon->destroy.notify = drag_icon_handle_destroy; | ||
317 | wl_signal_add(&wlr_drag_icon->events.destroy, &icon->destroy); | ||
318 | |||
319 | wl_list_insert(&root_container.sway_root->drag_icons, &icon->link); | ||
320 | |||
321 | drag_icon_update_position(icon); | ||
322 | } | ||
323 | |||
237 | static void collect_focus_iter(struct sway_container *con, void *data) { | 324 | static void collect_focus_iter(struct sway_container *con, void *data) { |
238 | struct sway_seat *seat = data; | 325 | struct sway_seat *seat = data; |
239 | if (con->type > C_WORKSPACE) { | 326 | if (con->type > C_WORKSPACE) { |
@@ -278,6 +365,9 @@ struct sway_seat *seat_create(struct sway_input_manager *input, | |||
278 | &seat->new_container); | 365 | &seat->new_container); |
279 | seat->new_container.notify = handle_new_container; | 366 | seat->new_container.notify = handle_new_container; |
280 | 367 | ||
368 | wl_signal_add(&seat->wlr_seat->events.new_drag_icon, &seat->new_drag_icon); | ||
369 | seat->new_drag_icon.notify = handle_new_drag_icon; | ||
370 | |||
281 | seat->input = input; | 371 | seat->input = input; |
282 | wl_list_init(&seat->devices); | 372 | wl_list_init(&seat->devices); |
283 | 373 | ||
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index a8aba618..d1ad044d 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -37,6 +37,7 @@ void layout_init(void) { | |||
37 | root_container.sway_root->output_layout = wlr_output_layout_create(); | 37 | root_container.sway_root->output_layout = wlr_output_layout_create(); |
38 | wl_list_init(&root_container.sway_root->outputs); | 38 | wl_list_init(&root_container.sway_root->outputs); |
39 | wl_list_init(&root_container.sway_root->xwayland_unmanaged); | 39 | wl_list_init(&root_container.sway_root->xwayland_unmanaged); |
40 | wl_list_init(&root_container.sway_root->drag_icons); | ||
40 | wl_signal_init(&root_container.sway_root->events.new_container); | 41 | wl_signal_init(&root_container.sway_root->events.new_container); |
41 | 42 | ||
42 | root_container.sway_root->output_layout_change.notify = | 43 | root_container.sway_root->output_layout_change.notify = |