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