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