diff options
-rw-r--r-- | include/client/window.h | 1 | ||||
-rw-r--r-- | include/extensions.h | 40 | ||||
-rw-r--r-- | sway/extensions.c | 2 | ||||
-rw-r--r-- | sway/handlers.c | 26 | ||||
-rw-r--r-- | swaybar/bar.c | 2 | ||||
-rw-r--r-- | swaybg/main.c | 1 | ||||
-rw-r--r-- | wayland/window.c | 10 |
7 files changed, 61 insertions, 21 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/include/extensions.h b/include/extensions.h index 158a40a2..7c508b5e 100644 --- a/include/extensions.h +++ b/include/extensions.h | |||
@@ -7,33 +7,37 @@ | |||
7 | #include "list.h" | 7 | #include "list.h" |
8 | 8 | ||
9 | struct background_config { | 9 | struct background_config { |
10 | wlc_handle output; | 10 | wlc_handle output; |
11 | wlc_resource surface; | 11 | wlc_resource surface; |
12 | // we need the wl_resource of the surface in the destructor | 12 | // we need the wl_resource of the surface in the destructor |
13 | struct wl_resource *wl_surface_res; | 13 | struct wl_resource *wl_surface_res; |
14 | // used to determine if client is a background | ||
15 | struct wl_client *client; | ||
14 | }; | 16 | }; |
15 | 17 | ||
16 | struct panel_config { | 18 | struct panel_config { |
17 | // wayland resource used in callbacks, is used to track this panel | 19 | // wayland resource used in callbacks, is used to track this panel |
18 | struct wl_resource *wl_resource; | 20 | struct wl_resource *wl_resource; |
19 | wlc_handle output; | 21 | wlc_handle output; |
20 | wlc_resource surface; | 22 | wlc_resource surface; |
21 | // we need the wl_resource of the surface in the destructor | 23 | // we need the wl_resource of the surface in the destructor |
22 | struct wl_resource *wl_surface_res; | 24 | struct wl_resource *wl_surface_res; |
23 | enum desktop_shell_panel_position panel_position; | 25 | enum desktop_shell_panel_position panel_position; |
26 | // used to determine if client is a panel | ||
27 | struct wl_client *client; | ||
24 | }; | 28 | }; |
25 | 29 | ||
26 | struct desktop_shell_state { | 30 | struct desktop_shell_state { |
27 | list_t *backgrounds; | 31 | list_t *backgrounds; |
28 | list_t *panels; | 32 | list_t *panels; |
29 | list_t *lock_surfaces; | 33 | list_t *lock_surfaces; |
30 | bool is_locked; | 34 | bool is_locked; |
31 | }; | 35 | }; |
32 | 36 | ||
33 | struct swaylock_state { | 37 | struct swaylock_state { |
34 | bool active; | 38 | bool active; |
35 | wlc_handle output; | 39 | wlc_handle output; |
36 | wlc_resource surface; | 40 | wlc_resource surface; |
37 | }; | 41 | }; |
38 | 42 | ||
39 | extern struct desktop_shell_state desktop_shell; | 43 | extern struct desktop_shell_state desktop_shell; |
diff --git a/sway/extensions.c b/sway/extensions.c index 7bc9bbe4..1fe15ac5 100644 --- a/sway/extensions.c +++ b/sway/extensions.c | |||
@@ -73,6 +73,7 @@ static void set_background(struct wl_client *client, struct wl_resource *resourc | |||
73 | } | 73 | } |
74 | sway_log(L_DEBUG, "Setting surface %p as background for output %d", surface, (int)output); | 74 | sway_log(L_DEBUG, "Setting surface %p as background for output %d", surface, (int)output); |
75 | struct background_config *config = malloc(sizeof(struct background_config)); | 75 | struct background_config *config = malloc(sizeof(struct background_config)); |
76 | config->client = client; | ||
76 | config->output = output; | 77 | config->output = output; |
77 | config->surface = wlc_resource_from_wl_surface_resource(surface); | 78 | config->surface = wlc_resource_from_wl_surface_resource(surface); |
78 | config->wl_surface_res = surface; | 79 | config->wl_surface_res = surface; |
@@ -91,6 +92,7 @@ static void set_panel(struct wl_client *client, struct wl_resource *resource, | |||
91 | sway_log(L_DEBUG, "Setting surface %p as panel for output %d (wl_resource: %p)", surface, (int)output, resource); | 92 | sway_log(L_DEBUG, "Setting surface %p as panel for output %d (wl_resource: %p)", surface, (int)output, resource); |
92 | struct panel_config *config = find_or_create_panel_config(resource); | 93 | struct panel_config *config = find_or_create_panel_config(resource); |
93 | config->output = output; | 94 | config->output = output; |
95 | config->client = client; | ||
94 | config->surface = wlc_resource_from_wl_surface_resource(surface); | 96 | config->surface = wlc_resource_from_wl_surface_resource(surface); |
95 | config->wl_surface_res = surface; | 97 | config->wl_surface_res = surface; |
96 | wl_resource_set_destructor(surface, panel_surface_destructor); | 98 | wl_resource_set_destructor(surface, panel_surface_destructor); |
diff --git a/sway/handlers.c b/sway/handlers.c index b7bb1fde..8f2f8a21 100644 --- a/sway/handlers.c +++ b/sway/handlers.c | |||
@@ -176,6 +176,28 @@ static void handle_output_focused(wlc_handle output, bool focus) { | |||
176 | } | 176 | } |
177 | } | 177 | } |
178 | 178 | ||
179 | static bool client_is_background(struct wl_client *client) { | ||
180 | int i; | ||
181 | for (i = 0; i < desktop_shell.backgrounds->length; i++) { | ||
182 | struct background_config *config = desktop_shell.backgrounds->items[i]; | ||
183 | if (config->client == client) { | ||
184 | return true; | ||
185 | } | ||
186 | } | ||
187 | return false; | ||
188 | } | ||
189 | |||
190 | static bool client_is_panel(struct wl_client *client) { | ||
191 | int i; | ||
192 | for (i = 0; i < desktop_shell.panels->length; i++) { | ||
193 | struct panel_config *config = desktop_shell.panels->items[i]; | ||
194 | if (config->client == client) { | ||
195 | return true; | ||
196 | } | ||
197 | } | ||
198 | return false; | ||
199 | } | ||
200 | |||
179 | static bool handle_view_created(wlc_handle handle) { | 201 | static bool handle_view_created(wlc_handle handle) { |
180 | // if view is child of another view, the use that as focused container | 202 | // if view is child of another view, the use that as focused container |
181 | wlc_handle parent = wlc_view_get_parent(handle); | 203 | wlc_handle parent = wlc_view_get_parent(handle); |
@@ -186,6 +208,10 @@ static bool handle_view_created(wlc_handle handle) { | |||
186 | struct wl_client *client = wlc_view_get_wl_client(handle); | 208 | struct wl_client *client = wlc_view_get_wl_client(handle); |
187 | pid_t pid; | 209 | pid_t pid; |
188 | 210 | ||
211 | if (client_is_background(client) || client_is_panel(client)) { | ||
212 | return true; | ||
213 | } | ||
214 | |||
189 | // Get parent container, to add view in | 215 | // Get parent container, to add view in |
190 | if (parent) { | 216 | if (parent) { |
191 | focused = swayc_by_handle(parent); | 217 | focused = swayc_by_handle(parent); |
diff --git a/swaybar/bar.c b/swaybar/bar.c index 957e5bdf..6d858f92 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c | |||
@@ -87,6 +87,8 @@ void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id) { | |||
87 | desktop_shell_set_panel(bar_output->registry->desktop_shell, output->output, bar_output->window->surface); | 87 | desktop_shell_set_panel(bar_output->registry->desktop_shell, output->output, bar_output->window->surface); |
88 | desktop_shell_set_panel_position(bar_output->registry->desktop_shell, bar->config->position); | 88 | desktop_shell_set_panel_position(bar_output->registry->desktop_shell, bar->config->position); |
89 | 89 | ||
90 | window_make_shell(bar_output->window); | ||
91 | |||
90 | /* set font */ | 92 | /* set font */ |
91 | bar_output->window->font = bar->config->font; | 93 | bar_output->window->font = bar->config->font; |
92 | 94 | ||
diff --git a/swaybg/main.c b/swaybg/main.c index fbd0d16b..4e0cc4b3 100644 --- a/swaybg/main.c +++ b/swaybg/main.c | |||
@@ -54,6 +54,7 @@ int main(int argc, const char **argv) { | |||
54 | sway_abort("Failed to create surfaces."); | 54 | sway_abort("Failed to create surfaces."); |
55 | } | 55 | } |
56 | desktop_shell_set_background(registry->desktop_shell, output->output, window->surface); | 56 | desktop_shell_set_background(registry->desktop_shell, output->output, window->surface); |
57 | window_make_shell(window); | ||
57 | list_add(surfaces, window); | 58 | list_add(surfaces, window); |
58 | 59 | ||
59 | #ifdef WITH_GDK_PIXBUF | 60 | #ifdef WITH_GDK_PIXBUF |
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); |