Compare commits

...

13 Commits

Author SHA1 Message Date
Allen Webster 4f8388f544 merge? 2026-02-28 03:01:43 -08:00
Allen Webster 710f72eeeb [digesting_libdecor] delete dead code, eliminate some more easily reducible functions 2026-02-28 02:56:34 -08:00
Allen Webster 79cc95b501 [digesting_libdecor] remove wl_surface listeners 2026-02-28 02:30:35 -08:00
Allen Webster 8b66e63249 [digesting_libdecor] remove 'cursor_outputs' 2026-02-28 02:14:47 -08:00
Allen Webster 23a607fa56 [digesting_libdecor] remove wl_callback and init_done 2026-02-27 21:22:14 -08:00
Allen Webster 913a5eb607 [digesting_libdecor] remove return-spaghetti from dispatch logic, cleanup pass over dispatch logic 2026-02-27 21:19:25 -08:00
Allen Webster 4c70db56b4 [digesting_libdecor] kill popup helper features 2026-02-27 19:14:52 -08:00
Allen Webster e27aa9edbe [digesting_libdecor] eliminate a bunch of return-spaghetti, eliminate a bunch of reducible functions 2026-02-27 19:12:48 -08:00
Allen Webster e556f5aa26 [digesting_libdecor] eliminate frame poitner pass throughs everywhere 2026-02-27 14:08:10 -08:00
Allen Webster 7e78a59c43 [digesting_libdecor] move all frame fields into main context 2026-02-27 13:44:53 -08:00
Allen Webster 0a2e383fcf [digesting_libdecor] eliminate the 'visible frames' list, and gtk_link field of frame 2026-02-27 11:41:59 -08:00
Allen Webster 85814a2bca [digesting_libdecor] remove frame's refcount 2026-02-27 10:38:36 -08:00
Allen Webster 3ba29693f4 [digesting_libdecor] collapse new/free states and just pass W,H to frame_commit 2026-02-27 09:28:56 -08:00
2 changed files with 1550 additions and 2847 deletions

File diff suppressed because it is too large Load Diff

View File

@ -50,6 +50,15 @@
#define STREQL(a,b) (((a)==0 && (b)==0) || \ #define STREQL(a,b) (((a)==0 && (b)==0) || \
((a)!=0 && (b)!=0 && strcmp((a),(b))==0)) ((a)!=0 && (b)!=0 && strcmp((a),(b))==0))
// mine
typedef struct Extent2D{
int x;
int y;
int w;
int h;
} Extent2D;
// libdecor.h // libdecor.h
struct libdecor_configuration; struct libdecor_configuration;
@ -77,6 +86,13 @@ enum libdecor_window_state {
LIBDECOR_WINDOW_STATE_CONSTRAINED_BOTTOM = 1 << 12, LIBDECOR_WINDOW_STATE_CONSTRAINED_BOTTOM = 1 << 12,
}; };
#define LIBDECOR_WINDOW_STATE_NON_FLOATING (LIBDECOR_WINDOW_STATE_MAXIMIZED |\
LIBDECOR_WINDOW_STATE_FULLSCREEN |\
LIBDECOR_WINDOW_STATE_TILED_LEFT |\
LIBDECOR_WINDOW_STATE_TILED_RIGHT |\
LIBDECOR_WINDOW_STATE_TILED_TOP |\
LIBDECOR_WINDOW_STATE_TILED_BOTTOM)
enum libdecor_resize_edge { enum libdecor_resize_edge {
LIBDECOR_RESIZE_EDGE_NONE, LIBDECOR_RESIZE_EDGE_NONE,
LIBDECOR_RESIZE_EDGE_TOP, LIBDECOR_RESIZE_EDGE_TOP,
@ -155,94 +171,12 @@ struct border_component {
struct wl_subsurface *wl_subsurface; struct wl_subsurface *wl_subsurface;
struct buffer *buffer; struct buffer *buffer;
bool opaque; bool opaque;
struct wl_list output_list;
int scale; int scale;
struct wl_list child_components; /* border_component::link */ struct wl_list child_components; /* border_component::link */
struct wl_list link; /* border_component::child_components */ struct wl_list link; /* border_component::child_components */
}; };
struct libdecor_frame {
//struct libdecor_frame;
struct wl_list frame_link;
//struct libdecor_frame_private;
int ref_count;
struct wl_surface *wl_surface;
void *user_data;
struct xdg_surface *xdg_surface;
struct xdg_toplevel *xdg_toplevel;
struct zxdg_toplevel_decoration_v1 *toplevel_decoration;
bool pending_map;
char *app_id;
char *title;
struct libdecor_limits content_limits;
struct xdg_toplevel *parent;
struct libdecor_configuration *pending_configuration;
int frame_content_width;
int frame_content_height;
enum libdecor_window_state frame_window_state;
bool has_decoration_mode;
enum zxdg_toplevel_decoration_v1_mode decoration_mode;
enum libdecor_capabilities frame_capabilities;
enum libdecor_wm_capabilities wm_capabilities;
/* original limits for interactive resize */
struct libdecor_limits interactive_limits;
bool visible;
//struct libdecor_frame_gtk;
int gtk_content_width;
int gtk_content_height;
enum libdecor_window_state gtk_window_state;
enum decoration_type decoration_type;
enum libdecor_capabilities gtk_capabilities;
struct border_component *active;
struct border_component *touch_active;
struct border_component *focus;
struct border_component *grab;
bool shadow_showing;
struct border_component shadow;
GtkWidget *window; /* offscreen window for rendering */
GtkWidget *header; /* header bar with widgets */
struct border_component headerbar;
struct header_element_data hdr_focus;
/* store pre-processed shadow tile */
cairo_surface_t *shadow_blur;
struct wl_list gtk_link;
struct {
enum titlebar_gesture_state state;
int button_pressed_count;
uint32_t first_pressed_button;
uint32_t first_pressed_time;
double pressed_x;
double pressed_y;
uint32_t pressed_serial;
} titlebar_gesture;
};
// #include "libdecor.c" // #include "libdecor.c"
struct libdecor_state { struct libdecor_state {
@ -295,7 +229,6 @@ struct seat {
struct wl_surface *cursor_surface; struct wl_surface *cursor_surface;
struct wl_cursor *current_cursor; struct wl_cursor *current_cursor;
int cursor_scale; int cursor_scale;
struct wl_list cursor_outputs;
struct wl_cursor_theme *cursor_theme; struct wl_cursor_theme *cursor_theme;
/* cursors for resize edges and corners */ /* cursors for resize edges and corners */
@ -305,7 +238,8 @@ struct seat {
struct wl_surface *pointer_focus; struct wl_surface *pointer_focus;
struct wl_surface *touch_focus; struct wl_surface *touch_focus;
int pointer_x, pointer_y; int pointer_x;
int pointer_y;
uint32_t touch_down_time_stamp; uint32_t touch_down_time_stamp;
@ -316,14 +250,6 @@ struct seat {
struct wl_list link; struct wl_list link;
}; };
struct output {
struct wl_output *wl_output;
uint32_t id;
int scale;
struct wl_list link;
};
struct buffer { struct buffer {
struct wl_buffer *wl_buffer; struct wl_buffer *wl_buffer;
bool in_use; bool in_use;
@ -338,16 +264,6 @@ struct buffer {
int buffer_height; int buffer_height;
}; };
struct surface_output {
struct output *output;
struct wl_list link;
};
struct cursor_output {
struct output *output;
struct wl_list link;
};
enum titlebar_gesture { enum titlebar_gesture {
TITLEBAR_GESTURE_DOUBLE_CLICK, TITLEBAR_GESTURE_DOUBLE_CLICK,
TITLEBAR_GESTURE_MIDDLE_CLICK, TITLEBAR_GESTURE_MIDDLE_CLICK,
@ -356,65 +272,20 @@ enum titlebar_gesture {
// libdecor.h // libdecor.h
void libdecor_frame_ref(struct libdecor_frame *frame); void libdecor_frame_set_visibility(bool visible);
void libdecor_frame_unref(struct libdecor_frame *frame); void libdecor_frame_show_window_menu(struct wl_seat *wl_seat, uint32_t serial, int x, int y);
void libdecor_frame_set_visibility(struct libdecor_frame *frame,
bool visible);
void libdecor_frame_set_title(struct libdecor_frame *frame, void libdecor_frame_translate_coordinate(int surface_x, int surface_y, int *frame_x, int *frame_y);
const char *title);
void libdecor_frame_set_app_id(struct libdecor_frame *frame,
const char *app_id);
void libdecor_frame_show_window_menu(struct libdecor_frame *frame,
struct wl_seat *wl_seat,
uint32_t serial,
int x,
int y);
void libdecor_frame_popup_grab(struct libdecor_frame *frame, void libdecor_frame_resize(struct wl_seat *wl_seat, uint32_t serial, enum libdecor_resize_edge edge);
const char *seat_name); void libdecor_frame_move(struct wl_seat *wl_seat, uint32_t serial);
void libdecor_frame_popup_ungrab(struct libdecor_frame *frame, void libdecor_frame_commit(int w, int h, struct libdecor_configuration *configuration);
const char *seat_name); void libdecor_frame_set_fullscreen(struct wl_output *output);
void libdecor_frame_translate_coordinate(struct libdecor_frame *frame, void libdecor_frame_unset_fullscreen(void);
int surface_x, int surface_y, void libdecor_frame_map(void);
int *frame_x, int *frame_y);
void libdecor_frame_resize(struct libdecor_frame *frame,
struct wl_seat *wl_seat,
uint32_t serial,
enum libdecor_resize_edge edge);
void libdecor_frame_move(struct libdecor_frame *frame,
struct wl_seat *wl_seat,
uint32_t serial);
void libdecor_frame_commit(struct libdecor_frame *frame,
int w, int h,
struct libdecor_configuration *configuration);
void libdecor_frame_set_minimized(struct libdecor_frame *frame);
void libdecor_frame_set_maximized(struct libdecor_frame *frame);
void libdecor_frame_unset_maximized(struct libdecor_frame *frame);
void libdecor_frame_set_fullscreen(struct libdecor_frame *frame,
struct wl_output *output);
void libdecor_frame_unset_fullscreen(struct libdecor_frame *frame);
bool libdecor_frame_is_floating(struct libdecor_frame *frame);
void libdecor_frame_close(struct libdecor_frame *frame);
void libdecor_frame_map(struct libdecor_frame *frame);
bool libdecor_configuration_get_content_size(struct libdecor_configuration *configuration, bool libdecor_configuration_get_content_size(struct libdecor_configuration *configuration, int *width, int *height);
struct libdecor_frame *frame,
int *width,
int *height);
bool libdecor_configuration_get_window_state(struct libdecor_configuration *configuration,
enum libdecor_window_state *window_state);
int libdecor_dispatch(int timeout);
// libdecor-plugin.h
int libdecor_state_get_content_width(struct libdecor_state *state);
int libdecor_state_get_content_height(struct libdecor_state *state);
enum libdecor_window_state libdecor_state_get_window_state(struct libdecor_state *state);
// #include "libdecor-cairo-blur.h" // #include "libdecor-cairo-blur.h"
@ -433,32 +304,32 @@ int libdecor_os_create_anonymous_file(off_t size);
// #include "libdecor.c" // #include "libdecor.c"
static void init_shell_surface(struct libdecor_frame *frame); static void init_shell_surface(void);
static void set_capabilities(struct libdecor_frame *frame, const enum libdecor_capabilities new_capabilities); static void do_map(void);
static void do_map(struct libdecor_frame *frame); // #include "plugins/gtk/libdecor-gtk.c"
//#include "plugins/gtk/libdecor-gtk.c"
static void init_wl_output( uint32_t id, uint32_t version);
static void output_removed(struct output *output);
static const char *libdecor_gtk_proxy_tag = "libdecor-gtk"; static const char *libdecor_gtk_proxy_tag = "libdecor-gtk";
static int libdecor_plugin_gtk_get_fd(void); static void libdecor_plugin_gtk_frame_free(void);
static int libdecor_plugin_gtk_get_fd(void); static void libdecor_plugin_gtk_frame_commit(struct libdecor_state *state, struct libdecor_configuration *configuration);
static int libdecor_plugin_gtk_dispatch(int timeout); static void libdecor_plugin_gtk_frame_get_border_size(enum libdecor_window_state window_state, int *left, int *right, int *top, int *bottom);
static void libdecor_plugin_gtk_set_handle_application_cursor(bool handle_cursor);
static void libdecor_plugin_gtk_frame_free(struct libdecor_frame *frame);
static void libdecor_plugin_gtk_frame_commit(struct libdecor_frame *frame, struct libdecor_state *state, struct libdecor_configuration *configuration);
static void libdecor_plugin_gtk_frame_popup_grab(struct libdecor_frame *frame, const char *seat_name);
static void libdecor_plugin_gtk_frame_popup_ungrab(struct libdecor_frame *frame, const char *seat_name);
static bool libdecor_plugin_gtk_frame_get_border_size(struct libdecor_frame *frame, struct libdecor_configuration *configuration, int *left, int *right, int *top, int *bottom);
static void draw_decoration(struct libdecor_frame *frame); static bool update_local_cursor(struct seat *seat);
static void draw_decoration(void);
static void draw_header_button(cairo_t *cr, cairo_surface_t *surface, enum header_element button_type);
static void redraw_scale(struct border_component *cmpnt);
static void buffer_free(struct buffer *buffer);
static void draw_border_component(struct border_component *border_component);
static bool own_proxy(void *proxy);
static struct border_component * border_component_from_wl_surface(const struct wl_surface *surface);
static struct header_element_data get_header_focus(const GtkHeaderBar *header_bar, const int x, const int y);
static void draw_title_bar(void);
enum libdecor_resize_edge component_edge(const struct border_component *cmpnt, const int pointer_x, const int pointer_y, const int margin);
static void toggle_maximized(void);
static void update_touch_focus(struct seat *seat, wl_fixed_t x, wl_fixed_t y);
// digesting_libdecor // digesting_libdecor
@ -476,23 +347,20 @@ typedef struct Ctx{
struct wl_shm *wl_shm; struct wl_shm *wl_shm;
struct xdg_wm_base *xdg_wm_base; struct xdg_wm_base *xdg_wm_base;
struct zxdg_decoration_manager_v1 *decoration_manager; struct zxdg_decoration_manager_v1 *decoration_manager;
struct wl_callback *wl_callback;
struct wl_list visible_frame_list;
struct wl_list seat_list; struct wl_list seat_list;
struct wl_list output_list;
bool init_done;
bool has_error; bool has_error;
bool has_argb; bool has_argb;
int double_click_time_ms; int double_click_time_ms;
int drag_threshold; int drag_threshold;
bool handle_cursor;
/* window */ /* window */
struct wl_surface *wl_surface; struct wl_surface *wl_surface;
struct libdecor_frame *frame; struct xdg_surface *xdg_surface;
struct xdg_toplevel *xdg_toplevel;
struct zxdg_toplevel_decoration_v1 *toplevel_decoration;
struct wl_egl_window *wl_egl_window; struct wl_egl_window *wl_egl_window;
int configured; int configured;
int w; int w;
@ -504,6 +372,64 @@ typedef struct Ctx{
int has_cached_config; int has_cached_config;
struct libdecor_configuration cached_config; struct libdecor_configuration cached_config;
//struct libdecor_frame_private;
char *title;
struct libdecor_limits content_limits;
struct xdg_toplevel *parent;
struct libdecor_configuration *pending_configuration;
int frame_content_width;
int frame_content_height;
enum libdecor_window_state frame_window_state;
bool has_decoration_mode;
enum zxdg_toplevel_decoration_v1_mode decoration_mode;
enum libdecor_capabilities frame_capabilities;
enum libdecor_wm_capabilities wm_capabilities;
/* original limits for interactive resize */
struct libdecor_limits interactive_limits;
bool visible;
//struct libdecor_frame_gtk;
int gtk_content_width;
int gtk_content_height;
enum libdecor_window_state gtk_window_state;
enum decoration_type decoration_type;
enum libdecor_capabilities gtk_capabilities;
struct border_component *active;
struct border_component *touch_active;
struct border_component *focus;
struct border_component *grab;
bool shadow_showing;
struct border_component shadow;
GtkWidget *window; /* offscreen window for rendering */
GtkWidget *header; /* header bar with widgets */
struct border_component headerbar;
struct header_element_data hdr_focus;
/* store pre-processed shadow tile */
cairo_surface_t *shadow_blur;
struct {
enum titlebar_gesture_state state;
int button_pressed_count;
uint32_t first_pressed_button;
uint32_t first_pressed_time;
double pressed_x;
double pressed_y;
uint32_t pressed_serial;
} titlebar_gesture;
} Ctx; } Ctx;
#endif //DIGESTING_LIBDECOR_H #endif //DIGESTING_LIBDECOR_H