[digesting_libdecor] replace with

main
Allen Webster 2026-02-28 12:23:13 -08:00
parent 3cbbc93591
commit c2e7631f4c
2 changed files with 25 additions and 37 deletions

View File

@ -100,20 +100,20 @@ pointer_enter(void *data, struct wl_pointer *wl_pointer, uint32_t serial,
seat->pointer_y = wl_fixed_to_int(y); seat->pointer_y = wl_fixed_to_int(y);
seat->serial = serial; seat->serial = serial;
seat->pointer_focus = surface; seat->pointer_focus = surface;
ctx.active = component_slot_from_wl_surface(surface);
if (own_proxy(surface)){ if (own_proxy(surface)){
ctx.active = component_slot_from_wl_surface(surface);
if (ctx.active != 0){ if (ctx.active != 0){
draw_decoration(); draw_decoration();
wl_surface_commit(ctx.wl_surface); wl_surface_commit(ctx.wl_surface);
} }
update_local_cursor(seat);
seat->current_cursor = wl_cursor_from_pos(seat->pointer_x, seat->pointer_y);
if (seat->current_cursor != 0){ if (seat->current_cursor != 0){
struct wl_cursor_image *image = seat->current_cursor->images[0]; struct wl_cursor_image *image = seat->current_cursor->images[0];
struct wl_buffer *buffer = wl_cursor_image_get_buffer(image); struct wl_buffer *buffer = wl_cursor_image_get_buffer(image);
wl_surface_attach(seat->cursor_surface, buffer, 0, 0);
wl_surface_set_buffer_scale(seat->cursor_surface, 1); wl_surface_set_buffer_scale(seat->cursor_surface, 1);
wl_surface_attach(seat->cursor_surface, buffer, 0, 0);
wl_surface_damage_buffer(seat->cursor_surface, 0, 0, image->width, image->height); wl_surface_damage_buffer(seat->cursor_surface, 0, 0, image->width, image->height);
wl_surface_commit(seat->cursor_surface); wl_surface_commit(seat->cursor_surface);
wl_pointer_set_cursor(seat->wl_pointer, seat->serial, seat->cursor_surface, image->hotspot_x, image->hotspot_y); wl_pointer_set_cursor(seat->wl_pointer, seat->serial, seat->cursor_surface, image->hotspot_x, image->hotspot_y);
@ -136,7 +136,7 @@ pointer_leave(void *data, struct wl_pointer *wl_pointer, uint32_t serial, struct
ctx.hdr_focus.type = HEADER_NONE; ctx.hdr_focus.type = HEADER_NONE;
draw_decoration(); draw_decoration();
wl_surface_commit(ctx.wl_surface); wl_surface_commit(ctx.wl_surface);
update_local_cursor(seat); seat->current_cursor = wl_cursor_from_pos(seat->pointer_x, seat->pointer_y);
} }
} }
@ -146,10 +146,10 @@ pointer_motion(void *data, struct wl_pointer *wl_pointer, uint32_t time,
struct seat *seat = data; struct seat *seat = data;
struct header_element_data new_focus; struct header_element_data new_focus;
if (seat->pointer_focus != 0 && own_proxy(seat->pointer_focus)){ if (own_proxy(seat->pointer_focus)){
seat->pointer_x = wl_fixed_to_int(surface_x); seat->pointer_x = wl_fixed_to_int(surface_x);
seat->pointer_y = wl_fixed_to_int(surface_y); seat->pointer_y = wl_fixed_to_int(surface_y);
if (update_local_cursor(seat)){ seat->current_cursor = wl_cursor_from_pos(seat->pointer_x, seat->pointer_y);
if (seat->current_cursor != 0){ if (seat->current_cursor != 0){
struct wl_cursor_image *image = seat->current_cursor->images[0]; struct wl_cursor_image *image = seat->current_cursor->images[0];
struct wl_buffer *buffer = wl_cursor_image_get_buffer(image); struct wl_buffer *buffer = wl_cursor_image_get_buffer(image);
@ -159,7 +159,6 @@ pointer_motion(void *data, struct wl_pointer *wl_pointer, uint32_t time,
wl_surface_commit(seat->cursor_surface); wl_surface_commit(seat->cursor_surface);
wl_pointer_set_cursor(seat->wl_pointer, seat->serial, seat->cursor_surface, image->hotspot_x, image->hotspot_y); wl_pointer_set_cursor(seat->wl_pointer, seat->serial, seat->cursor_surface, image->hotspot_x, image->hotspot_y);
} }
}
/* avoid warnings after decoration has been turned off */ /* avoid warnings after decoration has been turned off */
if (!GTK_IS_WIDGET(ctx.header) || ctx.active != COMPONENT_SLOT_HEADER){ if (!GTK_IS_WIDGET(ctx.header) || ctx.active != COMPONENT_SLOT_HEADER){
@ -193,7 +192,7 @@ static void
pointer_button(void *data, struct wl_pointer *wl_pointer, uint32_t serial, pointer_button(void *data, struct wl_pointer *wl_pointer, uint32_t serial,
uint32_t time, uint32_t button, uint32_t state){ uint32_t time, uint32_t button, uint32_t state){
struct seat *seat = data; struct seat *seat = data;
if (seat->pointer_focus && own_proxy(seat->pointer_focus)){ if (own_proxy(seat->pointer_focus)){
switch (ctx.active){ switch (ctx.active){
case COMPONENT_SLOT_SHADOW: { case COMPONENT_SLOT_SHADOW: {
enum libdecor_resize_edge edge = edge_from_pos(seat->pointer_x, seat->pointer_y); enum libdecor_resize_edge edge = edge_from_pos(seat->pointer_x, seat->pointer_y);
@ -2500,28 +2499,17 @@ edge_from_pos(int x, int y){
return(result); return(result);
} }
static bool static struct wl_cursor *
update_local_cursor(struct seat *seat){ wl_cursor_from_pos(int x, int y){
struct wl_cursor *wl_cursor = ctx.cursor_left_ptr; struct wl_cursor *result = ctx.cursor_left_ptr;
if (own_proxy(seat->pointer_focus)){
if (ctx.active != 0){
if (ctx.active == COMPONENT_SLOT_SHADOW && if (ctx.active == COMPONENT_SLOT_SHADOW &&
(ctx.frame_capabilities & LIBDECOR_ACTION_RESIZE)){ (ctx.frame_capabilities & LIBDECOR_ACTION_RESIZE)){
enum libdecor_resize_edge edge = edge_from_pos(seat->pointer_x, seat->pointer_y); enum libdecor_resize_edge edge = edge_from_pos(x, y);
if (edge != LIBDECOR_RESIZE_EDGE_NONE){ if (edge != LIBDECOR_RESIZE_EDGE_NONE){
wl_cursor = ctx.cursors[edge - 1]; result = ctx.cursors[edge - 1];
} }
} }
} return(result);
}
bool cursor_updated = false;
if (seat->current_cursor != wl_cursor) {
seat->current_cursor = wl_cursor;
cursor_updated = true;
}
return(cursor_updated);
} }

View File

@ -298,7 +298,7 @@ static void libdecor_plugin_gtk_frame_free(void);
static void libdecor_plugin_gtk_frame_commit(void); static void libdecor_plugin_gtk_frame_commit(void);
static Bounds2D border_size_from_window_state(enum libdecor_window_state window_state); static Bounds2D 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_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);