Files
huntedbytheirs 4e388d9f4f feat(client): add client_update_scale and layersurface_update_scale
- client_update_scale(): re-notifies clients when output scale changes
  using current_outputs max scale (avoids stale c->mon for floating windows)
- layersurface_update_scale(): same logic for layer shell surfaces (static)
- Initialize current_scale on initial commit for both surface types
- Uses 0.001f tolerance for float comparison to prevent redundant events
- Falls back to c->mon->wlr_output->scale if no current_outputs
2026-07-05 21:36:41 -04:00

140 lines
4.3 KiB
C

#pragma once
#include <wayland-server-core.h>
#include <wlr/util/box.h>
#include "monitor.h"
/* Forward declarations for pointer-only types */
struct wlr_surface;
struct wlr_keyboard;
struct wlr_scene_tree;
struct wlr_scene_rect;
struct wlr_scene_layer_surface_v1;
struct wlr_layer_surface_v1;
struct wlr_xdg_surface;
struct wlr_xwayland_surface;
struct wlr_xdg_toplevel_decoration_v1;
struct wlr_scene_shadow;
/* Client types */
enum { XDGShell, LayerShell, X11 };
typedef struct {
bool rounding;
bool shadows;
bool transparency;
bool blur;
bool gaps;
bool smartgaps;
bool border;
bool sloppy_focus;
} ClientRuleEffects;
typedef struct Client {
/* Must keep this field first — union-cast discriminant */
unsigned int type; /* XDGShell or X11 */
/* HOT — accessed every frame / arrange / focus / resize */
Monitor *mon;
uint32_t tags;
int isfloating;
int isurgent;
int isfullscreen;
int isscratchpad;
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 */
unsigned int bw;
int corner_radius;
float current_scale;
struct wlr_scene_shadow *shadow;
struct wlr_scene_blur *blur;
/* WARM — accessed less frequently */
struct wl_list link;
struct wl_list flink;
union {
struct wlr_xdg_surface *xdg;
struct wlr_xwayland_surface *xwayland;
} surface;
struct wlr_scene_tree *scene;
struct wlr_scene_rect *border_bg; /* single border rect with clipped content hole */
struct wlr_scene_tree *scene_surface;
struct wlr_xdg_toplevel_decoration_v1 *decoration;
/* Per-rule constraints and effects */
bool can_float;
bool can_fullscreen;
ClientRuleEffects rule_effects;
/* COLD — wl_listeners (set up once, rarely touched after) */
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
uint32_t resize; /* configure serial of a pending resize */
} Client;
typedef struct {
/* Must keep this field first — union-cast discriminant */
unsigned int type; /* LayerShell */
/* HOT */
Monitor *mon;
struct wlr_scene_tree *scene;
struct wlr_scene_tree *popups;
struct wlr_scene_layer_surface_v1 *scene_layer;
int mapped;
float current_scale;
struct wlr_layer_surface_v1 *layer_surface;
/* WARM */
struct wl_list link;
/* COLD — wl_listeners */
struct wl_listener destroy;
struct wl_listener unmap;
struct wl_listener surface_commit;
} LayerSurface;
/* Function declarations */
[[nodiscard]] int client_is_x11(Client *c);
struct wlr_surface *client_surface(Client *c);
[[nodiscard]] int toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc, LayerSurface **pl);
void client_activate_surface(struct wlr_surface *s, int activated);
uint32_t client_set_bounds(Client *c, int32_t width, int32_t height);
[[nodiscard]] const char *client_get_appid(Client *c);
void client_get_clip(Client *c, struct wlr_box *clip);
void client_get_geometry(Client *c, struct wlr_box *geom);
[[nodiscard]] Client *client_get_parent(Client *c);
[[nodiscard]] int client_has_children(Client *c);
[[nodiscard]] const char *client_get_title(Client *c);
[[nodiscard]] int client_is_float_type(Client *c);
[[nodiscard]] int client_is_rendered_on_mon(Client *c, Monitor *m);
[[nodiscard]] int client_is_stopped(Client *c);
[[nodiscard]] int client_is_unmanaged(Client *c);
void client_notify_enter(struct wlr_surface *s, struct wlr_keyboard *kb);
void client_send_close(Client *c);
void client_set_border_color(Client *c, const float color[static 4]);
void client_set_fullscreen(Client *c, int fullscreen);
void client_set_scale(struct wlr_surface *s, float scale);
void client_update_scale(Client *c);
uint32_t client_set_size(Client *c, uint32_t width, uint32_t height);
void client_set_tiled(Client *c, uint32_t edges);
void client_set_suspended(Client *c, int suspended);
[[nodiscard]] int client_wants_focus(Client *c);
[[nodiscard]] int client_wants_fullscreen(Client *c);