mirror of
https://github.com/labwc/labwc.git
synced 2025-11-05 13:29:58 -05:00
view: account for base size in resize indicator
For views with a non-pixel size increment (e.g. X11 terminals), it's helpful to subtract the base size of the window (typically including menu bar, scrollbars, etc.) before computing the number of size increments (e.g. cells/characters). This way, the displayed size will exactly match the terminal grid (e.g. 80x25 or whatever). wlr_box isn't really the best fit for size hints, so let's define a struct view_size_hints and a nice view_get_size_hints() function, wrapping view->impl->get_size_hints(). This also seems like a great opportunity to make view_adjust_size() window-system-agnostic and eliminate xwayland_apply_size_hints().
This commit is contained in:
parent
48e0b3f6a6
commit
ce36cbac2d
5 changed files with 90 additions and 77 deletions
|
|
@ -49,18 +49,6 @@ resize_indicator_init(struct view *view)
|
|||
resize_indicator_reconfigure_view(indicator);
|
||||
}
|
||||
|
||||
static struct wlr_box
|
||||
get_size_hints(struct view *view)
|
||||
{
|
||||
assert(view);
|
||||
|
||||
struct wlr_box hints = { 0 };
|
||||
if (view->impl->fill_size_hints) {
|
||||
view->impl->fill_size_hints(view, &hints);
|
||||
}
|
||||
return hints;
|
||||
}
|
||||
|
||||
static bool
|
||||
wants_indicator(struct view *view)
|
||||
{
|
||||
|
|
@ -70,8 +58,8 @@ wants_indicator(struct view *view)
|
|||
if (view->server->input_mode != LAB_INPUT_STATE_RESIZE) {
|
||||
return false;
|
||||
}
|
||||
struct wlr_box size_hints = get_size_hints(view);
|
||||
if (size_hints.width && size_hints.height) {
|
||||
struct view_size_hints hints = view_get_size_hints(view);
|
||||
if (hints.width_inc && hints.height_inc) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -173,10 +161,12 @@ resize_indicator_update(struct view *view)
|
|||
switch (view->server->input_mode) {
|
||||
case LAB_INPUT_STATE_RESIZE:
|
||||
; /* works around "a label can only be part of a statement" */
|
||||
struct wlr_box size_hints = get_size_hints(view);
|
||||
struct view_size_hints hints = view_get_size_hints(view);
|
||||
snprintf(text, sizeof(text), "%d x %d",
|
||||
view->current.width / MAX(1, size_hints.width),
|
||||
view->current.height / MAX(1, size_hints.height));
|
||||
MAX(0, view->current.width - hints.base_width)
|
||||
/ MAX(1, hints.width_inc),
|
||||
MAX(0, view->current.height - hints.base_height)
|
||||
/ MAX(1, hints.height_inc));
|
||||
break;
|
||||
case LAB_INPUT_STATE_MOVE:
|
||||
; /* works around "a label can only be part of a statement" */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue