aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/extensions.h2
-rw-r--r--sway/config.c1
-rw-r--r--sway/extensions.c1
-rw-r--r--sway/handlers.c53
-rw-r--r--swaybg/main.c1
5 files changed, 43 insertions, 15 deletions
diff --git a/include/extensions.h b/include/extensions.h
index d26e95c1..f6b0c00e 100644
--- a/include/extensions.h
+++ b/include/extensions.h
@@ -11,6 +11,8 @@ struct background_config {
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 struct wl_client *client;
15 wlc_handle handle;
14}; 16};
15 17
16struct panel_config { 18struct panel_config {
diff --git a/sway/config.c b/sway/config.c
index 766d2b23..9c957e2d 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -904,7 +904,6 @@ void apply_output_config(struct output_config *oc, swayc_t *output) {
904 } 904 }
905 905
906 if (oc && oc->background) { 906 if (oc && oc->background) {
907
908 if (output->bg_pid != 0) { 907 if (output->bg_pid != 0) {
909 terminate_swaybg(output->bg_pid); 908 terminate_swaybg(output->bg_pid);
910 } 909 }
diff --git a/sway/extensions.c b/sway/extensions.c
index ab425fa7..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;
diff --git a/sway/handlers.c b/sway/handlers.c
index 1b96be0a..72cb8057 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -44,6 +44,17 @@ static struct panel_config *if_panel_find_config(struct wl_client *client) {
44 return NULL; 44 return NULL;
45} 45}
46 46
47static struct background_config *if_background_find_config(struct wl_client *client) {
48 int i;
49 for (i = 0; i < desktop_shell.backgrounds->length; i++) {
50 struct background_config *config = desktop_shell.backgrounds->items[i];
51 if (config->client == client) {
52 return config;
53 }
54 }
55 return NULL;
56}
57
47static struct wlc_geometry compute_panel_geometry(struct panel_config *config) { 58static struct wlc_geometry compute_panel_geometry(struct panel_config *config) {
48 const struct wlc_size resolution = *wlc_output_get_resolution(config->output); 59 const struct wlc_size resolution = *wlc_output_get_resolution(config->output);
49 const struct wlc_geometry *old = wlc_view_get_geometry(config->handle); 60 const struct wlc_geometry *old = wlc_view_get_geometry(config->handle);
@@ -93,6 +104,21 @@ static void update_panel_geometries(wlc_handle output) {
93 } 104 }
94} 105}
95 106
107static void update_background_geometry(struct background_config *config) {
108 struct wlc_geometry geometry = { 0 };
109 geometry.size = *wlc_output_get_resolution(config->output);
110 wlc_view_set_geometry(config->handle, 0, &geometry);
111}
112
113static void update_background_geometries(wlc_handle output) {
114 for (int i = 0; i < desktop_shell.backgrounds->length; i++) {
115 struct background_config *config = desktop_shell.backgrounds->items[i];
116 if (config->output == output) {
117 update_background_geometry(config);
118 }
119 }
120}
121
96/* Handles */ 122/* Handles */
97 123
98static bool handle_input_created(struct libinput_device *device) { 124static bool handle_input_created(struct libinput_device *device) {
@@ -168,19 +194,6 @@ static void handle_output_destroyed(wlc_handle output) {
168 } 194 }
169} 195}
170 196
171static void handle_output_pre_render(wlc_handle output) {
172 struct wlc_size resolution = *wlc_output_get_resolution(output);
173
174 int i;
175 for (i = 0; i < desktop_shell.backgrounds->length; ++i) {
176 struct background_config *config = desktop_shell.backgrounds->items[i];
177 if (config->output == output) {
178 wlc_surface_render(config->surface, &(struct wlc_geometry){ wlc_origin_zero, resolution });
179 break;
180 }
181 }
182}
183
184static void handle_output_post_render(wlc_handle output) { 197static void handle_output_post_render(wlc_handle output) {
185 ipc_get_pixels(output); 198 ipc_get_pixels(output);
186 arrange_windows(swayc_by_handle(output), -1, -1); 199 arrange_windows(swayc_by_handle(output), -1, -1);
@@ -201,6 +214,7 @@ static void handle_output_resolution_change(wlc_handle output, const struct wlc_
201 c->height = to->h; 214 c->height = to->h;
202 215
203 update_panel_geometries(output); 216 update_panel_geometries(output);
217 update_background_geometries(output);
204 218
205 arrange_windows(&root_container, -1, -1); 219 arrange_windows(&root_container, -1, -1);
206} 220}
@@ -247,6 +261,7 @@ static bool handle_view_created(wlc_handle handle) {
247 struct wl_client *client = wlc_view_get_wl_client(handle); 261 struct wl_client *client = wlc_view_get_wl_client(handle);
248 pid_t pid; 262 pid_t pid;
249 struct panel_config *panel_config = NULL; 263 struct panel_config *panel_config = NULL;
264 struct background_config *background_config = NULL;
250 265
251 panel_config = if_panel_find_config(client); 266 panel_config = if_panel_find_config(client);
252 if (panel_config) { 267 if (panel_config) {
@@ -254,6 +269,17 @@ static bool handle_view_created(wlc_handle handle) {
254 update_panel_geometry(panel_config); 269 update_panel_geometry(panel_config);
255 wlc_view_set_mask(handle, VISIBLE); 270 wlc_view_set_mask(handle, VISIBLE);
256 wlc_view_set_output(handle, panel_config->output); 271 wlc_view_set_output(handle, panel_config->output);
272 wlc_view_bring_to_front(handle);
273 return true;
274 }
275
276 background_config = if_background_find_config(client);
277 if (background_config) {
278 background_config->handle = handle;
279 update_background_geometry(background_config);
280 wlc_view_set_mask(handle, VISIBLE);
281 wlc_view_set_output(handle, background_config->output);
282 wlc_view_send_to_back(handle);
257 return true; 283 return true;
258 } 284 }
259 285
@@ -883,7 +909,6 @@ void register_wlc_handlers() {
883 wlc_set_output_destroyed_cb(handle_output_destroyed); 909 wlc_set_output_destroyed_cb(handle_output_destroyed);
884 wlc_set_output_resolution_cb(handle_output_resolution_change); 910 wlc_set_output_resolution_cb(handle_output_resolution_change);
885 wlc_set_output_focus_cb(handle_output_focused); 911 wlc_set_output_focus_cb(handle_output_focused);
886 wlc_set_output_render_pre_cb(handle_output_pre_render);
887 wlc_set_output_render_post_cb(handle_output_post_render); 912 wlc_set_output_render_post_cb(handle_output_post_render);
888 wlc_set_view_created_cb(handle_view_created); 913 wlc_set_view_created_cb(handle_view_created);
889 wlc_set_view_destroyed_cb(handle_view_destroyed); 914 wlc_set_view_destroyed_cb(handle_view_destroyed);
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