Compare commits
No commits in common. "feature_cursor" and "main" have entirely different histories.
feature_cu
...
main
|
@ -18,11 +18,4 @@ pub mod structs {
|
||||||
Dock,
|
Dock,
|
||||||
Desktop,
|
Desktop,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
|
|
||||||
pub enum Cursor {
|
|
||||||
Normal,
|
|
||||||
Resize,
|
|
||||||
Move,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,11 +21,6 @@ pub trait WindowServerBackend {
|
||||||
fn focus_window(&self, window: Self::Window);
|
fn focus_window(&self, window: Self::Window);
|
||||||
fn unfocus_window(&self, window: Self::Window);
|
fn unfocus_window(&self, window: Self::Window);
|
||||||
fn raise_window(&self, window: Self::Window);
|
fn raise_window(&self, window: Self::Window);
|
||||||
fn set_window_fullscreen_state(
|
|
||||||
&self,
|
|
||||||
window: Self::Window,
|
|
||||||
fullscreen: bool,
|
|
||||||
);
|
|
||||||
fn hide_window(&self, window: Self::Window);
|
fn hide_window(&self, window: Self::Window);
|
||||||
fn kill_window(&self, window: Self::Window);
|
fn kill_window(&self, window: Self::Window);
|
||||||
fn get_parent_window(&self, window: Self::Window) -> Option<Self::Window>;
|
fn get_parent_window(&self, window: Self::Window) -> Option<Self::Window>;
|
||||||
|
|
|
@ -12,7 +12,6 @@ use crate::backends::{
|
||||||
|
|
||||||
use self::{
|
use self::{
|
||||||
connection::{PropMode, XLibConnection},
|
connection::{PropMode, XLibConnection},
|
||||||
cursors::Cursors,
|
|
||||||
ewmh::{EWMHAtom, EWMHAtoms},
|
ewmh::{EWMHAtom, EWMHAtoms},
|
||||||
keysym::{
|
keysym::{
|
||||||
keysym_to_virtual_keycode, virtual_keycode_to_keysym,
|
keysym_to_virtual_keycode, virtual_keycode_to_keysym,
|
||||||
|
@ -714,62 +713,6 @@ impl Display {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod cursors {
|
|
||||||
use std::{borrow::Borrow, ops::Index};
|
|
||||||
|
|
||||||
use x11::xlib::{Cursor as XCursor, XCreateFontCursor, XFreeCursor};
|
|
||||||
|
|
||||||
use crate::backends::structs::Cursor;
|
|
||||||
|
|
||||||
use super::connection::XLibConnection;
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
|
|
||||||
pub struct Cursors {
|
|
||||||
normal: XCursor,
|
|
||||||
resize: XCursor,
|
|
||||||
grab: XCursor,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Cursors {
|
|
||||||
const LEFT_PTR: u32 = 68;
|
|
||||||
const SIZING: u32 = 120;
|
|
||||||
const FLEUR: u32 = 52;
|
|
||||||
|
|
||||||
pub fn from_connection<C: Borrow<XLibConnection>>(con: C) -> Self {
|
|
||||||
unsafe {
|
|
||||||
Self {
|
|
||||||
normal: XCreateFontCursor(
|
|
||||||
con.borrow().dpy(),
|
|
||||||
Self::LEFT_PTR,
|
|
||||||
),
|
|
||||||
resize: XCreateFontCursor(con.borrow().dpy(), Self::SIZING),
|
|
||||||
grab: XCreateFontCursor(con.borrow().dpy(), Self::FLEUR),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub unsafe fn free<C: Borrow<XLibConnection>>(&self, con: C) {
|
|
||||||
unsafe {
|
|
||||||
XFreeCursor(con.borrow().dpy(), self.normal);
|
|
||||||
XFreeCursor(con.borrow().dpy(), self.resize);
|
|
||||||
XFreeCursor(con.borrow().dpy(), self.grab);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Index<Cursor> for Cursors {
|
|
||||||
type Output = XCursor;
|
|
||||||
|
|
||||||
fn index(&self, index: Cursor) -> &Self::Output {
|
|
||||||
match index {
|
|
||||||
Cursor::Normal => &self.normal,
|
|
||||||
Cursor::Resize => &self.resize,
|
|
||||||
Cursor::Move => &self.grab,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct XLib {
|
pub struct XLib {
|
||||||
connection: Rc<XLibConnection>,
|
connection: Rc<XLibConnection>,
|
||||||
atoms: ICCCMAtoms,
|
atoms: ICCCMAtoms,
|
||||||
|
@ -778,13 +721,6 @@ pub struct XLib {
|
||||||
active_border_color: Option<color::XftColor>,
|
active_border_color: Option<color::XftColor>,
|
||||||
inactive_border_color: Option<color::XftColor>,
|
inactive_border_color: Option<color::XftColor>,
|
||||||
wm_window: Window,
|
wm_window: Window,
|
||||||
cursors: Cursors,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Drop for XLib {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
unsafe { self.cursors.free(self.connection.clone()) };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl XLib {
|
impl XLib {
|
||||||
|
@ -800,7 +736,6 @@ impl XLib {
|
||||||
keybinds: Vec::new(),
|
keybinds: Vec::new(),
|
||||||
active_border_color: None,
|
active_border_color: None,
|
||||||
inactive_border_color: None,
|
inactive_border_color: None,
|
||||||
cursors: Cursors::from_connection(con.clone()),
|
|
||||||
wm_window: unsafe {
|
wm_window: unsafe {
|
||||||
xlib::XCreateSimpleWindow(
|
xlib::XCreateSimpleWindow(
|
||||||
con.dpy(),
|
con.dpy(),
|
||||||
|
@ -818,10 +753,9 @@ impl XLib {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn init_as_wm(&self) {
|
unsafe fn init_as_wm(&self) {
|
||||||
let mut window_attributes = unsafe {
|
let mut window_attributes =
|
||||||
std::mem::MaybeUninit::<xlib::XSetWindowAttributes>::zeroed()
|
std::mem::MaybeUninit::<xlib::XSetWindowAttributes>::zeroed()
|
||||||
.assume_init()
|
.assume_init();
|
||||||
};
|
|
||||||
|
|
||||||
window_attributes.event_mask = xlib::SubstructureRedirectMask
|
window_attributes.event_mask = xlib::SubstructureRedirectMask
|
||||||
| xlib::StructureNotifyMask
|
| xlib::StructureNotifyMask
|
||||||
|
@ -830,7 +764,6 @@ impl XLib {
|
||||||
| xlib::PointerMotionMask
|
| xlib::PointerMotionMask
|
||||||
| xlib::ButtonPressMask;
|
| xlib::ButtonPressMask;
|
||||||
|
|
||||||
unsafe {
|
|
||||||
xlib::XChangeWindowAttributes(
|
xlib::XChangeWindowAttributes(
|
||||||
self.connection.dpy(),
|
self.connection.dpy(),
|
||||||
self.connection.root(),
|
self.connection.root(),
|
||||||
|
@ -846,7 +779,6 @@ impl XLib {
|
||||||
|
|
||||||
xlib::XSetErrorHandler(Some(xlib_error_handler));
|
xlib::XSetErrorHandler(Some(xlib_error_handler));
|
||||||
xlib::XSync(self.dpy(), 0);
|
xlib::XSync(self.dpy(), 0);
|
||||||
}
|
|
||||||
|
|
||||||
self.ewmh_atoms.set_supported_atoms(self.connection.clone());
|
self.ewmh_atoms.set_supported_atoms(self.connection.clone());
|
||||||
self.connection.delete_property(
|
self.connection.delete_property(
|
||||||
|
@ -1726,30 +1658,6 @@ impl WindowServerBackend for XLib {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_window_fullscreen_state(
|
|
||||||
&self,
|
|
||||||
window: Self::Window,
|
|
||||||
fullscreen: bool,
|
|
||||||
) {
|
|
||||||
if fullscreen {
|
|
||||||
self.connection.change_property_long(
|
|
||||||
window,
|
|
||||||
self.ewmh_atoms[EWMHAtom::NetWmState],
|
|
||||||
XA_WINDOW,
|
|
||||||
PropMode::Replace,
|
|
||||||
&[self.ewmh_atoms[EWMHAtom::NetWmStateFullscreen] as _],
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
self.connection.change_property_long(
|
|
||||||
window,
|
|
||||||
self.ewmh_atoms[EWMHAtom::NetWmState],
|
|
||||||
XA_WINDOW,
|
|
||||||
PropMode::Replace,
|
|
||||||
&[0 as _],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TryFrom<EWMHAtom> for WindowType {
|
impl TryFrom<EWMHAtom> for WindowType {
|
||||||
|
@ -1775,7 +1683,7 @@ unsafe extern "C" fn xlib_error_handler(
|
||||||
_dpy: *mut x11::xlib::Display,
|
_dpy: *mut x11::xlib::Display,
|
||||||
ee: *mut x11::xlib::XErrorEvent,
|
ee: *mut x11::xlib::XErrorEvent,
|
||||||
) -> std::os::raw::c_int {
|
) -> std::os::raw::c_int {
|
||||||
let err_event = unsafe { ee.as_ref().unwrap() };
|
let err_event = ee.as_ref().unwrap();
|
||||||
let err = XlibError::from(err_event.error_code);
|
let err = XlibError::from(err_event.error_code);
|
||||||
|
|
||||||
match err {
|
match err {
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#![deny(unsafe_op_in_unsafe_fn)]
|
|
||||||
|
|
||||||
pub mod backends;
|
pub mod backends;
|
||||||
pub mod clients;
|
pub mod clients;
|
||||||
pub mod state;
|
pub mod state;
|
||||||
|
|
15
src/state.rs
15
src/state.rs
|
@ -203,6 +203,16 @@ where
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
|
|
||||||
|
// self.add_keybind(KeyBinding::new(
|
||||||
|
// KeyBind::new(VirtualKeyCode::Print),
|
||||||
|
// |wm, _| wm.spawn("screenshot.sh", &[]),
|
||||||
|
// ));
|
||||||
|
|
||||||
|
// self.add_keybind(KeyBinding::new(
|
||||||
|
// KeyBind::new(VirtualKeyCode::Print).with_mod(ModifierKey::Shift),
|
||||||
|
// |wm, _| wm.spawn("screenshot.sh", &["-edit"]),
|
||||||
|
// ));
|
||||||
|
|
||||||
self.add_keybind(KeyBinding::new(
|
self.add_keybind(KeyBinding::new(
|
||||||
KeyBind::new(VirtualKeyCode::M).with_mod(self.config.mod_key),
|
KeyBind::new(VirtualKeyCode::M).with_mod(self.config.mod_key),
|
||||||
|wm, _| wm.handle_switch_stack(),
|
|wm, _| wm.handle_switch_stack(),
|
||||||
|
@ -478,11 +488,6 @@ where
|
||||||
Some(self.clients.get_border())
|
Some(self.clients.get_border())
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
self.backend.set_window_fullscreen_state(
|
|
||||||
client.window,
|
|
||||||
client.is_fullscreen(),
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.arrange_clients();
|
self.arrange_clients();
|
||||||
|
|
Loading…
Reference in a new issue