chore: window state

This commit is contained in:
Ashley Wulber 2026-02-04 14:32:26 -05:00
parent 0370cadd67
commit a610ac9c7a
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
2 changed files with 142 additions and 1 deletions

View file

@ -0,0 +1,135 @@
use sctk::data_device_manager::{
data_device::DataDeviceHandler, data_offer::DataOfferHandler, data_source::DataSourceHandler,
};
use crate::platform_impl::wayland::state::WinitState;
impl DataDeviceHandler for WinitState {
fn enter(
&mut self,
conn: &wayland_client::Connection,
qh: &wayland_client::QueueHandle<Self>,
data_device: &wayland_client::protocol::wl_data_device::WlDataDevice,
x: f64,
y: f64,
wl_surface: &wayland_client::protocol::wl_surface::WlSurface,
) {
todo!()
}
fn leave(
&mut self,
conn: &wayland_client::Connection,
qh: &wayland_client::QueueHandle<Self>,
data_device: &wayland_client::protocol::wl_data_device::WlDataDevice,
) {
todo!()
}
fn motion(
&mut self,
conn: &wayland_client::Connection,
qh: &wayland_client::QueueHandle<Self>,
data_device: &wayland_client::protocol::wl_data_device::WlDataDevice,
x: f64,
y: f64,
) {
todo!()
}
fn selection(
&mut self,
conn: &wayland_client::Connection,
qh: &wayland_client::QueueHandle<Self>,
data_device: &wayland_client::protocol::wl_data_device::WlDataDevice,
) {
todo!()
}
fn drop_performed(
&mut self,
conn: &wayland_client::Connection,
qh: &wayland_client::QueueHandle<Self>,
data_device: &wayland_client::protocol::wl_data_device::WlDataDevice,
) {
todo!()
}
}
impl DataOfferHandler for WinitState {
fn source_actions(
&mut self,
conn: &wayland_client::Connection,
qh: &wayland_client::QueueHandle<Self>,
offer: &mut sctk::data_device_manager::data_offer::DragOffer,
actions: wayland_client::protocol::wl_data_device_manager::DndAction,
) {
todo!()
}
fn selected_action(
&mut self,
conn: &wayland_client::Connection,
qh: &wayland_client::QueueHandle<Self>,
offer: &mut sctk::data_device_manager::data_offer::DragOffer,
actions: wayland_client::protocol::wl_data_device_manager::DndAction,
) {
todo!()
}
}
impl DataSourceHandler for WinitState {
fn accept_mime(
&mut self,
conn: &wayland_client::Connection,
qh: &wayland_client::QueueHandle<Self>,
source: &wayland_client::protocol::wl_data_source::WlDataSource,
mime: Option<String>,
) {
}
fn send_request(
&mut self,
conn: &wayland_client::Connection,
qh: &wayland_client::QueueHandle<Self>,
source: &wayland_client::protocol::wl_data_source::WlDataSource,
mime: String,
fd: sctk::data_device_manager::WritePipe,
) {
}
fn cancelled(
&mut self,
conn: &wayland_client::Connection,
qh: &wayland_client::QueueHandle<Self>,
source: &wayland_client::protocol::wl_data_source::WlDataSource,
) {
}
fn dnd_dropped(
&mut self,
conn: &wayland_client::Connection,
qh: &wayland_client::QueueHandle<Self>,
source: &wayland_client::protocol::wl_data_source::WlDataSource,
) {
}
fn dnd_finished(
&mut self,
conn: &wayland_client::Connection,
qh: &wayland_client::QueueHandle<Self>,
source: &wayland_client::protocol::wl_data_source::WlDataSource,
) {
}
fn action(
&mut self,
conn: &wayland_client::Connection,
qh: &wayland_client::QueueHandle<Self>,
source: &wayland_client::protocol::wl_data_source::WlDataSource,
action: wayland_client::protocol::wl_data_device_manager::DndAction,
) {
}
}
sctk::delegate_data_device!(WinitState);

View file

@ -23,6 +23,7 @@ use dpi::{LogicalSize, PhysicalSize};
use rwh_06::HandleError;
use sctk::reexports::client::Proxy;
use sctk::reexports::client::protocol::wl_surface::WlSurface;
use sctk::reexports::csd_frame::WindowState;
use sctk::shm::slot::{Buffer, CreateBufferError, SlotPool};
use wayland_client::protocol::wl_shm::Format;
use winit_core::event_loop::ActiveEventLoop as CoreActiveEventLoop;
@ -104,6 +105,8 @@ pub trait WindowExtWayland {
fn xdg_toplevel(&self) -> Option<NonNull<c_void>>;
fn xdg_surface_handle<'a>(&'a self) -> Option<&dyn HasXdgSurfaceHandle>;
fn window_state(&self) -> Option<WindowState>;
}
impl WindowExtWayland for dyn CoreWindow + '_ {
@ -113,10 +116,13 @@ impl WindowExtWayland for dyn CoreWindow + '_ {
}
#[inline]
fn xdg_surface_handle(&self) -> Option<&dyn HasXdgSurfaceHandle> {
Some(self.cast_ref::<Window>()? as &dyn HasXdgSurfaceHandle)
}
fn window_state(&self) -> Option<WindowState> {
self.cast_ref::<Window>()?.xdg_window_state()
}
}
#[derive(Debug, Clone, PartialEq, Eq)]