diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-07-17 11:55:05 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2016-07-17 11:55:05 -0400 |
commit | 6d971af5c3ceae870c424325ca06fc635703bb29 (patch) | |
tree | 886e321930a4ee95f5cb7f0136138712f5ee1c57 /sway | |
parent | Remove SIGSERV and SIGABORT handler (diff) | |
download | sway-6d971af5c3ceae870c424325ca06fc635703bb29.tar.gz sway-6d971af5c3ceae870c424325ca06fc635703bb29.tar.zst sway-6d971af5c3ceae870c424325ca06fc635703bb29.zip |
Turn swaybg into a shell surface
Diffstat (limited to 'sway')
-rw-r--r-- | sway/config.c | 1 | ||||
-rw-r--r-- | sway/extensions.c | 1 | ||||
-rw-r--r-- | sway/handlers.c | 53 |
3 files changed, 40 insertions, 15 deletions
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 | ||
47 | static 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 | |||
47 | static struct wlc_geometry compute_panel_geometry(struct panel_config *config) { | 58 | static 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 | ||
107 | static 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 | |||
113 | static 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 | ||
98 | static bool handle_input_created(struct libinput_device *device) { | 124 | static 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 | ||
171 | static 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 | |||
184 | static void handle_output_post_render(wlc_handle output) { | 197 | static 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); |