1
0
Fork 0
forked from wry/wry

autocommit 2022-04-02 21:13:27 CEST

This commit is contained in:
Julian Orth 2022-04-02 21:13:27 +02:00
parent 6de9fb8303
commit 9ec1c5c995
5 changed files with 28 additions and 19 deletions

View file

@ -281,6 +281,7 @@ impl ZwlrLayerSurfaceV1 {
}
self.pos
.set(Rect::new_sized(x1, y1, width, height).unwrap());
self.surface.set_absolute_position(x1, y1);
self.client.state.tree_changed();
}
}

View file

@ -82,6 +82,7 @@ impl ZwlrLayerShellV1 {
}
}
};
log::info!("output = {:?}", output.position.get());
if req.layer > OVERLAY {
return Err(GetLayerSurfaceError::UnknownLayer(req.layer));
}

View file

@ -29,11 +29,16 @@ pub struct Renderer<'a> {
impl Renderer<'_> {
pub fn render_output(&mut self, output: &OutputNode, x: i32, y: i32) {
let opos = output.position.get();
macro_rules! render_layer {
($layer:expr) => {
for ls in $layer.iter() {
let pos = ls.position();
self.render_layer_surface(ls.deref(), pos.x1(), pos.y1());
self.render_layer_surface(
ls.deref(),
x + pos.x1() - opos.x1(),
y + pos.y1() - opos.y1(),
);
}
};
}
@ -321,7 +326,7 @@ impl Renderer<'_> {
pub fn render_layer_surface(&mut self, surface: &ZwlrLayerSurfaceV1, x: i32, y: i32) {
unsafe {
let body = surface.position();
let body = surface.position().at_point(x, y);
with_scissor(&body, || {
self.render_surface(&surface.surface, x, y);
});

View file

@ -2,7 +2,7 @@ use crate::backend::Output;
use crate::ifs::wl_output::WlOutputGlobal;
use crate::rect::Rect;
use crate::state::State;
use crate::tree::{Node, OutputNode, OutputRenderData, WorkspaceNode};
use crate::tree::{OutputNode, OutputRenderData, WorkspaceNode};
use crate::utils::asyncevent::AsyncEvent;
use crate::utils::clonecell::CloneCell;
use std::cell::{Cell, RefCell};
@ -22,10 +22,11 @@ impl OutputHandler {
}
let name = self.state.globals.name();
let global = Rc::new(WlOutputGlobal::new(name, self.output.clone()));
let x1 = self.state.root.outputs.lock().values().map(|o| o.position.get().x2()).max().unwrap_or(0);
let on = Rc::new(OutputNode {
id: self.state.node_ids.next(),
workspaces: Default::default(),
position: Cell::new(Default::default()),
position: Cell::new(Rect::new_empty(x1, 0)),
workspace: CloneCell::new(None),
seat_state: Default::default(),
global: global.clone(),
@ -51,7 +52,7 @@ impl OutputHandler {
let workspace = Rc::new(WorkspaceNode {
id: self.state.node_ids.next(),
output: CloneCell::new(on.clone()),
position: Cell::new(Default::default()),
position: Default::default(),
container: Default::default(),
stacked: Default::default(),
seat_state: Default::default(),
@ -78,8 +79,7 @@ impl OutputHandler {
if new_width != width || new_height != height {
width = new_width;
height = new_height;
on.clone()
.change_extents(&Rect::new_sized(0, 0, new_width, new_height).unwrap());
on.change_size(new_width, new_height);
}
global.update_properties();
ae.triggered().await;

View file

@ -94,6 +94,20 @@ impl OutputNode {
)
.unwrap()
}
pub fn change_size(&self, width: i32, height: i32) {
let pos = self.position.get();
let rect = Rect::new_sized(pos.x1(), pos.y1(), width, height).unwrap();
self.position.set(rect);
if let Some(c) = self.workspace.get() {
c.change_extents(&self.workspace_rect());
}
for layer in &self.layers {
for surface in layer.iter() {
surface.deref().clone().change_extents(&rect);
}
}
}
}
pub struct OutputTitle {
@ -198,16 +212,4 @@ impl Node for OutputNode {
fn into_output(self: Rc<Self>) -> Option<Rc<OutputNode>> {
Some(self)
}
fn change_extents(self: Rc<Self>, rect: &Rect) {
self.position.set(*rect);
if let Some(c) = self.workspace.get() {
c.change_extents(&self.workspace_rect());
}
for layer in &self.layers {
for surface in layer.iter() {
surface.deref().clone().change_extents(rect);
}
}
}
}