chore: clippy
This commit is contained in:
parent
22bef1b596
commit
e45d2ea694
5 changed files with 65 additions and 76 deletions
|
|
@ -92,13 +92,13 @@ impl AppData {
|
||||||
let Some(feedback) = self.dmabuf_feedback.as_ref() else {
|
let Some(feedback) = self.dmabuf_feedback.as_ref() else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
let drm_dev = drm_dev.unwrap_or(feedback.main_device() as u64);
|
let drm_dev = drm_dev.unwrap_or(feedback.main_device());
|
||||||
if let Some(vulkan) = &mut self.vulkan {
|
if let Some(vulkan) = &mut self.vulkan
|
||||||
if let Ok(Some(name)) = vulkan.device_name(drm_dev) {
|
&& let Ok(Some(name)) = vulkan.device_name(drm_dev)
|
||||||
// TODO Workaround: force shm on Meteor/Arrow/Lunar Lake
|
{
|
||||||
if name.contains("MTL") || name.contains("ARL") || name.contains("LNL") {
|
// TODO Workaround: force shm on Meteor/Arrow/Lunar Lake
|
||||||
return Ok(None);
|
if name.contains("MTL") || name.contains("ARL") || name.contains("LNL") {
|
||||||
}
|
return Ok(None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let Some((_dev_path, gbm)) = self.gbm_devices.gbm_device(drm_dev)? else {
|
let Some((_dev_path, gbm)) = self.gbm_devices.gbm_device(drm_dev)? else {
|
||||||
|
|
@ -204,7 +204,7 @@ impl AppData {
|
||||||
modifiers,
|
modifiers,
|
||||||
formats.buffer_size,
|
formats.buffer_size,
|
||||||
false,
|
false,
|
||||||
formats.dmabuf_device.map(|dev| dev as u64),
|
formats.dmabuf_device,
|
||||||
) {
|
) {
|
||||||
Ok(Some(buffer)) => {
|
Ok(Some(buffer)) => {
|
||||||
return buffer;
|
return buffer;
|
||||||
|
|
|
||||||
|
|
@ -91,59 +91,52 @@ impl AppData {
|
||||||
}
|
}
|
||||||
Cmd::CloseToplevel(toplevel_handle) => {
|
Cmd::CloseToplevel(toplevel_handle) => {
|
||||||
let info = self.toplevel_info_state.info(&toplevel_handle);
|
let info = self.toplevel_info_state.info(&toplevel_handle);
|
||||||
if let Some(cosmic_toplevel) = info.and_then(|x| x.cosmic_toplevel.as_ref()) {
|
if let Some(cosmic_toplevel) = info.and_then(|x| x.cosmic_toplevel.as_ref())
|
||||||
if let Some(state) = &self.toplevel_manager_state {
|
&& let Some(state) = &self.toplevel_manager_state
|
||||||
state.manager.close(cosmic_toplevel);
|
{
|
||||||
}
|
state.manager.close(cosmic_toplevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Cmd::MoveToplevelToWorkspace(toplevel_handle, workspace_handle, output) => {
|
Cmd::MoveToplevelToWorkspace(toplevel_handle, workspace_handle, output) => {
|
||||||
let info = self.toplevel_info_state.info(&toplevel_handle);
|
let info = self.toplevel_info_state.info(&toplevel_handle);
|
||||||
if let Some(cosmic_toplevel) = info.and_then(|x| x.cosmic_toplevel.as_ref()) {
|
if let Some(cosmic_toplevel) = info.and_then(|x| x.cosmic_toplevel.as_ref())
|
||||||
if let Some(state) = &self.toplevel_manager_state {
|
&& let Some(state) = &self.toplevel_manager_state
|
||||||
if state.manager.version() >= 2 {
|
&& state.manager.version() >= 2
|
||||||
state.manager.move_to_ext_workspace(
|
{
|
||||||
cosmic_toplevel,
|
state.manager.move_to_ext_workspace(
|
||||||
&workspace_handle,
|
cosmic_toplevel,
|
||||||
&output,
|
&workspace_handle,
|
||||||
);
|
&output,
|
||||||
}
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO version check
|
// TODO version check
|
||||||
Cmd::MoveWorkspaceBefore(workspace_handle, other_workspace_handle) => {
|
Cmd::MoveWorkspaceBefore(workspace_handle, other_workspace_handle) => {
|
||||||
if let Ok(workspace_manager) = self.workspace_state.workspace_manager().get() {
|
if let Ok(workspace_manager) = self.workspace_state.workspace_manager().get()
|
||||||
if let Some(cosmic_workspace) = self
|
&& let Some(cosmic_workspace) = self
|
||||||
.workspace_state
|
.workspace_state
|
||||||
.workspaces()
|
.workspaces()
|
||||||
.find(|w| w.handle == workspace_handle)
|
.find(|w| w.handle == workspace_handle)
|
||||||
.and_then(|w| w.cosmic_handle.as_ref())
|
.and_then(|w| w.cosmic_handle.as_ref())
|
||||||
{
|
&& cosmic_workspace.version()
|
||||||
if cosmic_workspace.version()
|
>= zcosmic_workspace_handle_v2::REQ_MOVE_BEFORE_SINCE
|
||||||
>= zcosmic_workspace_handle_v2::REQ_MOVE_BEFORE_SINCE
|
{
|
||||||
{
|
cosmic_workspace.move_before(&other_workspace_handle, 0);
|
||||||
cosmic_workspace.move_before(&other_workspace_handle, 0);
|
workspace_manager.commit();
|
||||||
workspace_manager.commit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Cmd::MoveWorkspaceAfter(workspace_handle, other_workspace_handle) => {
|
Cmd::MoveWorkspaceAfter(workspace_handle, other_workspace_handle) => {
|
||||||
if let Ok(workspace_manager) = self.workspace_state.workspace_manager().get() {
|
if let Ok(workspace_manager) = self.workspace_state.workspace_manager().get()
|
||||||
if let Some(cosmic_workspace) = self
|
&& let Some(cosmic_workspace) = self
|
||||||
.workspace_state
|
.workspace_state
|
||||||
.workspaces()
|
.workspaces()
|
||||||
.find(|w| w.handle == workspace_handle)
|
.find(|w| w.handle == workspace_handle)
|
||||||
.and_then(|w| w.cosmic_handle.as_ref())
|
.and_then(|w| w.cosmic_handle.as_ref())
|
||||||
{
|
&& cosmic_workspace.version()
|
||||||
if cosmic_workspace.version()
|
>= zcosmic_workspace_handle_v2::REQ_MOVE_AFTER_SINCE
|
||||||
>= zcosmic_workspace_handle_v2::REQ_MOVE_AFTER_SINCE
|
{
|
||||||
{
|
cosmic_workspace.move_after(&other_workspace_handle, 0);
|
||||||
cosmic_workspace.move_after(&other_workspace_handle, 0);
|
workspace_manager.commit();
|
||||||
workspace_manager.commit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Cmd::ActivateWorkspace(workspace_handle) => {
|
Cmd::ActivateWorkspace(workspace_handle) => {
|
||||||
|
|
@ -153,24 +146,21 @@ impl AppData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Cmd::SetWorkspacePinned(workspace_handle, pinned) => {
|
Cmd::SetWorkspacePinned(workspace_handle, pinned) => {
|
||||||
if let Ok(workspace_manager) = self.workspace_state.workspace_manager().get() {
|
if let Ok(workspace_manager) = self.workspace_state.workspace_manager().get()
|
||||||
if let Some(cosmic_workspace) = self
|
&& let Some(cosmic_workspace) = self
|
||||||
.workspace_state
|
.workspace_state
|
||||||
.workspaces()
|
.workspaces()
|
||||||
.find(|w| w.handle == workspace_handle)
|
.find(|w| w.handle == workspace_handle)
|
||||||
.and_then(|w| w.cosmic_handle.as_ref())
|
.and_then(|w| w.cosmic_handle.as_ref())
|
||||||
{
|
&& cosmic_workspace.version() >= zcosmic_workspace_handle_v2::REQ_PIN_SINCE
|
||||||
if cosmic_workspace.version() >= zcosmic_workspace_handle_v2::REQ_PIN_SINCE
|
{
|
||||||
{
|
// TODO check capability
|
||||||
// TODO check capability
|
if pinned {
|
||||||
if pinned {
|
cosmic_workspace.pin();
|
||||||
cosmic_workspace.pin();
|
} else {
|
||||||
} else {
|
cosmic_workspace.unpin();
|
||||||
cosmic_workspace.unpin();
|
|
||||||
}
|
|
||||||
workspace_manager.commit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
workspace_manager.commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -238,7 +238,7 @@ impl ScreencopyHandler for AppData {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
if let Some(formats) = &session.formats {
|
if let Some(formats) = &session.formats {
|
||||||
session.buffers = Some(array::from_fn(|_| self.create_buffer(&formats)));
|
session.buffers = Some(array::from_fn(|_| self.create_buffer(formats)));
|
||||||
}
|
}
|
||||||
session.attach_buffer_and_commit(&capture, conn, &self.qh);
|
session.attach_buffer_and_commit(&capture, conn, &self.qh);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ impl Vulkan {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|x| x.as_deref())
|
.map(|x| x.as_deref())
|
||||||
.map_err(|err| err.clone())
|
.map_err(|err| *err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn device_name_uncached(&mut self, dev: u64) -> VkResult<Option<String>> {
|
fn device_name_uncached(&mut self, dev: u64) -> VkResult<Option<String>> {
|
||||||
|
|
|
||||||
37
src/main.rs
37
src/main.rs
|
|
@ -4,8 +4,10 @@
|
||||||
#![allow(clippy::single_match)]
|
#![allow(clippy::single_match)]
|
||||||
|
|
||||||
use cctk::{
|
use cctk::{
|
||||||
cosmic_protocols::toplevel_management::v1::client::zcosmic_toplevel_manager_v1,
|
cosmic_protocols::{
|
||||||
cosmic_protocols::workspace::v2::client::zcosmic_workspace_handle_v2,
|
toplevel_management::v1::client::zcosmic_toplevel_manager_v1,
|
||||||
|
workspace::v2::client::zcosmic_workspace_handle_v2,
|
||||||
|
},
|
||||||
sctk::shell::wlr_layer::{Anchor, KeyboardInteractivity, Layer},
|
sctk::shell::wlr_layer::{Anchor, KeyboardInteractivity, Layer},
|
||||||
wayland_client::{Connection, Proxy, protocol::wl_output},
|
wayland_client::{Connection, Proxy, protocol::wl_output},
|
||||||
wayland_protocols::ext::workspace::v1::client::ext_workspace_handle_v1,
|
wayland_protocols::ext::workspace::v1::client::ext_workspace_handle_v1,
|
||||||
|
|
@ -456,10 +458,10 @@ impl Application for App {
|
||||||
Msg::WaylandEvent(evt) => match evt {
|
Msg::WaylandEvent(evt) => match evt {
|
||||||
WaylandEvent::Output(evt, output) => {
|
WaylandEvent::Output(evt, output) => {
|
||||||
// TODO: Less hacky way to get connection from iced-sctk
|
// TODO: Less hacky way to get connection from iced-sctk
|
||||||
if self.conn.is_none() {
|
if self.conn.is_none()
|
||||||
if let Some(backend) = output.backend().upgrade() {
|
&& let Some(backend) = output.backend().upgrade()
|
||||||
self.conn = Some(Connection::from_backend(backend));
|
{
|
||||||
}
|
self.conn = Some(Connection::from_backend(backend));
|
||||||
}
|
}
|
||||||
|
|
||||||
match evt {
|
match evt {
|
||||||
|
|
@ -581,13 +583,12 @@ impl Application for App {
|
||||||
}
|
}
|
||||||
backend::Event::WorkspaceCapture(handle, image) => {
|
backend::Event::WorkspaceCapture(handle, image) => {
|
||||||
//println!("Workspace capture");
|
//println!("Workspace capture");
|
||||||
if let Some(workspace) = self.workspaces.for_handle_mut(&handle) {
|
if let Some(workspace) = self.workspaces.for_handle_mut(&handle)
|
||||||
if self
|
&& self
|
||||||
.capture_filter
|
.capture_filter
|
||||||
.workspace_outputs_matches(&workspace.outputs)
|
.workspace_outputs_matches(&workspace.outputs)
|
||||||
{
|
{
|
||||||
workspace.img = Some(image);
|
workspace.img = Some(image);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
backend::Event::ToplevelCapture(handle, image) => {
|
backend::Event::ToplevelCapture(handle, image) => {
|
||||||
|
|
@ -607,10 +608,10 @@ impl Application for App {
|
||||||
return self.hide();
|
return self.hide();
|
||||||
}
|
}
|
||||||
Msg::ActivateWorkspace(workspace_handle) => {
|
Msg::ActivateWorkspace(workspace_handle) => {
|
||||||
if let Some(workspace) = self.workspaces.for_handle(&workspace_handle) {
|
if let Some(workspace) = self.workspaces.for_handle(&workspace_handle)
|
||||||
if workspace.is_active() {
|
&& workspace.is_active()
|
||||||
return self.hide();
|
{
|
||||||
}
|
return self.hide();
|
||||||
}
|
}
|
||||||
self.send_wayland_cmd(backend::Cmd::ActivateWorkspace(workspace_handle));
|
self.send_wayland_cmd(backend::Cmd::ActivateWorkspace(workspace_handle));
|
||||||
}
|
}
|
||||||
|
|
@ -770,11 +771,9 @@ impl Application for App {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Msg::PanelContainerEntries(entries) => {
|
Msg::PanelContainerEntries(entries) => {
|
||||||
self.panel_configs.retain(|k, _| entries.contains(&k));
|
self.panel_configs.retain(|k, _| entries.contains(k));
|
||||||
for entry in entries {
|
for entry in entries {
|
||||||
if !self.panel_configs.contains_key(&entry) {
|
self.panel_configs.entry(entry).or_insert(None);
|
||||||
self.panel_configs.insert(entry, None);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Msg::PanelConfig(config) => {
|
Msg::PanelConfig(config) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue