refactor: use cctk

This commit is contained in:
Ashley Wulber 2024-11-23 02:02:52 -05:00
parent 1b8a399ebd
commit 6e91eabf4c
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
46 changed files with 224 additions and 183 deletions

View file

@ -1,5 +1,5 @@
use iced_futures::futures::channel::oneshot::Sender;
use sctk::{
use cctk::sctk::{
activation::{ActivationHandler, RequestData, RequestDataExt},
delegate_activation,
reexports::client::protocol::{wl_seat::WlSeat, wl_surface::WlSurface},

View file

@ -1,5 +1,5 @@
// SPDX-License-Identifier: MPL-2.0-only
use sctk::{
use cctk::sctk::{
compositor::CompositorHandler,
delegate_compositor,
reexports::client::{

View file

@ -2,6 +2,7 @@
pub mod activation;
pub mod compositor;
pub mod output;
// pub mod overlap;
pub mod seat;
pub mod session_lock;
pub mod shell;
@ -9,7 +10,7 @@ pub mod subcompositor;
pub mod wp_fractional_scaling;
pub mod wp_viewporter;
use sctk::{
use cctk::sctk::{
delegate_registry, delegate_shm,
output::OutputState,
registry::{ProvidesRegistryState, RegistryState},

View file

@ -1,18 +1,18 @@
use crate::platform_specific::wayland::{
event_loop::state::SctkState, sctk_event::SctkEvent,
};
use sctk::{delegate_output, output::OutputHandler};
use cctk::sctk::{delegate_output, output::OutputHandler};
impl OutputHandler for SctkState {
fn output_state(&mut self) -> &mut sctk::output::OutputState {
fn output_state(&mut self) -> &mut cctk::sctk::output::OutputState {
&mut self.output_state
}
fn new_output(
&mut self,
_conn: &sctk::reexports::client::Connection,
_qh: &sctk::reexports::client::QueueHandle<Self>,
output: sctk::reexports::client::protocol::wl_output::WlOutput,
_conn: &cctk::sctk::reexports::client::Connection,
_qh: &cctk::sctk::reexports::client::QueueHandle<Self>,
output: cctk::sctk::reexports::client::protocol::wl_output::WlOutput,
) {
self.sctk_events.push(SctkEvent::NewOutput {
id: output.clone(),
@ -23,9 +23,9 @@ impl OutputHandler for SctkState {
fn update_output(
&mut self,
_conn: &sctk::reexports::client::Connection,
_qh: &sctk::reexports::client::QueueHandle<Self>,
output: sctk::reexports::client::protocol::wl_output::WlOutput,
_conn: &cctk::sctk::reexports::client::Connection,
_qh: &cctk::sctk::reexports::client::QueueHandle<Self>,
output: cctk::sctk::reexports::client::protocol::wl_output::WlOutput,
) {
if let Some(info) = self.output_state.info(&output) {
self.sctk_events.push(SctkEvent::UpdateOutput {
@ -37,9 +37,9 @@ impl OutputHandler for SctkState {
fn output_destroyed(
&mut self,
_conn: &sctk::reexports::client::Connection,
_qh: &sctk::reexports::client::QueueHandle<Self>,
output: sctk::reexports::client::protocol::wl_output::WlOutput,
_conn: &cctk::sctk::reexports::client::Connection,
_qh: &cctk::sctk::reexports::client::QueueHandle<Self>,
output: cctk::sctk::reexports::client::protocol::wl_output::WlOutput,
) {
self.sctk_events.push(SctkEvent::RemovedOutput(output));
// TODO clean up any layer surfaces on this output?

View file

@ -2,8 +2,8 @@ use crate::platform_specific::wayland::{
event_loop::state::SctkState,
sctk_event::{KeyboardEventVariant, SctkEvent},
};
use sctk::reexports::client::Proxy;
use sctk::{
use cctk::sctk::reexports::client::Proxy;
use cctk::sctk::{
delegate_keyboard,
seat::keyboard::{KeyboardHandler, Keysym},
};
@ -11,10 +11,10 @@ use sctk::{
impl KeyboardHandler for SctkState {
fn enter(
&mut self,
_conn: &sctk::reexports::client::Connection,
_qh: &sctk::reexports::client::QueueHandle<Self>,
keyboard: &sctk::reexports::client::protocol::wl_keyboard::WlKeyboard,
surface: &sctk::reexports::client::protocol::wl_surface::WlSurface,
_conn: &cctk::sctk::reexports::client::Connection,
_qh: &cctk::sctk::reexports::client::QueueHandle<Self>,
keyboard: &cctk::sctk::reexports::client::protocol::wl_keyboard::WlKeyboard,
surface: &cctk::sctk::reexports::client::protocol::wl_surface::WlSurface,
_serial: u32,
_raw: &[u32],
_keysyms: &[Keysym],
@ -57,20 +57,20 @@ impl KeyboardHandler for SctkState {
winit::event::WindowEvent::Focused(true),
));
self.sctk_events.push(SctkEvent::KeyboardEvent {
variant: KeyboardEventVariant::Enter(surface.clone()),
kbd_id: keyboard.clone(),
seat_id: seat,
surface: surface.clone(),
variant: KeyboardEventVariant::Enter(surface.clone()),
kbd_id: keyboard.clone(),
seat_id: seat,
surface: surface.clone(),
});
}
}
fn leave(
&mut self,
_conn: &sctk::reexports::client::Connection,
_qh: &sctk::reexports::client::QueueHandle<Self>,
keyboard: &sctk::reexports::client::protocol::wl_keyboard::WlKeyboard,
surface: &sctk::reexports::client::protocol::wl_surface::WlSurface,
_conn: &cctk::sctk::reexports::client::Connection,
_qh: &cctk::sctk::reexports::client::QueueHandle<Self>,
keyboard: &cctk::sctk::reexports::client::protocol::wl_keyboard::WlKeyboard,
surface: &cctk::sctk::reexports::client::protocol::wl_surface::WlSurface,
_serial: u32,
) {
self.request_redraw(surface);
@ -129,11 +129,11 @@ impl KeyboardHandler for SctkState {
fn press_key(
&mut self,
_conn: &sctk::reexports::client::Connection,
_qh: &sctk::reexports::client::QueueHandle<Self>,
keyboard: &sctk::reexports::client::protocol::wl_keyboard::WlKeyboard,
_conn: &cctk::sctk::reexports::client::Connection,
_qh: &cctk::sctk::reexports::client::QueueHandle<Self>,
keyboard: &cctk::sctk::reexports::client::protocol::wl_keyboard::WlKeyboard,
serial: u32,
event: sctk::seat::keyboard::KeyEvent,
event: cctk::sctk::seat::keyboard::KeyEvent,
) {
let (is_active, my_seat) =
match self.seats.iter_mut().enumerate().find_map(|(i, s)| {
@ -185,11 +185,11 @@ impl KeyboardHandler for SctkState {
fn release_key(
&mut self,
_conn: &sctk::reexports::client::Connection,
_qh: &sctk::reexports::client::QueueHandle<Self>,
keyboard: &sctk::reexports::client::protocol::wl_keyboard::WlKeyboard,
_conn: &cctk::sctk::reexports::client::Connection,
_qh: &cctk::sctk::reexports::client::QueueHandle<Self>,
keyboard: &cctk::sctk::reexports::client::protocol::wl_keyboard::WlKeyboard,
_serial: u32,
event: sctk::seat::keyboard::KeyEvent,
event: cctk::sctk::seat::keyboard::KeyEvent,
) {
let (is_active, my_seat) =
match self.seats.iter_mut().enumerate().find_map(|(i, s)| {
@ -220,11 +220,11 @@ impl KeyboardHandler for SctkState {
fn update_modifiers(
&mut self,
_conn: &sctk::reexports::client::Connection,
_qh: &sctk::reexports::client::QueueHandle<Self>,
keyboard: &sctk::reexports::client::protocol::wl_keyboard::WlKeyboard,
_conn: &cctk::sctk::reexports::client::Connection,
_qh: &cctk::sctk::reexports::client::QueueHandle<Self>,
keyboard: &cctk::sctk::reexports::client::protocol::wl_keyboard::WlKeyboard,
_serial: u32,
modifiers: sctk::seat::keyboard::Modifiers,
modifiers: cctk::sctk::seat::keyboard::Modifiers,
layout: u32,
) {
let (is_active, my_seat) =

View file

@ -4,7 +4,7 @@ use crate::{
event_loop::state::SctkState, sctk_event::SctkEvent,
},
};
use sctk::{
use cctk::sctk::{
delegate_pointer,
reexports::client::Proxy,
seat::pointer::{
@ -22,10 +22,10 @@ use winit::{
impl PointerHandler for SctkState {
fn pointer_frame(
&mut self,
conn: &sctk::reexports::client::Connection,
_qh: &sctk::reexports::client::QueueHandle<Self>,
pointer: &sctk::reexports::client::protocol::wl_pointer::WlPointer,
events: &[sctk::seat::pointer::PointerEvent],
conn: &cctk::sctk::reexports::client::Connection,
_qh: &cctk::sctk::reexports::client::QueueHandle<Self>,
pointer: &cctk::sctk::reexports::client::protocol::wl_pointer::WlPointer,
events: &[cctk::sctk::seat::pointer::PointerEvent],
) {
let (is_active, my_seat) =
match self.seats.iter_mut().enumerate().find_map(|(i, s)| {

View file

@ -2,23 +2,23 @@ use crate::platform_specific::wayland::{
event_loop::{state::SctkSeat, state::SctkState},
sctk_event::{KeyboardEventVariant, SctkEvent, SeatEventVariant},
};
use iced_runtime::keyboard::Modifiers;
use sctk::{
use cctk::sctk::{
delegate_seat,
reexports::client::{protocol::wl_keyboard::WlKeyboard, Proxy},
seat::{pointer::ThemeSpec, SeatHandler},
};
use iced_runtime::keyboard::Modifiers;
impl SeatHandler for SctkState {
fn seat_state(&mut self) -> &mut sctk::seat::SeatState {
fn seat_state(&mut self) -> &mut cctk::sctk::seat::SeatState {
&mut self.seat_state
}
fn new_seat(
&mut self,
_conn: &sctk::reexports::client::Connection,
qh: &sctk::reexports::client::QueueHandle<Self>,
seat: sctk::reexports::client::protocol::wl_seat::WlSeat,
_conn: &cctk::sctk::reexports::client::Connection,
qh: &cctk::sctk::reexports::client::QueueHandle<Self>,
seat: cctk::sctk::reexports::client::protocol::wl_seat::WlSeat,
) {
self.sctk_events.push(SctkEvent::SeatEvent {
variant: SeatEventVariant::New,
@ -43,10 +43,10 @@ impl SeatHandler for SctkState {
fn new_capability(
&mut self,
_conn: &sctk::reexports::client::Connection,
qh: &sctk::reexports::client::QueueHandle<Self>,
seat: sctk::reexports::client::protocol::wl_seat::WlSeat,
capability: sctk::seat::Capability,
_conn: &cctk::sctk::reexports::client::Connection,
qh: &cctk::sctk::reexports::client::QueueHandle<Self>,
seat: cctk::sctk::reexports::client::protocol::wl_seat::WlSeat,
capability: cctk::sctk::seat::Capability,
) {
let my_seat = match self.seats.iter_mut().find(|s| s.seat == seat) {
Some(s) => s,
@ -71,7 +71,7 @@ impl SeatHandler for SctkState {
};
// TODO data device
match capability {
sctk::seat::Capability::Keyboard => {
cctk::sctk::seat::Capability::Keyboard => {
let seat_clone = seat.clone();
let seat_clone_2 = seat.clone();
if let Ok(kbd) = self.seat_state.get_keyboard_with_repeat(
@ -107,7 +107,7 @@ impl SeatHandler for SctkState {
_ = my_seat.kbd.replace(kbd);
}
}
sctk::seat::Capability::Pointer => {
cctk::sctk::seat::Capability::Pointer => {
let surface = self.compositor_state.create_surface(qh);
if let Ok(ptr) = self.seat_state.get_pointer_with_theme(
@ -127,7 +127,7 @@ impl SeatHandler for SctkState {
_ = my_seat.ptr.replace(ptr);
}
}
sctk::seat::Capability::Touch => {
cctk::sctk::seat::Capability::Touch => {
if let Some(touch) = self.seat_state.get_touch(qh, &seat).ok() {
self.sctk_events.push(SctkEvent::SeatEvent {
variant: SeatEventVariant::NewCapability(
@ -145,10 +145,10 @@ impl SeatHandler for SctkState {
fn remove_capability(
&mut self,
_conn: &sctk::reexports::client::Connection,
_qh: &sctk::reexports::client::QueueHandle<Self>,
seat: sctk::reexports::client::protocol::wl_seat::WlSeat,
capability: sctk::seat::Capability,
_conn: &cctk::sctk::reexports::client::Connection,
_qh: &cctk::sctk::reexports::client::QueueHandle<Self>,
seat: cctk::sctk::reexports::client::protocol::wl_seat::WlSeat,
capability: cctk::sctk::seat::Capability,
) {
let my_seat = match self.seats.iter_mut().find(|s| s.seat == seat) {
Some(s) => s,
@ -158,7 +158,7 @@ impl SeatHandler for SctkState {
// TODO data device
match capability {
// TODO use repeating kbd?
sctk::seat::Capability::Keyboard => {
cctk::sctk::seat::Capability::Keyboard => {
if let Some(kbd) = my_seat.kbd.take() {
self.sctk_events.push(SctkEvent::SeatEvent {
variant: SeatEventVariant::RemoveCapability(
@ -169,7 +169,7 @@ impl SeatHandler for SctkState {
});
}
}
sctk::seat::Capability::Pointer => {
cctk::sctk::seat::Capability::Pointer => {
if let Some(ptr) = my_seat.ptr.take() {
self.sctk_events.push(SctkEvent::SeatEvent {
variant: SeatEventVariant::RemoveCapability(
@ -180,7 +180,7 @@ impl SeatHandler for SctkState {
});
}
}
sctk::seat::Capability::Touch => {
cctk::sctk::seat::Capability::Touch => {
if let Some(touch) = my_seat.touch.take() {
self.sctk_events.push(SctkEvent::SeatEvent {
variant: SeatEventVariant::RemoveCapability(
@ -197,9 +197,9 @@ impl SeatHandler for SctkState {
fn remove_seat(
&mut self,
_conn: &sctk::reexports::client::Connection,
_qh: &sctk::reexports::client::QueueHandle<Self>,
seat: sctk::reexports::client::protocol::wl_seat::WlSeat,
_conn: &cctk::sctk::reexports::client::Connection,
_qh: &cctk::sctk::reexports::client::QueueHandle<Self>,
seat: cctk::sctk::reexports::client::protocol::wl_seat::WlSeat,
) {
self.sctk_events.push(SctkEvent::SeatEvent {
variant: SeatEventVariant::Remove,

View file

@ -7,7 +7,7 @@ use crate::{
},
};
use iced_runtime::core::{touch, Point};
use sctk::{
use cctk::sctk::{
delegate_touch,
reexports::client::{
protocol::{wl_surface::WlSurface, wl_touch::WlTouch},

View file

@ -1,7 +1,7 @@
use crate::platform_specific::wayland::{
handlers::SctkState, sctk_event::SctkEvent,
};
use sctk::{
use cctk::sctk::{
delegate_session_lock,
reexports::client::{Connection, QueueHandle},
session_lock::{

View file

@ -2,7 +2,7 @@ use crate::platform_specific::wayland::{
event_loop::state::SctkState,
sctk_event::{LayerSurfaceEventVariant, SctkEvent},
};
use sctk::{
use cctk::sctk::{
delegate_layer,
reexports::client::Proxy,
shell::{
@ -16,9 +16,9 @@ use winit::dpi::LogicalSize;
impl LayerShellHandler for SctkState {
fn closed(
&mut self,
_conn: &sctk::reexports::client::Connection,
_qh: &sctk::reexports::client::QueueHandle<Self>,
layer: &sctk::shell::wlr_layer::LayerSurface,
_conn: &cctk::sctk::reexports::client::Connection,
_qh: &cctk::sctk::reexports::client::QueueHandle<Self>,
layer: &cctk::sctk::shell::wlr_layer::LayerSurface,
) {
let layer = match self.layer_surfaces.iter().position(|s| {
s.surface.wl_surface().id() == layer.wl_surface().id()
@ -36,10 +36,10 @@ impl LayerShellHandler for SctkState {
fn configure(
&mut self,
_conn: &sctk::reexports::client::Connection,
_qh: &sctk::reexports::client::QueueHandle<Self>,
layer: &sctk::shell::wlr_layer::LayerSurface,
mut configure: sctk::shell::wlr_layer::LayerSurfaceConfigure,
_conn: &cctk::sctk::reexports::client::Connection,
_qh: &cctk::sctk::reexports::client::QueueHandle<Self>,
layer: &cctk::sctk::shell::wlr_layer::LayerSurface,
mut configure: cctk::sctk::shell::wlr_layer::LayerSurfaceConfigure,
_serial: u32,
) {
self.request_redraw(layer.wl_surface());

View file

@ -2,7 +2,7 @@ use crate::platform_specific::wayland::{
event_loop::state::{self, PopupParent, SctkState},
sctk_event::{PopupEventVariant, SctkEvent},
};
use sctk::{
use cctk::sctk::{
delegate_xdg_popup, reexports::client::Proxy,
shell::xdg::popup::PopupHandler,
};
@ -10,10 +10,10 @@ use sctk::{
impl PopupHandler for SctkState {
fn configure(
&mut self,
_conn: &sctk::reexports::client::Connection,
_qh: &sctk::reexports::client::QueueHandle<Self>,
popup: &sctk::shell::xdg::popup::Popup,
configure: sctk::shell::xdg::popup::PopupConfigure,
_conn: &cctk::sctk::reexports::client::Connection,
_qh: &cctk::sctk::reexports::client::QueueHandle<Self>,
popup: &cctk::sctk::shell::xdg::popup::Popup,
configure: cctk::sctk::shell::xdg::popup::PopupConfigure,
) {
self.request_redraw(popup.wl_surface());
let sctk_popup = match self.popups.iter_mut().find(|s| {
@ -43,9 +43,9 @@ impl PopupHandler for SctkState {
fn done(
&mut self,
_conn: &sctk::reexports::client::Connection,
_qh: &sctk::reexports::client::QueueHandle<Self>,
popup: &sctk::shell::xdg::popup::Popup,
_conn: &cctk::sctk::reexports::client::Connection,
_qh: &cctk::sctk::reexports::client::QueueHandle<Self>,
popup: &cctk::sctk::shell::xdg::popup::Popup,
) {
let sctk_popup = match self.popups.iter().position(|s| {
s.popup.wl_surface().clone() == popup.wl_surface().clone()

View file

@ -1,23 +1,23 @@
use crate::platform_specific::wayland::event_loop::state::SctkState;
use sctk::{
use cctk::sctk::{
delegate_xdg_shell, delegate_xdg_window, shell::xdg::window::WindowHandler,
};
impl WindowHandler for SctkState {
fn request_close(
&mut self,
_conn: &sctk::reexports::client::Connection,
_qh: &sctk::reexports::client::QueueHandle<Self>,
_window: &sctk::shell::xdg::window::Window,
_conn: &cctk::sctk::reexports::client::Connection,
_qh: &cctk::sctk::reexports::client::QueueHandle<Self>,
_window: &cctk::sctk::shell::xdg::window::Window,
) {
}
fn configure(
&mut self,
_conn: &sctk::reexports::client::Connection,
_qh: &sctk::reexports::client::QueueHandle<Self>,
_window: &sctk::shell::xdg::window::Window,
_configure: sctk::shell::xdg::window::WindowConfigure,
_conn: &cctk::sctk::reexports::client::Connection,
_qh: &cctk::sctk::reexports::client::QueueHandle<Self>,
_window: &cctk::sctk::shell::xdg::window::Window,
_configure: cctk::sctk::shell::xdg::window::WindowConfigure,
_serial: u32,
) {
}

View file

@ -1,4 +1,4 @@
use crate::platform_specific::wayland::handlers::SctkState;
use sctk::delegate_subcompositor;
use cctk::sctk::delegate_subcompositor;
delegate_subcompositor!(SctkState);

View file

@ -1,15 +1,15 @@
// From: https://github.com/rust-windowing/winit/blob/master/src/platform_impl/linux/wayland/types/wp_fractional_scaling.rs
//! Handling of the fractional scaling.
use sctk::reexports::client::globals::{BindError, GlobalList};
use sctk::reexports::client::protocol::wl_surface::WlSurface;
use sctk::reexports::client::Dispatch;
use sctk::reexports::client::{delegate_dispatch, Connection, Proxy, QueueHandle};
use sctk::reexports::protocols::wp::fractional_scale::v1::client::wp_fractional_scale_manager_v1::WpFractionalScaleManagerV1;
use sctk::reexports::protocols::wp::fractional_scale::v1::client::wp_fractional_scale_v1::Event as FractionalScalingEvent;
use sctk::reexports::protocols::wp::fractional_scale::v1::client::wp_fractional_scale_v1::WpFractionalScaleV1;
use cctk::sctk::reexports::client::globals::{BindError, GlobalList};
use cctk::sctk::reexports::client::protocol::wl_surface::WlSurface;
use cctk::sctk::reexports::client::Dispatch;
use cctk::sctk::reexports::client::{delegate_dispatch, Connection, Proxy, QueueHandle};
use cctk::sctk::reexports::protocols::wp::fractional_scale::v1::client::wp_fractional_scale_manager_v1::WpFractionalScaleManagerV1;
use cctk::sctk::reexports::protocols::wp::fractional_scale::v1::client::wp_fractional_scale_v1::Event as FractionalScalingEvent;
use cctk::sctk::reexports::protocols::wp::fractional_scale::v1::client::wp_fractional_scale_v1::WpFractionalScaleV1;
use sctk::globals::GlobalData;
use cctk::sctk::globals::GlobalData;
use crate::platform_specific::wayland::event_loop::state::SctkState;

View file

@ -1,15 +1,15 @@
//! Handling of the wp-viewporter.
use sctk::reexports::client::globals::{BindError, GlobalList};
use sctk::reexports::client::protocol::wl_surface::WlSurface;
use sctk::reexports::client::Dispatch;
use sctk::reexports::client::{
use cctk::sctk::reexports::client::globals::{BindError, GlobalList};
use cctk::sctk::reexports::client::protocol::wl_surface::WlSurface;
use cctk::sctk::reexports::client::Dispatch;
use cctk::sctk::reexports::client::{
delegate_dispatch, Connection, Proxy, QueueHandle,
};
use sctk::reexports::protocols::wp::viewporter::client::wp_viewport::WpViewport;
use sctk::reexports::protocols::wp::viewporter::client::wp_viewporter::WpViewporter;
use cctk::sctk::reexports::protocols::wp::viewporter::client::wp_viewport::WpViewport;
use cctk::sctk::reexports::protocols::wp::viewporter::client::wp_viewporter::WpViewporter;
use sctk::globals::GlobalData;
use cctk::sctk::globals::GlobalData;
use crate::platform_specific::wayland::event_loop::state::SctkState;