aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input/seat.c
diff options
context:
space:
mode:
authorLibravatar Tony Crisci <tony@dubstepdish.com>2018-03-31 17:07:37 -0400
committerLibravatar Tony Crisci <tony@dubstepdish.com>2018-03-31 17:07:37 -0400
commit2aec85bf241f4bad59a23e8492e91d3e7add6ab6 (patch)
tree698224538940ba0d18c238f720ea1e3687b9aa67 /sway/input/seat.c
parenthandle container destroy in the seat (diff)
downloadsway-2aec85bf241f4bad59a23e8492e91d3e7add6ab6.tar.gz
sway-2aec85bf241f4bad59a23e8492e91d3e7add6ab6.tar.zst
sway-2aec85bf241f4bad59a23e8492e91d3e7add6ab6.zip
clean up view destroy seat cleanup
Diffstat (limited to 'sway/input/seat.c')
-rw-r--r--sway/input/seat.c61
1 files changed, 33 insertions, 28 deletions
diff --git a/sway/input/seat.c b/sway/input/seat.c
index e3d53cb6..adc4cb0a 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -58,6 +58,31 @@ static void seat_container_destroy(struct sway_seat_container *seat_con) {
58 free(seat_con); 58 free(seat_con);
59} 59}
60 60
61static void seat_send_focus(struct sway_seat *seat,
62 struct sway_container *con) {
63 if (con->type != C_VIEW) {
64 return;
65 }
66 struct sway_view *view = con->sway_view;
67 if (view->type == SWAY_XWAYLAND_VIEW) {
68 struct wlr_xwayland *xwayland =
69 seat->input->server->xwayland;
70 wlr_xwayland_set_seat(xwayland, seat->wlr_seat);
71 }
72 view_set_activated(view, true);
73 struct wlr_keyboard *keyboard =
74 wlr_seat_get_keyboard(seat->wlr_seat);
75 if (keyboard) {
76 wlr_seat_keyboard_notify_enter(seat->wlr_seat,
77 view->surface, keyboard->keycodes,
78 keyboard->num_keycodes, &keyboard->modifiers);
79 } else {
80 wlr_seat_keyboard_notify_enter(
81 seat->wlr_seat, view->surface, NULL, 0, NULL);
82 }
83
84}
85
61static void handle_seat_container_destroy(struct wl_listener *listener, 86static void handle_seat_container_destroy(struct wl_listener *listener,
62 void *data) { 87 void *data) {
63 struct sway_seat_container *seat_con = 88 struct sway_seat_container *seat_con =
@@ -74,7 +99,7 @@ static void handle_seat_container_destroy(struct wl_listener *listener,
74 99
75 seat_container_destroy(seat_con); 100 seat_container_destroy(seat_con);
76 101
77 if (set_focus && con->type != C_WORKSPACE) { 102 if (set_focus) {
78 struct sway_container *next_focus = NULL; 103 struct sway_container *next_focus = NULL;
79 while (next_focus == NULL) { 104 while (next_focus == NULL) {
80 next_focus = sway_seat_get_focus_by_type(seat, parent, C_VIEW); 105 next_focus = sway_seat_get_focus_by_type(seat, parent, C_VIEW);
@@ -86,7 +111,13 @@ static void handle_seat_container_destroy(struct wl_listener *listener,
86 } 111 }
87 } 112 }
88 113
89 sway_seat_set_focus(seat, next_focus); 114 // the structure change might have caused it to move up to the top of
115 // the focus stack without sending focus notifications to the view
116 if (sway_seat_get_focus(seat) == next_focus) {
117 seat_send_focus(seat, next_focus);
118 } else {
119 sway_seat_set_focus(seat, next_focus);
120 }
90 } 121 }
91} 122}
92 123
@@ -321,37 +352,11 @@ void sway_seat_configure_xcursor(struct sway_seat *seat) {
321 seat->cursor->cursor->y); 352 seat->cursor->cursor->y);
322} 353}
323 354
324static void seat_send_focus(struct sway_seat *seat,
325 struct sway_container *con) {
326 if (con->type != C_VIEW) {
327 return;
328 }
329 struct sway_view *view = con->sway_view;
330 if (view->type == SWAY_XWAYLAND_VIEW) {
331 struct wlr_xwayland *xwayland =
332 seat->input->server->xwayland;
333 wlr_xwayland_set_seat(xwayland, seat->wlr_seat);
334 }
335 view_set_activated(view, true);
336 struct wlr_keyboard *keyboard =
337 wlr_seat_get_keyboard(seat->wlr_seat);
338 if (keyboard) {
339 wlr_seat_keyboard_notify_enter(seat->wlr_seat,
340 view->surface, keyboard->keycodes,
341 keyboard->num_keycodes, &keyboard->modifiers);
342 } else {
343 wlr_seat_keyboard_notify_enter(
344 seat->wlr_seat, view->surface, NULL, 0, NULL);
345 }
346
347}
348
349void sway_seat_set_focus_warp(struct sway_seat *seat, 355void sway_seat_set_focus_warp(struct sway_seat *seat,
350 struct sway_container *container, bool warp) { 356 struct sway_container *container, bool warp) {
351 struct sway_container *last_focus = sway_seat_get_focus(seat); 357 struct sway_container *last_focus = sway_seat_get_focus(seat);
352 358
353 if (container && last_focus == container) { 359 if (container && last_focus == container) {
354 seat_send_focus(seat, container);
355 return; 360 return;
356 } 361 }
357 362