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