[digesting_libdecor] refer to border components by slot index instead of by pointer
parent
c2e7631f4c
commit
c4f50c6f6e
|
|
@ -1919,7 +1919,6 @@ static void
|
||||||
ensure_title_bar_surfaces(void){
|
ensure_title_bar_surfaces(void){
|
||||||
GtkStyleContext *context_hdr;
|
GtkStyleContext *context_hdr;
|
||||||
|
|
||||||
ctx.component_slot[COMPONENT_SLOT_HEADER].slot = COMPONENT_SLOT_HEADER;
|
|
||||||
ctx.component_slot[COMPONENT_SLOT_HEADER].opaque = false;
|
ctx.component_slot[COMPONENT_SLOT_HEADER].opaque = false;
|
||||||
ensure_component(&ctx.component_slot[COMPONENT_SLOT_HEADER]);
|
ensure_component(&ctx.component_slot[COMPONENT_SLOT_HEADER]);
|
||||||
|
|
||||||
|
|
@ -1961,7 +1960,7 @@ ensure_title_bar_surfaces(void){
|
||||||
}
|
}
|
||||||
|
|
||||||
static Extent2D
|
static Extent2D
|
||||||
extent2d_from_component_type(enum component_slot slot){
|
extent2d_from_component_slot(enum component_slot slot){
|
||||||
Extent2D result = {0};
|
Extent2D result = {0};
|
||||||
int width = ctx.frame_content_width;
|
int width = ctx.frame_content_width;
|
||||||
int height = ctx.frame_content_height;
|
int height = ctx.frame_content_height;
|
||||||
|
|
@ -2139,34 +2138,29 @@ draw_header_button(cairo_t *cr, cairo_surface_t *surface,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_component_input_region(struct border_component *border_component){
|
set_component_input_region(enum component_slot slot){
|
||||||
if (border_component->slot == COMPONENT_SLOT_SHADOW && ctx.shadow_showing){
|
if (slot == COMPONENT_SLOT_SHADOW && ctx.shadow_showing){
|
||||||
struct wl_region *input_region;
|
struct wl_region *input_region;
|
||||||
Extent2D extent = extent2d_from_component_type(border_component->slot);
|
Extent2D extent = extent2d_from_component_slot(COMPONENT_SLOT_SHADOW);
|
||||||
|
|
||||||
/*
|
|
||||||
* the input region is the outer surface size minus the inner
|
|
||||||
* content size
|
|
||||||
*/
|
|
||||||
input_region = wl_compositor_create_region(ctx.wl_compositor);
|
input_region = wl_compositor_create_region(ctx.wl_compositor);
|
||||||
wl_region_add(input_region, 0, 0, extent.w, extent.h);
|
wl_region_add(input_region, 0, 0, extent.w, extent.h);
|
||||||
wl_region_subtract(input_region, -extent.x, -extent.y, ctx.frame_content_width, ctx.frame_content_height);
|
wl_region_subtract(input_region, -extent.x, -extent.y, ctx.frame_content_width, ctx.frame_content_height);
|
||||||
wl_surface_set_input_region(border_component->wl_surface, input_region);
|
wl_surface_set_input_region(ctx.component_slot[slot].wl_surface, input_region);
|
||||||
wl_region_destroy(input_region);
|
wl_region_destroy(input_region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
draw_border_component(struct border_component *border_component){
|
draw_border_component(enum component_slot slot){
|
||||||
struct buffer *old_buffer;
|
struct buffer *old_buffer;
|
||||||
struct buffer *buffer = 0;
|
struct buffer *buffer = 0;
|
||||||
|
|
||||||
if (border_component->wl_surface != 0){
|
if (slot < COMPONENT_SLOT_COUNT &&
|
||||||
Extent2D extent = extent2d_from_component_type(border_component->slot);
|
ctx.component_slot[slot].wl_surface != 0){
|
||||||
|
Extent2D extent = extent2d_from_component_slot(slot);
|
||||||
|
set_component_input_region(slot);
|
||||||
|
|
||||||
set_component_input_region(border_component);
|
old_buffer = ctx.component_slot[slot].buffer;
|
||||||
|
|
||||||
old_buffer = border_component->buffer;
|
|
||||||
if (old_buffer != 0){
|
if (old_buffer != 0){
|
||||||
if (!old_buffer->in_use &&
|
if (!old_buffer->in_use &&
|
||||||
old_buffer->buffer_width == extent.w &&
|
old_buffer->buffer_width == extent.w &&
|
||||||
|
|
@ -2175,14 +2169,14 @@ draw_border_component(struct border_component *border_component){
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
buffer_free(old_buffer);
|
buffer_free(old_buffer);
|
||||||
border_component->buffer = 0;
|
ctx.component_slot[slot].buffer = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer == 0){
|
if (buffer == 0){
|
||||||
int width = extent.w;
|
int width = extent.w;
|
||||||
int height = extent.h;
|
int height = extent.h;
|
||||||
bool opaque = border_component->opaque;
|
bool opaque = ctx.component_slot[slot].opaque;
|
||||||
|
|
||||||
struct wl_shm_pool *pool;
|
struct wl_shm_pool *pool;
|
||||||
int fd, size, buffer_width, buffer_height, stride;
|
int fd, size, buffer_width, buffer_height, stride;
|
||||||
|
|
@ -2230,7 +2224,7 @@ draw_border_component(struct border_component *border_component){
|
||||||
cairo_t *cr = cairo_create(surface);
|
cairo_t *cr = cairo_create(surface);
|
||||||
cairo_surface_set_device_scale(surface, 1, 1);
|
cairo_surface_set_device_scale(surface, 1, 1);
|
||||||
|
|
||||||
switch (border_component->slot){
|
switch (slot){
|
||||||
default: case COMPONENT_SLOT_NONE: break;
|
default: case COMPONENT_SLOT_NONE: break;
|
||||||
|
|
||||||
case COMPONENT_SLOT_SHADOW: {
|
case COMPONENT_SLOT_SHADOW: {
|
||||||
|
|
@ -2300,14 +2294,17 @@ draw_border_component(struct border_component *border_component){
|
||||||
cairo_surface_destroy(surface);
|
cairo_surface_destroy(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_surface_attach(border_component->wl_surface, buffer->wl_buffer, 0, 0);
|
struct wl_surface *component_surface = ctx.component_slot[slot].wl_surface;
|
||||||
wl_surface_set_buffer_scale(border_component->wl_surface, 1);
|
struct wl_subsurface *component_subsurface = ctx.component_slot[slot].wl_subsurface;
|
||||||
buffer->in_use = true;
|
|
||||||
wl_surface_commit(border_component->wl_surface);
|
|
||||||
wl_surface_damage_buffer(border_component->wl_surface, 0, 0, extent.w, extent.h);
|
|
||||||
wl_subsurface_set_position(border_component->wl_subsurface, extent.x, extent.y);
|
|
||||||
|
|
||||||
border_component->buffer = buffer;
|
wl_surface_attach(component_surface, buffer->wl_buffer, 0, 0);
|
||||||
|
wl_surface_set_buffer_scale(component_surface, 1);
|
||||||
|
buffer->in_use = true;
|
||||||
|
wl_surface_commit(component_surface);
|
||||||
|
wl_surface_damage_buffer(component_surface, 0, 0, extent.w, extent.h);
|
||||||
|
wl_subsurface_set_position(component_subsurface, extent.x, extent.y);
|
||||||
|
|
||||||
|
ctx.component_slot[slot].buffer = buffer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2360,7 +2357,7 @@ draw_title_bar(void){
|
||||||
/* set default height */
|
/* set default height */
|
||||||
gtk_widget_get_preferred_height(ctx.header, 0, &allocation.height);
|
gtk_widget_get_preferred_height(ctx.header, 0, &allocation.height);
|
||||||
gtk_widget_size_allocate(ctx.header, &allocation);
|
gtk_widget_size_allocate(ctx.header, &allocation);
|
||||||
draw_border_component(&ctx.component_slot[COMPONENT_SLOT_HEADER]);
|
draw_border_component(COMPONENT_SLOT_HEADER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2374,10 +2371,9 @@ draw_decoration(void){
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case DECORATION_TYPE_ALL: {
|
case DECORATION_TYPE_ALL: {
|
||||||
ctx.component_slot[COMPONENT_SLOT_SHADOW].slot = COMPONENT_SLOT_SHADOW;
|
|
||||||
ctx.component_slot[COMPONENT_SLOT_SHADOW].opaque = false;
|
ctx.component_slot[COMPONENT_SLOT_SHADOW].opaque = false;
|
||||||
ensure_component(&ctx.component_slot[COMPONENT_SLOT_SHADOW]);
|
ensure_component(&ctx.component_slot[COMPONENT_SLOT_SHADOW]);
|
||||||
draw_border_component(&ctx.component_slot[COMPONENT_SLOT_SHADOW]);
|
draw_border_component(COMPONENT_SLOT_SHADOW);
|
||||||
ctx.shadow_showing = true;
|
ctx.shadow_showing = true;
|
||||||
ensure_title_bar_surfaces();
|
ensure_title_bar_surfaces();
|
||||||
draw_title_bar();
|
draw_title_bar();
|
||||||
|
|
@ -2457,7 +2453,6 @@ border_size_from_window_state(enum libdecor_window_state window_state){
|
||||||
case DECORATION_TYPE_NONE: break;
|
case DECORATION_TYPE_NONE: break;
|
||||||
|
|
||||||
case DECORATION_TYPE_ALL: {
|
case DECORATION_TYPE_ALL: {
|
||||||
ctx.component_slot[COMPONENT_SLOT_SHADOW].slot = COMPONENT_SLOT_SHADOW;
|
|
||||||
ctx.component_slot[COMPONENT_SLOT_SHADOW].opaque = false;
|
ctx.component_slot[COMPONENT_SLOT_SHADOW].opaque = false;
|
||||||
ensure_component(&ctx.component_slot[COMPONENT_SLOT_SHADOW]);
|
ensure_component(&ctx.component_slot[COMPONENT_SLOT_SHADOW]);
|
||||||
} G_GNUC_FALLTHROUGH;
|
} G_GNUC_FALLTHROUGH;
|
||||||
|
|
|
||||||
|
|
@ -163,8 +163,20 @@ enum component_slot {
|
||||||
COMPONENT_SLOT_COUNT
|
COMPONENT_SLOT_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct buffer {
|
||||||
|
struct wl_buffer *wl_buffer;
|
||||||
|
bool in_use;
|
||||||
|
bool is_detached;
|
||||||
|
|
||||||
|
void *data;
|
||||||
|
size_t data_size;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int buffer_width;
|
||||||
|
int buffer_height;
|
||||||
|
};
|
||||||
|
|
||||||
struct border_component {
|
struct border_component {
|
||||||
enum component_slot slot;
|
|
||||||
struct wl_surface *wl_surface;
|
struct wl_surface *wl_surface;
|
||||||
struct wl_subsurface *wl_subsurface;
|
struct wl_subsurface *wl_subsurface;
|
||||||
struct buffer *buffer;
|
struct buffer *buffer;
|
||||||
|
|
@ -238,19 +250,6 @@ struct seat {
|
||||||
struct wl_list link;
|
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 buffer_width;
|
|
||||||
int buffer_height;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum titlebar_gesture {
|
enum titlebar_gesture {
|
||||||
TITLEBAR_GESTURE_DOUBLE_CLICK,
|
TITLEBAR_GESTURE_DOUBLE_CLICK,
|
||||||
TITLEBAR_GESTURE_MIDDLE_CLICK,
|
TITLEBAR_GESTURE_MIDDLE_CLICK,
|
||||||
|
|
@ -302,7 +301,7 @@ static struct wl_cursor* wl_cursor_from_pos(int x, int y);
|
||||||
static void draw_decoration(void);
|
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_header_button(cairo_t *cr, cairo_surface_t *surface, enum header_element button_type);
|
||||||
static void buffer_free(struct buffer *buffer);
|
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 bool own_proxy(void *proxy);
|
||||||
static enum component_slot component_slot_from_wl_surface(const struct wl_surface *surface);
|
static enum component_slot component_slot_from_wl_surface(const struct wl_surface *surface);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue