mirror of
https://github.com/labwc/labwc.git
synced 2026-02-16 22:05:27 -05:00
cursor: Fix "jumping opposite edges" issue when resizing
Commit 08c537e ("xwayland: Honor size increments from
WM_SIZE_HINTS") adjusted only the window width/height according
to the size hints. If resizing from the top or left edge of the
window, we also need to adjust the window position to keep the
bottom or right edge from jumping around.
This commit is contained in:
parent
47912aebb6
commit
8e1f115486
5 changed files with 59 additions and 78 deletions
52
src/view.c
52
src/view.c
|
|
@ -4,6 +4,8 @@
|
|||
#include "labwc.h"
|
||||
#include "ssd.h"
|
||||
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
|
||||
void
|
||||
view_set_activated(struct view *view, bool activated)
|
||||
{
|
||||
|
|
@ -52,32 +54,44 @@ view_move_resize(struct view *view, struct wlr_box geo)
|
|||
#define MIN_VIEW_WIDTH (100)
|
||||
#define MIN_VIEW_HEIGHT (60)
|
||||
|
||||
#if HAVE_XWAYLAND
|
||||
static int
|
||||
round_to_increment(int val, int base, int inc)
|
||||
{
|
||||
if (base < 0 || inc <= 0)
|
||||
return val;
|
||||
return base + (val - base + inc / 2) / inc * inc;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
view_min_size(struct view *view, int *w, int *h)
|
||||
view_adjust_size(struct view *view, int *w, int *h)
|
||||
{
|
||||
int min_width = MIN_VIEW_WIDTH;
|
||||
int min_height = MIN_VIEW_HEIGHT;
|
||||
#if HAVE_XWAYLAND
|
||||
if (view->type != LAB_XWAYLAND_VIEW) {
|
||||
goto out;
|
||||
}
|
||||
if (!view->xwayland_surface->size_hints) {
|
||||
goto out;
|
||||
}
|
||||
if (view->xwayland_surface->size_hints->min_width > 0
|
||||
|| view->xwayland_surface->size_hints->min_height > 0) {
|
||||
min_width = view->xwayland_surface->size_hints->min_width;
|
||||
min_height = view->xwayland_surface->size_hints->min_height;
|
||||
}
|
||||
out:
|
||||
#endif
|
||||
if (view->type == LAB_XWAYLAND_VIEW) {
|
||||
struct wlr_xwayland_surface_size_hints *hints =
|
||||
view->xwayland_surface->size_hints;
|
||||
/*
|
||||
* Honor size increments from WM_SIZE_HINTS. Typically, X11
|
||||
* terminal emulators will use WM_SIZE_HINTS to make sure that
|
||||
* the terminal is resized to a width/height evenly divisible by
|
||||
* the cell (character) size.
|
||||
*/
|
||||
if (hints) {
|
||||
*w = round_to_increment(*w, hints->base_width,
|
||||
hints->width_inc);
|
||||
*h = round_to_increment(*h, hints->base_height,
|
||||
hints->height_inc);
|
||||
|
||||
if (w) {
|
||||
*w = min_width;
|
||||
}
|
||||
if (h) {
|
||||
*h = min_height;
|
||||
min_width = MAX(1, hints->min_width);
|
||||
min_height = MAX(1, hints->min_height);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
*w = MAX(*w, min_width);
|
||||
*h = MAX(*h, min_height);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue