Clippy fixes
This commit is contained in:
parent
8c690e9648
commit
a5b78a4300
4 changed files with 38 additions and 35 deletions
37
src/main.rs
37
src/main.rs
|
|
@ -1,14 +1,16 @@
|
||||||
|
#![allow(clippy::single_match)]
|
||||||
|
|
||||||
use cctk::{
|
use cctk::{
|
||||||
cosmic_protocols::{
|
cosmic_protocols::{
|
||||||
toplevel_info::v1::client::zcosmic_toplevel_handle_v1,
|
toplevel_info::v1::client::zcosmic_toplevel_handle_v1,
|
||||||
toplevel_management::v1::client::zcosmic_toplevel_manager_v1,
|
toplevel_management::v1::client::zcosmic_toplevel_manager_v1,
|
||||||
workspace::v1::client::{zcosmic_workspace_handle_v1, zcosmic_workspace_manager_v1},
|
workspace::v1::client::{zcosmic_workspace_handle_v1, zcosmic_workspace_manager_v1},
|
||||||
},
|
},
|
||||||
sctk::shell::layer::{Anchor, KeyboardInteractivity, Layer},
|
sctk::shell::layer::{KeyboardInteractivity, Layer},
|
||||||
toplevel_info::ToplevelInfo,
|
toplevel_info::ToplevelInfo,
|
||||||
wayland_client::{
|
wayland_client::{
|
||||||
protocol::{wl_output, wl_seat},
|
protocol::{wl_output, wl_seat},
|
||||||
Connection, QueueHandle, WEnum,
|
Connection, WEnum,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
|
|
@ -16,7 +18,7 @@ use cosmic::{
|
||||||
self,
|
self,
|
||||||
event::wayland::{Event as WaylandEvent, OutputEvent},
|
event::wayland::{Event as WaylandEvent, OutputEvent},
|
||||||
keyboard::KeyCode,
|
keyboard::KeyCode,
|
||||||
widget, Application, Command, Element, Subscription,
|
widget, Application, Command, Subscription,
|
||||||
},
|
},
|
||||||
iced_native::{
|
iced_native::{
|
||||||
command::platform_specific::wayland::layer_surface::{
|
command::platform_specific::wayland::layer_surface::{
|
||||||
|
|
@ -30,7 +32,7 @@ use cosmic::{
|
||||||
settings::InitialSurface,
|
settings::InitialSurface,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use std::{collections::HashMap, mem, process};
|
use std::{collections::HashMap, mem};
|
||||||
|
|
||||||
mod toggle_dbus;
|
mod toggle_dbus;
|
||||||
mod wayland;
|
mod wayland;
|
||||||
|
|
@ -132,7 +134,7 @@ impl App {
|
||||||
) -> Command<Msg> {
|
) -> Command<Msg> {
|
||||||
let id = self.next_surface_id();
|
let id = self.next_surface_id();
|
||||||
self.layer_surfaces.insert(
|
self.layer_surfaces.insert(
|
||||||
id.clone(),
|
id,
|
||||||
LayerSurface {
|
LayerSurface {
|
||||||
output: output.clone(),
|
output: output.clone(),
|
||||||
output_name,
|
output_name,
|
||||||
|
|
@ -242,8 +244,7 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
OutputEvent::Created(None) => {} // XXX?
|
OutputEvent::Created(None) => {} // XXX?
|
||||||
OutputEvent::InfoUpdate(info) => {
|
OutputEvent::InfoUpdate(info) => {
|
||||||
if let Some(output) = self.outputs.iter_mut().find(|x| &x.handle == &output)
|
if let Some(output) = self.outputs.iter_mut().find(|x| x.handle == output) {
|
||||||
{
|
|
||||||
if let Some((width, height)) = info.logical_size {
|
if let Some((width, height)) = info.logical_size {
|
||||||
output.width = width;
|
output.width = width;
|
||||||
output.height = height;
|
output.height = height;
|
||||||
|
|
@ -253,7 +254,7 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OutputEvent::Removed => {
|
OutputEvent::Removed => {
|
||||||
if let Some(idx) = self.outputs.iter().position(|x| &x.handle == &output) {
|
if let Some(idx) = self.outputs.iter().position(|x| x.handle == output) {
|
||||||
self.outputs.remove(idx);
|
self.outputs.remove(idx);
|
||||||
}
|
}
|
||||||
if self.visible {
|
if self.visible {
|
||||||
|
|
@ -288,7 +289,7 @@ impl Application for App {
|
||||||
// XXX efficiency
|
// XXX efficiency
|
||||||
let img = old_workspaces
|
let img = old_workspaces
|
||||||
.iter()
|
.iter()
|
||||||
.find(|i| &i.handle == &workspace.handle)
|
.find(|i| i.handle == workspace.handle)
|
||||||
.and_then(|i| i.img.clone());
|
.and_then(|i| i.img.clone());
|
||||||
|
|
||||||
self.workspaces.push(Workspace {
|
self.workspaces.push(Workspace {
|
||||||
|
|
@ -301,7 +302,7 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wayland::Event::NewToplevel(handle, info) => {
|
wayland::Event::NewToplevel(handle, info) => {
|
||||||
println!("New toplevel: {:?}", info);
|
println!("New toplevel: {info:?}");
|
||||||
self.toplevels.push(Toplevel {
|
self.toplevels.push(Toplevel {
|
||||||
handle,
|
handle,
|
||||||
info,
|
info,
|
||||||
|
|
@ -315,13 +316,13 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
wayland::Event::WorkspaceCapture(handle, image) => {
|
wayland::Event::WorkspaceCapture(handle, image) => {
|
||||||
if let Some(workspace) = self.workspace_for_handle_mut(&handle) {
|
if let Some(workspace) = self.workspace_for_handle_mut(&handle) {
|
||||||
workspace.img = Some(image.clone());
|
workspace.img = Some(image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wayland::Event::ToplevelCapture(handle, image) => {
|
wayland::Event::ToplevelCapture(handle, image) => {
|
||||||
if let Some(toplevel) = self.toplevel_for_handle_mut(&handle) {
|
if let Some(toplevel) = self.toplevel_for_handle_mut(&handle) {
|
||||||
println!("Got toplevel image!");
|
println!("Got toplevel image!");
|
||||||
toplevel.img = Some(image.clone());
|
toplevel.img = Some(image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wayland::Event::Seats(seats) => {
|
wayland::Event::Seats(seats) => {
|
||||||
|
|
@ -337,20 +338,20 @@ impl Application for App {
|
||||||
let workspace_manager = self.workspace_manager.as_ref().unwrap();
|
let workspace_manager = self.workspace_manager.as_ref().unwrap();
|
||||||
workspace_handle.activate();
|
workspace_handle.activate();
|
||||||
workspace_manager.commit();
|
workspace_manager.commit();
|
||||||
self.conn.as_ref().unwrap().flush();
|
let _ = self.conn.as_ref().unwrap().flush();
|
||||||
}
|
}
|
||||||
Msg::ActivateToplevel(toplevel_handle) => {
|
Msg::ActivateToplevel(toplevel_handle) => {
|
||||||
if let Some(toplevel_manager) = self.toplevel_manager.as_ref() {
|
if let Some(toplevel_manager) = self.toplevel_manager.as_ref() {
|
||||||
if !self.seats.is_empty() {
|
if !self.seats.is_empty() {
|
||||||
for seat in &self.seats {
|
for seat in &self.seats {
|
||||||
toplevel_manager.activate(&toplevel_handle, &seat);
|
toplevel_manager.activate(&toplevel_handle, seat);
|
||||||
self.conn.as_ref().unwrap().flush();
|
|
||||||
}
|
}
|
||||||
|
let _ = self.conn.as_ref().unwrap().flush();
|
||||||
return self.hide();
|
return self.hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Msg::CloseWorkspace(workspace_handle) => {}
|
Msg::CloseWorkspace(_workspace_handle) => {}
|
||||||
Msg::CloseToplevel(toplevel_handle) => {
|
Msg::CloseToplevel(toplevel_handle) => {
|
||||||
// TODO confirmation?
|
// TODO confirmation?
|
||||||
if let Some(toplevel_manager) = self.toplevel_manager.as_ref() {
|
if let Some(toplevel_manager) = self.toplevel_manager.as_ref() {
|
||||||
|
|
@ -407,7 +408,7 @@ fn layer_surface<'a>(app: &'a App, surface: &'a LayerSurface) -> cosmic::Element
|
||||||
workspaces_sidebar(
|
workspaces_sidebar(
|
||||||
app.workspaces
|
app.workspaces
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|i| &i.output_name == &surface.output_name),
|
.filter(|i| i.output_name == surface.output_name),
|
||||||
),
|
),
|
||||||
toplevel_previews(app.toplevels.iter().filter(|i| {
|
toplevel_previews(app.toplevels.iter().filter(|i| {
|
||||||
if let Some(workspace) = &i.info.workspace {
|
if let Some(workspace) = &i.info.workspace {
|
||||||
|
|
@ -461,7 +462,7 @@ fn workspaces_sidebar<'a>(
|
||||||
// New workspace
|
// New workspace
|
||||||
}
|
}
|
||||||
|
|
||||||
fn toplevel_preview<'a>(toplevel: &'a Toplevel) -> cosmic::Element<'a, Msg> {
|
fn toplevel_preview(toplevel: &Toplevel) -> cosmic::Element<Msg> {
|
||||||
// capture of window
|
// capture of window
|
||||||
// - selectable
|
// - selectable
|
||||||
// name of window
|
// name of window
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use cosmic::iced::{self, futures::StreamExt, subscription};
|
use cosmic::iced::{self, futures::StreamExt, subscription};
|
||||||
use futures_channel::mpsc;
|
use futures_channel::mpsc;
|
||||||
use std::{fmt::Debug, hash::Hash};
|
use std::fmt::Debug;
|
||||||
use zbus::{dbus_interface, Connection, ConnectionBuilder};
|
use zbus::{dbus_interface, Connection, ConnectionBuilder};
|
||||||
|
|
||||||
pub fn subscription() -> iced::Subscription<Event> {
|
pub fn subscription() -> iced::Subscription<Event> {
|
||||||
|
|
@ -36,7 +36,7 @@ async fn start_listening(state: State) -> (Option<Event>, State) {
|
||||||
return (None, State::Waiting(conn, rx));
|
return (None, State::Waiting(conn, rx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (None, State::Finished);
|
(None, State::Finished)
|
||||||
}
|
}
|
||||||
State::Waiting(conn, mut rx) => {
|
State::Waiting(conn, mut rx) => {
|
||||||
if let Some(Event::Toggle) = rx.next().await {
|
if let Some(Event::Toggle) = rx.next().await {
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ impl Buffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Buffer must be released by server for safety
|
// Buffer must be released by server for safety
|
||||||
|
#[allow(clippy::wrong_self_convention)]
|
||||||
pub unsafe fn to_image(&mut self) -> image::Handle {
|
pub unsafe fn to_image(&mut self) -> image::Handle {
|
||||||
// XXX is this at all a performance issue?
|
// XXX is this at all a performance issue?
|
||||||
image::Handle::from_pixels(
|
image::Handle::from_pixels(
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ enum CaptureSource {
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::derive_hash_xor_eq)]
|
||||||
impl std::hash::Hash for CaptureSource {
|
impl std::hash::Hash for CaptureSource {
|
||||||
fn hash<H>(&self, state: &mut H)
|
fn hash<H>(&self, state: &mut H)
|
||||||
where
|
where
|
||||||
|
|
@ -100,7 +101,7 @@ impl std::hash::Hash for CaptureSource {
|
||||||
{
|
{
|
||||||
match self {
|
match self {
|
||||||
Self::Toplevel(handle) => handle.id(),
|
Self::Toplevel(handle) => handle.id(),
|
||||||
Self::Workspace(handle, output) => handle.id(),
|
Self::Workspace(handle, _output) => handle.id(),
|
||||||
}
|
}
|
||||||
.hash(state)
|
.hash(state)
|
||||||
}
|
}
|
||||||
|
|
@ -152,7 +153,7 @@ impl Capture {
|
||||||
manager.capture_toplevel(
|
manager.capture_toplevel(
|
||||||
toplevel,
|
toplevel,
|
||||||
zcosmic_screencopy_manager_v1::CursorMode::Hidden,
|
zcosmic_screencopy_manager_v1::CursorMode::Hidden,
|
||||||
&qh,
|
qh,
|
||||||
udata,
|
udata,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -161,7 +162,7 @@ impl Capture {
|
||||||
workspace,
|
workspace,
|
||||||
output,
|
output,
|
||||||
zcosmic_screencopy_manager_v1::CursorMode::Hidden,
|
zcosmic_screencopy_manager_v1::CursorMode::Hidden,
|
||||||
&qh,
|
qh,
|
||||||
udata,
|
udata,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -319,7 +320,7 @@ impl ToplevelInfoHandler for AppData {
|
||||||
_qh: &QueueHandle<Self>,
|
_qh: &QueueHandle<Self>,
|
||||||
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();
|
||||||
self.send_event(Event::NewToplevel(toplevel.clone(), info.clone()));
|
self.send_event(Event::NewToplevel(toplevel.clone(), info.clone()));
|
||||||
|
|
||||||
self.add_capture_source(CaptureSource::Toplevel(toplevel.clone()));
|
self.add_capture_source(CaptureSource::Toplevel(toplevel.clone()));
|
||||||
|
|
@ -329,7 +330,7 @@ impl ToplevelInfoHandler for AppData {
|
||||||
&mut self,
|
&mut self,
|
||||||
_conn: &Connection,
|
_conn: &Connection,
|
||||||
_qh: &QueueHandle<Self>,
|
_qh: &QueueHandle<Self>,
|
||||||
toplevel: &zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1,
|
_toplevel: &zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1,
|
||||||
) {
|
) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
@ -423,8 +424,8 @@ impl ScreencopyHandler for AppData {
|
||||||
|
|
||||||
fn ready(
|
fn ready(
|
||||||
&mut self,
|
&mut self,
|
||||||
conn: &Connection,
|
_conn: &Connection,
|
||||||
qh: &QueueHandle<Self>,
|
_qh: &QueueHandle<Self>,
|
||||||
session: &zcosmic_screencopy_session_v1::ZcosmicScreencopySessionV1,
|
session: &zcosmic_screencopy_session_v1::ZcosmicScreencopySessionV1,
|
||||||
) {
|
) {
|
||||||
let capture = &session.data::<SessionData>().unwrap().capture;
|
let capture = &session.data::<SessionData>().unwrap().capture;
|
||||||
|
|
@ -451,10 +452,10 @@ impl ScreencopyHandler for AppData {
|
||||||
|
|
||||||
fn failed(
|
fn failed(
|
||||||
&mut self,
|
&mut self,
|
||||||
conn: &Connection,
|
_conn: &Connection,
|
||||||
qh: &QueueHandle<Self>,
|
_qh: &QueueHandle<Self>,
|
||||||
session: &zcosmic_screencopy_session_v1::ZcosmicScreencopySessionV1,
|
session: &zcosmic_screencopy_session_v1::ZcosmicScreencopySessionV1,
|
||||||
reason: WEnum<zcosmic_screencopy_session_v1::FailureReason>,
|
_reason: WEnum<zcosmic_screencopy_session_v1::FailureReason>,
|
||||||
) {
|
) {
|
||||||
// TODO
|
// TODO
|
||||||
println!("Failed");
|
println!("Failed");
|
||||||
|
|
@ -469,9 +470,9 @@ impl ToplevelManagerHandler for AppData {
|
||||||
|
|
||||||
fn capabilities(
|
fn capabilities(
|
||||||
&mut self,
|
&mut self,
|
||||||
conn: &Connection,
|
_conn: &Connection,
|
||||||
qh: &QueueHandle<Self>,
|
_qh: &QueueHandle<Self>,
|
||||||
capabilities: Vec<
|
_capabilities: Vec<
|
||||||
WEnum<zcosmic_toplevel_manager_v1::ZcosmicToplelevelManagementCapabilitiesV1>,
|
WEnum<zcosmic_toplevel_manager_v1::ZcosmicToplelevelManagementCapabilitiesV1>,
|
||||||
>,
|
>,
|
||||||
) {
|
) {
|
||||||
|
|
@ -481,7 +482,7 @@ impl ToplevelManagerHandler for AppData {
|
||||||
impl Dispatch<wl_buffer::WlBuffer, ()> for AppData {
|
impl Dispatch<wl_buffer::WlBuffer, ()> for AppData {
|
||||||
fn event(
|
fn event(
|
||||||
_app_data: &mut Self,
|
_app_data: &mut Self,
|
||||||
buffer: &wl_buffer::WlBuffer,
|
_buffer: &wl_buffer::WlBuffer,
|
||||||
event: wl_buffer::Event,
|
event: wl_buffer::Event,
|
||||||
_: &(),
|
_: &(),
|
||||||
_: &Connection,
|
_: &Connection,
|
||||||
|
|
@ -499,7 +500,7 @@ fn start() -> mpsc::Receiver<Event> {
|
||||||
|
|
||||||
// TODO share connection? Can't use same `WlOutput` with seperate connection
|
// TODO share connection? Can't use same `WlOutput` with seperate connection
|
||||||
let conn = Connection::connect_to_env().unwrap();
|
let conn = Connection::connect_to_env().unwrap();
|
||||||
let (globals, mut event_queue) = registry_queue_init(&conn).unwrap();
|
let (globals, event_queue) = registry_queue_init(&conn).unwrap();
|
||||||
let qh = event_queue.handle();
|
let qh = event_queue.handle();
|
||||||
|
|
||||||
let registry_state = RegistryState::new(&globals);
|
let registry_state = RegistryState::new(&globals);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue