1
0
Fork 0
forked from wry/wry

autocommit 2022-04-08 23:02:38 CEST

This commit is contained in:
Julian Orth 2022-04-08 23:02:38 +02:00
parent 0bd9a70e69
commit 21e2216ce5
40 changed files with 587 additions and 255 deletions

View file

@ -1,16 +1,16 @@
use {
crate::{
client::{Client, ClientError},
video::{
dma::{DmaBuf, DmaBufPlane},
INVALID_MODIFIER,
},
globals::{Global, GlobalName},
ifs::wl_buffer::WlBuffer,
leaks::Tracker,
object::Object,
render::RenderError,
utils::buffd::{MsgParser, MsgParserError},
video::{
dma::{DmaBuf, DmaBufPlane},
INVALID_MODIFIER,
},
wire::{wl_drm::*, WlDrmId},
},
bstr::ByteSlice,

View file

@ -274,6 +274,11 @@ impl WlSeatGlobal {
}
}
pub fn close(self: &Rc<Self>) {
let kb_node = self.keyboard_node.get();
kb_node.close();
}
pub fn move_focus(self: &Rc<Self>, direction: Direction) {
let kb_node = self.keyboard_node.get();
kb_node.move_focus(self, direction);

View file

@ -81,16 +81,32 @@ impl NodeSeatState {
}
pub fn release_kb_focus(&self) {
self.release_kb_focus2(true);
}
fn release_kb_focus2(&self, focus_last: bool) {
while let Some((_, seat)) = self.kb_foci.pop() {
seat.ungrab_kb();
seat.keyboard_node.set(seat.state.root.clone());
if let Some(tl) = seat.toplevel_focus_history.last() {
seat.focus_node(tl.focus_surface(seat.id));
if focus_last {
if let Some(tl) = seat.toplevel_focus_history.last() {
seat.focus_node(tl.focus_surface(seat.id));
}
}
}
}
pub fn for_each_kb_focus<F: FnMut(Rc<WlSeatGlobal>)>(&self, mut f: F) {
self.kb_foci.iter().for_each(|(_, s)| f(s));
}
pub fn destroy_node(&self, node: &dyn Node) {
self.destroy_node2(node, true);
}
fn destroy_node2(&self, node: &dyn Node, focus_last: bool) {
// NOTE: Also called by set_visible(false)
while let Some((_, seat)) = self.grabs.pop() {
seat.pointer_owner.revert_to_default(&seat);
}
@ -109,7 +125,16 @@ impl NodeSeatState {
}
seat.state.tree_changed();
}
self.release_kb_focus();
self.release_kb_focus2(focus_last);
}
pub fn set_visible(&self, node: &dyn Node, visible: bool) {
if !visible {
if !self.kb_foci.is_empty() {
node.active_changed(false);
}
self.destroy_node2(node, false);
}
}
}

View file

@ -84,6 +84,7 @@ pub struct WlSurface {
pub id: WlSurfaceId,
pub node_id: SurfaceNodeId,
pub client: Rc<Client>,
visible: Cell<bool>,
role: Cell<SurfaceRole>,
pending: PendingState,
input_region: Cell<Option<Rc<Region>>>,
@ -199,6 +200,7 @@ impl WlSurface {
id,
node_id: client.state.node_ids.next(),
client: client.clone(),
visible: Cell::new(false),
role: Cell::new(SurfaceRole::None),
pending: Default::default(),
input_region: Cell::new(None),
@ -624,6 +626,27 @@ impl Node for WlSurface {
self.node_id.into()
}
fn close(&self) {
if let Some(tl) = self.toplevel.get() {
tl.close();
}
}
fn visible(&self) -> bool {
self.visible.get()
}
fn set_visible(&self, visible: bool) {
self.visible.set(visible);
let children = self.children.borrow_mut();
if let Some(children) = children.deref() {
for child in children.subsurfaces.values() {
child.surface.set_visible(visible);
}
}
self.seat_state.set_visible(self, visible);
}
fn seat_state(&self) -> &NodeSeatState {
&self.seat_state
}

View file

@ -288,6 +288,15 @@ impl Node for XdgPopup {
visitor.visit_surface(&self.xdg.surface);
}
fn visible(&self) -> bool {
self.xdg.surface.visible.get()
}
fn set_visible(&self, visible: bool) {
self.xdg.surface.set_visible(visible);
self.xdg.seat_state.set_visible(self, visible);
}
fn get_workspace(&self) -> Option<Rc<WorkspaceNode>> {
self.xdg.workspace.get()
}

View file

@ -143,6 +143,12 @@ impl XdgToplevel {
self.send_configure(width, height)
}
fn send_close(&self) {
self.xdg.surface.client.event(Close {
self_id: self.id,
});
}
fn send_configure(&self, width: i32, height: i32) {
let states: Vec<_> = self.states.borrow().iter().copied().collect();
self.xdg.surface.client.event(Configure {
@ -384,6 +390,15 @@ impl Node for XdgToplevel {
visitor.visit_surface(&self.xdg.surface);
}
fn visible(&self) -> bool {
self.xdg.surface.visible.get()
}
fn set_visible(&self, visible: bool) {
self.xdg.surface.set_visible(visible);
self.xdg.seat_state.set_visible(self, visible);
}
fn get_workspace(&self) -> Option<Rc<WorkspaceNode>> {
self.xdg.workspace.get()
}
@ -508,6 +523,10 @@ impl ToplevelNode for XdgToplevel {
self.map_floating(&ws);
}
}
fn close(&self) {
self.send_close();
}
}
impl XdgSurfaceExt for XdgToplevel {
@ -546,12 +565,12 @@ impl XdgSurfaceExt for XdgToplevel {
}
}
}
{
let seats = surface.client.state.globals.lock_seats();
for seat in seats.values() {
seat.focus_toplevel(self.clone());
}
}
// {
// let seats = surface.client.state.globals.lock_seats();
// for seat in seats.values() {
// seat.focus_toplevel(self.clone());
// }
// }
surface.client.state.tree_changed();
}
}

View file

@ -1,4 +1,3 @@
use std::ops::Not;
use {
crate::{
client::Client,
@ -27,7 +26,7 @@ use {
jay_config::Direction,
std::{
cell::{Cell, RefCell},
ops::{Deref},
ops::{Deref, Not},
rc::Rc,
},
thiserror::Error,
@ -142,7 +141,6 @@ pub struct Xwindow {
pub events: Rc<AsyncQueue<XWaylandEvent>>,
pub workspace: CloneCell<Option<Rc<WorkspaceNode>>>,
pub display_link: RefCell<Option<LinkedNode<Rc<dyn Node>>>>,
pub display_xlink: RefCell<Option<LinkedNode<Rc<Xwindow>>>>,
pub toplevel_data: ToplevelData,
}
@ -219,7 +217,6 @@ impl Xwindow {
events: events.clone(),
workspace: Default::default(),
display_link: Default::default(),
display_xlink: Default::default(),
toplevel_data: Default::default(),
}
}
@ -279,8 +276,6 @@ impl Xwindow {
Change::Map if self.data.info.override_redirect.get() => {
*self.display_link.borrow_mut() =
Some(self.data.state.root.stacked.add_last(self.clone()));
*self.display_xlink.borrow_mut() =
Some(self.data.state.root.xstacked.add_last(self.clone()));
self.data.state.tree_changed();
}
Change::Map if self.data.info.wants_floating.get() => {
@ -334,13 +329,21 @@ impl Node for Xwindow {
self.id.into()
}
fn visible(&self) -> bool {
self.surface.visible.get()
}
fn set_visible(&self, visible: bool) {
self.surface.set_visible(visible);
self.seat_state.set_visible(self, visible);
}
fn seat_state(&self) -> &NodeSeatState {
&self.seat_state
}
fn destroy_node(&self, _detach: bool) {
self.toplevel_data.clear();
self.display_xlink.borrow_mut().take();
self.display_link.borrow_mut().take();
self.workspace.take();
self.focus_history.clear();
@ -449,7 +452,8 @@ impl ToplevelNode for Xwindow {
}
fn accepts_keyboard_focus(&self) -> bool {
self.data.info.never_focus.get().not() && self.data.info.input_model.get() != XInputModel::None
self.data.info.never_focus.get().not()
&& self.data.info.input_model.get() != XInputModel::None
}
fn default_surface(&self) -> Rc<WlSurface> {
@ -482,6 +486,10 @@ impl ToplevelNode for Xwindow {
.map_floating(self.clone(), extents.width(), extents.height(), &ws);
}
}
fn close(&self) {
self.events.push(XWaylandEvent::Close(self.data.clone()));
}
}
#[derive(Debug, Error)]

View file

@ -370,6 +370,10 @@ impl Node for ZwlrLayerSurfaceV1 {
self.surface.clone().visit(visitor);
}
fn visible(&self) -> bool {
true
}
fn absolute_position(&self) -> Rect {
self.pos.get()
}

View file

@ -1,10 +1,6 @@
use {
crate::{
client::ClientError,
video::{
dma::{DmaBuf, DmaBufPlane},
INVALID_MODIFIER,
},
ifs::{wl_buffer::WlBuffer, zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1},
leaks::Tracker,
object::Object,
@ -13,6 +9,10 @@ use {
buffd::{MsgParser, MsgParserError},
errorfmt::ErrorFmt,
},
video::{
dma::{DmaBuf, DmaBufPlane},
INVALID_MODIFIER,
},
wire::{zwp_linux_buffer_params_v1::*, WlBufferId, ZwpLinuxBufferParamsV1Id},
},
ahash::AHashMap,

View file

@ -1,12 +1,12 @@
use {
crate::{
client::{Client, ClientError},
video::INVALID_MODIFIER,
globals::{Global, GlobalName},
ifs::zwp_linux_buffer_params_v1::ZwpLinuxBufferParamsV1,
leaks::Tracker,
object::Object,
utils::buffd::{MsgParser, MsgParserError},
video::INVALID_MODIFIER,
wire::{zwp_linux_dmabuf_v1::*, ZwpLinuxDmabufV1Id},
},
std::rc::Rc,