diff options
Diffstat (limited to 'sway/desktop/layer_shell.c')
-rw-r--r-- | sway/desktop/layer_shell.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index c71abce7..6221b7b9 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c | |||
@@ -2,9 +2,12 @@ | |||
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <string.h> | 3 | #include <string.h> |
4 | #include <wayland-server-core.h> | 4 | #include <wayland-server-core.h> |
5 | #include <wlr/types/wlr_fractional_scale_v1.h> | ||
5 | #include <wlr/types/wlr_layer_shell_v1.h> | 6 | #include <wlr/types/wlr_layer_shell_v1.h> |
6 | #include <wlr/types/wlr_output.h> | 7 | #include <wlr/types/wlr_output.h> |
8 | #include <wlr/types/wlr_scene.h> | ||
7 | #include <wlr/types/wlr_subcompositor.h> | 9 | #include <wlr/types/wlr_subcompositor.h> |
10 | #include <wlr/types/wlr_xdg_shell.h> | ||
8 | #include "log.h" | 11 | #include "log.h" |
9 | #include "sway/scene_descriptor.h" | 12 | #include "sway/scene_descriptor.h" |
10 | #include "sway/desktop/transaction.h" | 13 | #include "sway/desktop/transaction.h" |
@@ -16,7 +19,6 @@ | |||
16 | #include "sway/server.h" | 19 | #include "sway/server.h" |
17 | #include "sway/tree/arrange.h" | 20 | #include "sway/tree/arrange.h" |
18 | #include "sway/tree/workspace.h" | 21 | #include "sway/tree/workspace.h" |
19 | #include <wlr/types/wlr_scene.h> | ||
20 | 22 | ||
21 | struct wlr_layer_surface_v1 *toplevel_layer_surface_from_surface( | 23 | struct wlr_layer_surface_v1 *toplevel_layer_surface_from_surface( |
22 | struct wlr_surface *surface) { | 24 | struct wlr_surface *surface) { |
@@ -85,6 +87,8 @@ void arrange_layers(struct sway_output *output) { | |||
85 | sway_log(SWAY_DEBUG, "Usable area changed, rearranging output"); | 87 | sway_log(SWAY_DEBUG, "Usable area changed, rearranging output"); |
86 | output->usable_area = usable_area; | 88 | output->usable_area = usable_area; |
87 | arrange_output(output); | 89 | arrange_output(output); |
90 | } else { | ||
91 | arrange_popups(root->layers.popup); | ||
88 | } | 92 | } |
89 | } | 93 | } |
90 | 94 | ||
@@ -120,10 +124,21 @@ static struct sway_layer_surface *sway_layer_surface_create( | |||
120 | return NULL; | 124 | return NULL; |
121 | } | 125 | } |
122 | 126 | ||
127 | surface->desc.relative = &scene->tree->node; | ||
128 | |||
129 | if (!scene_descriptor_assign(&popups->node, | ||
130 | SWAY_SCENE_DESC_POPUP, &surface->desc)) { | ||
131 | sway_log(SWAY_ERROR, "Failed to allocate a popup scene descriptor"); | ||
132 | wlr_scene_node_destroy(&popups->node); | ||
133 | free(surface); | ||
134 | return NULL; | ||
135 | } | ||
136 | |||
123 | surface->tree = scene->tree; | 137 | surface->tree = scene->tree; |
124 | surface->scene = scene; | 138 | surface->scene = scene; |
125 | surface->layer_surface = scene->layer_surface; | 139 | surface->layer_surface = scene->layer_surface; |
126 | surface->popups = popups; | 140 | surface->popups = popups; |
141 | surface->layer_surface->data = surface; | ||
127 | 142 | ||
128 | return surface; | 143 | return surface; |
129 | } | 144 | } |
@@ -197,6 +212,8 @@ static void handle_node_destroy(struct wl_listener *listener, void *data) { | |||
197 | wl_list_remove(&layer->node_destroy.link); | 212 | wl_list_remove(&layer->node_destroy.link); |
198 | wl_list_remove(&layer->output_destroy.link); | 213 | wl_list_remove(&layer->output_destroy.link); |
199 | 214 | ||
215 | layer->layer_surface->data = NULL; | ||
216 | |||
200 | free(layer); | 217 | free(layer); |
201 | } | 218 | } |
202 | 219 | ||
@@ -222,10 +239,6 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) { | |||
222 | arrange_layers(surface->output); | 239 | arrange_layers(surface->output); |
223 | transaction_commit_dirty(); | 240 | transaction_commit_dirty(); |
224 | } | 241 | } |
225 | |||
226 | int lx, ly; | ||
227 | wlr_scene_node_coords(&surface->scene->tree->node, &lx, &ly); | ||
228 | wlr_scene_node_set_position(&surface->popups->node, lx, ly); | ||
229 | } | 242 | } |
230 | 243 | ||
231 | static void handle_map(struct wl_listener *listener, void *data) { | 244 | static void handle_map(struct wl_listener *listener, void *data) { |
@@ -420,6 +433,12 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) { | |||
420 | 433 | ||
421 | surface->output = output; | 434 | surface->output = output; |
422 | 435 | ||
436 | // now that the surface's output is known, we can advertise its scale | ||
437 | wlr_fractional_scale_v1_notify_scale(surface->layer_surface->surface, | ||
438 | layer_surface->output->scale); | ||
439 | wlr_surface_set_preferred_buffer_scale(surface->layer_surface->surface, | ||
440 | ceil(layer_surface->output->scale)); | ||
441 | |||
423 | surface->surface_commit.notify = handle_surface_commit; | 442 | surface->surface_commit.notify = handle_surface_commit; |
424 | wl_signal_add(&layer_surface->surface->events.commit, | 443 | wl_signal_add(&layer_surface->surface->events.commit, |
425 | &surface->surface_commit); | 444 | &surface->surface_commit); |