mirror of
https://github.com/labwc/labwc.git
synced 2025-11-01 22:58:47 -04:00
view: make view_move_resize always work
It was not working before because in the case of wayland we are only dealing with sizes as wayland has no notion of a global position. A wayland client would thus not necessarily respond to a configure request which sets the same size again. This causes us to also not apply a new position set in view->pending because there may be no commit from the client in those cases. We previously worked around this issue in some parts of the code to check our new sizes against the pending ones and if they were the same we would call view_move instead. That had two issues: - Not all parts of the code did that which could end up delaying the positioning either to the next completely unrelated xdg commit event or to the next view_move call - The code started to repeat itself, e.g. the same condition with calls to either view_move or view_move_resize based on the result This patch fixes it by doing the check in the xdg configure handler instead. Xwayland is unaffected by this issue as we are always configuring a xwayland client with both, position and size.
This commit is contained in:
parent
231d88706a
commit
06e0771341
2 changed files with 34 additions and 33 deletions
17
src/view.c
17
src/view.c
|
|
@ -162,7 +162,6 @@ view_moved(struct view *view)
|
|||
}
|
||||
}
|
||||
|
||||
/* N.B. Use view_move() if not resizing. */
|
||||
void
|
||||
view_move_resize(struct view *view, struct wlr_box geo)
|
||||
{
|
||||
|
|
@ -417,13 +416,7 @@ view_apply_region_geometry(struct view *view)
|
|||
geo.width -= margin.left + margin.right;
|
||||
geo.height -= margin.top + margin.bottom;
|
||||
|
||||
if (view->pending.width == geo.width
|
||||
&& view->pending.height == geo.height) {
|
||||
/* move horizontally/vertically without changing size */
|
||||
view_move(view, geo.x, geo.y);
|
||||
} else {
|
||||
view_move_resize(view, geo);
|
||||
}
|
||||
view_move_resize(view, geo);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -439,13 +432,7 @@ view_apply_tiled_geometry(struct view *view, struct output *output)
|
|||
}
|
||||
|
||||
struct wlr_box dst = view_get_edge_snap_box(view, output, view->tiled);
|
||||
if (view->pending.width == dst.width
|
||||
&& view->pending.height == dst.height) {
|
||||
/* move horizontally/vertically without changing size */
|
||||
view_move(view, dst.x, dst.y);
|
||||
} else {
|
||||
view_move_resize(view, dst);
|
||||
}
|
||||
view_move_resize(view, dst);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
50
src/xdg.c
50
src/xdg.c
|
|
@ -200,24 +200,6 @@ handle_set_app_id(struct wl_listener *listener, void *data)
|
|||
view_update_app_id(view);
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_toplevel_view_configure(struct view *view, struct wlr_box geo)
|
||||
{
|
||||
view_adjust_size(view, &geo.width, &geo.height);
|
||||
view->pending = geo;
|
||||
|
||||
struct wlr_xdg_toplevel *xdg_toplevel = xdg_toplevel_from_view(view);
|
||||
uint32_t serial = wlr_xdg_toplevel_set_size(xdg_toplevel,
|
||||
(uint32_t)geo.width, (uint32_t)geo.height);
|
||||
if (serial > 0) {
|
||||
view->pending_configure_serial = serial;
|
||||
} else if (view->pending_configure_serial == 0) {
|
||||
view->current.x = geo.x;
|
||||
view->current.y = geo.y;
|
||||
view_moved(view);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_toplevel_view_move(struct view *view, int x, int y)
|
||||
{
|
||||
|
|
@ -231,6 +213,38 @@ xdg_toplevel_view_move(struct view *view, int x, int y)
|
|||
view_moved(view);
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_toplevel_view_configure(struct view *view, struct wlr_box geo)
|
||||
{
|
||||
view_adjust_size(view, &geo.width, &geo.height);
|
||||
|
||||
if (view->pending.width == geo.width && view->pending.height == geo.height) {
|
||||
/*
|
||||
* As wayland has no notion of a global position
|
||||
* we are only updating the size. If a wayland
|
||||
* client receives the same size it already has
|
||||
* it might not respond to the configure request
|
||||
* and thus we will never actually set the new
|
||||
* position. To handle this case just call move
|
||||
* directly.
|
||||
*/
|
||||
xdg_toplevel_view_move(view, geo.x, geo.y);
|
||||
return;
|
||||
}
|
||||
|
||||
view->pending = geo;
|
||||
struct wlr_xdg_toplevel *xdg_toplevel = xdg_toplevel_from_view(view);
|
||||
uint32_t serial = wlr_xdg_toplevel_set_size(xdg_toplevel,
|
||||
(uint32_t)geo.width, (uint32_t)geo.height);
|
||||
if (serial > 0) {
|
||||
view->pending_configure_serial = serial;
|
||||
} else if (view->pending_configure_serial == 0) {
|
||||
view->current.x = geo.x;
|
||||
view->current.y = geo.y;
|
||||
view_moved(view);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_toplevel_view_close(struct view *view)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue