mirror of
https://github.com/swaywm/sway.git
synced 2024-11-28 02:41:28 +00:00
Don't try to resize a client smaller than its constraints
Many clients will not ack & commit configures that make them smaller or larger than their specified constraints. This means that the transaction will timeout and poor perceived performance will endure.
This commit is contained in:
parent
f7290007b2
commit
0c8737d1ef
|
@ -149,6 +149,13 @@ static bool configure(struct sway_view *view, uint32_t *serial,
|
|||
return false;
|
||||
}
|
||||
|
||||
// avoid same size configures as clients may not ack & commit them
|
||||
struct wlr_xdg_toplevel *top = view->wlr_xdg_toplevel;
|
||||
if ((int) top->pending.width == width &&
|
||||
(int) top->pending.height == height) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*serial = wlr_xdg_toplevel_set_size(top, width, height);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#define _POSIX_C_SOURCE 200809L
|
||||
#include <stdlib.h>
|
||||
#include <strings.h>
|
||||
#include <math.h>
|
||||
#include <wayland-server-core.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_buffer.h>
|
||||
|
@ -166,6 +167,14 @@ void view_get_constraints(struct sway_view *view, double *min_width,
|
|||
|
||||
bool view_configure(struct sway_view *view, uint32_t *serial,
|
||||
double lx, double ly, int width, int height) {
|
||||
// Many clients don't play nicely if you try to reconfigure them out of
|
||||
// their specified constraints. Clamp the values.
|
||||
double minw, maxw, minh, maxh;
|
||||
view_get_constraints(view, &minw, &maxw, &minh, &maxh);
|
||||
|
||||
width = fmax(fmin(width, maxw), minw);
|
||||
height = fmax(fmin(height, maxh), minh);
|
||||
|
||||
if (view->impl->configure) {
|
||||
return view->impl->configure(view, serial, lx, ly, width, height);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue