autocommit 2022-02-04 00:45:22 CET
This commit is contained in:
parent
89b8396932
commit
bb1639a2ae
15 changed files with 196 additions and 77 deletions
25
src/bugs.rs
Normal file
25
src/bugs.rs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
use ahash::AHashMap;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
static BUGS: Lazy<AHashMap<&'static str, Bugs>> = Lazy::new(|| {
|
||||
let mut map = AHashMap::new();
|
||||
map.insert(
|
||||
"chromium",
|
||||
Bugs {
|
||||
respect_min_max_size: true,
|
||||
},
|
||||
);
|
||||
map
|
||||
});
|
||||
|
||||
pub fn get(app_id: &str) -> &'static Bugs {
|
||||
BUGS.get(app_id).unwrap_or(&NONE)
|
||||
}
|
||||
|
||||
pub static NONE: Bugs = Bugs {
|
||||
respect_min_max_size: false,
|
||||
};
|
||||
|
||||
pub struct Bugs {
|
||||
pub respect_min_max_size: bool,
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
use crate::format::ARGB8888;
|
||||
use crate::rect::Rect;
|
||||
use crate::render::{RenderContext, Renderer, Texture};
|
||||
use crate::{ErrorFmt, NumCell, RenderError};
|
||||
|
|
@ -10,12 +11,11 @@ use std::convert::TryInto;
|
|||
use std::fmt::{Debug, Formatter};
|
||||
use std::fs::File;
|
||||
use std::io::{BufRead, BufReader, Seek, SeekFrom};
|
||||
use std::mem::MaybeUninit;
|
||||
use std::rc::Rc;
|
||||
use std::{env, io, slice, str};
|
||||
use std::mem::MaybeUninit;
|
||||
use thiserror::Error;
|
||||
use uapi::c;
|
||||
use crate::format::ARGB8888;
|
||||
|
||||
const XCURSOR_MAGIC: u32 = 0x72756358;
|
||||
const XCURSOR_IMAGE_TYPE: u32 = 0xfffd0002;
|
||||
|
|
@ -30,8 +30,8 @@ pub trait Cursor {
|
|||
fn set_position(&self, x: i32, y: i32);
|
||||
fn render(&self, renderer: &mut Renderer, x: i32, y: i32);
|
||||
fn extents(&self) -> Rect;
|
||||
fn handle_unset(&self) { }
|
||||
fn tick(&self) { }
|
||||
fn handle_unset(&self) {}
|
||||
fn tick(&self) {}
|
||||
}
|
||||
|
||||
pub struct ServerCursors {
|
||||
|
|
@ -59,9 +59,7 @@ impl ServerCursors {
|
|||
pub fn load(ctx: &Rc<RenderContext>) -> Result<Self, CursorError> {
|
||||
let paths = find_cursor_paths();
|
||||
log::debug!("Trying to load cursors from paths {:?}", paths);
|
||||
let load = |name: &str| {
|
||||
ServerCursorTemplate::load(name, None, 16, &paths, ctx)
|
||||
};
|
||||
let load = |name: &str| ServerCursorTemplate::load(name, None, 16, &paths, ctx);
|
||||
Ok(Self {
|
||||
default: load("left_ptr")?,
|
||||
// default: load("left_ptr_watch")?,
|
||||
|
|
@ -100,14 +98,24 @@ impl ServerCursorTemplate {
|
|||
Ok(c) => {
|
||||
if c.len() == 1 {
|
||||
let c = &c[0];
|
||||
let cursor = CursorImage::from_bytes(ctx, &c.pixels, 0, c.width, c.height, c.xhot, c.yhot)?;
|
||||
let cursor = CursorImage::from_bytes(
|
||||
ctx, &c.pixels, 0, c.width, c.height, c.xhot, c.yhot,
|
||||
)?;
|
||||
Ok(ServerCursorTemplate {
|
||||
var: ServerCursorTemplateVariant::Static(Rc::new(cursor)),
|
||||
})
|
||||
} else {
|
||||
let mut images = vec!();
|
||||
let mut images = vec![];
|
||||
for c in c {
|
||||
let img = CursorImage::from_bytes(ctx, &c.pixels, c.delay as _, c.width, c.height, c.xhot, c.yhot)?;
|
||||
let img = CursorImage::from_bytes(
|
||||
ctx,
|
||||
&c.pixels,
|
||||
c.delay as _,
|
||||
c.width,
|
||||
c.height,
|
||||
c.xhot,
|
||||
c.yhot,
|
||||
)?;
|
||||
images.push(img);
|
||||
}
|
||||
Ok(ServerCursorTemplate {
|
||||
|
|
@ -128,14 +136,12 @@ impl ServerCursorTemplate {
|
|||
|
||||
pub fn instantiate(&self) -> Rc<dyn Cursor> {
|
||||
match &self.var {
|
||||
ServerCursorTemplateVariant::Static(s) => {
|
||||
Rc::new(StaticCursor {
|
||||
x: Cell::new(0),
|
||||
y: Cell::new(0),
|
||||
extents: Cell::new(s.extents),
|
||||
image: s.clone(),
|
||||
})
|
||||
},
|
||||
ServerCursorTemplateVariant::Static(s) => Rc::new(StaticCursor {
|
||||
x: Cell::new(0),
|
||||
y: Cell::new(0),
|
||||
extents: Cell::new(s.extents),
|
||||
image: s.clone(),
|
||||
}),
|
||||
ServerCursorTemplateVariant::Animated(a) => {
|
||||
let mut start = c::timespec {
|
||||
tv_sec: 0,
|
||||
|
|
@ -165,7 +171,15 @@ struct CursorImage {
|
|||
}
|
||||
|
||||
impl CursorImage {
|
||||
fn from_bytes(ctx: &Rc<RenderContext>, data: &[Cell<u8>], delay_ms: u64, width: i32, height: i32, xhot: i32, yhot: i32) -> Result<Self, CursorError> {
|
||||
fn from_bytes(
|
||||
ctx: &Rc<RenderContext>,
|
||||
data: &[Cell<u8>],
|
||||
delay_ms: u64,
|
||||
width: i32,
|
||||
height: i32,
|
||||
xhot: i32,
|
||||
yhot: i32,
|
||||
) -> Result<Self, CursorError> {
|
||||
Ok(Self {
|
||||
extents: Rect::new_sized(-xhot, -yhot, width, height).unwrap(),
|
||||
xhot,
|
||||
|
|
@ -467,7 +481,10 @@ fn parser_cursor_file<R: BufRead + Seek>(
|
|||
unsafe {
|
||||
image.pixels.reserve_exact(num_bytes as usize);
|
||||
image.pixels.set_len(num_bytes as usize);
|
||||
r.read_exact(slice::from_raw_parts_mut(image.pixels.as_mut_ptr() as _, num_bytes))?;
|
||||
r.read_exact(slice::from_raw_parts_mut(
|
||||
image.pixels.as_mut_ptr() as _,
|
||||
num_bytes,
|
||||
))?;
|
||||
}
|
||||
images.push(image);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ pub mod wl_touch;
|
|||
|
||||
use crate::backend::{Seat, SeatId};
|
||||
use crate::client::{Client, ClientId, DynEventFormatter};
|
||||
use crate::cursor::{Cursor, KnownCursor};
|
||||
use crate::fixed::Fixed;
|
||||
use crate::globals::{Global, GlobalName};
|
||||
use crate::ifs::wl_data_device::{WlDataDevice, WlDataDeviceId};
|
||||
|
|
@ -30,7 +31,6 @@ use std::io::Write;
|
|||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use uapi::{c, OwnedFd};
|
||||
use crate::cursor::{Cursor, KnownCursor};
|
||||
|
||||
id!(WlSeatId);
|
||||
|
||||
|
|
@ -142,12 +142,8 @@ impl WlSeatGlobal {
|
|||
if grabber.is_some() {
|
||||
return None;
|
||||
}
|
||||
*grabber = Some(PointerGrabber {
|
||||
node,
|
||||
});
|
||||
Some(PointerGrab {
|
||||
seat: self.clone(),
|
||||
})
|
||||
*grabber = Some(PointerGrabber { node });
|
||||
Some(PointerGrab { seat: self.clone() })
|
||||
}
|
||||
|
||||
pub fn set_known_cursor(&self, cursor: KnownCursor) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::DynEventFormatter;
|
||||
use crate::cursor::Cursor;
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_seat::WlSeatObj;
|
||||
use crate::ifs::wl_surface::WlSurfaceId;
|
||||
|
|
@ -8,7 +9,6 @@ use crate::object::{Interface, Object, ObjectId};
|
|||
use crate::utils::buffd::MsgParser;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use crate::cursor::Cursor;
|
||||
|
||||
const SET_CURSOR: u32 = 0;
|
||||
const RELEASE: u32 = 1;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use crate::cursor::Cursor;
|
||||
use crate::ifs::wl_seat::WlSeatGlobal;
|
||||
use crate::ifs::wl_surface::WlSurface;
|
||||
use crate::rect::Rect;
|
||||
use crate::render::Renderer;
|
||||
use std::cell::Cell;
|
||||
use std::rc::Rc;
|
||||
use crate::cursor::Cursor;
|
||||
|
||||
pub struct CursorSurface {
|
||||
seat: Rc<WlSeatGlobal>,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
mod types;
|
||||
|
||||
use crate::client::{ClientId, DynEventFormatter};
|
||||
use crate::cursor::KnownCursor;
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal};
|
||||
use crate::ifs::wl_surface::xdg_surface::{XdgSurface, XdgSurfaceError, XdgSurfaceExt};
|
||||
|
|
@ -15,7 +16,6 @@ use crate::utils::linkedlist::LinkedNode;
|
|||
use std::cell::{Cell, RefCell};
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use crate::cursor::KnownCursor;
|
||||
|
||||
const DESTROY: u32 = 0;
|
||||
const GRAB: u32 = 1;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
mod types;
|
||||
|
||||
use crate::backend::{SeatId};
|
||||
use crate::backend::SeatId;
|
||||
use crate::bugs::Bugs;
|
||||
use crate::client::{ClientId, DynEventFormatter};
|
||||
use crate::cursor::KnownCursor;
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal};
|
||||
use crate::ifs::wl_surface::xdg_surface::{XdgSurface, XdgSurfaceError, XdgSurfaceExt};
|
||||
|
|
@ -14,14 +16,14 @@ use crate::utils::buffd::MsgParser;
|
|||
use crate::utils::clonecell::CloneCell;
|
||||
use crate::utils::linkedlist::LinkedNode;
|
||||
use crate::utils::smallmap::SmallMap;
|
||||
use crate::NumCell;
|
||||
use crate::{bugs, NumCell};
|
||||
use ahash::{AHashMap, AHashSet};
|
||||
use bstr::ByteSlice;
|
||||
use num_derive::FromPrimitive;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
pub use types::*;
|
||||
use crate::cursor::KnownCursor;
|
||||
|
||||
const DESTROY: u32 = 0;
|
||||
const SET_PARENT: u32 = 1;
|
||||
|
|
@ -91,6 +93,11 @@ pub struct XdgToplevel {
|
|||
pub toplevel_history: SmallMap<SeatId, LinkedNode<Rc<XdgToplevel>>, 1>,
|
||||
active_surfaces: NumCell<u32>,
|
||||
pub decoration: Cell<Decoration>,
|
||||
bugs: Cell<&'static Bugs>,
|
||||
min_width: Cell<Option<i32>>,
|
||||
min_height: Cell<Option<i32>>,
|
||||
max_width: Cell<Option<i32>>,
|
||||
max_height: Cell<Option<i32>>,
|
||||
}
|
||||
|
||||
impl XdgToplevel {
|
||||
|
|
@ -111,6 +118,11 @@ impl XdgToplevel {
|
|||
toplevel_history: Default::default(),
|
||||
active_surfaces: Default::default(),
|
||||
decoration: Cell::new(Decoration::Server),
|
||||
bugs: Cell::new(&bugs::NONE),
|
||||
min_width: Cell::new(None),
|
||||
min_height: Cell::new(None),
|
||||
max_width: Cell::new(None),
|
||||
max_height: Cell::new(None),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -127,7 +139,7 @@ impl XdgToplevel {
|
|||
self.xdg
|
||||
.surface
|
||||
.client
|
||||
.event(self.configure(rect.width(), rect.height()));
|
||||
.event(self.configure_checked(rect.width(), rect.height()));
|
||||
self.xdg.send_configure();
|
||||
}
|
||||
}
|
||||
|
|
@ -139,7 +151,27 @@ impl XdgToplevel {
|
|||
false
|
||||
}
|
||||
|
||||
pub fn configure(self: &Rc<Self>, width: i32, height: i32) -> DynEventFormatter {
|
||||
fn configure_checked(self: &Rc<Self>, mut width: i32, mut height: i32) -> DynEventFormatter {
|
||||
width = width.max(1);
|
||||
height = height.max(1);
|
||||
if self.bugs.get().respect_min_max_size {
|
||||
if let Some(min) = self.min_width.get() {
|
||||
width = width.max(min);
|
||||
}
|
||||
if let Some(min) = self.min_height.get() {
|
||||
height = height.max(min);
|
||||
}
|
||||
if let Some(max) = self.max_width.get() {
|
||||
width = width.min(max);
|
||||
}
|
||||
if let Some(max) = self.max_height.get() {
|
||||
height = height.min(max);
|
||||
}
|
||||
}
|
||||
self.configure(width, height)
|
||||
}
|
||||
|
||||
fn configure(self: &Rc<Self>, width: i32, height: i32) -> DynEventFormatter {
|
||||
Box::new(Configure {
|
||||
obj: self.clone(),
|
||||
width,
|
||||
|
|
@ -175,7 +207,10 @@ impl XdgToplevel {
|
|||
}
|
||||
|
||||
fn set_app_id(&self, parser: MsgParser<'_, '_>) -> Result<(), SetAppIdError> {
|
||||
let _req: SetAppId = self.xdg.surface.client.parse(self, parser)?;
|
||||
let req: SetAppId = self.xdg.surface.client.parse(self, parser)?;
|
||||
if let Ok(s) = req.app_id.to_str() {
|
||||
self.bugs.set(bugs::get(s));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -201,12 +236,38 @@ impl XdgToplevel {
|
|||
}
|
||||
|
||||
fn set_max_size(&self, parser: MsgParser<'_, '_>) -> Result<(), SetMaxSizeError> {
|
||||
let _req: SetMaxSize = self.xdg.surface.client.parse(self, parser)?;
|
||||
let req: SetMaxSize = self.xdg.surface.client.parse(self, parser)?;
|
||||
if req.height < 0 || req.width < 0 {
|
||||
return Err(SetMaxSizeError::NonNegative);
|
||||
}
|
||||
self.max_width.set(if req.width == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(req.width)
|
||||
});
|
||||
self.max_height.set(if req.height == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(req.height)
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_min_size(&self, parser: MsgParser<'_, '_>) -> Result<(), SetMinSizeError> {
|
||||
let _req: SetMinSize = self.xdg.surface.client.parse(self, parser)?;
|
||||
let req: SetMinSize = self.xdg.surface.client.parse(self, parser)?;
|
||||
if req.height < 0 || req.width < 0 {
|
||||
return Err(SetMinSizeError::NonNegative);
|
||||
}
|
||||
self.min_width.set(if req.width == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(req.width)
|
||||
});
|
||||
self.min_height.set(if req.height == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(req.height)
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -416,7 +477,7 @@ impl Node for XdgToplevel {
|
|||
self.xdg
|
||||
.surface
|
||||
.client
|
||||
.event(self.configure(nw.max(1), nh.max(1)));
|
||||
.event(self.configure_checked(nw, nh));
|
||||
self.xdg.send_configure();
|
||||
self.xdg.surface.client.flush();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,6 +117,8 @@ pub enum SetMaxSizeError {
|
|||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("width/height must be non-negative")]
|
||||
NonNegative,
|
||||
}
|
||||
efrom!(SetMaxSizeError, ParseFailed, MsgParserError);
|
||||
efrom!(SetMaxSizeError, ClientError);
|
||||
|
|
@ -127,6 +129,8 @@ pub enum SetMinSizeError {
|
|||
ParseFailed(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("width/height must be non-negative")]
|
||||
NonNegative,
|
||||
}
|
||||
efrom!(SetMinSizeError, ParseFailed, MsgParserError);
|
||||
efrom!(SetMinSizeError, ClientError);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,4 @@
|
|||
#![feature(
|
||||
c_variadic,
|
||||
thread_local,
|
||||
label_break_value,
|
||||
)]
|
||||
#![feature(c_variadic, thread_local, label_break_value)]
|
||||
#![allow(
|
||||
clippy::len_zero,
|
||||
clippy::needless_lifetimes,
|
||||
|
|
@ -49,6 +45,7 @@ mod acceptor;
|
|||
mod async_engine;
|
||||
mod backend;
|
||||
mod backends;
|
||||
mod bugs;
|
||||
mod client;
|
||||
mod clientmem;
|
||||
mod cursor;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use crate::format::Format;
|
||||
use crate::ifs::wl_buffer::WlBuffer;
|
||||
use crate::ifs::wl_surface::xdg_surface::XdgSurface;
|
||||
use crate::ifs::wl_surface::WlSurface;
|
||||
|
|
@ -11,6 +12,7 @@ use crate::render::gl::sys::{
|
|||
};
|
||||
use crate::render::renderer::context::RenderContext;
|
||||
use crate::render::sys::{glDisable, glEnable, GL_BLEND};
|
||||
use crate::render::Texture;
|
||||
use crate::tree::{
|
||||
ContainerFocus, ContainerNode, ContainerSplit, FloatNode, OutputNode, WorkspaceNode,
|
||||
CONTAINER_BORDER, CONTAINER_TITLE_HEIGHT,
|
||||
|
|
@ -18,8 +20,6 @@ use crate::tree::{
|
|||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
use std::slice;
|
||||
use crate::format::Format;
|
||||
use crate::render::Texture;
|
||||
|
||||
const NON_COLOR: (f32, f32, f32) = (0.2, 0.2, 0.2);
|
||||
const CHILD_COLOR: (f32, f32, f32) = (0.8, 0.8, 0.8);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use crate::async_engine::{AsyncEngine, SpawnedFuture};
|
||||
use crate::backend::{BackendEvent, OutputId, OutputIds, SeatId, SeatIds};
|
||||
use crate::client::{Client, Clients};
|
||||
use crate::cursor::ServerCursors;
|
||||
use crate::event_loop::EventLoop;
|
||||
use crate::globals::{AddGlobal, Globals};
|
||||
use crate::ifs::wl_output::WlOutputGlobal;
|
||||
|
|
@ -18,7 +19,6 @@ use crate::{ErrorFmt, Wheel};
|
|||
use ahash::AHashMap;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::rc::Rc;
|
||||
use crate::cursor::ServerCursors;
|
||||
|
||||
pub struct State {
|
||||
pub eng: Rc<AsyncEngine>,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
use crate::ifs::wl_seat::{BTN_LEFT, NodeSeatState, PointerGrab, WlSeatGlobal};
|
||||
use crate::backend::{KeyState, SeatId};
|
||||
use crate::cursor::KnownCursor;
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, PointerGrab, WlSeatGlobal, BTN_LEFT};
|
||||
use crate::rect::Rect;
|
||||
use crate::render::Renderer;
|
||||
use crate::tree::{FindTreeResult, FoundNode, Node, NodeId, WorkspaceNode};
|
||||
|
|
@ -10,9 +13,6 @@ use std::cell::{Cell, RefCell};
|
|||
use std::mem;
|
||||
use std::ops::DerefMut;
|
||||
use std::rc::Rc;
|
||||
use crate::backend::{KeyState, SeatId};
|
||||
use crate::cursor::KnownCursor;
|
||||
use crate::fixed::Fixed;
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
|
|
@ -211,7 +211,12 @@ impl ContainerNode {
|
|||
ContainerSplit::Horizontal => {
|
||||
(pos, CONTAINER_TITLE_HEIGHT, body_size, other_content_size)
|
||||
}
|
||||
_ => (0, pos + CONTAINER_TITLE_HEIGHT, other_content_size, body_size),
|
||||
_ => (
|
||||
0,
|
||||
pos + CONTAINER_TITLE_HEIGHT,
|
||||
other_content_size,
|
||||
body_size,
|
||||
),
|
||||
};
|
||||
let body = Rect::new_sized(x1, y1, width, height).unwrap();
|
||||
child.body.set(body);
|
||||
|
|
@ -301,27 +306,41 @@ impl ContainerNode {
|
|||
SeatOpKind::Move => {
|
||||
// todo
|
||||
}
|
||||
SeatOpKind::Resize { dist_left, dist_right } => {
|
||||
SeatOpKind::Resize {
|
||||
dist_left,
|
||||
dist_right,
|
||||
} => {
|
||||
let prev = op.child.prev();
|
||||
let prev_body = prev.body.get();
|
||||
let child_body = op.child.body.get();
|
||||
match self.split.get() {
|
||||
let (prev_factor, child_factor) = match self.split.get() {
|
||||
ContainerSplit::Horizontal => {
|
||||
let cw = self.content_width.get();
|
||||
if prev_body.x1() + dist_left > x || x + dist_right > child_body.x2() {
|
||||
return;
|
||||
}
|
||||
let prev_factor = (x - prev_body.x1() - dist_left) as f64 / cw as f64;
|
||||
let child_factor = (child_body.x2() - x - dist_right) as f64 / cw as f64;
|
||||
let sum_factors = 1.0 - prev.factor.get() - op.child.factor.get() + prev_factor + child_factor;
|
||||
prev.factor.set(prev_factor);
|
||||
op.child.factor.set(child_factor);
|
||||
self.apply_factors(sum_factors);
|
||||
let child_factor =
|
||||
(child_body.x2() - x - dist_right) as f64 / cw as f64;
|
||||
(prev_factor, child_factor)
|
||||
}
|
||||
ContainerSplit::Vertical => {
|
||||
// todo
|
||||
let ch = self.content_height.get();
|
||||
if prev_body.y1() + dist_left > y || y + dist_right > child_body.y2() {
|
||||
return;
|
||||
}
|
||||
let prev_factor = (y - prev_body.y1() - dist_left) as f64 / ch as f64;
|
||||
let child_factor =
|
||||
(child_body.y2() - y - dist_right) as f64 / ch as f64;
|
||||
(prev_factor, child_factor)
|
||||
}
|
||||
}
|
||||
};
|
||||
let sum_factors = 1.0 - prev.factor.get() - op.child.factor.get()
|
||||
+ prev_factor
|
||||
+ child_factor;
|
||||
prev.factor.set(prev_factor);
|
||||
op.child.factor.set(child_factor);
|
||||
self.apply_factors(sum_factors);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
|
@ -364,10 +383,7 @@ struct SeatOp {
|
|||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
enum SeatOpKind {
|
||||
Move,
|
||||
Resize {
|
||||
dist_left: i32,
|
||||
dist_right: i32,
|
||||
}
|
||||
Resize { dist_left: i32, dist_right: i32 },
|
||||
}
|
||||
|
||||
impl Node for ContainerNode {
|
||||
|
|
@ -392,7 +408,13 @@ impl Node for ContainerNode {
|
|||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
Rect::new_sized(self.abs_x1.get(), self.abs_y1.get(), self.width.get(), self.height.get()).unwrap()
|
||||
Rect::new_sized(
|
||||
self.abs_x1.get(),
|
||||
self.abs_y1.get(),
|
||||
self.width.get(),
|
||||
self.height.get(),
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn button(self: Rc<Self>, seat: &Rc<WlSeatGlobal>, button: u32, state: KeyState) {
|
||||
|
|
@ -441,11 +463,11 @@ impl Node for ContainerNode {
|
|||
} else {
|
||||
for child in self.children.iter() {
|
||||
let body = child.body.get();
|
||||
if seat_data.x < body.y1() {
|
||||
let op = if seat_data.x < body.y1() - CONTAINER_TITLE_HEIGHT {
|
||||
if seat_data.y < body.y1() {
|
||||
let op = if seat_data.y < body.y1() - CONTAINER_TITLE_HEIGHT {
|
||||
SeatOpKind::Resize {
|
||||
dist_left: seat_data.y - child.prev().body.get().y2(),
|
||||
dist_right: body.y1() - seat_data.x,
|
||||
dist_right: body.y1() - seat_data.y,
|
||||
}
|
||||
} else {
|
||||
SeatOpKind::Move
|
||||
|
|
@ -456,6 +478,7 @@ impl Node for ContainerNode {
|
|||
};
|
||||
return;
|
||||
};
|
||||
log::info!("op = {:?}", kind);
|
||||
let grab = match seat.grab_pointer(self.clone()) {
|
||||
None => return,
|
||||
Some(g) => g,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use crate::backend::{KeyState, OutputId, ScrollAxis};
|
||||
use crate::client::ClientId;
|
||||
use crate::cursor::KnownCursor;
|
||||
use crate::fixed::Fixed;
|
||||
use crate::ifs::wl_output::WlOutputGlobal;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal};
|
||||
|
|
@ -16,7 +17,6 @@ use std::fmt::Display;
|
|||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
pub use workspace::*;
|
||||
use crate::cursor::KnownCursor;
|
||||
|
||||
mod container;
|
||||
mod workspace;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use crate::cursor::KnownCursor;
|
||||
use crate::ifs::wl_seat::{NodeSeatState, WlSeatGlobal};
|
||||
use crate::rect::Rect;
|
||||
use crate::render::Renderer;
|
||||
|
|
@ -6,7 +7,6 @@ use crate::tree::{FindTreeResult, FoundNode, Node, NodeId, OutputNode};
|
|||
use crate::utils::clonecell::CloneCell;
|
||||
use crate::utils::linkedlist::LinkedList;
|
||||
use std::rc::Rc;
|
||||
use crate::cursor::KnownCursor;
|
||||
|
||||
tree_id!(WorkspaceNodeId);
|
||||
|
||||
|
|
|
|||
|
|
@ -202,9 +202,7 @@ impl<T> NodeRef<T> {
|
|||
let data = self.data.as_ref();
|
||||
let other = data.prev.get();
|
||||
other.as_ref().rc.fetch_add(1);
|
||||
NodeRef {
|
||||
data: other,
|
||||
}
|
||||
NodeRef { data: other }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -214,9 +212,7 @@ impl<T> NodeRef<T> {
|
|||
let data = self.data.as_ref();
|
||||
let other = data.next.get();
|
||||
other.as_ref().rc.fetch_add(1);
|
||||
NodeRef {
|
||||
data: other,
|
||||
}
|
||||
NodeRef { data: other }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue