Add wl_region and wl_surface.set_input_region support

Needed for latest Xwayland.
This commit is contained in:
Shawn Wallace 2024-05-18 02:19:26 -04:00
parent c95655299e
commit 7c6915b0ec
2 changed files with 42 additions and 4 deletions

View file

@ -6,7 +6,7 @@ use wayland_client::protocol::{
wl_buffer::WlBuffer, wl_callback::WlCallback, wl_compositor::WlCompositor, wl_buffer::WlBuffer, wl_callback::WlCallback, wl_compositor::WlCompositor,
wl_keyboard::WlKeyboard, wl_output::WlOutput, wl_pointer::WlPointer, wl_registry::WlRegistry, wl_keyboard::WlKeyboard, wl_output::WlOutput, wl_pointer::WlPointer, wl_registry::WlRegistry,
wl_seat::WlSeat, wl_shm::WlShm, wl_shm_pool::WlShmPool, wl_surface::WlSurface, wl_seat::WlSeat, wl_shm::WlShm, wl_shm_pool::WlShmPool, wl_surface::WlSurface,
wl_touch::WlTouch, wl_touch::WlTouch, wl_region::WlRegion
}; };
use wayland_client::{delegate_noop, Connection, Dispatch, EventQueue, Proxy, QueueHandle}; use wayland_client::{delegate_noop, Connection, Dispatch, EventQueue, Proxy, QueueHandle};
use wayland_protocols::wp::relative_pointer::zv1::client::{ use wayland_protocols::wp::relative_pointer::zv1::client::{
@ -92,6 +92,7 @@ impl ClientState {
pub type Event<T> = <T as Proxy>::Event; pub type Event<T> = <T as Proxy>::Event;
delegate_noop!(Globals: WlCompositor); delegate_noop!(Globals: WlCompositor);
delegate_noop!(Globals: WlRegion);
delegate_noop!(Globals: ignore WlShm); delegate_noop!(Globals: ignore WlShm);
delegate_noop!(Globals: ignore ZwpLinuxDmabufV1); delegate_noop!(Globals: ignore ZwpLinuxDmabufV1);
delegate_noop!(Globals: ZwpRelativePointerManagerV1); delegate_noop!(Globals: ZwpRelativePointerManagerV1);

View file

@ -25,9 +25,18 @@ use wayland_protocols::{
}; };
use wayland_server::{ use wayland_server::{
protocol::{ protocol::{
wl_buffer::WlBuffer, wl_callback::WlCallback, wl_compositor::WlCompositor, wl_buffer::WlBuffer,
wl_keyboard::WlKeyboard, wl_output::WlOutput, wl_pointer::WlPointer, wl_seat::WlSeat, wl_callback::WlCallback,
wl_shm::WlShm, wl_shm_pool::WlShmPool, wl_surface::WlSurface, wl_touch::WlTouch, wl_compositor::WlCompositor,
wl_keyboard::WlKeyboard,
wl_output::WlOutput,
wl_pointer::WlPointer,
wl_region::{self, WlRegion},
wl_seat::WlSeat,
wl_shm::WlShm,
wl_shm_pool::WlShmPool,
wl_surface::WlSurface,
wl_touch::WlTouch,
}, },
Dispatch, DisplayHandle, GlobalDispatch, Resource, Dispatch, DisplayHandle, GlobalDispatch, Resource,
}; };
@ -114,11 +123,35 @@ impl<C: XConnection> Dispatch<WlSurface, ObjectKey> for ServerState<C> {
Request::<WlSurface>::SetBufferScale { scale } => { Request::<WlSurface>::SetBufferScale { scale } => {
surface.client.set_buffer_scale(scale); surface.client.set_buffer_scale(scale);
} }
Request::<WlSurface>::SetInputRegion { region } => {
let region = region.as_ref().map(|r| r.data().unwrap());
surface.client.set_input_region(region);
}
other => warn!("unhandled surface request: {other:?}"), other => warn!("unhandled surface request: {other:?}"),
} }
} }
} }
impl<C: XConnection> Dispatch<WlRegion, client::wl_region::WlRegion> for ServerState<C> {
fn request(
_: &mut Self,
_: &wayland_server::Client,
_: &WlRegion,
request: <WlRegion as Resource>::Request,
client: &client::wl_region::WlRegion,
_: &DisplayHandle,
_: &mut wayland_server::DataInit<'_, Self>,
) {
simple_event_shunt! {
client, request: wl_region::Request => [
Add { x, y, width, height },
Subtract { x, y, width, height },
Destroy
]
}
}
}
impl<C: XConnection> impl<C: XConnection>
Dispatch<WlCompositor, ClientGlobalWrapper<client::wl_compositor::WlCompositor>> Dispatch<WlCompositor, ClientGlobalWrapper<client::wl_compositor::WlCompositor>>
for ServerState<C> for ServerState<C>
@ -168,6 +201,10 @@ impl<C: XConnection>
} }
} }
} }
Request::<WlCompositor>::CreateRegion { id } => {
let c_region = client.create_region(&state.qh, ());
data_init.init(id, c_region);
}
other => { other => {
warn!("unhandled wlcompositor request: {other:?}"); warn!("unhandled wlcompositor request: {other:?}");
} }