refactor: popup for tooltip
this conflicts with autopopup switching. Either I need to drop autopopup switching, disable tooltips if autopopup switching is enabled, or I need to change how autohopopup switching is implemented to use dbus or wayland protocols instead of simulating a click.
This commit is contained in:
parent
6f643d1d3a
commit
66322b1e90
2 changed files with 29 additions and 41 deletions
|
|
@ -20,11 +20,9 @@ use crate::{
|
||||||
},
|
},
|
||||||
Application, Element, Renderer,
|
Application, Element, Renderer,
|
||||||
};
|
};
|
||||||
use cctk::sctk::shell::xdg::window::WindowConfigure;
|
|
||||||
pub use cosmic_panel_config;
|
pub use cosmic_panel_config;
|
||||||
use cosmic_panel_config::{CosmicPanelBackground, PanelAnchor, PanelSize};
|
use cosmic_panel_config::{CosmicPanelBackground, PanelAnchor, PanelSize};
|
||||||
use cosmic_theme::Theme;
|
use cosmic_theme::Theme;
|
||||||
use iced::platform_specific::runtime::wayland::subsurface;
|
|
||||||
use iced::Pixels;
|
use iced::Pixels;
|
||||||
use iced_core::{Layout, Padding, Shadow};
|
use iced_core::{Layout, Padding, Shadow};
|
||||||
use iced_widget::runtime::platform_specific::wayland::popup::{SctkPopupSettings, SctkPositioner};
|
use iced_widget::runtime::platform_specific::wayland::popup::{SctkPopupSettings, SctkPositioner};
|
||||||
|
|
@ -250,38 +248,14 @@ impl Context {
|
||||||
let subsurface_id = subsurface_id.clone();
|
let subsurface_id = subsurface_id.clone();
|
||||||
let tooltip = tooltip.clone();
|
let tooltip = tooltip.clone();
|
||||||
let window_id = window_id;
|
let window_id = window_id;
|
||||||
let (loc, gravity) = match anchor {
|
let (popup_anchor, gravity) = match anchor {
|
||||||
PanelAnchor::Left => (
|
PanelAnchor::Left => (Anchor::Right, Gravity::Right),
|
||||||
iced::Point {
|
PanelAnchor::Right => (Anchor::Left, Gravity::Left),
|
||||||
x: bounds.width,
|
PanelAnchor::Top => (Anchor::Bottom, Gravity::Bottom),
|
||||||
y: bounds.height / 2.,
|
PanelAnchor::Bottom => (Anchor::Top, Gravity::Top),
|
||||||
},
|
|
||||||
Gravity::Right,
|
|
||||||
),
|
|
||||||
PanelAnchor::Right => (
|
|
||||||
iced::Point {
|
|
||||||
x: 0.,
|
|
||||||
y: bounds.height / 2.,
|
|
||||||
},
|
|
||||||
Gravity::Left,
|
|
||||||
),
|
|
||||||
PanelAnchor::Top => (
|
|
||||||
iced::Point {
|
|
||||||
x: bounds.width / 2.,
|
|
||||||
y: bounds.height,
|
|
||||||
},
|
|
||||||
Gravity::Bottom,
|
|
||||||
),
|
|
||||||
PanelAnchor::Bottom => (
|
|
||||||
iced::Point {
|
|
||||||
x: bounds.width / 2.,
|
|
||||||
y: 0.,
|
|
||||||
},
|
|
||||||
Gravity::Top,
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
crate::app::message::simple_subsurface::<
|
crate::app::message::simple_popup::<
|
||||||
Message,
|
Message,
|
||||||
Option<
|
Option<
|
||||||
Box<
|
Box<
|
||||||
|
|
@ -292,16 +266,28 @@ impl Context {
|
||||||
>,
|
>,
|
||||||
>,
|
>,
|
||||||
>(
|
>(
|
||||||
move || subsurface::SctkSubsurfaceSettings {
|
move || SctkPopupSettings {
|
||||||
parent: window::Id::RESERVED,
|
parent: window::Id::RESERVED,
|
||||||
id: window_id,
|
id: window_id,
|
||||||
loc,
|
grab: false,
|
||||||
size: None,
|
input_zone: Some(Rectangle::default()),
|
||||||
z: 1,
|
positioner: SctkPositioner {
|
||||||
steal_keyboard_focus: false,
|
size: None,
|
||||||
offset: (0, 0),
|
size_limits: Limits::NONE.min_width(1.).min_height(1.),
|
||||||
gravity,
|
anchor_rect: Rectangle {
|
||||||
input_region: Rectangle::default(),
|
x: bounds.x.round() as i32,
|
||||||
|
y: bounds.y.round() as i32,
|
||||||
|
width: bounds.width.round() as i32,
|
||||||
|
height: bounds.height.round() as i32,
|
||||||
|
},
|
||||||
|
anchor: popup_anchor,
|
||||||
|
gravity,
|
||||||
|
constraint_adjustment: 15,
|
||||||
|
offset: (0, 0),
|
||||||
|
reactive: true,
|
||||||
|
},
|
||||||
|
parent_size: None,
|
||||||
|
close_with_children: true,
|
||||||
},
|
},
|
||||||
Some(Box::new(move || {
|
Some(Box::new(move || {
|
||||||
Element::<'static, crate::app::Message<Message>>::from(autosize::autosize(
|
Element::<'static, crate::app::Message<Message>>::from(autosize::autosize(
|
||||||
|
|
@ -405,6 +391,7 @@ impl Context {
|
||||||
parent_size: None,
|
parent_size: None,
|
||||||
grab: true,
|
grab: true,
|
||||||
close_with_children: false,
|
close_with_children: false,
|
||||||
|
input_zone: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -524,6 +524,7 @@ pub fn update<
|
||||||
SctkPopupSettings {
|
SctkPopupSettings {
|
||||||
parent,
|
parent,
|
||||||
id,
|
id,
|
||||||
|
input_zone: None,
|
||||||
positioner: SctkPositioner {
|
positioner: SctkPositioner {
|
||||||
size: Some((selections_width as u32 + gap as u32 + pad_width as u32 + icon_width as u32, 10)),
|
size: Some((selections_width as u32 + gap as u32 + pad_width as u32 + icon_width as u32, 10)),
|
||||||
anchor_rect,
|
anchor_rect,
|
||||||
|
|
@ -534,7 +535,7 @@ pub fn update<
|
||||||
},
|
},
|
||||||
parent_size: None,
|
parent_size: None,
|
||||||
grab: true,
|
grab: true,
|
||||||
close_with_children: true
|
close_with_children: true,
|
||||||
},
|
},
|
||||||
Arc::new(move || {
|
Arc::new(move || {
|
||||||
Element::from(
|
Element::from(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue