aboutsummaryrefslogtreecommitdiff
path: root/client.h
diff options
context:
space:
mode:
authorLeonardo Hernández Hernández <leohdz172@protonmail.com>2022-10-01 23:30:47 -0500
committerLeonardo Hernández Hernández <leohdz172@protonmail.com>2022-10-01 23:30:47 -0500
commitae3d435717f9c40313a516ed760094718104b9c3 (patch)
tree68abcc566b7b02fc895405cd0f61a9331088298f /client.h
parentd11358762d3693e8e268ecf01861f522a0dc96f5 (diff)
parentb8bc54b65d7dfaf1c7aa92de32f8ca37d8e011f9 (diff)
Merge remote-tracking branch 'djpohly/main' into wlroots-next
Diffstat (limited to 'client.h')
-rw-r--r--client.h141
1 files changed, 72 insertions, 69 deletions
diff --git a/client.h b/client.h
index 17f9aff..b89a659 100644
--- a/client.h
+++ b/client.h
@@ -16,21 +16,10 @@ client_is_x11(Client *c)
#endif
}
-static inline struct wlr_surface *
-client_surface(Client *c)
-{
-#ifdef XWAYLAND
- if (client_is_x11(c))
- return c->surface.xwayland->surface;
-#endif
- return c->surface.xdg->surface;
-}
-
static inline Client *
client_from_wlr_surface(struct wlr_surface *s)
{
struct wlr_xdg_surface *surface;
- struct wlr_surface *parent;
#ifdef XWAYLAND
struct wlr_xwayland_surface *xsurface;
@@ -48,6 +37,54 @@ client_from_wlr_surface(struct wlr_surface *s)
return NULL;
}
+static inline Client *
+client_get_parent(Client *c)
+{
+#ifdef XWAYLAND
+ if (client_is_x11(c) && c->surface.xwayland->parent)
+ return client_from_wlr_surface(c->surface.xwayland->parent->surface);
+#endif
+ if (c->surface.xdg->toplevel->parent)
+ return client_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface);
+
+ return NULL;
+}
+
+static inline void
+client_get_size_hints(Client *c, struct wlr_box *max, struct wlr_box *min)
+{
+ struct wlr_xdg_toplevel *toplevel;
+ struct wlr_xdg_toplevel_state *state;
+#ifdef XWAYLAND
+ if (client_is_x11(c)) {
+ xcb_size_hints_t *size_hints = c->surface.xwayland->size_hints;
+ if (size_hints) {
+ max->width = size_hints->max_width;
+ max->height = size_hints->max_height;
+ min->width = size_hints->min_width;
+ min->height = size_hints->min_height;
+ }
+ return;
+ }
+#endif
+ toplevel = c->surface.xdg->toplevel;
+ state = &toplevel->current;
+ max->width = state->max_width;
+ max->height = state->max_height;
+ min->width = state->min_width;
+ min->height = state->min_height;
+}
+
+static inline struct wlr_surface *
+client_surface(Client *c)
+{
+#ifdef XWAYLAND
+ if (client_is_x11(c))
+ return c->surface.xwayland->surface;
+#endif
+ return c->surface.xdg->surface;
+}
+
/* The others */
static inline void
client_activate_surface(struct wlr_surface *s, int activated)
@@ -116,31 +153,6 @@ client_get_geometry(Client *c, struct wlr_box *geom)
wlr_xdg_surface_get_geometry(c->surface.xdg, geom);
}
-static inline void
-client_get_size_hints(Client *c, struct wlr_box *max, struct wlr_box *min)
-{
- struct wlr_xdg_toplevel *toplevel;
- struct wlr_xdg_toplevel_state *state;
-#ifdef XWAYLAND
- if (client_is_x11(c)) {
- xcb_size_hints_t *size_hints = c->surface.xwayland->size_hints;
- if (size_hints) {
- max->width = size_hints->max_width;
- max->height = size_hints->max_height;
- min->width = size_hints->min_width;
- min->height = size_hints->min_height;
- }
- return;
- }
-#endif
- toplevel = c->surface.xdg->toplevel;
- state = &toplevel->current;
- max->width = state->max_width;
- max->height = state->max_height;
- min->width = state->min_width;
- min->height = state->min_height;
-}
-
static inline const char *
client_get_title(Client *c)
{
@@ -151,20 +163,6 @@ client_get_title(Client *c)
return c->surface.xdg->toplevel->title;
}
-static inline Client *
-client_get_parent(Client *c)
-{
- Client *p;
-#ifdef XWAYLAND
- if (client_is_x11(c) && c->surface.xwayland->parent)
- return client_from_wlr_surface(c->surface.xwayland->parent->surface);
-#endif
- if (c->surface.xdg->toplevel->parent)
- return client_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface);
-
- return NULL;
-}
-
static inline int
client_is_float_type(Client *c)
{
@@ -183,16 +181,11 @@ client_is_float_type(Client *c)
|| surface->window_type[i] == netatom[NetWMWindowTypeToolbar]
|| surface->window_type[i] == netatom[NetWMWindowTypeUtility])
return 1;
-
- return ((min.width > 0 || min.height > 0 || max.width > 0 || max.height > 0)
- && (min.width == max.width || min.height == max.height))
- || c->surface.xwayland->parent;
}
#endif
-
return ((min.width > 0 || min.height > 0 || max.width > 0 || max.height > 0)
&& (min.width == max.width || min.height == max.height))
- || c->surface.xdg->toplevel->parent;
+ || client_get_parent(c);
}
static inline int
@@ -206,22 +199,33 @@ client_is_mapped(Client *c)
}
static inline int
-client_wants_fullscreen(Client *c)
+client_is_unmanaged(Client *c)
{
#ifdef XWAYLAND
- if (client_is_x11(c))
- return c->surface.xwayland->fullscreen;
+ return c->type == X11Unmanaged;
#endif
- return c->surface.xdg->toplevel->requested.fullscreen;
+ return 0;
}
-static inline int
-client_is_unmanaged(Client *c)
+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);
+}
+
+static inline void
+client_restack_surface(Client *c)
{
#ifdef XWAYLAND
- return c->type == X11Unmanaged;
+ if (client_is_x11(c))
+ wlr_xwayland_surface_restack(c->surface.xwayland, NULL,
+ XCB_STACK_MODE_ABOVE);
#endif
- return 0;
+ return;
}
static inline void
@@ -282,15 +286,14 @@ client_surface_at(Client *c, double cx, double cy, double *sx, double *sy)
return wlr_xdg_surface_surface_at(c->surface.xdg, cx, cy, sx, sy);
}
-static inline void
-client_restack_surface(Client *c)
+static inline int
+client_wants_fullscreen(Client *c)
{
#ifdef XWAYLAND
if (client_is_x11(c))
- wlr_xwayland_surface_restack(c->surface.xwayland, NULL,
- XCB_STACK_MODE_ABOVE);
+ return c->surface.xwayland->fullscreen;
#endif
- return;
+ return c->surface.xdg->toplevel->requested.fullscreen;
}
static inline void *