layers: take into account usable area when maximizing views

This commit is contained in:
Johan Malm 2021-07-12 21:39:09 +01:00
parent 743803de3b
commit a3ac2f2767
4 changed files with 24 additions and 19 deletions

View file

@ -133,6 +133,8 @@ struct output {
struct wlr_output *wlr_output; struct wlr_output *wlr_output;
struct wlr_output_damage *damage; struct wlr_output_damage *damage;
struct wl_list layers[4]; struct wl_list layers[4];
struct wlr_box usable_area;
struct wl_listener destroy; struct wl_listener destroy;
struct wl_listener damage_frame; struct wl_listener damage_frame;
struct wl_listener damage_destroy; struct wl_listener damage_destroy;

View file

@ -167,9 +167,9 @@ arrange_layer(struct wlr_output *output, struct wl_list *list,
void void
arrange_layers(struct output *output) arrange_layers(struct output *output)
{ {
assert(output);
struct wlr_box usable_area = { 0 }; struct wlr_box usable_area = { 0 };
if (!output)
return;
wlr_output_effective_resolution(output->wlr_output, wlr_output_effective_resolution(output->wlr_output,
&usable_area.width, &usable_area.height); &usable_area.width, &usable_area.height);
@ -186,6 +186,9 @@ arrange_layers(struct output *output)
arrange_layer(output->wlr_output, arrange_layer(output->wlr_output,
&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND],
&usable_area, true); &usable_area, true);
memcpy(&output->usable_area, &usable_area, sizeof(struct wlr_box));
/* TODO: re-arrange all views taking into account updated usable_area */
/* Non-exclusive surfaces */ /* Non-exclusive surfaces */
arrange_layer(output->wlr_output, arrange_layer(output->wlr_output,

View file

@ -809,6 +809,8 @@ new_output_notify(struct wl_listener *listener, void *data)
output->wlr_output = wlr_output; output->wlr_output = wlr_output;
output->server = server; output->server = server;
output->damage = wlr_output_damage_create(wlr_output); output->damage = wlr_output_damage_create(wlr_output);
wlr_output_effective_resolution(wlr_output,
&output->usable_area.width, &output->usable_area.height);
wl_list_insert(&server->outputs, &output->link); wl_list_insert(&server->outputs, &output->link);
output->destroy.notify = output_destroy_notify; output->destroy.notify = output_destroy_notify;

View file

@ -73,26 +73,24 @@ view_maximize(struct view *view, bool maximize)
} }
view->impl->maximize(view, maximize); view->impl->maximize(view, maximize);
if (maximize) { if (maximize) {
struct wlr_output *output = view_output(view);
if (!output) {
return;
}
struct wlr_output_layout *layout = view->server->output_layout;
struct wlr_output_layout_output* ol_output =
wlr_output_layout_get(layout, output);
view->unmaximized_geometry.x = view->x; view->unmaximized_geometry.x = view->x;
view->unmaximized_geometry.y = view->y; view->unmaximized_geometry.y = view->y;
view->unmaximized_geometry.width = view->w; view->unmaximized_geometry.width = view->w;
view->unmaximized_geometry.height = view->h; view->unmaximized_geometry.height = view->h;
struct wlr_box box = { struct wlr_output *wlr_output = view_output(view);
.x = ol_output->x, struct output *output =
.y = ol_output->y, output_from_wlr_output(view->server, wlr_output);
.width = output->width,
.height = output->height, struct wlr_box box;
}; memcpy(&box, &output->usable_area, sizeof(struct wlr_box));
double ox = 0, oy = 0;
wlr_output_layout_output_coords(view->server->output_layout,
wlr_output, &ox, &oy);
box.x -= ox;
box.y -= oy;
if (view->ssd.enabled) { if (view->ssd.enabled) {
struct border border = ssd_thickness(view); struct border border = ssd_thickness(view);
box.x += border.left; box.x += border.left;
@ -100,8 +98,8 @@ view_maximize(struct view *view, bool maximize)
box.width -= border.right + border.left; box.width -= border.right + border.left;
box.height -= border.top + border.bottom; box.height -= border.top + border.bottom;
} }
box.width /= output->scale; box.width /= wlr_output->scale;
box.height /= output->scale; box.height /= wlr_output->scale;
view_move_resize(view, box); view_move_resize(view, box);
view_move(view, box.x, box.y); view_move(view, box.x, box.y);
view->maximized = true; view->maximized = true;