make button focus ring conditional on tab press
This commit is contained in:
1 parent
64a80dc069
commit
1d7a472847
5 files changed
+121
-14
No files matched your search
@@ -391,6 +391,7 @@ impl FereseShell {
|
||||
f32::from(self.config.theme.surface_popover[3]) / 255.0
|
||||
};
|
||||
let model = &self.display_mode;
|
||||
let focus_visible = self.system_modal.as_ref().is_some_and(|modal| modal.focus_visible);
|
||||
let pending = model.pending();
|
||||
let mut header = row![
|
||||
text("Display mode").size(17),
|
||||
@@ -435,10 +436,11 @@ impl FereseShell {
|
||||
.id(format!("ferese-display-mode-{}", mode.name()).into())
|
||||
.width(Length::Fill)
|
||||
.padding([14, 6])
|
||||
.class(ferese_theme::controls::material_button_style(
|
||||
.class(ferese_theme::controls::material_button_style_with_focus(
|
||||
palette,
|
||||
model.selected == mode,
|
||||
material_opacity,
|
||||
focus_visible,
|
||||
))
|
||||
.on_press_maybe(available.then_some(cosmic::Action::App(Message::SelectDisplayMode(mode)))),
|
||||
);
|
||||
@@ -504,6 +506,11 @@ impl FereseShell {
|
||||
palette,
|
||||
false
|
||||
)
|
||||
.class(ferese_theme::controls::button_style_with_focus(
|
||||
palette,
|
||||
false,
|
||||
focus_visible
|
||||
))
|
||||
.id("ferese-modal-cancel".into())
|
||||
.on_press_maybe((!model.busy).then_some(cosmic::Action::App(cancel))),
|
||||
ferese_theme::controls::text_button(
|
||||
@@ -512,6 +519,11 @@ impl FereseShell {
|
||||
palette,
|
||||
true
|
||||
)
|
||||
.class(ferese_theme::controls::button_style_with_focus(
|
||||
palette,
|
||||
true,
|
||||
focus_visible
|
||||
))
|
||||
.id("ferese-display-apply".into())
|
||||
.on_press_maybe(can_apply.then_some(cosmic::Action::App(apply))),
|
||||
]
|
||||
|
||||
@@ -368,6 +368,7 @@ impl cosmic::Application for FereseShell {
|
||||
.load(Ordering::Relaxed)
|
||||
.then_some(Message::Event(event, id)),
|
||||
Event::Keyboard(_)
|
||||
| Event::Mouse(cosmic::iced::mouse::Event::ButtonPressed(_))
|
||||
| Event::Window(window::Event::Opened { .. } | window::Event::Closed)
|
||||
| Event::PlatformSpecific(PlatformSpecific::Wayland(
|
||||
wayland::Event::Popup(..) | wayland::Event::Layer(..) | wayland::Event::Output(..),
|
||||
|
||||
@@ -164,6 +164,13 @@ impl FereseShell {
|
||||
}
|
||||
|
||||
pub(super) fn handle_event(&mut self, event: Event, id: window::Id) -> Task<Message> {
|
||||
if let Event::Mouse(cosmic::iced::mouse::Event::ButtonPressed(_)) = &event
|
||||
&& let Some(modal) = &mut self.system_modal
|
||||
&& modal.contains(id)
|
||||
{
|
||||
modal.focus_visible = false;
|
||||
}
|
||||
|
||||
if let Event::Mouse(mouse) = &event {
|
||||
if !self
|
||||
.outputs
|
||||
|
||||
@@ -69,6 +69,7 @@ pub(super) struct SystemModal {
|
||||
error: Option<String>,
|
||||
inhibitors: Option<compositor_ipc::Approval>,
|
||||
keyboard_nav: bool,
|
||||
pub(super) focus_visible: bool,
|
||||
}
|
||||
|
||||
impl SystemModal {
|
||||
@@ -236,6 +237,7 @@ impl FereseShell {
|
||||
error: None,
|
||||
inhibitors: mode.is_none().then(compositor_ipc::Approval::default),
|
||||
keyboard_nav,
|
||||
focus_visible: false,
|
||||
});
|
||||
Task::batch(tasks)
|
||||
}
|
||||
@@ -387,10 +389,17 @@ impl FereseShell {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn navigate_system_modal(&self, backwards: bool) -> Task<Message> {
|
||||
if self.system_modal.as_ref().is_none_or(|modal| modal.motion.closing()) {
|
||||
pub(super) fn navigate_system_modal(&mut self, backwards: bool) -> Task<Message> {
|
||||
let Some(modal) = &mut self.system_modal else {
|
||||
return Task::none();
|
||||
};
|
||||
|
||||
if modal.motion.closing() {
|
||||
return Task::none();
|
||||
}
|
||||
|
||||
modal.focus_visible = true;
|
||||
|
||||
cosmic::iced::advanced::widget::operate(modal_focus_operation(backwards))
|
||||
}
|
||||
|
||||
@@ -536,14 +545,25 @@ impl FereseShell {
|
||||
row![
|
||||
Space::new().width(Length::Fill),
|
||||
ferese_theme::controls::text_button("Cancel", shell_font(), palette, false)
|
||||
.class(ferese_theme::controls::button_style_with_focus(
|
||||
palette,
|
||||
false,
|
||||
modal.focus_visible,
|
||||
))
|
||||
.id("ferese-modal-cancel".into())
|
||||
.on_press(cosmic::Action::App(Message::CancelPower)),
|
||||
ferese_theme::controls::text_button(label, shell_font(), palette, true).on_press_maybe(
|
||||
modal
|
||||
.inhibitors
|
||||
.is_some()
|
||||
.then_some(cosmic::Action::App(Message::ExecutePower))
|
||||
),
|
||||
ferese_theme::controls::text_button(label, shell_font(), palette, true)
|
||||
.class(ferese_theme::controls::button_style_with_focus(
|
||||
palette,
|
||||
true,
|
||||
modal.focus_visible,
|
||||
))
|
||||
.on_press_maybe(
|
||||
modal
|
||||
.inhibitors
|
||||
.is_some()
|
||||
.then_some(cosmic::Action::App(Message::ExecutePower))
|
||||
),
|
||||
]
|
||||
.spacing(10),
|
||||
)
|
||||
@@ -582,6 +602,11 @@ impl FereseShell {
|
||||
container(row![
|
||||
Space::new().width(Length::Fill),
|
||||
ferese_theme::controls::text_button("Got it", shell_font(), palette, true,)
|
||||
.class(ferese_theme::controls::button_style_with_focus(
|
||||
palette,
|
||||
true,
|
||||
modal.focus_visible,
|
||||
))
|
||||
.id("ferese-modal-cancel".into())
|
||||
.on_press(cosmic::Action::App(Message::CancelPower)),
|
||||
])
|
||||
|
||||
Reference in new issue
Block a user