autocommit 2022-04-02 00:31:30 CEST
This commit is contained in:
parent
2dd433aa04
commit
6ad6d83b7e
34 changed files with 446 additions and 161 deletions
|
|
@ -7,7 +7,9 @@ use crate::utils::buffd::{MsgParser, MsgParserError};
|
|||
use crate::wire::jay_compositor::*;
|
||||
use crate::wire::JayCompositorId;
|
||||
use std::rc::Rc;
|
||||
use log::Level;
|
||||
use thiserror::Error;
|
||||
use crate::cli::CliLogLevel;
|
||||
|
||||
pub struct JayCompositorGlobal {
|
||||
name: GlobalName,
|
||||
|
|
@ -81,6 +83,25 @@ impl JayCompositor {
|
|||
self.client.state.el.stop();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_log_level(&self, parser: MsgParser<'_, '_>) -> Result<(), SetLogLevelError> {
|
||||
let req: SetLogLevel = self.client.parse(self, parser)?;
|
||||
const ERROR: u32 = CliLogLevel::Error as u32;
|
||||
const WARN: u32 = CliLogLevel::Warn as u32;
|
||||
const INFO: u32 = CliLogLevel::Info as u32;
|
||||
const DEBUG: u32 = CliLogLevel::Debug as u32;
|
||||
const TRACE: u32 = CliLogLevel::Trace as u32;
|
||||
let level = match req.level {
|
||||
ERROR => Level::Error,
|
||||
WARN => Level::Warn,
|
||||
INFO => Level::Info,
|
||||
DEBUG => Level::Debug,
|
||||
TRACE => Level::Trace,
|
||||
_ => return Err(SetLogLevelError::UnknownLogLevel(req.level)),
|
||||
};
|
||||
self.client.state.logger.set_level(level);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
|
|
@ -89,11 +110,12 @@ object_base! {
|
|||
DESTROY => destroy,
|
||||
GET_LOG_FILE => get_log_file,
|
||||
QUIT => quit,
|
||||
SET_LOG_LEVEL => set_log_level,
|
||||
}
|
||||
|
||||
impl Object for JayCompositor {
|
||||
fn num_requests(&self) -> u32 {
|
||||
QUIT + 1
|
||||
SET_LOG_LEVEL + 1
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -107,6 +129,8 @@ pub enum JayCompositorError {
|
|||
GetLogFileError(#[from] GetLogFileError),
|
||||
#[error("Could not process a `quit` request")]
|
||||
QuitError(#[from] QuitError),
|
||||
#[error("Could not process a `set_log_level` request")]
|
||||
SetLogLevelError(#[from] SetLogLevelError),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
|
|
@ -138,3 +162,12 @@ pub enum QuitError {
|
|||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
}
|
||||
efrom!(QuitError, MsgParserError);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum SetLogLevelError {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error("Unknown log level {0}")]
|
||||
UnknownLogLevel(u32),
|
||||
}
|
||||
efrom!(SetLogLevelError, MsgParserError);
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ use jay_config::Direction;
|
|||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::mem;
|
||||
use std::ops::{DerefMut};
|
||||
use std::ops::DerefMut;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use uapi::{c, Errno, OwnedFd};
|
||||
|
|
@ -373,6 +373,10 @@ impl WlSeatGlobal {
|
|||
self.id
|
||||
}
|
||||
|
||||
pub fn workspace_changed(self: &Rc<Self>, output: &Rc<OutputNode>) {
|
||||
self.kb_owner.workspace_changed(self, output);
|
||||
}
|
||||
|
||||
fn bind_(
|
||||
self: Rc<Self>,
|
||||
id: WlSeatId,
|
||||
|
|
|
|||
|
|
@ -192,8 +192,14 @@ impl WlSeatGlobal {
|
|||
}
|
||||
|
||||
pub fn last_tiled_keyboard_toplevel(&self, new: &dyn Node) -> Option<Rc<dyn ToplevelNode>> {
|
||||
let output = self.output.get();
|
||||
let workspace = output.workspace.get().unwrap();
|
||||
let is_container = new.is_container();
|
||||
for tl in self.toplevel_focus_history.rev_iter() {
|
||||
match tl.as_node().get_workspace() {
|
||||
Some(ws) if ws.id == workspace.id => { },
|
||||
_ => continue,
|
||||
};
|
||||
let parent_is_float = match tl.parent() {
|
||||
Some(pn) => pn.is_float(),
|
||||
_ => false,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use std::ops::Deref;
|
||||
use crate::ifs::wl_seat::WlSeatGlobal;
|
||||
use crate::tree::Node;
|
||||
use crate::tree::{Node, OutputNode};
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
|
|
@ -29,6 +30,10 @@ impl KbOwnerHolder {
|
|||
pub fn set_kb_node(&self, seat: &Rc<WlSeatGlobal>, node: Rc<dyn Node>) {
|
||||
self.owner.get().set_kb_node(seat, node);
|
||||
}
|
||||
|
||||
pub fn workspace_changed(&self, seat: &Rc<WlSeatGlobal>, output: &Rc<OutputNode>) {
|
||||
self.owner.get().workspace_changed(seat, output);
|
||||
}
|
||||
}
|
||||
|
||||
struct DefaultKbOwner;
|
||||
|
|
@ -39,6 +44,7 @@ trait KbOwner {
|
|||
fn grab(&self, seat: &Rc<WlSeatGlobal>, node: Rc<dyn Node>) -> bool;
|
||||
fn ungrab(&self, seat: &Rc<WlSeatGlobal>);
|
||||
fn set_kb_node(&self, seat: &Rc<WlSeatGlobal>, node: Rc<dyn Node>);
|
||||
fn workspace_changed(&self, seat: &Rc<WlSeatGlobal>, output: &Rc<OutputNode>);
|
||||
}
|
||||
|
||||
impl KbOwner for DefaultKbOwner {
|
||||
|
|
@ -68,6 +74,31 @@ impl KbOwner for DefaultKbOwner {
|
|||
node.clone().focus(seat);
|
||||
seat.keyboard_node.set(node.clone());
|
||||
}
|
||||
|
||||
fn workspace_changed(&self, seat: &Rc<WlSeatGlobal>, output: &Rc<OutputNode>) {
|
||||
let new_ws = match output.workspace.get() {
|
||||
Some(ws) => ws,
|
||||
_ => return,
|
||||
};
|
||||
let node = seat.keyboard_node.get();
|
||||
let ws = match node.get_workspace() {
|
||||
None => return,
|
||||
Some(ws) => ws,
|
||||
};
|
||||
let ws_output = ws.output.get();
|
||||
if ws_output.id != output.id {
|
||||
return;
|
||||
}
|
||||
for tl in seat.toplevel_focus_history.rev_iter() {
|
||||
if let Some(tl_ws) = tl.as_node().get_workspace() {
|
||||
if tl_ws.id == new_ws.id {
|
||||
self.set_kb_node(seat, tl.deref().clone().into_node());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
self.set_kb_node(seat, seat.state.root.clone());
|
||||
}
|
||||
}
|
||||
|
||||
impl KbOwner for GrabKbOwner {
|
||||
|
|
@ -82,4 +113,8 @@ impl KbOwner for GrabKbOwner {
|
|||
fn set_kb_node(&self, _seat: &Rc<WlSeatGlobal>, _node: Rc<dyn Node>) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
fn workspace_changed(&self, _seat: &Rc<WlSeatGlobal>, _output: &Rc<OutputNode>) {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use crate::rect::Rect;
|
|||
use crate::render::Renderer;
|
||||
use crate::tree::toplevel::ToplevelNode;
|
||||
use crate::tree::walker::NodeVisitor;
|
||||
use crate::tree::{ContainerNode, ContainerSplit, Node, NodeId};
|
||||
use crate::tree::{ContainerNode, ContainerSplit, Node, NodeId, WorkspaceNode};
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use crate::utils::clonecell::CloneCell;
|
||||
use crate::utils::linkedlist::LinkedList;
|
||||
|
|
@ -643,6 +643,13 @@ impl Node for WlSurface {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
if let Some(tl) = self.toplevel.get() {
|
||||
return tl.as_node().get_workspace();
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
fn get_parent_mono(&self) -> Option<bool> {
|
||||
self.toplevel
|
||||
.get()
|
||||
|
|
@ -679,7 +686,7 @@ impl Node for WlSurface {
|
|||
Some(tl) => tl,
|
||||
_ => return,
|
||||
};
|
||||
let ws = match tl.workspace() {
|
||||
let ws = match tl.as_node().get_workspace() {
|
||||
Some(ws) => ws,
|
||||
_ => return,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -289,6 +289,10 @@ impl SurfaceExt for WlSubsurface {
|
|||
fn into_subsurface(self: Rc<Self>) -> Option<Rc<WlSubsurface>> {
|
||||
Some(self)
|
||||
}
|
||||
|
||||
fn accepts_kb_focus(&self) -> bool {
|
||||
self.parent.accepts_kb_focus()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
|
|
|||
|
|
@ -356,6 +356,10 @@ impl SurfaceExt for XdgSurface {
|
|||
fn extents_changed(&self) {
|
||||
self.update_extents();
|
||||
}
|
||||
|
||||
fn accepts_kb_focus(&self) -> bool {
|
||||
self.role.get() == XdgSurfaceRole::XdgToplevel
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::client::{Client, ClientError};
|
||||
use crate::cursor::KnownCursor;
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal};
|
||||
use crate::ifs::wl_seat::{ NodeSeatState, WlSeatGlobal};
|
||||
use crate::ifs::wl_surface::xdg_surface::{XdgSurface, XdgSurfaceError, XdgSurfaceExt};
|
||||
use crate::ifs::xdg_positioner::{XdgPositioned, XdgPositioner, CA};
|
||||
use crate::leaks::Tracker;
|
||||
|
|
@ -281,6 +281,10 @@ impl Node for XdgPopup {
|
|||
visitor.visit_surface(&self.xdg.surface);
|
||||
}
|
||||
|
||||
fn get_workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
self.xdg.workspace.get()
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
self.xdg.absolute_desired_extents.get()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use crate::rect::Rect;
|
|||
use crate::render::Renderer;
|
||||
use crate::tree::toplevel::{ToplevelData, ToplevelNode};
|
||||
use crate::tree::walker::NodeVisitor;
|
||||
use crate::tree::FindTreeResult;
|
||||
use crate::tree::{FindTreeResult};
|
||||
use crate::tree::{FoundNode, Node, NodeId, ToplevelNodeId, WorkspaceNode};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
|
|
@ -374,6 +374,10 @@ impl Node for XdgToplevel {
|
|||
visitor.visit_surface(&self.xdg.surface);
|
||||
}
|
||||
|
||||
fn get_workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
self.xdg.workspace.get()
|
||||
}
|
||||
|
||||
fn is_contained_in(&self, other: NodeId) -> bool {
|
||||
if let Some(parent) = self.parent_node.get() {
|
||||
if parent.id() == other {
|
||||
|
|
@ -443,10 +447,6 @@ impl ToplevelNode for XdgToplevel {
|
|||
self.parent_node.get()
|
||||
}
|
||||
|
||||
fn workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
self.xdg.workspace.get()
|
||||
}
|
||||
|
||||
fn as_node(&self) -> &dyn Node {
|
||||
self
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::client::Client;
|
||||
use crate::client::{Client};
|
||||
use crate::cursor::KnownCursor;
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, SeatId, WlSeatGlobal};
|
||||
|
|
@ -353,6 +353,10 @@ impl Node for Xwindow {
|
|||
visitor.visit_surface(&self.surface);
|
||||
}
|
||||
|
||||
fn get_workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
self.workspace.get()
|
||||
}
|
||||
|
||||
fn is_contained_in(&self, other: NodeId) -> bool {
|
||||
if let Some(parent) = self.parent_node.get() {
|
||||
if parent.id() == other {
|
||||
|
|
@ -429,10 +433,6 @@ impl ToplevelNode for Xwindow {
|
|||
self.parent_node.get()
|
||||
}
|
||||
|
||||
fn workspace(&self) -> Option<Rc<WorkspaceNode>> {
|
||||
self.workspace.get()
|
||||
}
|
||||
|
||||
fn as_node(&self) -> &dyn Node {
|
||||
self
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::client::{Client, ClientError};
|
||||
use crate::ifs::wl_seat::NodeSeatState;
|
||||
use crate::ifs::wl_seat::{NodeSeatState};
|
||||
use crate::ifs::wl_surface::{
|
||||
CommitAction, CommitContext, SurfaceExt, SurfaceRole, WlSurface, WlSurfaceError,
|
||||
};
|
||||
|
|
@ -359,10 +359,6 @@ impl Node for ZwlrLayerSurfaceV1 {
|
|||
self.surface.clone().visit(visitor);
|
||||
}
|
||||
|
||||
fn render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
renderer.render_layer_surface(self, x, y);
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
self.pos.get()
|
||||
}
|
||||
|
|
@ -376,6 +372,10 @@ impl Node for ZwlrLayerSurfaceV1 {
|
|||
self.surface.find_tree_at(x, y, tree)
|
||||
}
|
||||
|
||||
fn render(&self, renderer: &mut Renderer, x: i32, y: i32) {
|
||||
renderer.render_layer_surface(self, x, y);
|
||||
}
|
||||
|
||||
fn change_extents(self: Rc<Self>, _rect: &Rect) {
|
||||
self.compute_position();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue