[digesting_libdecor] lift some deferred init into main init, move unnecessary per-seat cursor theme to main context
parent
1c78761080
commit
3cbbc93591
|
|
@ -96,9 +96,6 @@ pointer_enter(void *data, struct wl_pointer *wl_pointer, uint32_t serial,
|
||||||
struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y){
|
struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y){
|
||||||
struct seat *seat = data;
|
struct seat *seat = data;
|
||||||
|
|
||||||
if (seat->cursor_surface == 0){
|
|
||||||
seat->cursor_surface = wl_compositor_create_surface(ctx.wl_compositor);
|
|
||||||
}
|
|
||||||
seat->pointer_x = wl_fixed_to_int(x);
|
seat->pointer_x = wl_fixed_to_int(x);
|
||||||
seat->pointer_y = wl_fixed_to_int(y);
|
seat->pointer_y = wl_fixed_to_int(y);
|
||||||
seat->serial = serial;
|
seat->serial = serial;
|
||||||
|
|
@ -470,22 +467,22 @@ static void
|
||||||
seat_capabilities(void *data, struct wl_seat *wl_seat, uint32_t capabilities){
|
seat_capabilities(void *data, struct wl_seat *wl_seat, uint32_t capabilities){
|
||||||
struct seat *seat = data;
|
struct seat *seat = data;
|
||||||
|
|
||||||
if ((capabilities & WL_SEAT_CAPABILITY_POINTER) && !seat->wl_pointer){
|
if ((capabilities & WL_SEAT_CAPABILITY_POINTER) && seat->wl_pointer == 0){
|
||||||
seat->wl_pointer = wl_seat_get_pointer(wl_seat);
|
seat->wl_pointer = wl_seat_get_pointer(wl_seat);
|
||||||
wl_pointer_add_listener(seat->wl_pointer, &pointer_listener, seat);
|
wl_pointer_add_listener(seat->wl_pointer, &pointer_listener, seat);
|
||||||
}
|
}
|
||||||
else if (!(capabilities & WL_SEAT_CAPABILITY_POINTER) && seat->wl_pointer){
|
else if (!(capabilities & WL_SEAT_CAPABILITY_POINTER) && seat->wl_pointer != 0){
|
||||||
wl_pointer_release(seat->wl_pointer);
|
wl_pointer_release(seat->wl_pointer);
|
||||||
seat->wl_pointer = NULL;
|
seat->wl_pointer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((capabilities & WL_SEAT_CAPABILITY_TOUCH) && !seat->wl_touch){
|
if ((capabilities & WL_SEAT_CAPABILITY_TOUCH) && seat->wl_touch == 0){
|
||||||
seat->wl_touch = wl_seat_get_touch(wl_seat);
|
seat->wl_touch = wl_seat_get_touch(wl_seat);
|
||||||
wl_touch_add_listener(seat->wl_touch, &touch_listener, seat);
|
wl_touch_add_listener(seat->wl_touch, &touch_listener, seat);
|
||||||
}
|
}
|
||||||
else if (!(capabilities & WL_SEAT_CAPABILITY_TOUCH) && seat->wl_touch) {
|
else if (!(capabilities & WL_SEAT_CAPABILITY_TOUCH) && seat->wl_touch != 0){
|
||||||
wl_touch_release(seat->wl_touch);
|
wl_touch_release(seat->wl_touch);
|
||||||
seat->wl_touch = NULL;
|
seat->wl_touch = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -549,7 +546,7 @@ wl_registry_global(void *data, struct wl_registry *wl_registry,
|
||||||
seat->wl_seat = wl_registry_bind(ctx.wl_registry, name, &wl_seat_interface, 3);
|
seat->wl_seat = wl_registry_bind(ctx.wl_registry, name, &wl_seat_interface, 3);
|
||||||
wl_seat_add_listener(seat->wl_seat, &seat_listener, seat);
|
wl_seat_add_listener(seat->wl_seat, &seat_listener, seat);
|
||||||
|
|
||||||
|
seat->cursor_surface = wl_compositor_create_surface(ctx.wl_compositor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -785,6 +782,16 @@ int main(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ctx.has_error){
|
||||||
|
ctx.cursor_theme = wl_cursor_theme_load(ctx.cursor_theme_name, ctx.cursor_size, ctx.wl_shm);
|
||||||
|
if (ctx.cursor_theme != 0){
|
||||||
|
for (unsigned int i = 0; i < ARRAY_LENGTH(cursor_names); i += 1){
|
||||||
|
ctx.cursors[i] = wl_cursor_theme_get_cursor(ctx.cursor_theme, cursor_names[i]);
|
||||||
|
}
|
||||||
|
ctx.cursor_left_ptr = wl_cursor_theme_get_cursor(ctx.cursor_theme, "left_ptr");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int opengl_load_success = 0;
|
int opengl_load_success = 0;
|
||||||
if (!ctx.has_error){
|
if (!ctx.has_error){
|
||||||
/* (egl) eglGetDisplay
|
/* (egl) eglGetDisplay
|
||||||
|
|
@ -1350,15 +1357,14 @@ cleanup(void){
|
||||||
if (seat->wl_touch){
|
if (seat->wl_touch){
|
||||||
wl_touch_destroy(seat->wl_touch);
|
wl_touch_destroy(seat->wl_touch);
|
||||||
}
|
}
|
||||||
if (seat->cursor_surface){
|
wl_surface_destroy(seat->cursor_surface);
|
||||||
wl_surface_destroy(seat->cursor_surface);
|
|
||||||
}
|
|
||||||
wl_seat_destroy(seat->wl_seat);
|
wl_seat_destroy(seat->wl_seat);
|
||||||
if (seat->cursor_theme){
|
if (ctx.cursor_theme != 0){
|
||||||
wl_cursor_theme_destroy(seat->cursor_theme);
|
wl_cursor_theme_destroy(ctx.cursor_theme);
|
||||||
|
}
|
||||||
|
if (seat->name != 0){
|
||||||
|
free(seat->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(seat->name);
|
|
||||||
free(seat);
|
free(seat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2496,25 +2502,14 @@ edge_from_pos(int x, int y){
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
update_local_cursor(struct seat *seat){
|
update_local_cursor(struct seat *seat){
|
||||||
if (seat->cursor_theme == 0){
|
struct wl_cursor *wl_cursor = ctx.cursor_left_ptr;
|
||||||
struct wl_cursor_theme *theme = wl_cursor_theme_load(ctx.cursor_theme_name, ctx.cursor_size, ctx.wl_shm);
|
|
||||||
if (theme != 0){
|
|
||||||
seat->cursor_theme = theme;
|
|
||||||
for (unsigned int i = 0; i < ARRAY_LENGTH(cursor_names); i += 1){
|
|
||||||
seat->cursors[i] = wl_cursor_theme_get_cursor(theme, cursor_names[i]);
|
|
||||||
}
|
|
||||||
seat->cursor_left_ptr = wl_cursor_theme_get_cursor(seat->cursor_theme, "left_ptr");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct wl_cursor *wl_cursor = seat->cursor_left_ptr;
|
|
||||||
if (own_proxy(seat->pointer_focus)){
|
if (own_proxy(seat->pointer_focus)){
|
||||||
if (ctx.active != 0){
|
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(seat->pointer_x, seat->pointer_y);
|
||||||
if (edge != LIBDECOR_RESIZE_EDGE_NONE){
|
if (edge != LIBDECOR_RESIZE_EDGE_NONE){
|
||||||
wl_cursor = seat->cursors[edge - 1];
|
wl_cursor = ctx.cursors[edge - 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -223,11 +223,6 @@ struct seat {
|
||||||
struct wl_surface *cursor_surface;
|
struct wl_surface *cursor_surface;
|
||||||
struct wl_cursor *current_cursor;
|
struct wl_cursor *current_cursor;
|
||||||
|
|
||||||
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 *pointer_focus;
|
||||||
struct wl_surface *touch_focus;
|
struct wl_surface *touch_focus;
|
||||||
|
|
||||||
|
|
@ -336,6 +331,10 @@ typedef struct Ctx{
|
||||||
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_cursor_theme *cursor_theme;
|
||||||
|
struct wl_cursor *cursors[ARRAY_LENGTH(cursor_names)];
|
||||||
|
struct wl_cursor *cursor_left_ptr;
|
||||||
|
|
||||||
struct wl_list seat_list;
|
struct wl_list seat_list;
|
||||||
|
|
||||||
bool has_error;
|
bool has_error;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue