diff options
author | Simon Ser <contact@emersion.fr> | 2023-02-01 20:24:40 +0100 |
---|---|---|
committer | Kirill Primak <vyivel@eclair.cafe> | 2023-02-02 14:53:15 +0300 |
commit | 9959e6b8dc9b7fbfcccd516e38bc50681f38e275 (patch) | |
tree | 8a59226530bc87f2299ee9934f99618ab089af81 | |
parent | root: free non_desktop_outputs list on root_destroy (diff) | |
download | sway-9959e6b8dc9b7fbfcccd516e38bc50681f38e275.tar.gz sway-9959e6b8dc9b7fbfcccd516e38bc50681f38e275.tar.zst sway-9959e6b8dc9b7fbfcccd516e38bc50681f38e275.zip |
Convert to *_try_from_wlr_surface()
References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3991
-rw-r--r-- | sway/input/cursor.c | 9 | ||||
-rw-r--r-- | sway/input/seatop_default.c | 18 | ||||
-rw-r--r-- | sway/tree/container.c | 10 | ||||
-rw-r--r-- | sway/tree/view.c | 20 | ||||
-rw-r--r-- | sway/xdg_activation_v1.c | 6 |
5 files changed, 23 insertions, 40 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index efd67a76..ad69e7c3 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -53,12 +53,9 @@ static struct wlr_surface *layer_surface_at(struct sway_output *output, | |||
53 | } | 53 | } |
54 | 54 | ||
55 | static bool surface_is_xdg_popup(struct wlr_surface *surface) { | 55 | static bool surface_is_xdg_popup(struct wlr_surface *surface) { |
56 | if (wlr_surface_is_xdg_surface(surface)) { | 56 | struct wlr_xdg_surface *xdg_surface = |
57 | struct wlr_xdg_surface *xdg_surface = | 57 | wlr_xdg_surface_try_from_wlr_surface(surface); |
58 | wlr_xdg_surface_from_wlr_surface(surface); | 58 | return xdg_surface != NULL && xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP; |
59 | return xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP; | ||
60 | } | ||
61 | return false; | ||
62 | } | 59 | } |
63 | 60 | ||
64 | static struct wlr_surface *layer_surface_popup_at(struct sway_output *output, | 61 | static struct wlr_surface *layer_surface_popup_at(struct sway_output *output, |
diff --git a/sway/input/seatop_default.c b/sway/input/seatop_default.c index a1c1d319..0dcb87ab 100644 --- a/sway/input/seatop_default.c +++ b/sway/input/seatop_default.c | |||
@@ -228,17 +228,15 @@ static void handle_tablet_tool_tip(struct sway_seat *seat, | |||
228 | struct sway_container *cont = node && node->type == N_CONTAINER ? | 228 | struct sway_container *cont = node && node->type == N_CONTAINER ? |
229 | node->sway_container : NULL; | 229 | node->sway_container : NULL; |
230 | 230 | ||
231 | struct wlr_layer_surface_v1 *layer; | ||
231 | #if HAVE_XWAYLAND | 232 | #if HAVE_XWAYLAND |
232 | struct wlr_xwayland_surface *xsurface; | 233 | struct wlr_xwayland_surface *xsurface; |
233 | #endif | 234 | #endif |
234 | if (wlr_surface_is_layer_surface(surface)) { | 235 | if ((layer = wlr_layer_surface_v1_try_from_wlr_surface(surface)) && |
236 | layer->current.keyboard_interactive) { | ||
235 | // Handle tapping a layer surface | 237 | // Handle tapping a layer surface |
236 | struct wlr_layer_surface_v1 *layer = | 238 | seat_set_focus_layer(seat, layer); |
237 | wlr_layer_surface_v1_from_wlr_surface(surface); | 239 | transaction_commit_dirty(); |
238 | if (layer->current.keyboard_interactive) { | ||
239 | seat_set_focus_layer(seat, layer); | ||
240 | transaction_commit_dirty(); | ||
241 | } | ||
242 | } else if (cont) { | 240 | } else if (cont) { |
243 | bool is_floating_or_child = container_is_floating_or_child(cont); | 241 | bool is_floating_or_child = container_is_floating_or_child(cont); |
244 | bool is_fullscreen_or_child = container_is_fullscreen_or_child(cont); | 242 | bool is_fullscreen_or_child = container_is_fullscreen_or_child(cont); |
@@ -368,9 +366,9 @@ static void handle_button(struct sway_seat *seat, uint32_t time_msec, | |||
368 | } | 366 | } |
369 | 367 | ||
370 | // Handle clicking a layer surface | 368 | // Handle clicking a layer surface |
371 | if (surface && wlr_surface_is_layer_surface(surface)) { | 369 | struct wlr_layer_surface_v1 *layer; |
372 | struct wlr_layer_surface_v1 *layer = | 370 | if (surface && |
373 | wlr_layer_surface_v1_from_wlr_surface(surface); | 371 | (layer = wlr_layer_surface_v1_try_from_wlr_surface(surface))) { |
374 | if (layer->current.keyboard_interactive) { | 372 | if (layer->current.keyboard_interactive) { |
375 | seat_set_focus_layer(seat, layer); | 373 | seat_set_focus_layer(seat, layer); |
376 | transaction_commit_dirty(); | 374 | transaction_commit_dirty(); |
diff --git a/sway/tree/container.c b/sway/tree/container.c index c60c8f8f..dbe88028 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -387,16 +387,16 @@ struct sway_container *tiling_container_at(struct sway_node *parent, | |||
387 | } | 387 | } |
388 | 388 | ||
389 | static bool surface_is_popup(struct wlr_surface *surface) { | 389 | static bool surface_is_popup(struct wlr_surface *surface) { |
390 | while (!wlr_surface_is_xdg_surface(surface)) { | 390 | while (wlr_xdg_surface_try_from_wlr_surface(surface) == NULL) { |
391 | if (!wlr_surface_is_subsurface(surface)) { | 391 | struct wlr_subsurface *subsurface = |
392 | wlr_subsurface_try_from_wlr_surface(surface); | ||
393 | if (subsurface == NULL) { | ||
392 | return false; | 394 | return false; |
393 | } | 395 | } |
394 | struct wlr_subsurface *subsurface = | ||
395 | wlr_subsurface_from_wlr_surface(surface); | ||
396 | surface = subsurface->parent; | 396 | surface = subsurface->parent; |
397 | } | 397 | } |
398 | struct wlr_xdg_surface *xdg_surface = | 398 | struct wlr_xdg_surface *xdg_surface = |
399 | wlr_xdg_surface_from_wlr_surface(surface); | 399 | wlr_xdg_surface_try_from_wlr_surface(surface); |
400 | return xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP; | 400 | return xdg_surface->role == WLR_XDG_SURFACE_ROLE_POPUP; |
401 | } | 401 | } |
402 | 402 | ||
diff --git a/sway/tree/view.c b/sway/tree/view.c index db902562..ec0ad4af 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -951,7 +951,7 @@ static void subsurface_get_view_coords(struct sway_view_child *child, | |||
951 | *sx = *sy = 0; | 951 | *sx = *sy = 0; |
952 | } | 952 | } |
953 | struct wlr_subsurface *subsurface = | 953 | struct wlr_subsurface *subsurface = |
954 | wlr_subsurface_from_wlr_surface(surface); | 954 | wlr_subsurface_try_from_wlr_surface(surface); |
955 | *sx += subsurface->current.x; | 955 | *sx += subsurface->current.x; |
956 | *sy += subsurface->current.y; | 956 | *sy += subsurface->current.y; |
957 | } | 957 | } |
@@ -1187,12 +1187,8 @@ void view_child_destroy(struct sway_view_child *child) { | |||
1187 | } | 1187 | } |
1188 | 1188 | ||
1189 | struct sway_view *view_from_wlr_surface(struct wlr_surface *wlr_surface) { | 1189 | struct sway_view *view_from_wlr_surface(struct wlr_surface *wlr_surface) { |
1190 | if (wlr_surface_is_xdg_surface(wlr_surface)) { | 1190 | struct wlr_xdg_surface *xdg_surface; |
1191 | struct wlr_xdg_surface *xdg_surface = | 1191 | if ((xdg_surface = wlr_xdg_surface_try_from_wlr_surface(wlr_surface))) { |
1192 | wlr_xdg_surface_from_wlr_surface(wlr_surface); | ||
1193 | if (xdg_surface == NULL) { | ||
1194 | return NULL; | ||
1195 | } | ||
1196 | return view_from_wlr_xdg_surface(xdg_surface); | 1192 | return view_from_wlr_xdg_surface(xdg_surface); |
1197 | } | 1193 | } |
1198 | #if HAVE_XWAYLAND | 1194 | #if HAVE_XWAYLAND |
@@ -1201,15 +1197,11 @@ struct sway_view *view_from_wlr_surface(struct wlr_surface *wlr_surface) { | |||
1201 | return view_from_wlr_xwayland_surface(xsurface); | 1197 | return view_from_wlr_xwayland_surface(xsurface); |
1202 | } | 1198 | } |
1203 | #endif | 1199 | #endif |
1204 | if (wlr_surface_is_subsurface(wlr_surface)) { | 1200 | struct wlr_subsurface *subsurface; |
1205 | struct wlr_subsurface *subsurface = | 1201 | if ((subsurface = wlr_subsurface_try_from_wlr_surface(wlr_surface))) { |
1206 | wlr_subsurface_from_wlr_surface(wlr_surface); | ||
1207 | if (subsurface == NULL) { | ||
1208 | return NULL; | ||
1209 | } | ||
1210 | return view_from_wlr_surface(subsurface->parent); | 1202 | return view_from_wlr_surface(subsurface->parent); |
1211 | } | 1203 | } |
1212 | if (wlr_surface_is_layer_surface(wlr_surface)) { | 1204 | if (wlr_layer_surface_v1_try_from_wlr_surface(wlr_surface) != NULL) { |
1213 | return NULL; | 1205 | return NULL; |
1214 | } | 1206 | } |
1215 | 1207 | ||
diff --git a/sway/xdg_activation_v1.c b/sway/xdg_activation_v1.c index 2b94136c..cc3dcec0 100644 --- a/sway/xdg_activation_v1.c +++ b/sway/xdg_activation_v1.c | |||
@@ -6,12 +6,8 @@ void xdg_activation_v1_handle_request_activate(struct wl_listener *listener, | |||
6 | void *data) { | 6 | void *data) { |
7 | const struct wlr_xdg_activation_v1_request_activate_event *event = data; | 7 | const struct wlr_xdg_activation_v1_request_activate_event *event = data; |
8 | 8 | ||
9 | if (!wlr_surface_is_xdg_surface(event->surface)) { | ||
10 | return; | ||
11 | } | ||
12 | |||
13 | struct wlr_xdg_surface *xdg_surface = | 9 | struct wlr_xdg_surface *xdg_surface = |
14 | wlr_xdg_surface_from_wlr_surface(event->surface); | 10 | wlr_xdg_surface_try_from_wlr_surface(event->surface); |
15 | if (xdg_surface == NULL) { | 11 | if (xdg_surface == NULL) { |
16 | return; | 12 | return; |
17 | } | 13 | } |