Skip to content

Commit 6062fa2

Browse files
committed
chore(Workspace): hide features unsupported by comp
1 parent 05e38a1 commit 6062fa2

File tree

4 files changed

+108
-101
lines changed

4 files changed

+108
-101
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cosmic-settings/src/pages/desktop/workspaces.rs

Lines changed: 87 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ use slab::Slab;
1818
use slotmap::SlotMap;
1919
use tracing::error;
2020

21+
use crate::utils::system_has_touchpad;
22+
2123
#[derive(Clone, Debug)]
2224
pub enum Message {
2325
SetWorkspaceMode(WorkspaceMode),
@@ -162,7 +164,8 @@ impl page::Page<crate::pages::Message> for Page {
162164
sections: &mut SlotMap<section::Entity, Section<crate::pages::Message>>,
163165
) -> Option<page::Content> {
164166
Some(vec![
165-
sections.insert(multi_behavior()),
167+
// FIXME currently unsupported by cosmic-comp
168+
// sections.insert(multi_behavior()),
166169
sections.insert(workspace_orientation()),
167170
sections.insert(workspace_overview()),
168171
])
@@ -386,99 +389,103 @@ fn workspace_orientation() -> Section<crate::pages::Message> {
386389
)
387390
.spacing(cosmic::theme::active().cosmic().space_m())
388391
.align_x(Alignment::Center),
389-
)
390-
.add(settings::item(
391-
&descriptions[thumbnail_placement_label],
392-
thumbnail_placement,
393-
))
394-
.add(
395-
cosmic::iced::widget::MouseArea::new(settings::item(
396-
&descriptions[trackpad_gestures],
397-
cosmic::iced::widget::container(
398-
icon::from_name(if page.show_trackpad_gesture {
399-
"go-up-symbolic"
400-
} else {
401-
"go-down-symbolic"
402-
})
403-
.size(16),
404-
)
405-
.width(Length::Shrink),
406-
))
407-
.on_press(Message::ShowTrackpadGestureInfo(
408-
!page.show_trackpad_gesture,
409-
)),
410392
);
411-
if page.show_trackpad_gesture {
412-
let (switch_ws, open_ws, open_app) =
413-
match page.comp_workspace_config.workspace_layout {
414-
WorkspaceLayout::Vertical => (
415-
asset_handle(Asset::TrackpadGestureSwipeVertical),
416-
asset_handle(Asset::TrackpadGestureSwipeLeft),
417-
asset_handle(Asset::TrackpadGestureSwipeRight),
418-
),
419-
WorkspaceLayout::Horizontal => (
420-
asset_handle(Asset::TrackpadGestureSwipeHorizontal),
421-
asset_handle(Asset::TrackpadGestureSwipeUp),
422-
asset_handle(Asset::TrackpadGestureSwipeDown),
423-
),
424-
};
425-
let (switch_ws_label, open_ws_label, open_app_label) =
426-
match page.comp_workspace_config.workspace_layout {
427-
WorkspaceLayout::Vertical => (swipe_vertical, swipe_left, swipe_right),
428-
WorkspaceLayout::Horizontal => (swipe_horizontal, swipe_up, swipe_down),
429-
};
430-
section = section.add(
431-
cosmic::widget::list_column()
432-
.padding([0, 32])
433-
.add(
434-
cosmic::iced::widget::row!(
435-
text(&descriptions[switch_workspace]),
436-
cosmic::iced::widget::horizontal_space().width(2),
437-
text(&descriptions[switch_ws_label]).font(cosmic::font::bold()),
438-
cosmic::iced::widget::horizontal_space().width(Length::Fill),
439-
cosmic::iced::widget::container(cosmic::iced::widget::svg(
440-
switch_ws
441-
))
442-
.width(115)
443-
.height(92)
444-
)
445-
.width(Length::Fill)
446-
.align_y(Alignment::Center)
447-
.padding([0, 16]),
448-
)
449-
.add(
450-
cosmic::iced::widget::row!(
451-
text(&descriptions[open_workspaces]),
452-
cosmic::iced::widget::horizontal_space().width(2),
453-
text(&descriptions[open_ws_label]).font(cosmic::font::bold()),
454-
cosmic::iced::widget::horizontal_space().width(Length::Fill),
455-
cosmic::iced::widget::container(cosmic::iced::widget::svg(open_ws))
456-
.width(115)
457-
.height(92)
393+
// FIXME currently unsupported by cosmic-comp
394+
// .add(settings::item(
395+
// &descriptions[thumbnail_placement_label],
396+
// thumbnail_placement,
397+
// ));
398+
if system_has_touchpad() {
399+
section = section
400+
.add(
401+
cosmic::iced::widget::MouseArea::new(settings::item(
402+
&descriptions[trackpad_gestures],
403+
cosmic::iced::widget::container(
404+
icon::from_name(if page.show_trackpad_gesture {
405+
"go-up-symbolic"
406+
} else {
407+
"go-down-symbolic"
408+
})
409+
.size(16),
458410
)
459-
.width(Length::Fill)
460-
.align_y(Alignment::Center)
461-
.padding([0, 16]),
462-
)
463-
.add(
464-
cosmic::widget::list_column().add(
411+
.width(Length::Shrink),
412+
))
413+
.on_press(Message::ShowTrackpadGestureInfo(
414+
!page.show_trackpad_gesture,
415+
)),
416+
);
417+
if page.show_trackpad_gesture {
418+
let (switch_ws, open_ws, open_app) =
419+
match page.comp_workspace_config.workspace_layout {
420+
WorkspaceLayout::Vertical => (
421+
asset_handle(Asset::TrackpadGestureSwipeVertical),
422+
asset_handle(Asset::TrackpadGestureSwipeLeft),
423+
asset_handle(Asset::TrackpadGestureSwipeRight),
424+
),
425+
WorkspaceLayout::Horizontal => (
426+
asset_handle(Asset::TrackpadGestureSwipeHorizontal),
427+
asset_handle(Asset::TrackpadGestureSwipeUp),
428+
asset_handle(Asset::TrackpadGestureSwipeDown),
429+
),
430+
};
431+
let (switch_ws_label, open_ws_label, open_app_label) =
432+
match page.comp_workspace_config.workspace_layout {
433+
WorkspaceLayout::Vertical => (swipe_vertical, swipe_left, swipe_right),
434+
WorkspaceLayout::Horizontal => (swipe_horizontal, swipe_up, swipe_down),
435+
};
436+
section = section.add(
437+
cosmic::widget::list_column()
438+
.padding([0, 32])
439+
.add(
465440
cosmic::iced::widget::row!(
466-
text(&descriptions[open_applications]),
441+
text(&descriptions[switch_workspace]),
467442
cosmic::iced::widget::horizontal_space().width(2),
468-
text(&descriptions[open_app_label]).font(cosmic::font::bold()),
443+
text(&descriptions[switch_ws_label]).font(cosmic::font::bold()),
469444
cosmic::iced::widget::horizontal_space().width(Length::Fill),
470445
cosmic::iced::widget::container(cosmic::iced::widget::svg(
471-
open_app
446+
switch_ws
472447
))
473448
.width(115)
474449
.height(92)
475450
)
476451
.width(Length::Fill)
477452
.align_y(Alignment::Center)
478453
.padding([0, 16]),
454+
)
455+
.add(
456+
cosmic::iced::widget::row!(
457+
text(&descriptions[open_workspaces]),
458+
cosmic::iced::widget::horizontal_space().width(2),
459+
text(&descriptions[open_ws_label]).font(cosmic::font::bold()),
460+
cosmic::iced::widget::horizontal_space().width(Length::Fill),
461+
cosmic::iced::widget::container(cosmic::iced::widget::svg(open_ws))
462+
.width(115)
463+
.height(92)
464+
)
465+
.width(Length::Fill)
466+
.align_y(Alignment::Center)
467+
.padding([0, 16]),
468+
)
469+
.add(
470+
cosmic::widget::list_column().add(
471+
cosmic::iced::widget::row!(
472+
text(&descriptions[open_applications]),
473+
cosmic::iced::widget::horizontal_space().width(2),
474+
text(&descriptions[open_app_label]).font(cosmic::font::bold()),
475+
cosmic::iced::widget::horizontal_space().width(Length::Fill),
476+
cosmic::iced::widget::container(cosmic::iced::widget::svg(
477+
open_app
478+
))
479+
.width(115)
480+
.height(92)
481+
)
482+
.width(Length::Fill)
483+
.align_y(Alignment::Center)
484+
.padding([0, 16]),
485+
),
479486
),
480-
),
481-
);
487+
);
488+
}
482489
}
483490

484491
section

cosmic-settings/src/pages/input/mod.rs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::app;
1+
use crate::{app, utils::system_has_touchpad};
22
use cosmic::{
33
cosmic_config::{self, ConfigGet, ConfigSet},
44
Task,
@@ -200,22 +200,3 @@ impl page::AutoBind<crate::pages::Message> for Page {
200200
}
201201
}
202202
}
203-
204-
/// Uses `udev` to check if a touchpad device exists on the system.
205-
fn system_has_touchpad() -> bool {
206-
let Ok(mut enumerator) = udev::Enumerator::new() else {
207-
return false;
208-
};
209-
210-
let _res = enumerator.match_subsystem("input");
211-
212-
let Ok(mut devices) = enumerator.scan_devices() else {
213-
return false;
214-
};
215-
216-
devices.any(|device| {
217-
device
218-
.property_value("ID_INPUT_TOUCHPAD")
219-
.map_or(false, |value| value == "1")
220-
})
221-
}

cosmic-settings/src/utils.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,25 @@ pub fn map_stderr_output(result: io::Result<process::Output>) -> Result<(), Stri
5858
})
5959
}
6060

61+
/// Uses `udev` to check if a touchpad device exists on the system.
62+
pub fn system_has_touchpad() -> bool {
63+
let Ok(mut enumerator) = udev::Enumerator::new() else {
64+
return false;
65+
};
66+
67+
let _res = enumerator.match_subsystem("input");
68+
69+
let Ok(mut devices) = enumerator.scan_devices() else {
70+
return false;
71+
};
72+
73+
devices.any(|device| {
74+
device
75+
.property_value("ID_INPUT_TOUCHPAD")
76+
.map_or(false, |value| value == "1")
77+
})
78+
}
79+
6180
/// Creates a slab with predefined items
6281
#[macro_export]
6382
macro_rules! slab {

0 commit comments

Comments
 (0)