aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Alexander Orzechowski <orzechowski.alexander@gmail.com>2022-03-04 19:23:27 -0500
committerLibravatar Kirill Primak <vyivel@eclair.cafe>2024-01-18 18:36:54 +0300
commitdbd2fbf4301d441be4f9a04a1df6d93c81c361f6 (patch)
treeed1e1da485e28529bf28922c08b021a7bc1856ac
parentdesktop: Rename layers to shell_layers (diff)
downloadsway-dbd2fbf4301d441be4f9a04a1df6d93c81c361f6.tar.gz
sway-dbd2fbf4301d441be4f9a04a1df6d93c81c361f6.tar.zst
sway-dbd2fbf4301d441be4f9a04a1df6d93c81c361f6.zip
view: init function should return a success bool
-rw-r--r--include/sway/tree/view.h2
-rw-r--r--sway/desktop/xdg_shell.c5
-rw-r--r--sway/desktop/xwayland.c5
-rw-r--r--sway/tree/view.c3
4 files changed, 11 insertions, 4 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index 856651a5..822e7bb3 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -311,7 +311,7 @@ void view_for_each_popup_surface(struct sway_view *view,
311 311
312// view implementation 312// view implementation
313 313
314void view_init(struct sway_view *view, enum sway_view_type type, 314bool view_init(struct sway_view *view, enum sway_view_type type,
315 const struct sway_view_impl *impl); 315 const struct sway_view_impl *impl);
316 316
317void view_destroy(struct sway_view *view); 317void view_destroy(struct sway_view *view);
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index 63a0835b..11c112be 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -548,7 +548,10 @@ void handle_xdg_shell_toplevel(struct wl_listener *listener, void *data) {
548 return; 548 return;
549 } 549 }
550 550
551 view_init(&xdg_shell_view->view, SWAY_VIEW_XDG_SHELL, &view_impl); 551 if (!view_init(&xdg_shell_view->view, SWAY_VIEW_XDG_SHELL, &view_impl)) {
552 free(xdg_shell_view);
553 return;
554 }
552 xdg_shell_view->view.wlr_xdg_toplevel = xdg_toplevel; 555 xdg_shell_view->view.wlr_xdg_toplevel = xdg_toplevel;
553 556
554 xdg_shell_view->map.notify = handle_map; 557 xdg_shell_view->map.notify = handle_map;
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 2c6184fd..8f79b5e7 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -796,7 +796,10 @@ struct sway_xwayland_view *create_xwayland_view(struct wlr_xwayland_surface *xsu
796 return NULL; 796 return NULL;
797 } 797 }
798 798
799 view_init(&xwayland_view->view, SWAY_VIEW_XWAYLAND, &view_impl); 799 if (!view_init(&xwayland_view->view, SWAY_VIEW_XWAYLAND, &view_impl)) {
800 free(xwayland_view);
801 return NULL;
802 }
800 xwayland_view->view.wlr_xwayland_surface = xsurface; 803 xwayland_view->view.wlr_xwayland_surface = xsurface;
801 804
802 wl_signal_add(&xsurface->events.destroy, &xwayland_view->destroy); 805 wl_signal_add(&xsurface->events.destroy, &xwayland_view->destroy);
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 00dc4721..d62a0667 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -35,7 +35,7 @@
35#include "pango.h" 35#include "pango.h"
36#include "stringop.h" 36#include "stringop.h"
37 37
38void view_init(struct sway_view *view, enum sway_view_type type, 38bool view_init(struct sway_view *view, enum sway_view_type type,
39 const struct sway_view_impl *impl) { 39 const struct sway_view_impl *impl) {
40 view->type = type; 40 view->type = type;
41 view->impl = impl; 41 view->impl = impl;
@@ -44,6 +44,7 @@ void view_init(struct sway_view *view, enum sway_view_type type,
44 view->allow_request_urgent = true; 44 view->allow_request_urgent = true;
45 view->shortcuts_inhibit = SHORTCUTS_INHIBIT_DEFAULT; 45 view->shortcuts_inhibit = SHORTCUTS_INHIBIT_DEFAULT;
46 wl_signal_init(&view->events.unmap); 46 wl_signal_init(&view->events.unmap);
47 return true;
47} 48}
48 49
49void view_destroy(struct sway_view *view) { 50void view_destroy(struct sway_view *view) {