mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
view: adjust views safety following layout change
Refactor view_adjust_for_layout_change() in order to: - Use view_maximize() - otherwise the unmaximized geometry remains off the screen. - Avoid relying on view_apply_maximized_geometry() to handle missing output Issue #194
This commit is contained in:
parent
be89478f7a
commit
ab07b68d7e
1 changed files with 20 additions and 9 deletions
19
src/view.c
19
src/view.c
|
|
@ -166,6 +166,10 @@ static void
|
||||||
view_apply_maximized_geometry(struct view *view)
|
view_apply_maximized_geometry(struct view *view)
|
||||||
{
|
{
|
||||||
struct output *output = view_output(view);
|
struct output *output = view_output(view);
|
||||||
|
if (!output) {
|
||||||
|
wlr_log(WLR_ERROR, "view %p has no output", view);
|
||||||
|
return;
|
||||||
|
}
|
||||||
struct wlr_box box = output_usable_area_in_layout_coords(output);
|
struct wlr_box box = output_usable_area_in_layout_coords(output);
|
||||||
if (box.height == output->wlr_output->height && output->wlr_output->scale != 1) {
|
if (box.height == output->wlr_output->height && output->wlr_output->scale != 1) {
|
||||||
box.height /= output->wlr_output->scale;
|
box.height /= output->wlr_output->scale;
|
||||||
|
|
@ -315,19 +319,26 @@ view_adjust_for_layout_change(struct view *view)
|
||||||
if (wlr_output_layout_get(layout, view->fullscreen)) {
|
if (wlr_output_layout_get(layout, view->fullscreen)) {
|
||||||
/* recompute fullscreen geometry */
|
/* recompute fullscreen geometry */
|
||||||
view_apply_fullscreen_geometry(view, view->fullscreen);
|
view_apply_fullscreen_geometry(view, view->fullscreen);
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
/* output is gone, exit fullscreen */
|
/* output is gone, exit fullscreen */
|
||||||
view_set_fullscreen(view, false, NULL);
|
view_set_fullscreen(view, false, NULL);
|
||||||
}
|
}
|
||||||
} else if (view->maximized) {
|
}
|
||||||
/* recompute maximized geometry */
|
|
||||||
view_apply_maximized_geometry(view);
|
bool was_maximized = view->maximized;
|
||||||
} else {
|
if (was_maximized) {
|
||||||
|
view_maximize(view, false);
|
||||||
|
}
|
||||||
|
|
||||||
/* reposition view if it's offscreen */
|
/* reposition view if it's offscreen */
|
||||||
struct wlr_box box = { view->x, view->y, view->w, view->h };
|
struct wlr_box box = { view->x, view->y, view->w, view->h };
|
||||||
if (!wlr_output_layout_intersects(layout, NULL, &box)) {
|
if (!wlr_output_layout_intersects(layout, NULL, &box)) {
|
||||||
view_center(view);
|
view_center(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (was_maximized) {
|
||||||
|
view_maximize(view, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue