update to wlroots 0.19

feat:wlr_alpha_modifier_v1 protocol
This commit is contained in:
DreamMaoMao 2025-03-04 10:18:28 +08:00
parent 954a6e6848
commit 7880d44a2a
3 changed files with 366 additions and 330 deletions

208
client.h
View file

@ -6,14 +6,18 @@
*/ */
/* Leave these functions first; they're used in the others */ /* Leave these functions first; they're used in the others */
static inline int client_is_x11(Client *c) { static inline int
client_is_x11(Client *c)
{
#ifdef XWAYLAND #ifdef XWAYLAND
return c->type == X11; return c->type == X11;
#endif #endif
return 0; return 0;
} }
static inline struct wlr_surface *client_surface(Client *c) { static inline struct wlr_surface *
client_surface(Client *c)
{
#ifdef XWAYLAND #ifdef XWAYLAND
if (client_is_x11(c)) if (client_is_x11(c))
return c->surface.xwayland->surface; return c->surface.xwayland->surface;
@ -21,8 +25,9 @@ static inline struct wlr_surface *client_surface(Client *c) {
return c->surface.xdg->surface; return c->surface.xdg->surface;
} }
static inline int toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc, static inline int
LayerSurface **pl) { toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc, LayerSurface **pl)
{
struct wlr_xdg_surface *xdg_surface, *tmp_xdg_surface; struct wlr_xdg_surface *xdg_surface, *tmp_xdg_surface;
struct wlr_surface *root_surface; struct wlr_surface *root_surface;
struct wlr_layer_surface_v1 *layer_surface; struct wlr_layer_surface_v1 *layer_surface;
@ -45,8 +50,7 @@ static inline int toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc,
} }
#endif #endif
if ((layer_surface = if ((layer_surface = wlr_layer_surface_v1_try_from_wlr_surface(root_surface))) {
wlr_layer_surface_v1_try_from_wlr_surface(root_surface))) {
l = layer_surface->data; l = layer_surface->data;
type = LayerShell; type = LayerShell;
goto end; goto end;
@ -60,8 +64,7 @@ static inline int toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc,
if (!xdg_surface->popup || !xdg_surface->popup->parent) if (!xdg_surface->popup || !xdg_surface->popup->parent)
return -1; return -1;
tmp_xdg_surface = tmp_xdg_surface = wlr_xdg_surface_try_from_wlr_surface(xdg_surface->popup->parent);
wlr_xdg_surface_try_from_wlr_surface(xdg_surface->popup->parent);
if (!tmp_xdg_surface) if (!tmp_xdg_surface)
return toplevel_from_wlr_surface(xdg_surface->popup->parent, pc, pl); return toplevel_from_wlr_surface(xdg_surface->popup->parent, pc, pl);
@ -86,8 +89,9 @@ end:
} }
/* The others */ /* The others */
static inline void client_activate_surface(struct wlr_surface *s, static inline void
int activated) { client_activate_surface(struct wlr_surface *s, int activated)
{
struct wlr_xdg_toplevel *toplevel; struct wlr_xdg_toplevel *toplevel;
#ifdef XWAYLAND #ifdef XWAYLAND
struct wlr_xwayland_surface *xsurface; struct wlr_xwayland_surface *xsurface;
@ -100,16 +104,16 @@ static inline void client_activate_surface(struct wlr_surface *s,
wlr_xdg_toplevel_set_activated(toplevel, activated); wlr_xdg_toplevel_set_activated(toplevel, activated);
} }
static inline uint32_t client_set_bounds(Client *c, int32_t width, static inline uint32_t
int32_t height) { client_set_bounds(Client *c, int32_t width, int32_t height)
{
#ifdef XWAYLAND #ifdef XWAYLAND
if (client_is_x11(c)) if (client_is_x11(c))
return 0; return 0;
#endif #endif
if (wl_resource_get_version(c->surface.xdg->toplevel->resource) >= if (wl_resource_get_version(c->surface.xdg->toplevel->resource) >=
XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION && XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION && width >= 0 && height >= 0
width >= 0 && height >= 0 && && (c->bounds.width != width || c->bounds.height != height)) {
(c->bounds.width != width || c->bounds.height != height)) {
c->bounds.width = width; c->bounds.width = width;
c->bounds.height = height; c->bounds.height = height;
return wlr_xdg_toplevel_set_bounds(c->surface.xdg->toplevel, width, height); return wlr_xdg_toplevel_set_bounds(c->surface.xdg->toplevel, width, height);
@ -117,16 +121,19 @@ static inline uint32_t client_set_bounds(Client *c, int32_t width,
return 0; return 0;
} }
static inline const char *client_get_appid(Client *c) { static inline const char *
client_get_appid(Client *c)
{
#ifdef XWAYLAND #ifdef XWAYLAND
if (client_is_x11(c)) if (client_is_x11(c))
return c->surface.xwayland->class; return c->surface.xwayland->class ? c->surface.xwayland->class : "broken";
#endif #endif
return c->surface.xdg->toplevel->app_id; return c->surface.xdg->toplevel->app_id ? c->surface.xdg->toplevel->app_id : "broken";
} }
static inline void client_get_clip(Client *c, struct wlr_box *clip) { static inline void
struct wlr_box xdg_geom = {0}; client_get_clip(Client *c, struct wlr_box *clip)
{
*clip = (struct wlr_box){ *clip = (struct wlr_box){
.x = 0, .x = 0,
.y = 0, .y = 0,
@ -139,12 +146,13 @@ static inline void client_get_clip(Client *c, struct wlr_box *clip) {
return; return;
#endif #endif
wlr_xdg_surface_get_geometry(c->surface.xdg, &xdg_geom); clip->x = c->surface.xdg->geometry.x;
clip->x = xdg_geom.x; clip->y = c->surface.xdg->geometry.y;
clip->y = xdg_geom.y;
} }
static inline void client_get_geometry(Client *c, struct wlr_box *geom) { static inline void
client_get_geometry(Client *c, struct wlr_box *geom)
{
#ifdef XWAYLAND #ifdef XWAYLAND
if (client_is_x11(c)) { if (client_is_x11(c)) {
geom->x = c->surface.xwayland->x; geom->x = c->surface.xwayland->x;
@ -154,10 +162,12 @@ static inline void client_get_geometry(Client *c, struct wlr_box *geom) {
return; return;
} }
#endif #endif
wlr_xdg_surface_get_geometry(c->surface.xdg, geom); *geom = c->surface.xdg->geometry;
} }
static inline Client *client_get_parent(Client *c) { static inline Client *
client_get_parent(Client *c)
{
Client *p = NULL; Client *p = NULL;
#ifdef XWAYLAND #ifdef XWAYLAND
if (client_is_x11(c)) { if (client_is_x11(c)) {
@ -167,12 +177,13 @@ static inline Client *client_get_parent(Client *c) {
} }
#endif #endif
if (c->surface.xdg->toplevel->parent) if (c->surface.xdg->toplevel->parent)
toplevel_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface, toplevel_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface, &p, NULL);
&p, NULL);
return p; return p;
} }
static inline int client_has_children(Client *c) { static inline int
client_has_children(Client *c)
{
#ifdef XWAYLAND #ifdef XWAYLAND
if (client_is_x11(c)) if (client_is_x11(c))
return !wl_list_empty(&c->surface.xwayland->children); return !wl_list_empty(&c->surface.xwayland->children);
@ -182,15 +193,19 @@ static inline int client_has_children(Client *c) {
return wl_list_length(&c->surface.xdg->link) > 1; return wl_list_length(&c->surface.xdg->link) > 1;
} }
static inline const char *client_get_title(Client *c) { static inline const char *
client_get_title(Client *c)
{
#ifdef XWAYLAND #ifdef XWAYLAND
if (client_is_x11(c)) if (client_is_x11(c))
return c->surface.xwayland->title; return c->surface.xwayland->title ? c->surface.xwayland->title : "broken";
#endif #endif
return c->surface.xdg->toplevel->title; return c->surface.xdg->toplevel->title ? c->surface.xdg->toplevel->title : "broken";
} }
static inline int client_is_float_type(Client *c) { static inline int
client_is_float_type(Client *c)
{
struct wlr_xdg_toplevel *toplevel; struct wlr_xdg_toplevel *toplevel;
struct wlr_xdg_toplevel_state state; struct wlr_xdg_toplevel_state state;
@ -198,32 +213,32 @@ static inline int client_is_float_type(Client *c) {
if (client_is_x11(c)) { if (client_is_x11(c)) {
struct wlr_xwayland_surface *surface = c->surface.xwayland; struct wlr_xwayland_surface *surface = c->surface.xwayland;
xcb_size_hints_t *size_hints = surface->size_hints; xcb_size_hints_t *size_hints = surface->size_hints;
size_t i;
if (surface->modal) if (surface->modal)
return 1; return 1;
for (i = 0; i < surface->window_type_len; i++) if (wlr_xwayland_surface_has_window_type(surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_DIALOG)
if (surface->window_type[i] == netatom[NetWMWindowTypeDialog] || || wlr_xwayland_surface_has_window_type(surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_SPLASH)
surface->window_type[i] == netatom[NetWMWindowTypeSplash] || || wlr_xwayland_surface_has_window_type(surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_TOOLBAR)
surface->window_type[i] == netatom[NetWMWindowTypeToolbar] || || wlr_xwayland_surface_has_window_type(surface, WLR_XWAYLAND_NET_WM_WINDOW_TYPE_UTILITY)) {
surface->window_type[i] == netatom[NetWMWindowTypeUtility])
return 1; return 1;
}
return size_hints && size_hints->min_width > 0 && return size_hints && size_hints->min_width > 0 && size_hints->min_height > 0
size_hints->min_height > 0 && && (size_hints->max_width == size_hints->min_width
(size_hints->max_width == size_hints->min_width || || size_hints->max_height == size_hints->min_height);
size_hints->max_height == size_hints->min_height);
} }
#endif #endif
toplevel = c->surface.xdg->toplevel; toplevel = c->surface.xdg->toplevel;
state = toplevel->current; state = toplevel->current;
return toplevel->parent || (state.min_width != 0 && state.min_height != 0 && return toplevel->parent || (state.min_width != 0 && state.min_height != 0
(state.min_width == state.max_width || && (state.min_width == state.max_width
state.min_height == state.max_height)); || state.min_height == state.max_height));
} }
static inline int client_is_rendered_on_mon(Client *c, Monitor *m) { static inline int
client_is_rendered_on_mon(Client *c, Monitor *m)
{
/* This is needed for when you don't want to check formal assignment, /* This is needed for when you don't want to check formal assignment,
* but rather actual displaying of the pixels. * but rather actual displaying of the pixels.
* Usually VISIBLEON suffices and is also faster. */ * Usually VISIBLEON suffices and is also faster. */
@ -231,12 +246,15 @@ static inline int client_is_rendered_on_mon(Client *c, Monitor *m) {
int unused_lx, unused_ly; int unused_lx, unused_ly;
if (!wlr_scene_node_coords(&c->scene->node, &unused_lx, &unused_ly)) if (!wlr_scene_node_coords(&c->scene->node, &unused_lx, &unused_ly))
return 0; return 0;
wl_list_for_each(s, &client_surface(c)->current_outputs, wl_list_for_each(s, &client_surface(c)->current_outputs, link)
link) if (s->output == m->wlr_output) return 1; if (s->output == m->wlr_output)
return 1;
return 0; return 0;
} }
static inline int client_is_stopped(Client *c) { static inline int
client_is_stopped(Client *c)
{
int pid; int pid;
siginfo_t in = {0}; siginfo_t in = {0};
#ifdef XWAYLAND #ifdef XWAYLAND
@ -260,7 +278,9 @@ static inline int client_is_stopped(Client *c) {
return 0; return 0;
} }
static inline int client_is_unmanaged(Client *c) { static inline int
client_is_unmanaged(Client *c)
{
#ifdef XWAYLAND #ifdef XWAYLAND
if (client_is_x11(c)) if (client_is_x11(c))
return c->surface.xwayland->override_redirect; return c->surface.xwayland->override_redirect;
@ -268,25 +288,19 @@ static inline int client_is_unmanaged(Client *c) {
return 0; return 0;
} }
static inline void client_notify_enter(struct wlr_surface *s, static inline void
struct wlr_keyboard *kb) { client_notify_enter(struct wlr_surface *s, struct wlr_keyboard *kb)
{
if (kb) if (kb)
wlr_seat_keyboard_notify_enter(seat, s, kb->keycodes, kb->num_keycodes, wlr_seat_keyboard_notify_enter(seat, s, kb->keycodes,
&kb->modifiers); kb->num_keycodes, &kb->modifiers);
else else
wlr_seat_keyboard_notify_enter(seat, s, NULL, 0, NULL); wlr_seat_keyboard_notify_enter(seat, s, NULL, 0, NULL);
} }
static inline void client_restack_surface(Client *c) { static inline void
#ifdef XWAYLAND client_send_close(Client *c)
if (client_is_x11(c)) {
wlr_xwayland_surface_restack(c->surface.xwayland, NULL,
XCB_STACK_MODE_ABOVE);
#endif
return;
}
static inline void client_send_close(Client *c) {
#ifdef XWAYLAND #ifdef XWAYLAND
if (client_is_x11(c)) { if (client_is_x11(c)) {
wlr_xwayland_surface_close(c->surface.xwayland); wlr_xwayland_surface_close(c->surface.xwayland);
@ -296,14 +310,17 @@ static inline void client_send_close(Client *c) {
wlr_xdg_toplevel_send_close(c->surface.xdg->toplevel); wlr_xdg_toplevel_send_close(c->surface.xdg->toplevel);
} }
static inline void client_set_border_color(Client *c, static inline void
const float color[static 4]) { client_set_border_color(Client *c, const float color[static 4])
{
int i; int i;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
wlr_scene_rect_set_color(c->border[i], color); wlr_scene_rect_set_color(c->border[i], color);
} }
static inline void client_set_fullscreen(Client *c, int fullscreen) { static inline void
client_set_fullscreen(Client *c, int fullscreen)
{
#ifdef XWAYLAND #ifdef XWAYLAND
if (client_is_x11(c)) { if (client_is_x11(c)) {
wlr_xwayland_surface_set_fullscreen(c->surface.xwayland, fullscreen); wlr_xwayland_surface_set_fullscreen(c->surface.xwayland, fullscreen);
@ -313,42 +330,50 @@ static inline void client_set_fullscreen(Client *c, int fullscreen) {
wlr_xdg_toplevel_set_fullscreen(c->surface.xdg->toplevel, fullscreen); wlr_xdg_toplevel_set_fullscreen(c->surface.xdg->toplevel, fullscreen);
} }
static inline void client_set_scale(struct wlr_surface *s, float scale) { static inline void
client_set_scale(struct wlr_surface *s, float scale)
{
wlr_fractional_scale_v1_notify_scale(s, scale); wlr_fractional_scale_v1_notify_scale(s, scale);
wlr_surface_set_preferred_buffer_scale(s, (int32_t)ceilf(scale)); wlr_surface_set_preferred_buffer_scale(s, (int32_t)ceilf(scale));
} }
static inline uint32_t client_set_size(Client *c, uint32_t width, static inline uint32_t
uint32_t height) { client_set_size(Client *c, uint32_t width, uint32_t height)
{
#ifdef XWAYLAND #ifdef XWAYLAND
if (client_is_x11(c)) { if (client_is_x11(c)) {
wlr_xwayland_surface_configure(c->surface.xwayland, c->geom.x, c->geom.y, wlr_xwayland_surface_configure(c->surface.xwayland,
width, height); c->geom.x + c->bw, c->geom.y + c->bw, width, height);
return 0; return 0;
} }
#endif #endif
if ((int32_t)width == c->surface.xdg->toplevel->current.width && if ((int32_t)width == c->surface.xdg->toplevel->current.width
(int32_t)height == c->surface.xdg->toplevel->current.height) && (int32_t)height == c->surface.xdg->toplevel->current.height)
return 0; return 0;
return wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width, return wlr_xdg_toplevel_set_size(c->surface.xdg->toplevel, (int32_t)width, (int32_t)height);
(int32_t)height);
} }
static inline void client_set_tiled(Client *c, uint32_t edges) { static inline void
client_set_tiled(Client *c, uint32_t edges)
{
#ifdef XWAYLAND #ifdef XWAYLAND
if (client_is_x11(c)) if (client_is_x11(c)) {
wlr_xwayland_surface_set_maximized(c->surface.xwayland,
edges != WLR_EDGE_NONE, edges != WLR_EDGE_NONE);
return; return;
}
#endif #endif
if (wl_resource_get_version(c->surface.xdg->toplevel->resource) >= if (wl_resource_get_version(c->surface.xdg->toplevel->resource)
XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION) { >= XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION) {
wlr_xdg_toplevel_set_tiled(c->surface.xdg->toplevel, edges); wlr_xdg_toplevel_set_tiled(c->surface.xdg->toplevel, edges);
} else { } else {
wlr_xdg_toplevel_set_maximized(c->surface.xdg->toplevel, wlr_xdg_toplevel_set_maximized(c->surface.xdg->toplevel, edges != WLR_EDGE_NONE);
edges != WLR_EDGE_NONE);
} }
} }
static inline void client_set_suspended(Client *c, int suspended) { static inline void
client_set_suspended(Client *c, int suspended)
{
#ifdef XWAYLAND #ifdef XWAYLAND
if (client_is_x11(c)) if (client_is_x11(c))
return; return;
@ -357,17 +382,20 @@ static inline void client_set_suspended(Client *c, int suspended) {
wlr_xdg_toplevel_set_suspended(c->surface.xdg->toplevel, suspended); wlr_xdg_toplevel_set_suspended(c->surface.xdg->toplevel, suspended);
} }
static inline int client_wants_focus(Client *c) { static inline int
client_wants_focus(Client *c)
{
#ifdef XWAYLAND #ifdef XWAYLAND
return client_is_unmanaged(c) && return client_is_unmanaged(c)
wlr_xwayland_or_surface_wants_focus(c->surface.xwayland) && && wlr_xwayland_surface_override_redirect_wants_focus(c->surface.xwayland)
wlr_xwayland_icccm_input_model(c->surface.xwayland) != && wlr_xwayland_surface_icccm_input_model(c->surface.xwayland) != WLR_ICCCM_INPUT_MODEL_NONE;
WLR_ICCCM_INPUT_MODEL_NONE;
#endif #endif
return 0; return 0;
} }
static inline int client_wants_fullscreen(Client *c) { static inline int
client_wants_fullscreen(Client *c)
{
#ifdef XWAYLAND #ifdef XWAYLAND
if (client_is_x11(c)) if (client_is_x11(c))
return c->surface.xwayland->fullscreen; return c->surface.xwayland->fullscreen;

View file

@ -20,6 +20,9 @@
#include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_cursor.h> #include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_data_control_v1.h> #include <wlr/types/wlr_data_control_v1.h>
#include <wlr/types/wlr_alpha_modifier_v1.h>
#include <wlr/types/wlr_linux_dmabuf_v1.h>
#include <wlr/types/wlr_linux_drm_syncobj_v1.h>
#include <wlr/types/wlr_data_device.h> #include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_drm.h> #include <wlr/types/wlr_drm.h>
#include <wlr/types/wlr_export_dmabuf_v1.h> #include <wlr/types/wlr_export_dmabuf_v1.h>
@ -4824,7 +4827,7 @@ void setup(void) {
init_baked_points(); init_baked_points();
int i, sig[] = {SIGCHLD, SIGINT, SIGTERM, SIGPIPE}; int drm_fd, i, sig[] = {SIGCHLD, SIGINT, SIGTERM, SIGPIPE};
struct sigaction sa = {.sa_flags = SA_RESTART, .sa_handler = handlesig}; struct sigaction sa = {.sa_flags = SA_RESTART, .sa_handler = handlesig};
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
@ -4875,6 +4878,10 @@ void setup(void) {
scene, wlr_linux_dmabuf_v1_create_with_renderer(dpy, 5, drw)); scene, wlr_linux_dmabuf_v1_create_with_renderer(dpy, 5, drw));
} }
if ((drm_fd = wlr_renderer_get_drm_fd(drw)) >= 0 && drw->features.timeline
&& backend->features.timeline)
wlr_linux_drm_syncobj_manager_v1_create(dpy, 1, drm_fd);
/* Create a default allocator */ /* Create a default allocator */
if (!(alloc = wlr_allocator_autocreate(backend, drw))) if (!(alloc = wlr_allocator_autocreate(backend, drw)))
die("couldn't create allocator"); die("couldn't create allocator");
@ -4894,8 +4901,9 @@ void setup(void) {
wlr_viewporter_create(dpy); wlr_viewporter_create(dpy);
wlr_single_pixel_buffer_manager_v1_create(dpy); wlr_single_pixel_buffer_manager_v1_create(dpy);
wlr_fractional_scale_manager_v1_create(dpy, 1); wlr_fractional_scale_manager_v1_create(dpy, 1);
wlr_presentation_create(dpy, backend); wlr_presentation_create(dpy, backend, 2);
wlr_subcompositor_create(dpy); wlr_subcompositor_create(dpy);
wlr_alpha_modifier_v1_create(dpy);
/* Initializes the interface used to implement urgency hints */ /* Initializes the interface used to implement urgency hints */
activation = wlr_xdg_activation_v1_create(dpy); activation = wlr_xdg_activation_v1_create(dpy);

View file

@ -33,7 +33,7 @@ libm = cc.find_library('m')
xcb = dependency('xcb', required : get_option('xwayland')) xcb = dependency('xcb', required : get_option('xwayland'))
xlibs = dependency('xcb-icccm', required : get_option('xwayland')) xlibs = dependency('xcb-icccm', required : get_option('xwayland'))
wayland_server_dep = dependency('wayland-server') wayland_server_dep = dependency('wayland-server')
wlroots_dep = dependency('wlroots-0.18') wlroots_dep = dependency('wlroots-0.19')
xkbcommon_dep = dependency('xkbcommon') xkbcommon_dep = dependency('xkbcommon')
libinput_dep = dependency('libinput') libinput_dep = dependency('libinput')
libwayland_client_dep = dependency('wayland-client') libwayland_client_dep = dependency('wayland-client')