diff options
Diffstat (limited to 'client.h')
-rw-r--r-- | client.h | 117 |
1 files changed, 93 insertions, 24 deletions
@@ -5,7 +5,7 @@ * that they will simply compile out if the chosen #defines leave them unused. */ -/* Leave this function first; it's used in the others */ +/* Leave these functions first; they're used in the others */ static inline int client_is_x11(Client *c) { @@ -16,6 +16,16 @@ 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; +} + /* The others */ static inline void client_activate_surface(struct wlr_surface *s, int activated) @@ -35,14 +45,12 @@ client_activate_surface(struct wlr_surface *s, int activated) static inline void client_for_each_surface(Client *c, wlr_surface_iterator_func_t fn, void *data) { + wlr_surface_for_each_surface(client_surface(c), fn, data); #ifdef XWAYLAND - if (client_is_x11(c)) { - wlr_surface_for_each_surface(c->surface.xwayland->surface, - fn, data); + if (client_is_x11(c)) return; - } #endif - wlr_xdg_surface_for_each_surface(c->surface.xdg, fn, data); + wlr_xdg_surface_for_each_popup_surface(c->surface.xdg, fn, data); } static inline const char * @@ -83,16 +91,47 @@ client_get_title(Client *c) static inline int client_is_float_type(Client *c) { + struct wlr_xdg_toplevel *toplevel; + struct wlr_xdg_toplevel_state state; + #ifdef XWAYLAND - if (client_is_x11(c)) - for (size_t i = 0; i < c->surface.xwayland->window_type_len; i++) - if (c->surface.xwayland->window_type[i] == netatom[NetWMWindowTypeDialog] || - c->surface.xwayland->window_type[i] == netatom[NetWMWindowTypeSplash] || - c->surface.xwayland->window_type[i] == netatom[NetWMWindowTypeToolbar] || - c->surface.xwayland->window_type[i] == netatom[NetWMWindowTypeUtility]) + if (client_is_x11(c)) { + struct wlr_xwayland_surface *surface = c->surface.xwayland; + struct wlr_xwayland_surface_size_hints *size_hints; + if (surface->modal) + return 1; + + for (size_t i = 0; i < surface->window_type_len; i++) + if (surface->window_type[i] == netatom[NetWMWindowTypeDialog] || + surface->window_type[i] == netatom[NetWMWindowTypeSplash] || + surface->window_type[i] == netatom[NetWMWindowTypeToolbar] || + surface->window_type[i] == netatom[NetWMWindowTypeUtility]) return 1; + + size_hints = surface->size_hints; + if (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)) + return 1; + } #endif - return 0; + + toplevel = c->surface.xdg->toplevel; + state = toplevel->current; + return (state.min_width != 0 && state.min_height != 0 + && (state.min_width == state.max_width + || state.min_height == state.max_height)) + || toplevel->parent; +} + +static inline int +client_wants_fullscreen(Client *c) +{ +#ifdef XWAYLAND + if (client_is_x11(c)) + return c->surface.xwayland->fullscreen; +#endif + return c->surface.xdg->toplevel->requested.fullscreen; } static inline int @@ -148,27 +187,57 @@ client_set_tiled(Client *c, uint32_t edges) if (client_is_x11(c)) return; #endif - wlr_xdg_toplevel_set_tiled(c->surface.xdg, WLR_EDGE_TOP | - WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT); + wlr_xdg_toplevel_set_tiled(c->surface.xdg, edges); } static inline struct wlr_surface * -client_surface(Client *c) +client_surface_at(Client *c, double cx, double cy, double *sx, double *sy) { #ifdef XWAYLAND if (client_is_x11(c)) - return c->surface.xwayland->surface; + return wlr_surface_surface_at(c->surface.xwayland->surface, + cx, cy, sx, sy); #endif - return c->surface.xdg->surface; + return wlr_xdg_surface_surface_at(c->surface.xdg, cx, cy, sx, sy); } -static inline struct wlr_surface * -client_surface_at(Client *c, double cx, double cy, double *sx, double *sy) +static inline void +client_min_size(Client *c, int *width, int *height) { + struct wlr_xdg_toplevel *toplevel; + struct wlr_xdg_toplevel_state *state; #ifdef XWAYLAND - if (client_is_x11(c)) - return wlr_surface_surface_at(c->surface.xwayland->surface, - cx, cy, sx, sy); + if (client_is_x11(c)) { + struct wlr_xwayland_surface_size_hints *size_hints; + size_hints = c->surface.xwayland->size_hints; + *width = size_hints->min_width; + *height = size_hints->min_height; + return; + } #endif - return wlr_xdg_surface_surface_at(c->surface.xdg, cx, cy, sx, sy); + toplevel = c->surface.xdg->toplevel; + state = &toplevel->current; + *width = state->min_width; + *height = state->min_height; +} + +static inline Client * +client_from_popup(struct wlr_xdg_popup *popup) +{ + struct wlr_xdg_surface *surface = popup->base; + + while (1) { + switch (surface->role) { + case WLR_XDG_SURFACE_ROLE_POPUP: + if (!wlr_surface_is_xdg_surface(surface->popup->parent)) + return NULL; + + surface = wlr_xdg_surface_from_wlr_surface(surface->popup->parent); + break; + case WLR_XDG_SURFACE_ROLE_TOPLEVEL: + return surface->data; + case WLR_XDG_SURFACE_ROLE_NONE: + return NULL; + } + } } |