Try to support selecting toplevel
This commit is contained in:
parent
82cedc6b78
commit
61726ad3cc
2 changed files with 59 additions and 8 deletions
21
src/main.rs
21
src/main.rs
|
|
@ -6,7 +6,10 @@ use cctk::{
|
|||
},
|
||||
sctk::shell::layer::{Anchor, KeyboardInteractivity, Layer},
|
||||
toplevel_info::ToplevelInfo,
|
||||
wayland_client::{protocol::wl_output, Connection, QueueHandle, WEnum},
|
||||
wayland_client::{
|
||||
protocol::{wl_output, wl_seat},
|
||||
Connection, QueueHandle, WEnum,
|
||||
},
|
||||
};
|
||||
use iced::{
|
||||
event::wayland::{Event as WaylandEvent, OutputEvent},
|
||||
|
|
@ -68,6 +71,7 @@ struct App {
|
|||
conn: Option<Connection>,
|
||||
workspace_manager: Option<zcosmic_workspace_manager_v1::ZcosmicWorkspaceManagerV1>,
|
||||
toplevel_manager: Option<zcosmic_toplevel_manager_v1::ZcosmicToplevelManagerV1>,
|
||||
seats: Vec<wl_seat::WlSeat>,
|
||||
}
|
||||
|
||||
impl App {
|
||||
|
|
@ -223,6 +227,9 @@ impl Application for App {
|
|||
toplevel.img = Some(image.clone());
|
||||
}
|
||||
}
|
||||
wayland::Event::Seats(seats) => {
|
||||
self.seats = seats;
|
||||
}
|
||||
}
|
||||
}
|
||||
Msg::Close => {
|
||||
|
|
@ -236,13 +243,15 @@ impl Application for App {
|
|||
self.conn.as_ref().unwrap().flush();
|
||||
}
|
||||
Msg::ActivateToplevel(toplevel_handle) => {
|
||||
/*
|
||||
if let Some(toplevel_manager) = self.toplevel_manager.as_ref() {
|
||||
toplevel_manager.activate(&toplevel_handle, todo!());
|
||||
self.conn.as_ref().unwrap().flush();
|
||||
std::process::exit(0); // Can we assume flush is suficient to ensure this takes effect?
|
||||
if !self.seats.is_empty() {
|
||||
for seat in &self.seats {
|
||||
toplevel_manager.activate(&toplevel_handle, todo!());
|
||||
self.conn.as_ref().unwrap().flush();
|
||||
}
|
||||
std::process::exit(0); // Can we assume flush is suficient to ensure this takes effect?
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use cctk::{
|
|||
self,
|
||||
output::{OutputHandler, OutputState},
|
||||
registry::{ProvidesRegistryState, RegistryState},
|
||||
seat::{SeatHandler, SeatState},
|
||||
shm::{raw::RawPool, ShmHandler, ShmState},
|
||||
},
|
||||
toplevel_info::{ToplevelInfo, ToplevelInfoHandler, ToplevelInfoState},
|
||||
|
|
@ -25,7 +26,7 @@ use cctk::{
|
|||
wayland_client::{
|
||||
backend::ObjectId,
|
||||
globals::registry_queue_init,
|
||||
protocol::{wl_buffer, wl_output, wl_shm},
|
||||
protocol::{wl_buffer, wl_output, wl_seat, wl_shm},
|
||||
Connection, Dispatch, Proxy, QueueHandle, WEnum,
|
||||
},
|
||||
workspace::{WorkspaceHandler, WorkspaceState},
|
||||
|
|
@ -58,6 +59,7 @@ pub enum Event {
|
|||
zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1,
|
||||
image::Handle,
|
||||
),
|
||||
Seats(Vec<wl_seat::WlSeat>),
|
||||
}
|
||||
|
||||
pub fn subscription() -> iced::Subscription<Event> {
|
||||
|
|
@ -82,11 +84,13 @@ pub struct AppData {
|
|||
toplevel_info_state: ToplevelInfoState,
|
||||
workspace_state: WorkspaceState,
|
||||
screencopy_state: ScreencopyState,
|
||||
seat_state: SeatState,
|
||||
shm_state: ShmState,
|
||||
toplevel_manager_state: ToplevelManagerState,
|
||||
sender: mpsc::Sender<Event>,
|
||||
frames: HashMap<ObjectId, Frame>,
|
||||
output_names: HashMap<ObjectId, Option<String>>,
|
||||
seats: Vec<wl_seat::WlSeat>,
|
||||
}
|
||||
|
||||
impl AppData {
|
||||
|
|
@ -100,7 +104,42 @@ impl ProvidesRegistryState for AppData {
|
|||
&mut self.registry_state
|
||||
}
|
||||
|
||||
sctk::registry_handlers!(OutputState,);
|
||||
sctk::registry_handlers!(OutputState, SeatState);
|
||||
}
|
||||
|
||||
impl SeatHandler for AppData {
|
||||
fn seat_state(&mut self) -> &mut SeatState {
|
||||
&mut self.seat_state
|
||||
}
|
||||
|
||||
fn new_seat(&mut self, _: &Connection, _: &QueueHandle<Self>, seat: wl_seat::WlSeat) {
|
||||
self.seats.push(seat);
|
||||
self.send_event(Event::Seats(self.seats.clone()));
|
||||
}
|
||||
|
||||
fn remove_seat(&mut self, _: &Connection, _: &QueueHandle<Self>, seat: wl_seat::WlSeat) {
|
||||
if let Some(idx) = self.seats.iter().position(|i| i == &seat) {
|
||||
self.seats.remove(idx);
|
||||
}
|
||||
self.send_event(Event::Seats(self.seats.clone()));
|
||||
}
|
||||
|
||||
fn new_capability(
|
||||
&mut self,
|
||||
_: &Connection,
|
||||
_: &QueueHandle<Self>,
|
||||
_: wl_seat::WlSeat,
|
||||
_: sctk::seat::Capability,
|
||||
) {
|
||||
}
|
||||
fn remove_capability(
|
||||
&mut self,
|
||||
_: &Connection,
|
||||
_: &QueueHandle<Self>,
|
||||
_: wl_seat::WlSeat,
|
||||
_: sctk::seat::Capability,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
impl ShmHandler for AppData {
|
||||
|
|
@ -354,10 +393,12 @@ fn start() -> mpsc::Receiver<Event> {
|
|||
toplevel_manager_state: ToplevelManagerState::new(®istry_state, &qh),
|
||||
screencopy_state: ScreencopyState::new(&globals, &qh),
|
||||
registry_state,
|
||||
seat_state: SeatState::new(&globals, &qh),
|
||||
shm_state: ShmState::bind(&globals, &qh).unwrap(),
|
||||
sender,
|
||||
frames: HashMap::new(),
|
||||
output_names: HashMap::new(),
|
||||
seats: Vec::new(),
|
||||
};
|
||||
|
||||
app_data.send_event(Event::Connection(conn));
|
||||
|
|
@ -377,6 +418,7 @@ fn start() -> mpsc::Receiver<Event> {
|
|||
|
||||
sctk::delegate_output!(AppData);
|
||||
sctk::delegate_registry!(AppData);
|
||||
sctk::delegate_seat!(AppData);
|
||||
sctk::delegate_shm!(AppData);
|
||||
cctk::delegate_toplevel_info!(AppData);
|
||||
cctk::delegate_toplevel_manager!(AppData);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue