diff options
author | David Eklov <david.eklov@gmail.com> | 2016-07-04 17:01:37 -0500 |
---|---|---|
committer | David Eklov <david.eklov@gmail.com> | 2016-07-04 21:58:41 -0500 |
commit | bb35960e652f98a882ed3cd2d1968b860942b896 (patch) | |
tree | 28a5b8207a166c24a636cfcf25448baa446d2943 | |
parent | Enable backgrounds and panels to be shell surfaces (diff) | |
download | sway-bb35960e652f98a882ed3cd2d1968b860942b896.tar.gz sway-bb35960e652f98a882ed3cd2d1968b860942b896.tar.zst sway-bb35960e652f98a882ed3cd2d1968b860942b896.zip |
Move code to make a window a shell surface into seperate function
-rw-r--r-- | include/client/window.h | 1 | ||||
-rw-r--r-- | wayland/window.c | 10 |
2 files changed, 8 insertions, 3 deletions
diff --git a/include/client/window.h b/include/client/window.h index eff9032d..e48ec4f3 100644 --- a/include/client/window.h +++ b/include/client/window.h | |||
@@ -42,5 +42,6 @@ struct window *window_setup(struct registry *registry, uint32_t width, uint32_t | |||
42 | void window_teardown(struct window *state); | 42 | void window_teardown(struct window *state); |
43 | int window_prerender(struct window *state); | 43 | int window_prerender(struct window *state); |
44 | int window_render(struct window *state); | 44 | int window_render(struct window *state); |
45 | void window_make_shell(struct window *window); | ||
45 | 46 | ||
46 | #endif | 47 | #endif |
diff --git a/wayland/window.c b/wayland/window.c index ba64cb60..7ca9e4ec 100644 --- a/wayland/window.c +++ b/wayland/window.c | |||
@@ -59,6 +59,12 @@ static const struct wl_shell_surface_listener surface_listener = { | |||
59 | .configure = shell_surface_configure | 59 | .configure = shell_surface_configure |
60 | }; | 60 | }; |
61 | 61 | ||
62 | void window_make_shell(struct window *window) { | ||
63 | window->shell_surface = wl_shell_get_shell_surface(window->registry->shell, window->surface); | ||
64 | wl_shell_surface_add_listener(window->shell_surface, &surface_listener, window); | ||
65 | wl_shell_surface_set_toplevel(window->shell_surface); | ||
66 | } | ||
67 | |||
62 | struct window *window_setup(struct registry *registry, uint32_t width, uint32_t height, bool shell_surface) { | 68 | struct window *window_setup(struct registry *registry, uint32_t width, uint32_t height, bool shell_surface) { |
63 | struct window *window = malloc(sizeof(struct window)); | 69 | struct window *window = malloc(sizeof(struct window)); |
64 | memset(window, 0, sizeof(struct window)); | 70 | memset(window, 0, sizeof(struct window)); |
@@ -69,9 +75,7 @@ struct window *window_setup(struct registry *registry, uint32_t width, uint32_t | |||
69 | 75 | ||
70 | window->surface = wl_compositor_create_surface(registry->compositor); | 76 | window->surface = wl_compositor_create_surface(registry->compositor); |
71 | if (shell_surface) { | 77 | if (shell_surface) { |
72 | window->shell_surface = wl_shell_get_shell_surface(registry->shell, window->surface); | 78 | window_make_shell(window); |
73 | wl_shell_surface_add_listener(window->shell_surface, &surface_listener, window); | ||
74 | wl_shell_surface_set_toplevel(window->shell_surface); | ||
75 | } | 79 | } |
76 | if (registry->pointer) { | 80 | if (registry->pointer) { |
77 | wl_pointer_add_listener(registry->pointer, &pointer_listener, window); | 81 | wl_pointer_add_listener(registry->pointer, &pointer_listener, window); |