mirror of
https://github.com/labwc/labwc.git
synced 2025-11-02 09:01:47 -05:00
src/view.c: move xwayland specific function to xwayland.c
Also remove the `<xcb/xcb_icccm.h>` include as its already included by `"labwc.h"` -> `<wlr/xwayland.h>` -> `<wlr/xwayland/xwayland.h>`.
This commit is contained in:
parent
ed31381eb8
commit
7790da7b4e
3 changed files with 49 additions and 41 deletions
|
|
@ -351,6 +351,7 @@ void xdg_toplevel_decoration(struct wl_listener *listener, void *data);
|
||||||
void xdg_surface_new(struct wl_listener *listener, void *data);
|
void xdg_surface_new(struct wl_listener *listener, void *data);
|
||||||
|
|
||||||
#if HAVE_XWAYLAND
|
#if HAVE_XWAYLAND
|
||||||
|
bool xwayland_apply_size_hints(struct view *view, int *w, int *h);
|
||||||
void xwayland_surface_new(struct wl_listener *listener, void *data);
|
void xwayland_surface_new(struct wl_listener *listener, void *data);
|
||||||
struct xwayland_unmanaged *xwayland_unmanaged_create(struct server *server,
|
struct xwayland_unmanaged *xwayland_unmanaged_create(struct server *server,
|
||||||
struct wlr_xwayland_surface *xsurface);
|
struct wlr_xwayland_surface *xsurface);
|
||||||
|
|
|
||||||
52
src/view.c
52
src/view.c
|
|
@ -9,12 +9,11 @@
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
#include "workspaces.h"
|
#include "workspaces.h"
|
||||||
|
|
||||||
#if HAVE_XWAYLAND
|
#define LAB_MIN_VIEW_WIDTH 100
|
||||||
#include <xcb/xcb_icccm.h>
|
#define LAB_MIN_VIEW_HEIGHT 60
|
||||||
#endif
|
#define LAB_FALLBACK_WIDTH 640
|
||||||
|
|
||||||
#define LAB_FALLBACK_WIDTH 640
|
|
||||||
#define LAB_FALLBACK_HEIGHT 480
|
#define LAB_FALLBACK_HEIGHT 480
|
||||||
|
|
||||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -168,49 +167,20 @@ 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
|
void
|
||||||
view_adjust_size(struct view *view, int *w, int *h)
|
view_adjust_size(struct view *view, int *w, int *h)
|
||||||
{
|
{
|
||||||
assert(view);
|
assert(view);
|
||||||
int min_width = MIN_VIEW_WIDTH;
|
|
||||||
int min_height = MIN_VIEW_HEIGHT;
|
|
||||||
#if HAVE_XWAYLAND
|
#if HAVE_XWAYLAND
|
||||||
if (view->type == LAB_XWAYLAND_VIEW) {
|
if (xwayland_apply_size_hints(view, w, h)) {
|
||||||
xcb_size_hints_t *hints =
|
/* We don't want to cap the size to keep the aspect ratio */
|
||||||
xwayland_surface_from_view(view)->size_hints;
|
return;
|
||||||
|
|
||||||
/*
|
|
||||||
* 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);
|
|
||||||
|
|
||||||
min_width = MAX(1, hints->min_width);
|
|
||||||
min_height = MAX(1, hints->min_height);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
*w = MAX(*w, min_width);
|
|
||||||
*h = MAX(*h, min_height);
|
*w = MAX(*w, LAB_MIN_VIEW_WIDTH);
|
||||||
|
*h = MAX(*h, LAB_MIN_VIEW_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,43 @@
|
||||||
#include "view.h"
|
#include "view.h"
|
||||||
#include "workspaces.h"
|
#include "workspaces.h"
|
||||||
|
|
||||||
|
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
xwayland_apply_size_hints(struct view *view, int *w, int *h)
|
||||||
|
{
|
||||||
|
if (view->type == LAB_XWAYLAND_VIEW) {
|
||||||
|
xcb_size_hints_t *hints =
|
||||||
|
xwayland_surface_from_view(view)->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);
|
||||||
|
|
||||||
|
*w = MAX(*w, MAX(1, hints->min_width));
|
||||||
|
*h = MAX(*h, MAX(1, hints->min_height));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static struct xwayland_view *
|
static struct xwayland_view *
|
||||||
xwayland_view_from_view(struct view *view)
|
xwayland_view_from_view(struct view *view)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue