Compare commits

..

7 Commits

2 changed files with 364 additions and 622 deletions

File diff suppressed because it is too large Load Diff

View File

@ -59,6 +59,11 @@ typedef struct Extent2D{
int h;
} Extent2D;
typedef struct Sides2D{
int x[2];
int y[2];
} Sides2D;
// libdecor.h
struct libdecor_configuration;
@ -122,13 +127,6 @@ 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 */
@ -148,7 +146,6 @@ 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;
};
@ -159,22 +156,23 @@ enum decoration_type {
DECORATION_TYPE_TITLE_ONLY
};
enum component {
NONE = 0,
SHADOW,
HEADER,
enum component_slot {
COMPONENT_SLOT_NONE,
COMPONENT_SLOT_SHADOW,
COMPONENT_SLOT_HEADER,
COMPONENT_SLOT_COUNT
};
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_list child_components; /* border_component::link */
struct wl_list link; /* border_component::child_components */
struct wl_buffer *wl_buffer;
void *data;
size_t data_size;
int width;
int height;
};
// #include "libdecor.c"
@ -228,12 +226,6 @@ 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;
@ -250,20 +242,6 @@ 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,
@ -275,14 +253,9 @@ 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);
@ -313,24 +286,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(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 void libdecor_plugin_gtk_frame_commit(void);
static Sides2D border_size_from_window_state(enum libdecor_window_state window_state);
static bool update_local_cursor(struct seat *seat);
static struct wl_cursor* wl_cursor_from_pos(int x, int y);
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 void draw_border_component(enum component_slot slot);
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 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 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 enum libdecor_resize_edge edge_from_pos(int x, int y);
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{
@ -348,6 +321,10 @@ 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;
@ -375,7 +352,7 @@ typedef struct Ctx{
//struct libdecor_frame_private;
char *title;
struct libdecor_limits content_limits;
Sides2D size_bounds;
struct xdg_toplevel *parent;
struct libdecor_configuration *pending_configuration;
@ -391,8 +368,6 @@ 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;
@ -405,20 +380,17 @@ typedef struct Ctx{
enum libdecor_capabilities gtk_capabilities;
struct border_component *active;
struct border_component *touch_active;
struct border_component *focus;
struct border_component *grab;
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];
bool shadow_showing;
struct border_component shadow;
GtkWidget *window; /* offscreen window for rendering */
GtkWidget *header; /* header bar with widgets */
struct border_component headerbar;
GtkWidget *window;
GtkWidget *header;
struct header_element_data hdr_focus;
/* store pre-processed shadow tile */
cairo_surface_t *shadow_blur;
struct {
@ -426,9 +398,9 @@ typedef struct Ctx{
int button_pressed_count;
uint32_t first_pressed_button;
uint32_t first_pressed_time;
double pressed_x;
double pressed_y;
uint32_t pressed_serial;
int pressed_x;
int pressed_y;
uint32_t serial;
} titlebar_gesture;
} Ctx;