2020-12-25 01:33:55 -05:00
|
|
|
/*
|
|
|
|
|
* Attempt to consolidate unavoidable suck into one file, away from dwl.c. This
|
|
|
|
|
* file is not meant to be pretty. We use a .h file with static inline
|
|
|
|
|
* functions instead of a separate .c module, or function pointers like sway, so
|
|
|
|
|
* that they will simply compile out if the chosen #defines leave them unused.
|
|
|
|
|
*/
|
2025-08-27 16:36:00 +10:00
|
|
|
#ifndef CRYWL_CLIENT_H
|
|
|
|
|
#define CRYWL_CLIENT_H
|
|
|
|
|
|
|
|
|
|
enum { XDGShell, LayerShell, X11 }; /* client types */
|
|
|
|
|
|
2025-08-27 17:59:12 +10:00
|
|
|
typedef struct Monitor Monitor; // forward declare
|
|
|
|
|
|
2025-08-27 16:36:00 +10:00
|
|
|
typedef struct {
|
|
|
|
|
/* Must keep this field first */
|
|
|
|
|
unsigned int type; /* XDGShell or X11* */
|
|
|
|
|
|
|
|
|
|
Monitor *mon;
|
|
|
|
|
struct wlr_scene_tree *scene;
|
|
|
|
|
struct wlr_scene_rect *border[4]; /* top, bottom, left, right */
|
|
|
|
|
struct wlr_scene_tree *scene_surface;
|
|
|
|
|
struct wl_list link;
|
|
|
|
|
struct wl_list flink;
|
|
|
|
|
struct wlr_box geom; /* layout-relative, includes border */
|
|
|
|
|
struct wlr_box prev; /* layout-relative, includes border */
|
|
|
|
|
struct wlr_box bounds; /* only width and height are used */
|
|
|
|
|
union {
|
|
|
|
|
struct wlr_xdg_surface *xdg;
|
|
|
|
|
struct wlr_xwayland_surface *xwayland;
|
|
|
|
|
} surface;
|
|
|
|
|
struct wlr_xdg_toplevel_decoration_v1 *decoration;
|
|
|
|
|
struct wl_listener commit;
|
|
|
|
|
struct wl_listener map;
|
|
|
|
|
struct wl_listener maximize;
|
|
|
|
|
struct wl_listener unmap;
|
|
|
|
|
struct wl_listener destroy;
|
|
|
|
|
struct wl_listener set_title;
|
|
|
|
|
struct wl_listener fullscreen;
|
|
|
|
|
struct wl_listener set_decoration_mode;
|
|
|
|
|
struct wl_listener destroy_decoration;
|
|
|
|
|
#ifdef XWAYLAND
|
|
|
|
|
struct wl_listener activate;
|
|
|
|
|
struct wl_listener associate;
|
|
|
|
|
struct wl_listener dissociate;
|
|
|
|
|
struct wl_listener configure;
|
|
|
|
|
struct wl_listener set_hints;
|
|
|
|
|
#endif
|
|
|
|
|
unsigned int bw;
|
|
|
|
|
uint32_t tags;
|
|
|
|
|
int isfloating, isurgent, isfullscreen;
|
|
|
|
|
uint32_t resize; /* configure serial of a pending resize */
|
|
|
|
|
} Client;
|
|
|
|
|
|
|
|
|
|
/* ===== Function Declarations ===== */
|
|
|
|
|
static void applybounds(Client *c, struct wlr_box *bbox);
|
|
|
|
|
static void applyrules(Client *c);
|
|
|
|
|
static void focusclient(Client *c, int lift);
|
|
|
|
|
static void killclient(const Arg *arg);
|
|
|
|
|
static void resize(Client *c, struct wlr_box geo, int interact);
|
|
|
|
|
static void setfloating(Client *c, int floating);
|
|
|
|
|
static void setfullscreen(Client *c, int fullscreen);
|
|
|
|
|
static void setpsel(struct wl_listener *listener, void *data);
|
|
|
|
|
static void setsel(struct wl_listener *listener, void *data);
|
|
|
|
|
static void togglefloating(const Arg *arg);
|
|
|
|
|
static void togglefullscreen(const Arg *arg);
|
|
|
|
|
static void toggletag(const Arg *arg);
|
|
|
|
|
static void toggleview(const Arg *arg);
|
|
|
|
|
static void updatetitle(struct wl_listener *listener, void *data);
|
|
|
|
|
static void urgent(struct wl_listener *listener, void *data);
|
|
|
|
|
static void view(const Arg *arg);
|
|
|
|
|
static void xytonode(double x, double y, struct wlr_surface **psurface,
|
|
|
|
|
Client **pc, LayerSurface **pl, double *nx, double *ny);
|
|
|
|
|
static void zoom(const Arg *arg);
|
2020-12-25 01:33:55 -05:00
|
|
|
|
2021-09-05 11:41:23 -05:00
|
|
|
/* Leave these functions first; they're used in the others */
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline int client_is_x11(Client *c) {
|
2020-12-25 01:33:55 -05:00
|
|
|
#ifdef XWAYLAND
|
2025-08-27 12:50:29 +10:00
|
|
|
return c->type == X11;
|
2020-12-25 01:33:55 -05:00
|
|
|
#endif
|
2025-08-27 12:50:29 +10:00
|
|
|
return 0;
|
2020-12-25 01:33:55 -05:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline struct wlr_surface *client_surface(Client *c) {
|
2022-08-27 16:29:23 -05:00
|
|
|
#ifdef XWAYLAND
|
2025-08-27 12:50:29 +10:00
|
|
|
if (client_is_x11(c))
|
|
|
|
|
return c->surface.xwayland->surface;
|
2022-08-27 16:29:23 -05:00
|
|
|
#endif
|
2025-08-27 12:50:29 +10:00
|
|
|
return c->surface.xdg->surface;
|
2022-08-27 16:29:23 -05:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline int toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc,
|
|
|
|
|
LayerSurface **pl) {
|
|
|
|
|
struct wlr_xdg_surface *xdg_surface, *tmp_xdg_surface;
|
|
|
|
|
struct wlr_surface *root_surface;
|
|
|
|
|
struct wlr_layer_surface_v1 *layer_surface;
|
|
|
|
|
Client *c = NULL;
|
|
|
|
|
LayerSurface *l = NULL;
|
|
|
|
|
int type = -1;
|
2022-12-03 14:31:18 -06:00
|
|
|
#ifdef XWAYLAND
|
2025-08-27 12:50:29 +10:00
|
|
|
struct wlr_xwayland_surface *xsurface;
|
2022-12-03 14:31:18 -06:00
|
|
|
#endif
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
if (!s)
|
|
|
|
|
return -1;
|
|
|
|
|
root_surface = wlr_surface_get_root_surface(s);
|
2022-12-03 14:31:18 -06:00
|
|
|
|
|
|
|
|
#ifdef XWAYLAND
|
2025-08-27 12:50:29 +10:00
|
|
|
if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(root_surface))) {
|
|
|
|
|
c = xsurface->data;
|
|
|
|
|
type = c->type;
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
2022-12-03 14:31:18 -06:00
|
|
|
#endif
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
if ((layer_surface =
|
|
|
|
|
wlr_layer_surface_v1_try_from_wlr_surface(root_surface))) {
|
|
|
|
|
l = layer_surface->data;
|
|
|
|
|
type = LayerShell;
|
|
|
|
|
goto end;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
xdg_surface = wlr_xdg_surface_try_from_wlr_surface(root_surface);
|
|
|
|
|
while (xdg_surface) {
|
|
|
|
|
tmp_xdg_surface = NULL;
|
|
|
|
|
switch (xdg_surface->role) {
|
|
|
|
|
case WLR_XDG_SURFACE_ROLE_POPUP:
|
|
|
|
|
if (!xdg_surface->popup || !xdg_surface->popup->parent)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
tmp_xdg_surface =
|
|
|
|
|
wlr_xdg_surface_try_from_wlr_surface(xdg_surface->popup->parent);
|
|
|
|
|
|
|
|
|
|
if (!tmp_xdg_surface)
|
|
|
|
|
return toplevel_from_wlr_surface(xdg_surface->popup->parent, pc, pl);
|
|
|
|
|
|
|
|
|
|
xdg_surface = tmp_xdg_surface;
|
|
|
|
|
break;
|
|
|
|
|
case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
|
|
|
|
|
c = xdg_surface->data;
|
|
|
|
|
type = c->type;
|
|
|
|
|
goto end;
|
|
|
|
|
case WLR_XDG_SURFACE_ROLE_NONE:
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-03 14:31:18 -06:00
|
|
|
|
2022-12-03 15:17:43 -06:00
|
|
|
end:
|
2025-08-27 12:50:29 +10:00
|
|
|
if (pl)
|
|
|
|
|
*pl = l;
|
|
|
|
|
if (pc)
|
|
|
|
|
*pc = c;
|
|
|
|
|
return type;
|
2022-12-03 14:31:18 -06:00
|
|
|
}
|
|
|
|
|
|
2020-12-25 01:33:55 -05:00
|
|
|
/* The others */
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline void client_activate_surface(struct wlr_surface *s,
|
|
|
|
|
int activated) {
|
|
|
|
|
struct wlr_xdg_toplevel *toplevel;
|
2020-12-25 01:33:55 -05:00
|
|
|
#ifdef XWAYLAND
|
2025-08-27 12:50:29 +10:00
|
|
|
struct wlr_xwayland_surface *xsurface;
|
|
|
|
|
if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(s))) {
|
|
|
|
|
wlr_xwayland_surface_activate(xsurface, activated);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-12-25 01:33:55 -05:00
|
|
|
#endif
|
2025-08-27 12:50:29 +10:00
|
|
|
if ((toplevel = wlr_xdg_toplevel_try_from_wlr_surface(s)))
|
|
|
|
|
wlr_xdg_toplevel_set_activated(toplevel, activated);
|
2020-12-25 01:33:55 -05:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline uint32_t client_set_bounds(Client *c, int32_t width,
|
|
|
|
|
int32_t height) {
|
2022-06-09 12:45:42 -05:00
|
|
|
#ifdef XWAYLAND
|
2025-08-27 12:50:29 +10:00
|
|
|
if (client_is_x11(c))
|
|
|
|
|
return 0;
|
2022-06-09 12:45:42 -05:00
|
|
|
#endif
|
2025-08-27 12:50:29 +10:00
|
|
|
if (wl_resource_get_version(c->surface.xdg->toplevel->resource) >=
|
|
|
|
|
XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION &&
|
|
|
|
|
width >= 0 && height >= 0 &&
|
|
|
|
|
(c->bounds.width != width || c->bounds.height != height)) {
|
|
|
|
|
c->bounds.width = width;
|
|
|
|
|
c->bounds.height = height;
|
|
|
|
|
return wlr_xdg_toplevel_set_bounds(c->surface.xdg->toplevel, width, height);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
2022-06-09 12:45:42 -05:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline const char *client_get_appid(Client *c) {
|
2020-12-25 01:33:55 -05:00
|
|
|
#ifdef XWAYLAND
|
2025-08-27 12:50:29 +10:00
|
|
|
if (client_is_x11(c))
|
|
|
|
|
return c->surface.xwayland->class ? c->surface.xwayland->class : "broken";
|
2020-12-25 01:33:55 -05:00
|
|
|
#endif
|
2025-08-27 12:50:29 +10:00
|
|
|
return c->surface.xdg->toplevel->app_id ? c->surface.xdg->toplevel->app_id
|
|
|
|
|
: "broken";
|
2020-12-25 01:33:55 -05:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline void client_get_clip(Client *c, struct wlr_box *clip) {
|
|
|
|
|
*clip = (struct wlr_box){
|
|
|
|
|
.x = 0,
|
|
|
|
|
.y = 0,
|
|
|
|
|
.width = c->geom.width - c->bw,
|
|
|
|
|
.height = c->geom.height - c->bw,
|
|
|
|
|
};
|
2023-11-16 21:12:50 -06:00
|
|
|
|
2023-07-08 20:08:45 -06:00
|
|
|
#ifdef XWAYLAND
|
2025-08-27 12:50:29 +10:00
|
|
|
if (client_is_x11(c))
|
|
|
|
|
return;
|
2023-07-08 20:08:45 -06:00
|
|
|
#endif
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
clip->x = c->surface.xdg->geometry.x;
|
|
|
|
|
clip->y = c->surface.xdg->geometry.y;
|
2023-07-08 20:08:45 -06:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline void client_get_geometry(Client *c, struct wlr_box *geom) {
|
2020-12-25 01:33:55 -05:00
|
|
|
#ifdef XWAYLAND
|
2025-08-27 12:50:29 +10:00
|
|
|
if (client_is_x11(c)) {
|
|
|
|
|
geom->x = c->surface.xwayland->x;
|
|
|
|
|
geom->y = c->surface.xwayland->y;
|
|
|
|
|
geom->width = c->surface.xwayland->width;
|
|
|
|
|
geom->height = c->surface.xwayland->height;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-12-25 01:33:55 -05:00
|
|
|
#endif
|
2025-08-27 12:50:29 +10:00
|
|
|
*geom = c->surface.xdg->geometry;
|
2020-12-25 01:33:55 -05:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline Client *client_get_parent(Client *c) {
|
|
|
|
|
Client *p = NULL;
|
2022-12-03 14:30:38 -06:00
|
|
|
#ifdef XWAYLAND
|
2025-08-27 12:50:29 +10:00
|
|
|
if (client_is_x11(c)) {
|
|
|
|
|
if (c->surface.xwayland->parent)
|
|
|
|
|
toplevel_from_wlr_surface(c->surface.xwayland->parent->surface, &p, NULL);
|
|
|
|
|
return p;
|
|
|
|
|
}
|
2022-12-03 14:30:38 -06:00
|
|
|
#endif
|
2025-08-27 12:50:29 +10:00
|
|
|
if (c->surface.xdg->toplevel->parent)
|
|
|
|
|
toplevel_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface,
|
|
|
|
|
&p, NULL);
|
|
|
|
|
return p;
|
2022-12-03 14:30:38 -06:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline int client_has_children(Client *c) {
|
2024-07-14 21:01:36 -06:00
|
|
|
#ifdef XWAYLAND
|
2025-08-27 12:50:29 +10:00
|
|
|
if (client_is_x11(c))
|
|
|
|
|
return !wl_list_empty(&c->surface.xwayland->children);
|
2024-07-14 21:01:36 -06:00
|
|
|
#endif
|
2025-08-27 12:50:29 +10:00
|
|
|
/* surface.xdg->link is never empty because it always contains at least the
|
|
|
|
|
* surface itself. */
|
|
|
|
|
return wl_list_length(&c->surface.xdg->link) > 1;
|
2024-07-14 21:01:36 -06:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline const char *client_get_title(Client *c) {
|
2020-12-25 01:33:55 -05:00
|
|
|
#ifdef XWAYLAND
|
2025-08-27 12:50:29 +10:00
|
|
|
if (client_is_x11(c))
|
|
|
|
|
return c->surface.xwayland->title ? c->surface.xwayland->title : "broken";
|
2020-12-25 01:33:55 -05:00
|
|
|
#endif
|
2025-08-27 12:50:29 +10:00
|
|
|
return c->surface.xdg->toplevel->title ? c->surface.xdg->toplevel->title
|
|
|
|
|
: "broken";
|
2020-12-25 01:33:55 -05:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline int client_is_float_type(Client *c) {
|
|
|
|
|
struct wlr_xdg_toplevel *toplevel;
|
|
|
|
|
struct wlr_xdg_toplevel_state state;
|
2022-03-21 13:52:33 -06:00
|
|
|
|
2020-12-25 01:33:55 -05:00
|
|
|
#ifdef XWAYLAND
|
2025-08-27 12:50:29 +10:00
|
|
|
if (client_is_x11(c)) {
|
|
|
|
|
struct wlr_xwayland_surface *surface = c->surface.xwayland;
|
|
|
|
|
xcb_size_hints_t *size_hints = surface->size_hints;
|
|
|
|
|
if (surface->modal)
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
if (wlr_xwayland_surface_has_window_type(
|
|
|
|
|
surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_DIALOG) ||
|
|
|
|
|
wlr_xwayland_surface_has_window_type(
|
|
|
|
|
surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_SPLASH) ||
|
|
|
|
|
wlr_xwayland_surface_has_window_type(
|
|
|
|
|
surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_TOOLBAR) ||
|
|
|
|
|
wlr_xwayland_surface_has_window_type(
|
|
|
|
|
surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_UTILITY)) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return size_hints && size_hints->min_width > 0 &&
|
|
|
|
|
size_hints->min_height > 0 &&
|
|
|
|
|
(size_hints->max_width == size_hints->min_width ||
|
|
|
|
|
size_hints->max_height == size_hints->min_height);
|
|
|
|
|
}
|
2020-12-25 01:33:55 -05:00
|
|
|
#endif
|
2023-07-08 20:07:27 -06:00
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
toplevel = c->surface.xdg->toplevel;
|
|
|
|
|
state = toplevel->current;
|
|
|
|
|
return toplevel->parent || (state.min_width != 0 && state.min_height != 0 &&
|
|
|
|
|
(state.min_width == state.max_width ||
|
|
|
|
|
state.min_height == state.max_height));
|
2020-12-25 01:33:55 -05:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline int client_is_rendered_on_mon(Client *c, Monitor *m) {
|
|
|
|
|
/* This is needed for when you don't want to check formal assignment,
|
|
|
|
|
* but rather actual displaying of the pixels.
|
|
|
|
|
* Usually VISIBLEON suffices and is also faster. */
|
|
|
|
|
struct wlr_surface_output *s;
|
|
|
|
|
int unused_lx, unused_ly;
|
|
|
|
|
if (!wlr_scene_node_coords(&c->scene->node, &unused_lx, &unused_ly))
|
|
|
|
|
return 0;
|
|
|
|
|
wl_list_for_each(s, &client_surface(c)->current_outputs,
|
|
|
|
|
link) if (s->output == m->wlr_output) return 1;
|
|
|
|
|
return 0;
|
2022-12-06 14:47:55 -06:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline int client_is_stopped(Client *c) {
|
|
|
|
|
int pid;
|
|
|
|
|
siginfo_t in = {0};
|
2022-12-21 14:28:27 -06:00
|
|
|
#ifdef XWAYLAND
|
2025-08-27 12:50:29 +10:00
|
|
|
if (client_is_x11(c))
|
|
|
|
|
return 0;
|
2022-12-21 14:28:27 -06:00
|
|
|
#endif
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
wl_client_get_credentials(c->surface.xdg->client->client, &pid, NULL, NULL);
|
|
|
|
|
if (waitid(P_PID, pid, &in, WNOHANG | WCONTINUED | WSTOPPED | WNOWAIT) < 0) {
|
|
|
|
|
/* This process is not our child process, while is very unlikely that
|
|
|
|
|
* it is stopped, in order to do not skip frames, assume that it is. */
|
|
|
|
|
if (errno == ECHILD)
|
|
|
|
|
return 1;
|
|
|
|
|
} else if (in.si_pid) {
|
|
|
|
|
if (in.si_code == CLD_STOPPED || in.si_code == CLD_TRAPPED)
|
|
|
|
|
return 1;
|
|
|
|
|
if (in.si_code == CLD_CONTINUED)
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
2022-12-21 14:28:27 -06:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline int client_is_unmanaged(Client *c) {
|
2022-03-13 20:54:44 -06:00
|
|
|
#ifdef XWAYLAND
|
2025-08-27 12:50:29 +10:00
|
|
|
if (client_is_x11(c))
|
|
|
|
|
return c->surface.xwayland->override_redirect;
|
2022-03-13 20:54:44 -06:00
|
|
|
#endif
|
2025-08-27 12:50:29 +10:00
|
|
|
return 0;
|
2022-03-13 20:54:44 -06:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline void client_notify_enter(struct wlr_surface *s,
|
|
|
|
|
struct wlr_keyboard *kb) {
|
|
|
|
|
if (kb)
|
|
|
|
|
wlr_seat_keyboard_notify_enter(seat, s, kb->keycodes, kb->num_keycodes,
|
|
|
|
|
&kb->modifiers);
|
|
|
|
|
else
|
|
|
|
|
wlr_seat_keyboard_notify_enter(seat, s, NULL, 0, NULL);
|
2022-08-27 16:05:12 -05:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline void client_send_close(Client *c) {
|
2020-12-25 01:33:55 -05:00
|
|
|
#ifdef XWAYLAND
|
2025-08-27 12:50:29 +10:00
|
|
|
if (client_is_x11(c)) {
|
|
|
|
|
wlr_xwayland_surface_close(c->surface.xwayland);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-12-25 01:33:55 -05:00
|
|
|
#endif
|
2025-08-27 12:50:29 +10:00
|
|
|
wlr_xdg_toplevel_send_close(c->surface.xdg->toplevel);
|
2020-12-25 01:33:55 -05:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline void client_set_border_color(Client *c,
|
|
|
|
|
const float color[static 4]) {
|
|
|
|
|
int i;
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
|
wlr_scene_rect_set_color(c->border[i], color);
|
2023-10-05 22:20:08 -06:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline void client_set_fullscreen(Client *c, int fullscreen) {
|
2020-12-25 01:33:55 -05:00
|
|
|
#ifdef XWAYLAND
|
2025-08-27 12:50:29 +10:00
|
|
|
if (client_is_x11(c)) {
|
|
|
|
|
wlr_xwayland_surface_set_fullscreen(c->surface.xwayland, fullscreen);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-12-25 01:33:55 -05:00
|
|
|
#endif
|
2025-08-27 12:50:29 +10:00
|
|
|
wlr_xdg_toplevel_set_fullscreen(c->surface.xdg->toplevel, fullscreen);
|
2020-12-25 01:33:55 -05:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline void client_set_scale(struct wlr_surface *s, float scale) {
|
|
|
|
|
wlr_fractional_scale_v1_notify_scale(s, scale);
|
|
|
|
|
wlr_surface_set_preferred_buffer_scale(s, (int32_t)ceilf(scale));
|
2024-08-09 22:05:04 -06:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline uint32_t client_set_size(Client *c, uint32_t width,
|
|
|
|
|
uint32_t height) {
|
2020-12-25 01:33:55 -05:00
|
|
|
#ifdef XWAYLAND
|
2025-08-27 12:50:29 +10:00
|
|
|
if (client_is_x11(c)) {
|
|
|
|
|
wlr_xwayland_surface_configure(c->surface.xwayland, c->geom.x + c->bw,
|
|
|
|
|
c->geom.y + c->bw, width, height);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2020-12-25 01:33:55 -05:00
|
|
|
#endif
|
2025-08-27 12:50:29 +10:00
|
|
|
if ((int32_t)width == c->surface.xdg->toplevel->current.width &&
|
|
|
|
|
(int32_t)height == c->surface.xdg->toplevel->current.height)
|
|
|
|
|
return 0;
|
|
|
|
|
return wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width,
|
|
|
|
|
(int32_t)height);
|
2020-12-25 01:33:55 -05:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline void client_set_tiled(Client *c, uint32_t edges) {
|
2021-05-23 18:28:13 -05:00
|
|
|
#ifdef XWAYLAND
|
2025-08-27 12:50:29 +10:00
|
|
|
if (client_is_x11(c)) {
|
|
|
|
|
wlr_xwayland_surface_set_maximized(
|
|
|
|
|
c->surface.xwayland, edges != WLR_EDGE_NONE, edges != WLR_EDGE_NONE);
|
|
|
|
|
return;
|
2024-08-25 13:02:34 -06:00
|
|
|
}
|
2021-05-23 18:28:13 -05:00
|
|
|
#endif
|
2025-08-27 12:50:29 +10:00
|
|
|
if (wl_resource_get_version(c->surface.xdg->toplevel->resource) >=
|
|
|
|
|
XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION) {
|
|
|
|
|
wlr_xdg_toplevel_set_tiled(c->surface.xdg->toplevel, edges);
|
|
|
|
|
} else {
|
|
|
|
|
wlr_xdg_toplevel_set_maximized(c->surface.xdg->toplevel,
|
|
|
|
|
edges != WLR_EDGE_NONE);
|
|
|
|
|
}
|
2021-05-23 18:28:13 -05:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline void client_set_suspended(Client *c, int suspended) {
|
2023-07-23 20:59:29 -06:00
|
|
|
#ifdef XWAYLAND
|
2025-08-27 12:50:29 +10:00
|
|
|
if (client_is_x11(c))
|
|
|
|
|
return;
|
2023-07-23 20:59:29 -06:00
|
|
|
#endif
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
wlr_xdg_toplevel_set_suspended(c->surface.xdg->toplevel, suspended);
|
2023-07-23 20:59:29 -06:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline int client_wants_focus(Client *c) {
|
2022-06-16 16:05:07 -05:00
|
|
|
#ifdef XWAYLAND
|
2025-08-27 12:50:29 +10:00
|
|
|
return client_is_unmanaged(c) &&
|
|
|
|
|
wlr_xwayland_surface_override_redirect_wants_focus(
|
|
|
|
|
c->surface.xwayland) &&
|
|
|
|
|
wlr_xwayland_surface_icccm_input_model(c->surface.xwayland) !=
|
|
|
|
|
WLR_ICCCM_INPUT_MODEL_NONE;
|
2022-06-16 16:05:07 -05:00
|
|
|
#endif
|
2025-08-27 12:50:29 +10:00
|
|
|
return 0;
|
2022-06-16 16:05:07 -05:00
|
|
|
}
|
|
|
|
|
|
2025-08-27 12:50:29 +10:00
|
|
|
static inline int client_wants_fullscreen(Client *c) {
|
2022-03-18 01:25:53 -06:00
|
|
|
#ifdef XWAYLAND
|
2025-08-27 12:50:29 +10:00
|
|
|
if (client_is_x11(c))
|
|
|
|
|
return c->surface.xwayland->fullscreen;
|
2022-03-18 01:25:53 -06:00
|
|
|
#endif
|
2025-08-27 12:50:29 +10:00
|
|
|
return c->surface.xdg->toplevel->requested.fullscreen;
|
2022-03-18 01:25:53 -06:00
|
|
|
}
|
2025-08-27 16:36:00 +10:00
|
|
|
|
|
|
|
|
#endif /* CRYWL_CLIENT_H */
|