mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-06-16 16:25:39 +02:00
Implement wp_cursor_shape_v1
This commit is contained in:
parent
43e1944607
commit
56b374b569
3 changed files with 57 additions and 3 deletions
|
@ -15,11 +15,18 @@ if backend_wayland
|
||||||
|
|
||||||
wl_proto_headers = []
|
wl_proto_headers = []
|
||||||
wl_proto_src = []
|
wl_proto_src = []
|
||||||
foreach prot : [
|
wl_proto_xml = [
|
||||||
'../external/wlr-layer-shell-unstable-v1.xml',
|
'../external/wlr-layer-shell-unstable-v1.xml',
|
||||||
wayland_protocols_datadir + '/stable/xdg-shell/xdg-shell.xml',
|
wayland_protocols_datadir + '/stable/xdg-shell/xdg-shell.xml',
|
||||||
wayland_protocols_datadir + '/unstable/xdg-output/xdg-output-unstable-v1.xml']
|
wayland_protocols_datadir + '/unstable/xdg-output/xdg-output-unstable-v1.xml']
|
||||||
|
|
||||||
|
if wayland_protocols.version().version_compare('>=1.32')
|
||||||
|
wl_proto_xml += [
|
||||||
|
wayland_protocols_datadir + '/staging/cursor-shape/cursor-shape-v1.xml',
|
||||||
|
wayland_protocols_datadir + '/unstable/tablet/tablet-unstable-v2.xml']
|
||||||
|
endif
|
||||||
|
|
||||||
|
foreach prot : wl_proto_xml
|
||||||
wl_proto_headers += custom_target(
|
wl_proto_headers += custom_target(
|
||||||
prot.underscorify() + '-client-header',
|
prot.underscorify() + '-client-header',
|
||||||
output: '@BASENAME@.h',
|
output: '@BASENAME@.h',
|
||||||
|
|
|
@ -21,6 +21,10 @@
|
||||||
#include <wlr-layer-shell-unstable-v1.h>
|
#include <wlr-layer-shell-unstable-v1.h>
|
||||||
#include <xdg-output-unstable-v1.h>
|
#include <xdg-output-unstable-v1.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSOR_SHAPE
|
||||||
|
#include <cursor-shape-v1.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LOG_MODULE "bar:wayland"
|
#define LOG_MODULE "bar:wayland"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "../log.h"
|
#include "../log.h"
|
||||||
|
@ -107,6 +111,10 @@ struct wayland_backend {
|
||||||
|
|
||||||
struct zxdg_output_manager_v1 *xdg_output_manager;
|
struct zxdg_output_manager_v1 *xdg_output_manager;
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSOR_SHAPE
|
||||||
|
struct wp_cursor_shape_manager_v1 *cursor_shape_manager;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* TODO: set directly in bar instead */
|
/* TODO: set directly in bar instead */
|
||||||
int width, height;
|
int width, height;
|
||||||
|
|
||||||
|
@ -145,6 +153,23 @@ seat_destroy(struct seat *seat)
|
||||||
wl_seat_release(seat->seat);
|
wl_seat_release(seat->seat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool attempt_cursor_shape(struct wayland_backend *wayl, struct wl_pointer *wl_pointer,
|
||||||
|
uint32_t serial) {
|
||||||
|
#ifdef HAVE_CURSOR_SHAPE
|
||||||
|
if (wayl->cursor_shape_manager) {
|
||||||
|
struct wp_cursor_shape_device_v1 *device =
|
||||||
|
wp_cursor_shape_manager_v1_get_pointer(
|
||||||
|
wayl->cursor_shape_manager, wl_pointer);
|
||||||
|
wp_cursor_shape_device_v1_set_shape(device, serial,
|
||||||
|
WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DEFAULT);
|
||||||
|
wp_cursor_shape_device_v1_destroy(device);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
bar_backend_wayland_new(void)
|
bar_backend_wayland_new(void)
|
||||||
{
|
{
|
||||||
|
@ -235,8 +260,11 @@ wl_pointer_enter(void *data, struct wl_pointer *wl_pointer, uint32_t serial, str
|
||||||
seat->pointer.y = wl_fixed_to_int(surface_y) * backend->scale;
|
seat->pointer.y = wl_fixed_to_int(surface_y) * backend->scale;
|
||||||
|
|
||||||
backend->active_seat = seat;
|
backend->active_seat = seat;
|
||||||
|
|
||||||
|
if (!attempt_cursor_shape(backend, wl_pointer, serial)) {
|
||||||
reload_cursor_theme(seat, backend->monitor->scale);
|
reload_cursor_theme(seat, backend->monitor->scale);
|
||||||
update_cursor_surface(backend, seat);
|
update_cursor_surface(backend, seat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -678,6 +706,16 @@ handle_global(void *data, struct wl_registry *registry, uint32_t name, const cha
|
||||||
|
|
||||||
backend->xdg_output_manager = wl_registry_bind(registry, name, &zxdg_output_manager_v1_interface, required);
|
backend->xdg_output_manager = wl_registry_bind(registry, name, &zxdg_output_manager_v1_interface, required);
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_CURSOR_SHAPE
|
||||||
|
else if (strcmp(interface, wp_cursor_shape_manager_v1_interface.name) == 0) {
|
||||||
|
const uint32_t required = 1;
|
||||||
|
if (!verify_iface_version(interface, version, required))
|
||||||
|
return;
|
||||||
|
|
||||||
|
backend->cursor_shape_manager = wl_registry_bind(
|
||||||
|
backend->registry, name, &wp_cursor_shape_manager_v1_interface, required);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1146,6 +1184,11 @@ cleanup(struct bar *_bar)
|
||||||
if (backend->xdg_output_manager != NULL)
|
if (backend->xdg_output_manager != NULL)
|
||||||
zxdg_output_manager_v1_destroy(backend->xdg_output_manager);
|
zxdg_output_manager_v1_destroy(backend->xdg_output_manager);
|
||||||
|
|
||||||
|
#ifdef HAVE_CURSOR_SHAPE
|
||||||
|
if (backend->cursor_shape_manager != NULL)
|
||||||
|
wp_cursor_shape_manager_v1_destroy(backend->cursor_shape_manager);
|
||||||
|
#endif
|
||||||
|
|
||||||
tll_foreach(backend->seats, it) seat_destroy(&it->item);
|
tll_foreach(backend->seats, it) seat_destroy(&it->item);
|
||||||
tll_free(backend->seats);
|
tll_free(backend->seats);
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,11 @@ backend_x11 = xcb_aux.found() and xcb_cursor.found() and xcb_event.found() and \
|
||||||
# Wayland dependencies
|
# Wayland dependencies
|
||||||
wayland_client = dependency('wayland-client', required: get_option('backend-wayland'))
|
wayland_client = dependency('wayland-client', required: get_option('backend-wayland'))
|
||||||
wayland_cursor = dependency('wayland-cursor', required: get_option('backend-wayland'))
|
wayland_cursor = dependency('wayland-cursor', required: get_option('backend-wayland'))
|
||||||
|
wayland_protocols = dependency('wayland-protocols', required: get_option('backend-wayland'))
|
||||||
backend_wayland = wayland_client.found() and wayland_cursor.found()
|
backend_wayland = wayland_client.found() and wayland_cursor.found()
|
||||||
|
if backend_wayland and wayland_protocols.version().version_compare('>=1.32')
|
||||||
|
add_project_arguments('-DHAVE_CURSOR_SHAPE=1', language: 'c')
|
||||||
|
endif
|
||||||
|
|
||||||
# "My" dependencies, fallback to subproject
|
# "My" dependencies, fallback to subproject
|
||||||
tllist = dependency('tllist', version: '>=1.0.1', fallback: 'tllist')
|
tllist = dependency('tllist', version: '>=1.0.1', fallback: 'tllist')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue