tree: add Node::node_make_visible
This commit is contained in:
parent
289c201a69
commit
4bfa9fb7fc
15 changed files with 147 additions and 34 deletions
|
|
@ -1818,6 +1818,12 @@ impl Node for WlSurface {
|
|||
self.ext.get().tray_item()
|
||||
}
|
||||
|
||||
fn node_make_visible(self: Rc<Self>) {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
tl.node_make_visible();
|
||||
}
|
||||
}
|
||||
|
||||
fn node_on_key(
|
||||
&self,
|
||||
seat: &WlSeatGlobal,
|
||||
|
|
|
|||
|
|
@ -212,6 +212,10 @@ impl<T: TrayItem> XdgPopupParent for Popup<T> {
|
|||
self.parent.node_visible()
|
||||
}
|
||||
|
||||
fn make_visible(self: Rc<Self>) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn tray_item(&self) -> Option<TrayItemId> {
|
||||
Some(self.parent.data().tray_item_id)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -412,6 +412,10 @@ impl Node for Xwindow {
|
|||
Some(self)
|
||||
}
|
||||
|
||||
fn node_make_visible(self: Rc<Self>) {
|
||||
self.toplevel_data.make_visible(&*self);
|
||||
}
|
||||
|
||||
fn node_on_pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.enter_toplevel(self.clone());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,6 +146,12 @@ impl XdgPopupParent for Popup {
|
|||
self.parent.surface.visible.get()
|
||||
}
|
||||
|
||||
fn make_visible(self: Rc<Self>) {
|
||||
if let Some(ext) = self.parent.ext.get() {
|
||||
ext.make_visible();
|
||||
}
|
||||
}
|
||||
|
||||
fn tray_item(&self) -> Option<TrayItemId> {
|
||||
self.parent.clone().tray_item()
|
||||
}
|
||||
|
|
@ -193,6 +199,8 @@ pub trait XdgSurfaceExt: Debug {
|
|||
fn tray_item(&self) -> Option<TrayItemId> {
|
||||
None
|
||||
}
|
||||
|
||||
fn make_visible(self: Rc<Self>);
|
||||
}
|
||||
|
||||
impl XdgSurface {
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ pub trait XdgPopupParent {
|
|||
fn has_workspace_link(&self) -> bool;
|
||||
fn post_commit(&self);
|
||||
fn visible(&self) -> bool;
|
||||
fn make_visible(self: Rc<Self>);
|
||||
fn tray_item(&self) -> Option<TrayItemId> {
|
||||
None
|
||||
}
|
||||
|
|
@ -344,6 +345,12 @@ impl Node for XdgPopup {
|
|||
Some(self.xdg.surface.client.clone())
|
||||
}
|
||||
|
||||
fn node_make_visible(self: Rc<Self>) {
|
||||
if let Some(parent) = self.parent.get() {
|
||||
parent.make_visible();
|
||||
}
|
||||
}
|
||||
|
||||
fn node_on_pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.enter_popup(&self);
|
||||
}
|
||||
|
|
@ -430,6 +437,10 @@ impl XdgSurfaceExt for XdgPopup {
|
|||
fn tray_item(&self) -> Option<TrayItemId> {
|
||||
self.parent.get()?.tray_item()
|
||||
}
|
||||
|
||||
fn make_visible(self: Rc<Self>) {
|
||||
self.node_make_visible();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
|
|
|||
|
|
@ -610,6 +610,10 @@ impl Node for XdgToplevel {
|
|||
Some(self)
|
||||
}
|
||||
|
||||
fn node_make_visible(self: Rc<Self>) {
|
||||
self.toplevel_data.make_visible(&*self)
|
||||
}
|
||||
|
||||
fn node_on_pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.enter_toplevel(self.clone());
|
||||
}
|
||||
|
|
@ -780,6 +784,10 @@ impl XdgSurfaceExt for XdgToplevel {
|
|||
.state
|
||||
.damage(self.node_absolute_position());
|
||||
}
|
||||
|
||||
fn make_visible(self: Rc<Self>) {
|
||||
self.node_make_visible();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
|
|
|||
|
|
@ -724,6 +724,10 @@ impl XdgPopupParent for Popup {
|
|||
fn visible(&self) -> bool {
|
||||
self.parent.node_visible()
|
||||
}
|
||||
|
||||
fn make_visible(self: Rc<Self>) {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
|
|
|
|||
70
src/state.rs
70
src/state.rs
|
|
@ -853,41 +853,28 @@ impl State {
|
|||
node.node_do_focus(&seat, Direction::Unspecified);
|
||||
}
|
||||
|
||||
pub fn show_workspace(&self, seat: &Rc<WlSeatGlobal>, name: &str) {
|
||||
let (output, ws) = match self.workspaces.get(name) {
|
||||
Some(ws) => {
|
||||
let output = ws.output.get();
|
||||
let mut pinned_is_focused = false;
|
||||
for pinned in output.pinned.iter() {
|
||||
pinned
|
||||
.deref()
|
||||
.clone()
|
||||
.node_visit(&mut generic_node_visitor(|node| {
|
||||
node.node_seat_state().for_each_kb_focus(|s| {
|
||||
pinned_is_focused |= s.id() == seat.id();
|
||||
});
|
||||
}));
|
||||
}
|
||||
let did_change = output.show_workspace(&ws);
|
||||
if !pinned_is_focused {
|
||||
ws.clone().node_do_focus(seat, Direction::Unspecified);
|
||||
}
|
||||
if !did_change {
|
||||
return;
|
||||
}
|
||||
(output, ws)
|
||||
pub fn show_workspace2(&self, seat: Option<&Rc<WlSeatGlobal>>, ws: &Rc<WorkspaceNode>) {
|
||||
let output = ws.output.get();
|
||||
let mut pinned_is_focused = false;
|
||||
if let Some(seat) = seat {
|
||||
for pinned in output.pinned.iter() {
|
||||
pinned
|
||||
.deref()
|
||||
.clone()
|
||||
.node_visit(&mut generic_node_visitor(|node| {
|
||||
node.node_seat_state().for_each_kb_focus(|s| {
|
||||
pinned_is_focused |= s.id() == seat.id();
|
||||
});
|
||||
}));
|
||||
}
|
||||
_ => {
|
||||
let output = seat.get_output();
|
||||
if output.is_dummy {
|
||||
log::warn!("Not showing workspace because seat is on dummy output");
|
||||
return;
|
||||
}
|
||||
let ws = output.create_workspace(name);
|
||||
output.show_workspace(&ws);
|
||||
(output, ws)
|
||||
}
|
||||
};
|
||||
}
|
||||
let did_change = output.show_workspace(&ws);
|
||||
if !pinned_is_focused && let Some(seat) = seat {
|
||||
ws.clone().node_do_focus(seat, Direction::Unspecified);
|
||||
}
|
||||
if !did_change {
|
||||
return;
|
||||
}
|
||||
ws.flush_jay_workspaces();
|
||||
output.schedule_update_render_data();
|
||||
self.tree_changed();
|
||||
|
|
@ -897,6 +884,21 @@ impl State {
|
|||
// }
|
||||
}
|
||||
|
||||
pub fn show_workspace(&self, seat: &Rc<WlSeatGlobal>, name: &str) {
|
||||
let ws = match self.workspaces.get(name) {
|
||||
Some(ws) => ws,
|
||||
_ => {
|
||||
let output = seat.get_output();
|
||||
if output.is_dummy {
|
||||
log::warn!("Not showing workspace because seat is on dummy output");
|
||||
return;
|
||||
}
|
||||
output.create_workspace(name)
|
||||
}
|
||||
};
|
||||
self.show_workspace2(Some(seat), &ws);
|
||||
}
|
||||
|
||||
pub fn float_map_ws(&self) -> Rc<WorkspaceNode> {
|
||||
if let Some(seat) = self.seat_queue.last() {
|
||||
let output = seat.get_output();
|
||||
|
|
|
|||
|
|
@ -193,6 +193,10 @@ pub trait Node: 'static {
|
|||
None
|
||||
}
|
||||
|
||||
fn node_make_visible(self: Rc<Self>) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
// EVENT HANDLERS
|
||||
|
||||
fn node_on_key(
|
||||
|
|
|
|||
|
|
@ -1636,6 +1636,10 @@ impl Node for ContainerNode {
|
|||
Some(self)
|
||||
}
|
||||
|
||||
fn node_make_visible(self: Rc<Self>) {
|
||||
self.toplevel_data.make_visible(&*self);
|
||||
}
|
||||
|
||||
fn node_on_button(
|
||||
self: Rc<Self>,
|
||||
seat: &Rc<WlSeatGlobal>,
|
||||
|
|
@ -1919,6 +1923,28 @@ impl ContainingNode for ContainerNode {
|
|||
self.workspace.get()
|
||||
}
|
||||
|
||||
fn cnode_make_visible(self: Rc<Self>, child: &dyn Node) {
|
||||
let Some(child) = self
|
||||
.child_nodes
|
||||
.borrow()
|
||||
.get(&child.node_id())
|
||||
.map(|n| n.to_ref())
|
||||
else {
|
||||
return;
|
||||
};
|
||||
self.toplevel_data.make_visible(&*self);
|
||||
if !self.node_visible() {
|
||||
return;
|
||||
}
|
||||
let Some(cur) = self.mono_child.get() else {
|
||||
return;
|
||||
};
|
||||
if cur.node.node_id() == child.node.node_id() {
|
||||
return;
|
||||
}
|
||||
self.activate_child(&child);
|
||||
}
|
||||
|
||||
fn cnode_set_child_position(self: Rc<Self>, child: &dyn Node, x: i32, y: i32) {
|
||||
let Some(parent) = self.toplevel_data.parent.get() else {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ pub trait ContainingNode: Node {
|
|||
fn cnode_accepts_child(&self, node: &dyn Node) -> bool;
|
||||
fn cnode_child_attention_request_changed(self: Rc<Self>, child: &dyn Node, set: bool);
|
||||
fn cnode_workspace(self: Rc<Self>) -> Rc<WorkspaceNode>;
|
||||
fn cnode_make_visible(self: Rc<Self>, child: &dyn Node);
|
||||
fn cnode_set_child_position(self: Rc<Self>, child: &dyn Node, x: i32, y: i32) {
|
||||
let _ = child;
|
||||
let _ = x;
|
||||
|
|
|
|||
|
|
@ -752,6 +752,13 @@ impl Node for FloatNode {
|
|||
renderer.render_floating(self, x, y)
|
||||
}
|
||||
|
||||
fn node_make_visible(self: Rc<Self>) {
|
||||
if self.visible.get() {
|
||||
return;
|
||||
}
|
||||
self.workspace.get().cnode_make_visible(&*self);
|
||||
}
|
||||
|
||||
fn node_on_button(
|
||||
self: Rc<Self>,
|
||||
seat: &Rc<WlSeatGlobal>,
|
||||
|
|
@ -904,6 +911,10 @@ impl ContainingNode for FloatNode {
|
|||
self.workspace.get()
|
||||
}
|
||||
|
||||
fn cnode_make_visible(self: Rc<Self>, _child: &dyn Node) {
|
||||
self.node_make_visible();
|
||||
}
|
||||
|
||||
fn cnode_set_child_position(self: Rc<Self>, _child: &dyn Node, x: i32, y: i32) {
|
||||
let theme = &self.state.theme;
|
||||
let th = theme.sizes.title_height.get();
|
||||
|
|
|
|||
|
|
@ -211,6 +211,10 @@ impl Node for PlaceholderNode {
|
|||
Some(self)
|
||||
}
|
||||
|
||||
fn node_make_visible(self: Rc<Self>) {
|
||||
self.toplevel.make_visible(&*self);
|
||||
}
|
||||
|
||||
fn node_on_pointer_enter(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, _x: Fixed, _y: Fixed) {
|
||||
seat.pointer_cursor().set_known(KnownCursor::Default);
|
||||
seat.enter_toplevel(self.clone());
|
||||
|
|
|
|||
|
|
@ -866,6 +866,15 @@ impl ToplevelData {
|
|||
self.property_changed(TL_CHANGED_CONTENT_TY);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn make_visible(&self, slf: &dyn Node) {
|
||||
if self.visible.get() {
|
||||
return;
|
||||
}
|
||||
if let Some(parent) = self.parent.get() {
|
||||
parent.cnode_make_visible(slf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for ToplevelData {
|
||||
|
|
|
|||
|
|
@ -359,6 +359,13 @@ impl Node for WorkspaceNode {
|
|||
renderer.render_workspace(self, x, y);
|
||||
}
|
||||
|
||||
fn node_make_visible(self: Rc<Self>) {
|
||||
if self.is_dummy {
|
||||
return;
|
||||
}
|
||||
self.state.show_workspace2(None, &self);
|
||||
}
|
||||
|
||||
fn node_on_pointer_focus(&self, seat: &Rc<WlSeatGlobal>) {
|
||||
// log::info!("workspace focus");
|
||||
seat.pointer_cursor().set_known(KnownCursor::Default);
|
||||
|
|
@ -434,6 +441,10 @@ impl ContainingNode for WorkspaceNode {
|
|||
fn cnode_workspace(self: Rc<Self>) -> Rc<WorkspaceNode> {
|
||||
self
|
||||
}
|
||||
|
||||
fn cnode_make_visible(self: Rc<Self>, _child: &dyn Node) {
|
||||
self.node_make_visible();
|
||||
}
|
||||
}
|
||||
|
||||
pub struct WsMoveConfig {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue