diff options
author | Tony Crisci <tony@dubstepdish.com> | 2018-04-04 00:20:44 -0400 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2018-04-04 00:20:44 -0400 |
commit | 741e3959e30283f5f699f7e9fa6620e3578b9c76 (patch) | |
tree | 8489f010c2f3e112722e7b999bacef18dfe418ef /sway/desktop | |
parent | simplify container close (diff) | |
parent | Merge pull request #1722 from swaywm/swaybar-hidpi (diff) | |
download | sway-741e3959e30283f5f699f7e9fa6620e3578b9c76.tar.gz sway-741e3959e30283f5f699f7e9fa6620e3578b9c76.tar.zst sway-741e3959e30283f5f699f7e9fa6620e3578b9c76.zip |
Merge branch 'wlroots' into split-containers2
Diffstat (limited to 'sway/desktop')
-rw-r--r-- | sway/desktop/layer_shell.c | 29 | ||||
-rw-r--r-- | sway/desktop/output.c | 40 |
2 files changed, 47 insertions, 22 deletions
diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index c18f51c7..663ec7ba 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c | |||
@@ -7,6 +7,8 @@ | |||
7 | #include <wlr/types/wlr_output_damage.h> | 7 | #include <wlr/types/wlr_output_damage.h> |
8 | #include <wlr/types/wlr_output.h> | 8 | #include <wlr/types/wlr_output.h> |
9 | #include <wlr/util/log.h> | 9 | #include <wlr/util/log.h> |
10 | #include "sway/input/input-manager.h" | ||
11 | #include "sway/input/seat.h" | ||
10 | #include "sway/layers.h" | 12 | #include "sway/layers.h" |
11 | #include "sway/output.h" | 13 | #include "sway/output.h" |
12 | #include "sway/server.h" | 14 | #include "sway/server.h" |
@@ -187,6 +189,31 @@ void arrange_layers(struct sway_output *output) { | |||
187 | &usable_area, false); | 189 | &usable_area, false); |
188 | arrange_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], | 190 | arrange_layer(output, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], |
189 | &usable_area, false); | 191 | &usable_area, false); |
192 | |||
193 | // Find topmost keyboard interactive layer, if such a layer exists | ||
194 | uint32_t layers_above_shell[] = { | ||
195 | ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY, | ||
196 | ZWLR_LAYER_SHELL_V1_LAYER_TOP, | ||
197 | }; | ||
198 | size_t nlayers = sizeof(layers_above_shell) / sizeof(layers_above_shell[0]); | ||
199 | struct sway_layer_surface *layer, *topmost = NULL; | ||
200 | for (size_t i = 0; i < nlayers; ++i) { | ||
201 | wl_list_for_each_reverse(layer, | ||
202 | &output->layers[layers_above_shell[i]], link) { | ||
203 | if (layer->layer_surface->current.keyboard_interactive) { | ||
204 | topmost = layer; | ||
205 | break; | ||
206 | } | ||
207 | } | ||
208 | if (topmost != NULL) { | ||
209 | break; | ||
210 | } | ||
211 | } | ||
212 | |||
213 | struct sway_seat *seat; | ||
214 | wl_list_for_each(seat, &input_manager->seats, link) { | ||
215 | seat_set_focus_layer(seat, topmost ? topmost->layer_surface : NULL); | ||
216 | } | ||
190 | } | 217 | } |
191 | 218 | ||
192 | static void handle_output_destroy(struct wl_listener *listener, void *data) { | 219 | static void handle_output_destroy(struct wl_listener *listener, void *data) { |
@@ -251,6 +278,8 @@ static void handle_map(struct wl_listener *listener, void *data) { | |||
251 | sway_layer, map); | 278 | sway_layer, map); |
252 | struct sway_output *output = sway_layer->layer_surface->output->data; | 279 | struct sway_output *output = sway_layer->layer_surface->output->data; |
253 | wlr_output_damage_add_box(output->damage, &sway_layer->geo); | 280 | wlr_output_damage_add_box(output->damage, &sway_layer->geo); |
281 | wlr_surface_send_enter(sway_layer->layer_surface->surface, | ||
282 | sway_layer->layer_surface->output); | ||
254 | } | 283 | } |
255 | 284 | ||
256 | static void handle_unmap(struct wl_listener *listener, void *data) { | 285 | static void handle_unmap(struct wl_listener *listener, void *data) { |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 96f23291..8a4fb4a2 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -57,10 +57,7 @@ static void rotate_child_position(double *sx, double *sy, double sw, double sh, | |||
57 | */ | 57 | */ |
58 | static bool surface_intersect_output(struct wlr_surface *surface, | 58 | static bool surface_intersect_output(struct wlr_surface *surface, |
59 | struct wlr_output_layout *output_layout, struct wlr_output *wlr_output, | 59 | struct wlr_output_layout *output_layout, struct wlr_output *wlr_output, |
60 | double lx, double ly, float rotation, struct wlr_box *box) { | 60 | double ox, double oy, float rotation, struct wlr_box *box) { |
61 | double ox = lx, oy = ly; | ||
62 | wlr_output_layout_output_coords(output_layout, wlr_output, &ox, &oy); | ||
63 | |||
64 | if (box != NULL) { | 61 | if (box != NULL) { |
65 | box->x = ox * wlr_output->scale; | 62 | box->x = ox * wlr_output->scale; |
66 | box->y = oy * wlr_output->scale; | 63 | box->y = oy * wlr_output->scale; |
@@ -69,7 +66,7 @@ static bool surface_intersect_output(struct wlr_surface *surface, | |||
69 | } | 66 | } |
70 | 67 | ||
71 | struct wlr_box layout_box = { | 68 | struct wlr_box layout_box = { |
72 | .x = lx, .y = ly, | 69 | .x = wlr_output->lx + ox, .y = wlr_output->ly + oy, |
73 | .width = surface->current->width, .height = surface->current->height, | 70 | .width = surface->current->width, .height = surface->current->height, |
74 | }; | 71 | }; |
75 | wlr_box_rotated_bounds(&layout_box, rotation, &layout_box); | 72 | wlr_box_rotated_bounds(&layout_box, rotation, &layout_box); |
@@ -78,7 +75,7 @@ static bool surface_intersect_output(struct wlr_surface *surface, | |||
78 | 75 | ||
79 | static void render_surface(struct wlr_surface *surface, | 76 | static void render_surface(struct wlr_surface *surface, |
80 | struct wlr_output *wlr_output, struct timespec *when, | 77 | struct wlr_output *wlr_output, struct timespec *when, |
81 | double lx, double ly, float rotation) { | 78 | double ox, double oy, float rotation) { |
82 | struct wlr_renderer *renderer = | 79 | struct wlr_renderer *renderer = |
83 | wlr_backend_get_renderer(wlr_output->backend); | 80 | wlr_backend_get_renderer(wlr_output->backend); |
84 | 81 | ||
@@ -90,7 +87,7 @@ static void render_surface(struct wlr_surface *surface, | |||
90 | 87 | ||
91 | struct wlr_box box; | 88 | struct wlr_box box; |
92 | bool intersects = surface_intersect_output(surface, layout, wlr_output, | 89 | bool intersects = surface_intersect_output(surface, layout, wlr_output, |
93 | lx, ly, rotation, &box); | 90 | ox, oy, rotation, &box); |
94 | if (intersects) { | 91 | if (intersects) { |
95 | float matrix[9]; | 92 | float matrix[9]; |
96 | enum wl_output_transform transform = | 93 | enum wl_output_transform transform = |
@@ -113,7 +110,7 @@ static void render_surface(struct wlr_surface *surface, | |||
113 | surface->current->width, surface->current->height, rotation); | 110 | surface->current->width, surface->current->height, rotation); |
114 | 111 | ||
115 | render_surface(subsurface->surface, wlr_output, when, | 112 | render_surface(subsurface->surface, wlr_output, when, |
116 | lx + sx, ly + sy, rotation); | 113 | ox + sx, oy + sy, rotation); |
117 | } | 114 | } |
118 | } | 115 | } |
119 | 116 | ||
@@ -211,9 +208,7 @@ static void render_view(struct sway_container *view, void *data) { | |||
211 | } | 208 | } |
212 | } | 209 | } |
213 | 210 | ||
214 | static void render_layer(struct sway_output *output, | 211 | static void render_layer(struct sway_output *output, struct timespec *when, |
215 | const struct wlr_box *output_layout_box, | ||
216 | struct timespec *when, | ||
217 | struct wl_list *layer) { | 212 | struct wl_list *layer) { |
218 | struct sway_layer_surface *sway_layer; | 213 | struct sway_layer_surface *sway_layer; |
219 | wl_list_for_each(sway_layer, layer, link) { | 214 | wl_list_for_each(sway_layer, layer, link) { |
@@ -245,14 +240,15 @@ static void render_output(struct sway_output *output, struct timespec *when, | |||
245 | float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f}; | 240 | float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f}; |
246 | wlr_renderer_clear(renderer, clear_color); | 241 | wlr_renderer_clear(renderer, clear_color); |
247 | 242 | ||
248 | struct wlr_output_layout *layout = root_container.sway_root->output_layout; | 243 | struct wlr_output_layout *output_layout = |
244 | root_container.sway_root->output_layout; | ||
249 | const struct wlr_box *output_box = | 245 | const struct wlr_box *output_box = |
250 | wlr_output_layout_get_box(layout, wlr_output); | 246 | wlr_output_layout_get_box(output_layout, wlr_output); |
251 | 247 | ||
252 | render_layer(output, output_box, when, | 248 | render_layer(output, when, |
253 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]); | 249 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]); |
254 | render_layer(output, output_box, when, | 250 | render_layer(output, when, |
255 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]); | 251 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]); |
256 | 252 | ||
257 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 253 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
258 | struct sway_container *focus = | 254 | struct sway_container *focus = |
@@ -262,7 +258,7 @@ static void render_output(struct sway_output *output, struct timespec *when, | |||
262 | focus = output->swayc->children->items[0]; | 258 | focus = output->swayc->children->items[0]; |
263 | } | 259 | } |
264 | struct sway_container *workspace = focus->type == C_WORKSPACE ? | 260 | struct sway_container *workspace = focus->type == C_WORKSPACE ? |
265 | focus : container_parent(focus, C_WORKSPACE); | 261 | focus : container_parent(focus, C_WORKSPACE); |
266 | 262 | ||
267 | struct render_data rdata = { | 263 | struct render_data rdata = { |
268 | .output = output, | 264 | .output = output, |
@@ -296,10 +292,10 @@ static void render_output(struct sway_output *output, struct timespec *when, | |||
296 | } | 292 | } |
297 | 293 | ||
298 | // TODO: Consider revising this when fullscreen windows are supported | 294 | // TODO: Consider revising this when fullscreen windows are supported |
299 | render_layer(output, output_box, when, | 295 | render_layer(output, when, |
300 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); | 296 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP]); |
301 | render_layer(output, output_box, when, | 297 | render_layer(output, when, |
302 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); | 298 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); |
303 | 299 | ||
304 | renderer_end: | 300 | renderer_end: |
305 | wlr_renderer_end(renderer); | 301 | wlr_renderer_end(renderer); |