Update dependencies
This commit is contained in:
parent
63f299a0be
commit
01b007ef83
5 changed files with 730 additions and 406 deletions
1056
Cargo.lock
generated
1056
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -4,7 +4,7 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
calloop = "0.10.5"
|
||||
calloop = "0.12.3"
|
||||
cctk = { package = "cosmic-client-toolkit", git = "https://github.com/pop-os/cosmic-protocols" }
|
||||
env_logger = "0.10.0"
|
||||
futures-channel = "0.3.25"
|
||||
|
|
|
|||
35
src/main.rs
35
src/main.rs
|
|
@ -20,7 +20,7 @@ use cosmic::{
|
|||
keyboard::KeyCode,
|
||||
wayland::{
|
||||
actions::data_device::{DataFromMimeType, DndIcon},
|
||||
data_device::{accept_mime_type, start_drag, set_actions},
|
||||
data_device::{accept_mime_type, set_actions, start_drag},
|
||||
},
|
||||
widget, Application, Command, Size, Subscription,
|
||||
},
|
||||
|
|
@ -35,7 +35,10 @@ use cosmic::{
|
|||
settings::InitialSurface,
|
||||
},
|
||||
};
|
||||
use std::{collections::HashMap, mem};
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
mem,
|
||||
};
|
||||
|
||||
// accept_mime_type, finish_dnd, request_dnd_data, set_actions,
|
||||
|
||||
|
|
@ -88,7 +91,7 @@ struct Workspace {
|
|||
struct Toplevel {
|
||||
handle: zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1,
|
||||
info: ToplevelInfo,
|
||||
output_name: Option<String>,
|
||||
output_names: HashSet<String>,
|
||||
img: Option<iced::widget::image::Handle>,
|
||||
}
|
||||
|
||||
|
|
@ -354,20 +357,20 @@ impl Application for App {
|
|||
}
|
||||
self.update_capture_filter();
|
||||
}
|
||||
wayland::Event::NewToplevel(handle, output_name, info) => {
|
||||
wayland::Event::NewToplevel(handle, output_names, info) => {
|
||||
println!("New toplevel: {info:?}");
|
||||
self.toplevels.push(Toplevel {
|
||||
handle,
|
||||
output_name,
|
||||
output_names,
|
||||
info,
|
||||
img: None,
|
||||
});
|
||||
}
|
||||
wayland::Event::UpdateToplevel(handle, output_name, info) => {
|
||||
wayland::Event::UpdateToplevel(handle, output_names, info) => {
|
||||
if let Some(toplevel) =
|
||||
self.toplevels.iter_mut().find(|x| x.handle == handle)
|
||||
{
|
||||
toplevel.output_name = output_name;
|
||||
toplevel.output_names = output_names;
|
||||
toplevel.info = info;
|
||||
}
|
||||
}
|
||||
|
|
@ -528,16 +531,14 @@ fn layer_surface<'a>(app: &'a App, surface: &'a LayerSurface) -> cosmic::Element
|
|||
&surface.output_name
|
||||
),
|
||||
toplevel_previews(app.toplevels.iter().filter(|i| {
|
||||
if i.output_name.as_ref() != Some(&surface.output_name) {
|
||||
if !i.output_names.contains(&surface.output_name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if let Some(workspace) = &i.info.workspace {
|
||||
i.info.workspace.iter().any(|workspace| {
|
||||
app.workspace_for_handle(workspace)
|
||||
.map_or(false, |x| x.is_active)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
})
|
||||
}))
|
||||
]
|
||||
.spacing(12)
|
||||
|
|
@ -547,7 +548,7 @@ fn layer_surface<'a>(app: &'a App, surface: &'a LayerSurface) -> cosmic::Element
|
|||
}
|
||||
|
||||
fn close_button(on_press: Msg) -> cosmic::Element<'static, Msg> {
|
||||
iced::widget::button(cosmic::widget::icon("window-close-symbolic", 16))
|
||||
cosmic::widget::button(cosmic::widget::icon::from_name("window-close-symbolic").size(16))
|
||||
.style(cosmic::theme::Button::Destructive)
|
||||
.on_press(on_press)
|
||||
.into()
|
||||
|
|
@ -556,13 +557,13 @@ fn close_button(on_press: Msg) -> cosmic::Element<'static, Msg> {
|
|||
fn workspace_item<'a>(workspace: &'a Workspace, output_name: &'a str) -> cosmic::Element<'a, Msg> {
|
||||
// TODO style
|
||||
let theme = if workspace.is_active {
|
||||
cosmic::theme::Button::Primary
|
||||
cosmic::theme::Button::Suggested
|
||||
} else {
|
||||
cosmic::theme::Button::Secondary
|
||||
cosmic::theme::Button::Standard
|
||||
};
|
||||
widget::column![
|
||||
close_button(Msg::CloseWorkspace(workspace.handle.clone())),
|
||||
widget::button(widget::column![
|
||||
cosmic::widget::button(widget::column![
|
||||
widget::Image::new(
|
||||
workspace
|
||||
.img_for_output
|
||||
|
|
@ -615,7 +616,7 @@ fn workspaces_sidebar<'a>(
|
|||
.on_enter(Msg::DndWorkspaceEnter)
|
||||
.on_exit(Msg::DndWorkspaceLeave)
|
||||
.on_drop(Msg::DndWorkspaceDrop)
|
||||
.on_data(Msg::DndWorkspaceData)
|
||||
.on_data(Msg::DndWorkspaceData),
|
||||
)
|
||||
.width(iced::Length::Fill)
|
||||
.height(iced::Length::Fill)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use cctk::{
|
|||
sctk::{
|
||||
self,
|
||||
output::{OutputHandler, OutputState},
|
||||
reexports::calloop_wayland_source::WaylandSource,
|
||||
registry::{ProvidesRegistryState, RegistryState},
|
||||
seat::{SeatHandler, SeatState},
|
||||
shm::{Shm, ShmHandler},
|
||||
|
|
@ -26,7 +27,7 @@ use cctk::{
|
|||
backend::ObjectId,
|
||||
globals::registry_queue_init,
|
||||
protocol::{wl_output, wl_seat},
|
||||
Connection, Proxy, QueueHandle, WaylandSource,
|
||||
Connection, Proxy, QueueHandle,
|
||||
},
|
||||
workspace::WorkspaceState,
|
||||
};
|
||||
|
|
@ -36,7 +37,12 @@ use cosmic::iced::{
|
|||
widget::image,
|
||||
};
|
||||
use futures_channel::mpsc;
|
||||
use std::{cell::RefCell, collections::HashMap, sync::Arc, thread};
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
collections::{HashMap, HashSet},
|
||||
sync::Arc,
|
||||
thread,
|
||||
};
|
||||
|
||||
mod buffer;
|
||||
use buffer::Buffer;
|
||||
|
|
@ -65,12 +71,12 @@ pub enum Event {
|
|||
),
|
||||
NewToplevel(
|
||||
zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1,
|
||||
Option<String>,
|
||||
HashSet<String>,
|
||||
ToplevelInfo,
|
||||
),
|
||||
UpdateToplevel(
|
||||
zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1,
|
||||
Option<String>,
|
||||
HashSet<String>,
|
||||
ToplevelInfo,
|
||||
),
|
||||
CloseToplevel(zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1),
|
||||
|
|
@ -126,13 +132,11 @@ impl AppData {
|
|||
match source {
|
||||
CaptureSource::Toplevel(toplevel) => {
|
||||
let info = self.toplevel_info_state.info(toplevel).unwrap();
|
||||
if let Some(workspace) = &info.workspace {
|
||||
info.workspace.iter().any(|workspace| {
|
||||
self.capture_filter
|
||||
.toplevels_on_workspaces
|
||||
.contains(workspace)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
})
|
||||
}
|
||||
CaptureSource::Workspace(_, output) => {
|
||||
if let Some(name) = &self.output_state.info(&output).and_then(|x| x.name) {
|
||||
|
|
@ -286,7 +290,7 @@ fn start() -> mpsc::Receiver<Event> {
|
|||
captures: RefCell::new(HashMap::new()),
|
||||
};
|
||||
|
||||
app_data.send_event(Event::Connection(conn));
|
||||
app_data.send_event(Event::Connection(conn.clone()));
|
||||
app_data.send_event(Event::Seats(app_data.seat_state.seats().collect()));
|
||||
app_data.send_event(Event::ToplevelManager(
|
||||
app_data.toplevel_manager_state.manager.clone(),
|
||||
|
|
@ -303,8 +307,7 @@ fn start() -> mpsc::Receiver<Event> {
|
|||
app_data.send_event(Event::CmdSender(cmd_sender));
|
||||
|
||||
let mut event_loop = calloop::EventLoop::try_new().unwrap();
|
||||
WaylandSource::new(event_queue)
|
||||
.unwrap()
|
||||
WaylandSource::new(conn, event_queue)
|
||||
.insert(event_loop.handle())
|
||||
.unwrap();
|
||||
event_loop
|
||||
|
|
|
|||
|
|
@ -23,13 +23,14 @@ impl ToplevelInfoHandler for AppData {
|
|||
toplevel: &zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1,
|
||||
) {
|
||||
let info = self.toplevel_info_state.info(toplevel).unwrap();
|
||||
let output_name = info
|
||||
let output_names = info
|
||||
.output
|
||||
.as_ref()
|
||||
.and_then(|o| self.output_names.get(&o.id()).cloned()?);
|
||||
.iter()
|
||||
.filter_map(|o| self.output_names.get(&o.id()).cloned()?)
|
||||
.collect();
|
||||
self.send_event(Event::NewToplevel(
|
||||
toplevel.clone(),
|
||||
output_name,
|
||||
output_names,
|
||||
info.clone(),
|
||||
));
|
||||
|
||||
|
|
@ -43,13 +44,14 @@ impl ToplevelInfoHandler for AppData {
|
|||
toplevel: &zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1,
|
||||
) {
|
||||
let info = self.toplevel_info_state.info(toplevel).unwrap();
|
||||
let output_name = info
|
||||
let output_names = info
|
||||
.output
|
||||
.as_ref()
|
||||
.and_then(|o| self.output_names.get(&o.id()).cloned()?);
|
||||
.iter()
|
||||
.filter_map(|o| self.output_names.get(&o.id()).cloned()?)
|
||||
.collect();
|
||||
self.send_event(Event::UpdateToplevel(
|
||||
toplevel.clone(),
|
||||
output_name,
|
||||
output_names,
|
||||
info.clone(),
|
||||
));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue