refactor: make get_popup_toplevel() PopupKind agnostic
- for preparation to make unconstrain_popup() PopupKind agnostic.
This commit is contained in:
parent
b5a1a6d317
commit
977d4c2dca
5 changed files with 11 additions and 8 deletions
|
|
@ -197,7 +197,7 @@ impl PointerFocusTarget {
|
||||||
PointerFocusTarget::WlSurface {
|
PointerFocusTarget::WlSurface {
|
||||||
toplevel: Some(PointerFocusToplevel::Popup(PopupKind::Xdg(popup))),
|
toplevel: Some(PointerFocusToplevel::Popup(PopupKind::Xdg(popup))),
|
||||||
..
|
..
|
||||||
} => get_popup_toplevel(popup)
|
} => get_popup_toplevel(&PopupKind::Xdg(popup.clone()))
|
||||||
.and_then(|s| shell.element_for_surface(&s).map(|mapped| (mapped, s)))
|
.and_then(|s| shell.element_for_surface(&s).map(|mapped| (mapped, s)))
|
||||||
.and_then(|(m, s)| {
|
.and_then(|(m, s)| {
|
||||||
m.windows()
|
m.windows()
|
||||||
|
|
@ -243,7 +243,7 @@ impl KeyboardFocusTarget {
|
||||||
match self {
|
match self {
|
||||||
KeyboardFocusTarget::Element(mapped) => mapped.wl_surface(),
|
KeyboardFocusTarget::Element(mapped) => mapped.wl_surface(),
|
||||||
KeyboardFocusTarget::Popup(PopupKind::Xdg(xdg)) => {
|
KeyboardFocusTarget::Popup(PopupKind::Xdg(xdg)) => {
|
||||||
get_popup_toplevel(xdg).map(Cow::Owned)
|
get_popup_toplevel(&PopupKind::Xdg(xdg.clone())).map(Cow::Owned)
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1278,7 +1278,7 @@ impl FloatingLayout {
|
||||||
let Some(focused) = (match target {
|
let Some(focused) = (match target {
|
||||||
KeyboardFocusTarget::Popup(popup) => {
|
KeyboardFocusTarget::Popup(popup) => {
|
||||||
let Some(toplevel_surface) = (match popup {
|
let Some(toplevel_surface) = (match popup {
|
||||||
PopupKind::Xdg(xdg) => get_popup_toplevel(&xdg),
|
PopupKind::Xdg(_) => get_popup_toplevel(&popup),
|
||||||
PopupKind::InputMethod(_) => unreachable!(),
|
PopupKind::InputMethod(_) => unreachable!(),
|
||||||
}) else {
|
}) else {
|
||||||
return MoveResult::None;
|
return MoveResult::None;
|
||||||
|
|
|
||||||
|
|
@ -2848,7 +2848,7 @@ impl TilingLayout {
|
||||||
// if the focus is currently on a popup, treat it's toplevel as the target
|
// if the focus is currently on a popup, treat it's toplevel as the target
|
||||||
if let KeyboardFocusTarget::Popup(popup) = target {
|
if let KeyboardFocusTarget::Popup(popup) = target {
|
||||||
let toplevel_surface = match popup {
|
let toplevel_surface = match popup {
|
||||||
PopupKind::Xdg(xdg) => get_popup_toplevel(&xdg),
|
PopupKind::Xdg(_) => get_popup_toplevel(&popup),
|
||||||
PopupKind::InputMethod(_) => unreachable!(),
|
PopupKind::InputMethod(_) => unreachable!(),
|
||||||
}?;
|
}?;
|
||||||
let root_id = tree.root_node_id()?;
|
let root_id = tree.root_node_id()?;
|
||||||
|
|
|
||||||
|
|
@ -3883,7 +3883,7 @@ impl Shell {
|
||||||
let Some(focused) = (match target {
|
let Some(focused) = (match target {
|
||||||
KeyboardFocusTarget::Popup(popup) => {
|
KeyboardFocusTarget::Popup(popup) => {
|
||||||
let Some(toplevel_surface) = (match popup {
|
let Some(toplevel_surface) = (match popup {
|
||||||
PopupKind::Xdg(xdg) => get_popup_toplevel(&xdg),
|
PopupKind::Xdg(_) => get_popup_toplevel(&popup),
|
||||||
PopupKind::InputMethod(_) => unreachable!(),
|
PopupKind::InputMethod(_) => unreachable!(),
|
||||||
}) else {
|
}) else {
|
||||||
return FocusResult::None;
|
return FocusResult::None;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ use tracing::warn;
|
||||||
|
|
||||||
impl Shell {
|
impl Shell {
|
||||||
pub fn unconstrain_popup(&self, surface: &PopupSurface) {
|
pub fn unconstrain_popup(&self, surface: &PopupSurface) {
|
||||||
if let Some(parent) = get_popup_toplevel(surface) {
|
if let Some(parent) = get_popup_toplevel(&PopupKind::from(surface.clone())) {
|
||||||
if let Some(elem) = self.element_for_surface(&parent) {
|
if let Some(elem) = self.element_for_surface(&parent) {
|
||||||
let (mut element_geo, output, is_tiled) =
|
let (mut element_geo, output, is_tiled) =
|
||||||
if let Some(workspace) = self.space_for(elem) {
|
if let Some(workspace) = self.space_for(elem) {
|
||||||
|
|
@ -173,8 +173,11 @@ fn unconstrain_layer_popup(surface: &PopupSurface, output: &Output, layer_surfac
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_popup_toplevel(popup: &PopupSurface) -> Option<WlSurface> {
|
pub fn get_popup_toplevel(popup: &PopupKind) -> Option<WlSurface> {
|
||||||
let mut parent = popup.get_parent_surface()?;
|
let mut parent = match popup {
|
||||||
|
PopupKind::Xdg(popup) => popup.get_parent_surface()?,
|
||||||
|
PopupKind::InputMethod(popup) => popup.get_parent()?.surface.clone(),
|
||||||
|
};
|
||||||
while get_role(&parent) == Some(XDG_POPUP_ROLE) {
|
while get_role(&parent) == Some(XDG_POPUP_ROLE) {
|
||||||
parent = with_states(&parent, |states| {
|
parent = with_states(&parent, |states| {
|
||||||
states
|
states
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue