Files
peachwm/include/client.h
T
huntedbytheirs fb0f49e861 perf(wave1): reduce Config caps, reorder Client/Monitor for cache
Wave 1 changes:
- Reduce CFG_MAX_KEYBINDS 256→128, CFG_MAX_STRLEN 256→64, CFG_MAX_ARGS 16→8
  → saves ~2.5 MB BSS from Config struct
- Add truncation warnings to config_load when keybind/button/scroll limit reached
- Reorder Client struct: HOT fields (type, mon, tags, floating flags, geom) in first
  cache line, COLD fields (wl_listeners) at end — saves cache misses in arrange()
- Reorder LayerSurface struct similarly
- Split Monitor into Monitor/MonitorCold: hot fields (~120B) stay inline, cold layout
  state lazily allocated on first dwindle/master use
- All cold-field accesses through m->cold-> indirection
- cleanupmon frees m->cold
- Zero-warning build with clang -Werror -Wpedantic
2026-07-02 23:35:37 -04:00

120 lines
3.9 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 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;
struct wlr_scene_shadow *shadow;
/* 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;
/* 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;
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);
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);