mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
layers: take into account usable area when maximizing views
This commit is contained in:
parent
743803de3b
commit
a3ac2f2767
4 changed files with 24 additions and 19 deletions
|
|
@ -133,6 +133,8 @@ struct output {
|
|||
struct wlr_output *wlr_output;
|
||||
struct wlr_output_damage *damage;
|
||||
struct wl_list layers[4];
|
||||
struct wlr_box usable_area;
|
||||
|
||||
struct wl_listener destroy;
|
||||
struct wl_listener damage_frame;
|
||||
struct wl_listener damage_destroy;
|
||||
|
|
|
|||
|
|
@ -167,9 +167,9 @@ arrange_layer(struct wlr_output *output, struct wl_list *list,
|
|||
void
|
||||
arrange_layers(struct output *output)
|
||||
{
|
||||
assert(output);
|
||||
|
||||
struct wlr_box usable_area = { 0 };
|
||||
if (!output)
|
||||
return;
|
||||
wlr_output_effective_resolution(output->wlr_output,
|
||||
&usable_area.width, &usable_area.height);
|
||||
|
||||
|
|
@ -186,6 +186,9 @@ arrange_layers(struct output *output)
|
|||
arrange_layer(output->wlr_output,
|
||||
&output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND],
|
||||
&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 */
|
||||
arrange_layer(output->wlr_output,
|
||||
|
|
|
|||
|
|
@ -809,6 +809,8 @@ new_output_notify(struct wl_listener *listener, void *data)
|
|||
output->wlr_output = wlr_output;
|
||||
output->server = server;
|
||||
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);
|
||||
|
||||
output->destroy.notify = output_destroy_notify;
|
||||
|
|
|
|||
32
src/view.c
32
src/view.c
|
|
@ -73,26 +73,24 @@ view_maximize(struct view *view, bool maximize)
|
|||
}
|
||||
view->impl->maximize(view, 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.y = view->y;
|
||||
view->unmaximized_geometry.width = view->w;
|
||||
view->unmaximized_geometry.height = view->h;
|
||||
|
||||
struct wlr_box box = {
|
||||
.x = ol_output->x,
|
||||
.y = ol_output->y,
|
||||
.width = output->width,
|
||||
.height = output->height,
|
||||
};
|
||||
struct wlr_output *wlr_output = view_output(view);
|
||||
struct output *output =
|
||||
output_from_wlr_output(view->server, wlr_output);
|
||||
|
||||
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) {
|
||||
struct border border = ssd_thickness(view);
|
||||
box.x += border.left;
|
||||
|
|
@ -100,8 +98,8 @@ view_maximize(struct view *view, bool maximize)
|
|||
box.width -= border.right + border.left;
|
||||
box.height -= border.top + border.bottom;
|
||||
}
|
||||
box.width /= output->scale;
|
||||
box.height /= output->scale;
|
||||
box.width /= wlr_output->scale;
|
||||
box.height /= wlr_output->scale;
|
||||
view_move_resize(view, box);
|
||||
view_move(view, box.x, box.y);
|
||||
view->maximized = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue