autocommit 2022-02-01 01:20:49 CET
This commit is contained in:
parent
f2117256b9
commit
7654e70f64
39 changed files with 830 additions and 761 deletions
|
|
@ -1,8 +1,8 @@
|
|||
use crate::ifs::wl_seat::WlSeatGlobal;
|
||||
use crate::ifs::wl_surface::WlSurface;
|
||||
use crate::rect::Rect;
|
||||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
use crate::ifs::wl_seat::{WlSeatGlobal};
|
||||
use crate::ifs::wl_surface::{WlSurface};
|
||||
use crate::rect::Rect;
|
||||
|
||||
pub struct CursorSurface {
|
||||
seat: Rc<WlSeatGlobal>,
|
||||
|
|
@ -19,7 +19,7 @@ impl CursorSurface {
|
|||
surface: surface.clone(),
|
||||
hotspot: Cell::new((0, 0)),
|
||||
pos: Cell::new((0, 0)),
|
||||
extents: Cell::new(Default::default())
|
||||
extents: Cell::new(Default::default()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -27,7 +27,15 @@ impl CursorSurface {
|
|||
let (pos_x, pos_y) = self.pos.get();
|
||||
let extents = self.extents.get();
|
||||
let (hot_x, hot_y) = self.hotspot.get();
|
||||
self.extents.set(Rect::new_sized(pos_x - hot_x, pos_y - hot_y, extents.width(), extents.height()).unwrap());
|
||||
self.extents.set(
|
||||
Rect::new_sized(
|
||||
pos_x - hot_x,
|
||||
pos_y - hot_y,
|
||||
extents.width(),
|
||||
extents.height(),
|
||||
)
|
||||
.unwrap(),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn set_position(&self, x: i32, y: i32) {
|
||||
|
|
@ -48,7 +56,8 @@ impl CursorSurface {
|
|||
Some(b) => (b.rect.width(), b.rect.height()),
|
||||
_ => (0, 0),
|
||||
};
|
||||
self.extents.set(Rect::new_sized(0, 0, width, height).unwrap());
|
||||
self.extents
|
||||
.set(Rect::new_sized(0, 0, width, height).unwrap());
|
||||
self.update_extents();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,22 +1,28 @@
|
|||
pub mod cursor;
|
||||
mod types;
|
||||
pub mod wl_subsurface;
|
||||
pub mod xdg_surface;
|
||||
pub mod cursor;
|
||||
|
||||
use crate::backend::{KeyState, ScrollAxis, SeatId};
|
||||
use crate::client::{Client, ClientId, DynEventFormatter, RequestParser};
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_buffer::WlBuffer;
|
||||
use crate::ifs::wl_callback::WlCallback;
|
||||
use crate::ifs::wl_output::WlOutputId;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal};
|
||||
use crate::ifs::wl_surface::cursor::CursorSurface;
|
||||
use crate::ifs::wl_surface::wl_subsurface::WlSubsurface;
|
||||
use crate::ifs::wl_surface::xdg_surface::{XdgSurface, XdgSurfaceRole};
|
||||
use crate::object::{Interface, Object, ObjectId};
|
||||
use crate::pixman::Region;
|
||||
use crate::rect::Rect;
|
||||
use crate::render::Renderer;
|
||||
use crate::tree::{Node, NodeId};
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
use crate::utils::linkedlist::LinkedList;
|
||||
use crate::utils::smallmap::SmallMap;
|
||||
use crate::xkbcommon::ModifierState;
|
||||
use crate::NumCell;
|
||||
use ahash::AHashMap;
|
||||
use std::cell::{Cell, RefCell};
|
||||
|
|
@ -24,12 +30,6 @@ use std::mem;
|
|||
use std::ops::{Deref, DerefMut};
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use crate::ifs::wl_output::WlOutputId;
|
||||
use crate::ifs::wl_surface::cursor::CursorSurface;
|
||||
use crate::ifs::wl_surface::xdg_surface::{XdgSurface, XdgSurfaceRole};
|
||||
use crate::render::Renderer;
|
||||
use crate::utils::smallmap::SmallMap;
|
||||
use crate::xkbcommon::ModifierState;
|
||||
|
||||
const DESTROY: u32 = 0;
|
||||
const ATTACH: u32 = 1;
|
||||
|
|
@ -197,7 +197,10 @@ impl WlSurface {
|
|||
self.role.get() == SurfaceRole::Cursor
|
||||
}
|
||||
|
||||
pub fn get_cursor(self: &Rc<Self>, seat: &Rc<WlSeatGlobal>) -> Result<Rc<CursorSurface>, WlSurfaceError> {
|
||||
pub fn get_cursor(
|
||||
self: &Rc<Self>,
|
||||
seat: &Rc<WlSeatGlobal>,
|
||||
) -> Result<Rc<CursorSurface>, WlSurfaceError> {
|
||||
if let Some(cursor) = self.cursors.get(&seat.id()) {
|
||||
return Ok(cursor);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::wl_callback::WlCallbackId;
|
||||
use crate::ifs::wl_output::WlOutputId;
|
||||
use crate::ifs::wl_region::WlRegionId;
|
||||
use crate::ifs::wl_surface::xdg_surface::XdgSurfaceError;
|
||||
use crate::ifs::wl_surface::{ENTER, SurfaceRole, WlSurface, WlSurfaceId};
|
||||
use crate::ifs::wl_surface::{SurfaceRole, WlSurface, WlSurfaceId, ENTER};
|
||||
use crate::object::Object;
|
||||
use crate::utils::buffd::{MsgFormatter, MsgParser, MsgParserError};
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use crate::ifs::wl_output::WlOutputId;
|
||||
use crate::object::Object;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum WlSurfaceError {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@ mod types;
|
|||
pub mod xdg_popup;
|
||||
pub mod xdg_toplevel;
|
||||
|
||||
use crate::backend::SeatId;
|
||||
use crate::client::DynEventFormatter;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal};
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_popup::{XdgPopup, XdgPopupId};
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevel;
|
||||
use crate::ifs::wl_surface::{
|
||||
|
|
@ -15,13 +17,11 @@ use crate::tree::{FindTreeResult, FoundNode, Node, WorkspaceNode};
|
|||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
use crate::utils::copyhashmap::CopyHashMap;
|
||||
use crate::utils::smallmap::SmallMap;
|
||||
use crate::NumCell;
|
||||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use crate::backend::SeatId;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal};
|
||||
use crate::utils::smallmap::SmallMap;
|
||||
|
||||
const DESTROY: u32 = 0;
|
||||
const GET_TOPLEVEL: u32 = 1;
|
||||
|
|
@ -158,7 +158,9 @@ impl XdgSurface {
|
|||
}
|
||||
|
||||
pub fn focus_surface(&self, seat: &WlSeatGlobal) -> Rc<WlSurface> {
|
||||
self.focus_surface.get(&seat.id()).unwrap_or_else(|| self.surface.clone())
|
||||
self.focus_surface
|
||||
.get(&seat.id())
|
||||
.unwrap_or_else(|| self.surface.clone())
|
||||
}
|
||||
|
||||
fn destroy_node(&self) {
|
||||
|
|
@ -318,16 +320,10 @@ impl XdgSurface {
|
|||
}
|
||||
match self.surface.find_surface_at(x, y) {
|
||||
Some((node, x, y)) => {
|
||||
tree.push(FoundNode {
|
||||
node,
|
||||
x,
|
||||
y,
|
||||
});
|
||||
tree.push(FoundNode { node, x, y });
|
||||
FindTreeResult::AcceptsInput
|
||||
},
|
||||
_ => {
|
||||
FindTreeResult::Other
|
||||
}
|
||||
_ => FindTreeResult::Other,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::client::{ClientError, EventFormatter, RequestParser};
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_popup::{XdgPopupError, XdgPopupId};
|
||||
use crate::ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevelId;
|
||||
use crate::ifs::wl_surface::xdg_surface::{XdgSurface, XdgSurfaceId, CONFIGURE, XdgSurfaceRole};
|
||||
use crate::ifs::wl_surface::xdg_surface::{XdgSurface, XdgSurfaceId, XdgSurfaceRole, CONFIGURE};
|
||||
use crate::ifs::wl_surface::{WlSurfaceError, WlSurfaceId};
|
||||
use crate::ifs::xdg_positioner::XdgPositionerId;
|
||||
use crate::object::Object;
|
||||
|
|
|
|||
|
|
@ -268,7 +268,7 @@ impl XdgSurfaceExt for XdgPopup {
|
|||
_ => {
|
||||
log::info!("no ws");
|
||||
return;
|
||||
},
|
||||
}
|
||||
};
|
||||
let surface = &self.xdg.surface;
|
||||
let state = &surface.client.state;
|
||||
|
|
@ -276,12 +276,7 @@ impl XdgSurfaceExt for XdgPopup {
|
|||
if wl.is_none() {
|
||||
self.xdg.set_workspace(&ws);
|
||||
*wl = Some(ws.stacked.add_last(self.clone()));
|
||||
*dl = Some(
|
||||
state
|
||||
.root
|
||||
.stacked
|
||||
.add_last(self.clone()),
|
||||
);
|
||||
*dl = Some(state.root.stacked.add_last(self.clone()));
|
||||
state.tree_changed();
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
mod types;
|
||||
|
||||
use crate::backend::SeatId;
|
||||
use crate::client::{ClientId, DynEventFormatter};
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal};
|
||||
|
|
@ -11,16 +12,15 @@ use crate::tree::{ContainerNode, FindTreeResult};
|
|||
use crate::tree::{FloatNode, FoundNode, Node, NodeId, ToplevelNodeId, WorkspaceNode};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
use crate::utils::linkedlist::LinkedNode;
|
||||
use crate::utils::smallmap::SmallMap;
|
||||
use crate::NumCell;
|
||||
use ahash::{AHashMap, AHashSet};
|
||||
use num_derive::FromPrimitive;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use crate::backend::{SeatId};
|
||||
use crate::NumCell;
|
||||
use crate::utils::linkedlist::LinkedNode;
|
||||
use crate::utils::smallmap::SmallMap;
|
||||
|
||||
const DESTROY: u32 = 0;
|
||||
const SET_PARENT: u32 = 1;
|
||||
|
|
@ -72,6 +72,13 @@ const STATE_TILED_BOTTOM: u32 = 8;
|
|||
|
||||
id!(XdgToplevelId);
|
||||
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||
pub enum Decoration {
|
||||
#[allow(dead_code)]
|
||||
Client,
|
||||
Server,
|
||||
}
|
||||
|
||||
pub struct XdgToplevel {
|
||||
pub id: XdgToplevelId,
|
||||
pub xdg: Rc<XdgSurface>,
|
||||
|
|
@ -82,6 +89,7 @@ pub struct XdgToplevel {
|
|||
states: RefCell<AHashSet<u32>>,
|
||||
pub toplevel_history: SmallMap<SeatId, LinkedNode<Rc<XdgToplevel>>, 1>,
|
||||
active_surfaces: NumCell<u32>,
|
||||
pub decoration: Cell<Decoration>,
|
||||
}
|
||||
|
||||
impl XdgToplevel {
|
||||
|
|
@ -101,6 +109,7 @@ impl XdgToplevel {
|
|||
states: RefCell::new(states),
|
||||
toplevel_history: Default::default(),
|
||||
active_surfaces: Default::default(),
|
||||
decoration: Cell::new(Decoration::Server),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -114,7 +123,10 @@ impl XdgToplevel {
|
|||
};
|
||||
if changed {
|
||||
let rect = self.xdg.absolute_desired_extents.get();
|
||||
self.xdg.surface.client.event(self.configure(rect.width(), rect.height()));
|
||||
self.xdg
|
||||
.surface
|
||||
.client
|
||||
.event(self.configure(rect.width(), rect.height()));
|
||||
self.xdg.send_configure();
|
||||
}
|
||||
}
|
||||
|
|
@ -282,17 +294,12 @@ impl XdgToplevel {
|
|||
seat_state: Default::default(),
|
||||
});
|
||||
self.parent_node.set(Some(floater.clone()));
|
||||
floater.display_link.set(Some(
|
||||
state
|
||||
.root
|
||||
.stacked
|
||||
.add_last(floater.clone()),
|
||||
));
|
||||
floater.workspace_link.set(Some(
|
||||
workspace
|
||||
.stacked
|
||||
.add_last(floater.clone()),
|
||||
));
|
||||
floater
|
||||
.display_link
|
||||
.set(Some(state.root.stacked.add_last(floater.clone())));
|
||||
floater
|
||||
.workspace_link
|
||||
.set(Some(workspace.stacked.add_last(floater.clone())));
|
||||
}
|
||||
|
||||
fn map_tiled(self: &Rc<Self>) {
|
||||
|
|
@ -319,8 +326,12 @@ impl XdgToplevel {
|
|||
container.append_child(self.clone());
|
||||
self.parent_node.set(Some(container));
|
||||
} else {
|
||||
let container =
|
||||
Rc::new(ContainerNode::new(state, &workspace, workspace.clone(), self.clone()));
|
||||
let container = Rc::new(ContainerNode::new(
|
||||
state,
|
||||
&workspace,
|
||||
workspace.clone(),
|
||||
self.clone(),
|
||||
));
|
||||
workspace.set_container(&container);
|
||||
self.parent_node.set(Some(container));
|
||||
};
|
||||
|
|
@ -444,7 +455,10 @@ impl XdgSurfaceExt for XdgToplevel {
|
|||
let bindings = output.global.bindings.borrow_mut();
|
||||
for binding in bindings.get(&self.xdg.surface.client.id) {
|
||||
for binding in binding.values() {
|
||||
self.xdg.surface.client.event(self.xdg.surface.enter_event(binding.id));
|
||||
self.xdg
|
||||
.surface
|
||||
.client
|
||||
.event(self.xdg.surface.enter_event(binding.id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue