mirror of
https://github.com/labwc/labwc.git
synced 2025-11-02 09:01:47 -05:00
xwayland: center stored natural geometry for initially maximized views
For views that are initially maximized or fullscreen and have no explicitly specified position, we need to center the stored natural geometry, or the view may end up partially offscreen once unmaximized/ unfullscreened.
This commit is contained in:
parent
45a4b3c047
commit
a1324c8cdc
3 changed files with 27 additions and 8 deletions
|
|
@ -337,6 +337,8 @@ void view_move(struct view *view, int x, int y);
|
||||||
void view_move_to_cursor(struct view *view);
|
void view_move_to_cursor(struct view *view);
|
||||||
void view_moved(struct view *view);
|
void view_moved(struct view *view);
|
||||||
void view_minimize(struct view *view, bool minimized);
|
void view_minimize(struct view *view, bool minimized);
|
||||||
|
bool view_compute_centered_position(struct view *view,
|
||||||
|
const struct wlr_box *ref, int w, int h, int *x, int *y);
|
||||||
void view_store_natural_geometry(struct view *view);
|
void view_store_natural_geometry(struct view *view);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -539,7 +539,7 @@ view_minimize(struct view *view, bool minimized)
|
||||||
minimize_sub_views(root, minimized);
|
minimize_sub_views(root, minimized);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
bool
|
||||||
view_compute_centered_position(struct view *view, const struct wlr_box *ref,
|
view_compute_centered_position(struct view *view, const struct wlr_box *ref,
|
||||||
int w, int h, int *x, int *y)
|
int w, int h, int *x, int *y)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -452,10 +452,30 @@ set_initial_position(struct view *view,
|
||||||
XCB_ICCCM_SIZE_HINT_P_POSITION));
|
XCB_ICCCM_SIZE_HINT_P_POSITION));
|
||||||
|
|
||||||
if (has_position) {
|
if (has_position) {
|
||||||
/* Just make sure the view is on-screen */
|
/*
|
||||||
view_adjust_for_layout_change(view);
|
* Make sure a floating view is onscreen. For a
|
||||||
|
* maximized/fullscreen view, do nothing; if it is
|
||||||
|
* unmaximized/leaves fullscreen later, we will make
|
||||||
|
* sure it is on-screen at that point.
|
||||||
|
*/
|
||||||
|
if (view_is_floating(view)) {
|
||||||
|
view_adjust_for_layout_change(view);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
view_center(view, NULL);
|
if (view_is_floating(view)) {
|
||||||
|
view_center(view, NULL);
|
||||||
|
} else {
|
||||||
|
/*
|
||||||
|
* View is maximized/fullscreen. Center the
|
||||||
|
* stored natural geometry without actually
|
||||||
|
* moving the view.
|
||||||
|
*/
|
||||||
|
view_compute_centered_position(view, NULL,
|
||||||
|
view->natural_geometry.width,
|
||||||
|
view->natural_geometry.height,
|
||||||
|
&view->natural_geometry.x,
|
||||||
|
&view->natural_geometry.y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -554,10 +574,7 @@ xwayland_view_map(struct view *view)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!view->been_mapped) {
|
if (!view->been_mapped) {
|
||||||
if (view_is_floating(view)) {
|
set_initial_position(view, xwayland_surface);
|
||||||
set_initial_position(view, xwayland_surface);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When mapping the view for the first time, visual
|
* When mapping the view for the first time, visual
|
||||||
* artifacts are reduced if we display it immediately at
|
* artifacts are reduced if we display it immediately at
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue