autocommit 2022-04-05 18:28:42 CEST
This commit is contained in:
parent
1f05ea431e
commit
a3e9f21fc5
29 changed files with 568 additions and 225 deletions
|
|
@ -1,11 +1,11 @@
|
|||
use crate::backend;
|
||||
use crate::backend::Connector;
|
||||
use crate::client::{Client, ClientError, ClientId};
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::zxdg_output_v1::ZxdgOutputV1;
|
||||
use crate::leaks::Tracker;
|
||||
use crate::object::Object;
|
||||
use crate::rect::Rect;
|
||||
use crate::state::ConnectorData;
|
||||
use crate::tree::OutputNode;
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
|
|
@ -53,21 +53,38 @@ const MODE_PREFERRED: u32 = 2;
|
|||
|
||||
pub struct WlOutputGlobal {
|
||||
name: GlobalName,
|
||||
pub connector: Rc<dyn Connector>,
|
||||
pub connector: Rc<ConnectorData>,
|
||||
pub pos: Cell<Rect>,
|
||||
pub manufacturer: String,
|
||||
pub display: String,
|
||||
pub mode: Cell<backend::Mode>,
|
||||
pub node: CloneCell<Option<Rc<OutputNode>>>,
|
||||
pub width_mm: i32,
|
||||
pub height_mm: i32,
|
||||
pub bindings: RefCell<AHashMap<ClientId, AHashMap<WlOutputId, Rc<WlOutput>>>>,
|
||||
}
|
||||
|
||||
impl WlOutputGlobal {
|
||||
pub fn new(name: GlobalName, connector: Rc<dyn Connector>, x1: i32) -> Self {
|
||||
pub fn new(
|
||||
name: GlobalName,
|
||||
connector: &Rc<ConnectorData>,
|
||||
x1: i32,
|
||||
mode: &backend::Mode,
|
||||
manufacturer: &str,
|
||||
product: &str,
|
||||
width_mm: i32,
|
||||
height_mm: i32,
|
||||
) -> Self {
|
||||
Self {
|
||||
name,
|
||||
connector: connector.clone(),
|
||||
pos: Cell::new(Rect::new_empty(x1, 0)),
|
||||
mode: Default::default(),
|
||||
pos: Cell::new(Rect::new_sized(x1, 0, mode.width, mode.height).unwrap()),
|
||||
manufacturer: manufacturer.to_string(),
|
||||
display: product.to_string(),
|
||||
mode: Cell::new(*mode),
|
||||
node: Default::default(),
|
||||
width_mm,
|
||||
height_mm,
|
||||
bindings: Default::default(),
|
||||
}
|
||||
}
|
||||
|
|
@ -163,24 +180,25 @@ impl WlOutput {
|
|||
self_id: self.id,
|
||||
x: pos.x1(),
|
||||
y: pos.y1(),
|
||||
physical_width: pos.width(),
|
||||
physical_height: pos.height(),
|
||||
physical_width: self.global.width_mm,
|
||||
physical_height: self.global.height_mm,
|
||||
subpixel: SP_UNKNOWN,
|
||||
make: "jay",
|
||||
model: "jay",
|
||||
make: &self.global.manufacturer,
|
||||
model: &self.global.display,
|
||||
transform: TF_NORMAL,
|
||||
};
|
||||
self.client.event(event);
|
||||
}
|
||||
|
||||
fn send_mode(&self) {
|
||||
let mode = self.global.mode.get();
|
||||
let pos = self.global.pos.get();
|
||||
let event = Mode {
|
||||
self_id: self.id,
|
||||
flags: MODE_CURRENT,
|
||||
width: pos.width(),
|
||||
height: pos.height(),
|
||||
refresh: 60_000_000,
|
||||
width: mode.width,
|
||||
height: mode.height,
|
||||
refresh: mode.refresh_rate_millihz as _,
|
||||
};
|
||||
self.client.event(event);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use crate::client::{Client, ClientError};
|
||||
use crate::leaks::Tracker;
|
||||
use crate::object::Object;
|
||||
use crate::rect::{Rect, Region, RegionBuilder};
|
||||
use crate::utils::buffd::MsgParser;
|
||||
use crate::utils::buffd::MsgParserError;
|
||||
use crate::wire::wl_region::*;
|
||||
|
|
@ -8,7 +9,6 @@ use crate::wire::WlRegionId;
|
|||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use thiserror::Error;
|
||||
use crate::rect::{Rect, Region, RegionBuilder};
|
||||
|
||||
pub struct WlRegion {
|
||||
id: WlRegionId,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::backend::{InputEvent, KeyState, OutputId, ScrollAxis};
|
||||
use crate::backend::{ConnectorId, InputEvent, KeyState, ScrollAxis};
|
||||
use crate::client::{Client, ClientId};
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::ipc;
|
||||
|
|
@ -113,19 +113,28 @@ impl WlSeatGlobal {
|
|||
pub fn event(self: &Rc<Self>, event: InputEvent) {
|
||||
match event {
|
||||
InputEvent::Key(k, s) => self.key_event(k, s),
|
||||
InputEvent::OutputPosition(o, x, y) => self.output_position_event(o, x, y),
|
||||
InputEvent::ConnectorPosition(o, x, y) => self.connector_position_event(o, x, y),
|
||||
InputEvent::Motion(dx, dy) => self.motion_event(dx, dy),
|
||||
InputEvent::Button(b, s) => self.pointer_owner.button(self, b, s),
|
||||
InputEvent::Scroll(d, a) => self.pointer_owner.scroll(self, d, a),
|
||||
}
|
||||
}
|
||||
|
||||
fn output_position_event(self: &Rc<Self>, output: OutputId, mut x: Fixed, mut y: Fixed) {
|
||||
let output = match self.state.outputs.get(&output) {
|
||||
fn connector_position_event(
|
||||
self: &Rc<Self>,
|
||||
connector: ConnectorId,
|
||||
mut x: Fixed,
|
||||
mut y: Fixed,
|
||||
) {
|
||||
let output = match self.state.connectors.get(&connector) {
|
||||
Some(o) => o,
|
||||
_ => return,
|
||||
};
|
||||
let pos = output.position();
|
||||
let node = match output.node.get() {
|
||||
Some(n) => n,
|
||||
_ => return,
|
||||
};
|
||||
let pos = node.global.pos.get();
|
||||
x += Fixed::from_int(pos.x1());
|
||||
y += Fixed::from_int(pos.y1());
|
||||
self.set_new_position(x, y);
|
||||
|
|
|
|||
|
|
@ -75,11 +75,13 @@ impl ZwlrLayerShellV1 {
|
|||
break 'get_output output;
|
||||
}
|
||||
}
|
||||
let outputs = self.client.state.outputs.lock();
|
||||
match outputs.values().next() {
|
||||
Some(ou) => ou.node.get().unwrap(),
|
||||
_ => return Err(GetLayerSurfaceError::NoOutputs),
|
||||
let outputs = self.client.state.connectors.lock();
|
||||
for output in outputs.values() {
|
||||
if let Some(node) = output.node.get() {
|
||||
break 'get_output node;
|
||||
}
|
||||
}
|
||||
return Err(GetLayerSurfaceError::NoOutputs);
|
||||
}
|
||||
};
|
||||
log::info!("output = {:?}", output.global.pos.get());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue