Compare commits

..

No commits in common. "abac463a702fd0be3b07526d3aa003ff12f6ba6e" and "4f8388f544e69673a949ee1d1180a1a384b62822" have entirely different histories.

2 changed files with 623 additions and 365 deletions

File diff suppressed because it is too large Load Diff

View File

@ -59,11 +59,6 @@ typedef struct Extent2D{
int h;
} Extent2D;
typedef struct Sides2D{
int x[2];
int y[2];
} Sides2D;
// libdecor.h
struct libdecor_configuration;
@ -127,6 +122,13 @@ enum libdecor_wm_capabilities {
// libdecor-plugin.h
struct libdecor_limits {
int min_width;
int min_height;
int max_width;
int max_height;
};
enum header_element {
HEADER_NONE,
HEADER_FULL, /* entire header bar */
@ -146,6 +148,7 @@ enum titlebar_gesture_state {
struct header_element_data {
const char *name;
enum header_element type;
/* pointer to button or NULL if not found*/
GtkWidget *widget;
GtkStateFlags state;
};
@ -156,23 +159,22 @@ enum decoration_type {
DECORATION_TYPE_TITLE_ONLY
};
enum component_slot {
COMPONENT_SLOT_NONE,
COMPONENT_SLOT_SHADOW,
COMPONENT_SLOT_HEADER,
COMPONENT_SLOT_COUNT
enum component {
NONE = 0,
SHADOW,
HEADER,
};
struct border_component {
enum component type;
struct wl_surface *wl_surface;
struct wl_subsurface *wl_subsurface;
struct buffer *buffer;
bool opaque;
int scale;
struct wl_buffer *wl_buffer;
void *data;
size_t data_size;
int width;
int height;
struct wl_list child_components; /* border_component::link */
struct wl_list link; /* border_component::child_components */
};
// #include "libdecor.c"
@ -226,6 +228,12 @@ struct seat {
struct wl_surface *cursor_surface;
struct wl_cursor *current_cursor;
int cursor_scale;
struct wl_cursor_theme *cursor_theme;
/* cursors for resize edges and corners */
struct wl_cursor *cursors[ARRAY_LENGTH(cursor_names)];
struct wl_cursor *cursor_left_ptr;
struct wl_surface *pointer_focus;
struct wl_surface *touch_focus;
@ -242,6 +250,20 @@ struct seat {
struct wl_list link;
};
struct buffer {
struct wl_buffer *wl_buffer;
bool in_use;
bool is_detached;
void *data;
size_t data_size;
int width;
int height;
int scale;
int buffer_width;
int buffer_height;
};
enum titlebar_gesture {
TITLEBAR_GESTURE_DOUBLE_CLICK,
TITLEBAR_GESTURE_MIDDLE_CLICK,
@ -253,9 +275,14 @@ enum titlebar_gesture {
void libdecor_frame_set_visibility(bool visible);
void libdecor_frame_show_window_menu(struct wl_seat *wl_seat, uint32_t serial, int x, int y);
void libdecor_frame_translate_coordinate(int surface_x, int surface_y, int *frame_x, int *frame_y);
void libdecor_frame_resize(struct wl_seat *wl_seat, uint32_t serial, enum libdecor_resize_edge edge);
void libdecor_frame_move(struct wl_seat *wl_seat, uint32_t serial);
void libdecor_frame_commit(int w, int h, struct libdecor_configuration *configuration);
void libdecor_frame_set_fullscreen(struct wl_output *output);
void libdecor_frame_unset_fullscreen(void);
void libdecor_frame_map(void);
bool libdecor_configuration_get_content_size(struct libdecor_configuration *configuration, int *width, int *height);
@ -286,24 +313,24 @@ static void do_map(void);
static const char *libdecor_gtk_proxy_tag = "libdecor-gtk";
static void libdecor_plugin_gtk_frame_free(void);
static void libdecor_plugin_gtk_frame_commit(void);
static Sides2D border_size_from_window_state(enum libdecor_window_state window_state);
static void libdecor_plugin_gtk_frame_commit(struct libdecor_state *state, struct libdecor_configuration *configuration);
static void libdecor_plugin_gtk_frame_get_border_size(enum libdecor_window_state window_state, int *left, int *right, int *top, int *bottom);
static struct wl_cursor* wl_cursor_from_pos(int x, int y);
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 draw_border_component(enum component_slot slot);
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 enum component_slot component_slot_from_wl_surface(const struct wl_surface *surface);
static struct header_element_data get_header_focus(const GtkHeaderBar *header_bar, int x, int y);
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);
static enum libdecor_resize_edge edge_from_pos(int x, int y);
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);
static enum xdg_toplevel_resize_edge xdg_edge_from_edge(enum libdecor_resize_edge edge);
// digesting_libdecor
typedef struct Ctx{
@ -321,10 +348,6 @@ typedef struct Ctx{
struct xdg_wm_base *xdg_wm_base;
struct zxdg_decoration_manager_v1 *decoration_manager;
struct wl_cursor_theme *cursor_theme;
struct wl_cursor *cursors[ARRAY_LENGTH(cursor_names)];
struct wl_cursor *cursor_left_ptr;
struct wl_list seat_list;
bool has_error;
@ -352,7 +375,7 @@ typedef struct Ctx{
//struct libdecor_frame_private;
char *title;
Sides2D size_bounds;
struct libdecor_limits content_limits;
struct xdg_toplevel *parent;
struct libdecor_configuration *pending_configuration;
@ -368,6 +391,8 @@ typedef struct Ctx{
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;
@ -380,17 +405,20 @@ typedef struct Ctx{
enum libdecor_capabilities gtk_capabilities;
enum component_slot active;
enum component_slot touch_active;
enum component_slot focus;
enum component_slot grab;
struct border_component component_slot[COMPONENT_SLOT_COUNT];
struct border_component *active;
struct border_component *touch_active;
struct border_component *focus;
struct border_component *grab;
bool shadow_showing;
GtkWidget *window;
GtkWidget *header;
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 {
@ -398,9 +426,9 @@ typedef struct Ctx{
int button_pressed_count;
uint32_t first_pressed_button;
uint32_t first_pressed_time;
int pressed_x;
int pressed_y;
uint32_t serial;
double pressed_x;
double pressed_y;
uint32_t pressed_serial;
} titlebar_gesture;
} Ctx;