made gaps prettier
This commit is contained in:
parent
019ce4e350
commit
95d7740119
|
@ -3,7 +3,7 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::num::NonZeroI32;
|
use std::num::NonZeroI32;
|
||||||
|
|
||||||
use log::{debug, error};
|
use log::{error, info};
|
||||||
|
|
||||||
use crate::util::BuildIdentityHasher;
|
use crate::util::BuildIdentityHasher;
|
||||||
|
|
||||||
|
@ -630,17 +630,6 @@ impl ClientState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
there should be no need to call this function since a `VirtualScreen` refreshes it self on
|
|
||||||
client removal.
|
|
||||||
*/
|
|
||||||
#[deprecated]
|
|
||||||
fn refresh_virtual_screen(&mut self) {
|
|
||||||
if let Some(vs) = self.virtual_screens.front_mut() {
|
|
||||||
vs.refresh();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
resizes and moves clients on the current virtual screen with `width` and `height` as
|
resizes and moves clients on the current virtual screen with `width` and `height` as
|
||||||
screen width and screen height.
|
screen width and screen height.
|
||||||
|
@ -657,24 +646,25 @@ impl ClientState {
|
||||||
// should be fine to unwrap since we will always have at least 1 virtual screen
|
// should be fine to unwrap since we will always have at least 1 virtual screen
|
||||||
if let Some(vs) = self.virtual_screens.front_mut() {
|
if let Some(vs) = self.virtual_screens.front_mut() {
|
||||||
// if aux is empty -> width : width / 2
|
// if aux is empty -> width : width / 2
|
||||||
let width = width / (1 + i32::from(!vs.aux.is_empty()));
|
let width = (width - gap * 2) / (1 + i32::from(!vs.aux.is_empty()));
|
||||||
|
|
||||||
// make sure we dont devide by 0
|
// make sure we dont devide by 0
|
||||||
// height is max height / number of clients in the stack
|
// height is max height / number of clients in the stack
|
||||||
let master_height = height
|
let master_height = (height - gap * 2)
|
||||||
/ match NonZeroI32::new(vs.master.len() as i32) {
|
/ match NonZeroI32::new(vs.master.len() as i32) {
|
||||||
Some(i) => i.get(),
|
Some(i) => i.get(),
|
||||||
None => 1,
|
None => 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
// height is max height / number of clients in the stack
|
// height is max height / number of clients in the stack
|
||||||
let aux_height = height
|
let aux_height = (height - gap * 2)
|
||||||
/ match NonZeroI32::new(vs.aux.len() as i32) {
|
/ match NonZeroI32::new(vs.aux.len() as i32) {
|
||||||
Some(i) => i.get(),
|
Some(i) => i.get(),
|
||||||
None => 1,
|
None => 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
// chaining master and aux together with `Zip`s for height and x reduces duplicate code
|
// chaining master and aux together with `Zip`s for height and x
|
||||||
|
// reduces duplicate code
|
||||||
for ((i, key), (height, x)) in vs
|
for ((i, key), (height, x)) in vs
|
||||||
.master
|
.master
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -690,7 +680,7 @@ impl ClientState {
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
let size = (width - gap * 2, height - gap * 2);
|
let size = (width - gap * 2, height - gap * 2);
|
||||||
let position = (x + gap, height * i as i32 + gap);
|
let position = (x + gap * 2, height * i as i32 + gap * 2);
|
||||||
|
|
||||||
if let Some(client) = self.clients.get_mut(key) {
|
if let Some(client) = self.clients.get_mut(key) {
|
||||||
*client = Client {
|
*client = Client {
|
||||||
|
@ -702,7 +692,7 @@ impl ClientState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("{:#?}", self);
|
info!("{:#?}", self);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should have xlib send those changes back to the x server after this function
|
// Should have xlib send those changes back to the x server after this function
|
||||||
|
|
13
src/xlib.rs
13
src/xlib.rs
|
@ -443,10 +443,15 @@ impl XLib {
|
||||||
|
|
||||||
pub fn dimensions(&self) -> (i32, i32) {
|
pub fn dimensions(&self) -> (i32, i32) {
|
||||||
unsafe {
|
unsafe {
|
||||||
(
|
let mut wa =
|
||||||
xlib::XDisplayWidth(self.dpy(), self.screen),
|
std::mem::MaybeUninit::<xlib::XWindowAttributes>::zeroed()
|
||||||
xlib::XDisplayHeight(self.dpy(), self.screen),
|
.assume_init();
|
||||||
)
|
|
||||||
|
xlib::XGetWindowAttributes(self.dpy(), self.root, &mut wa);
|
||||||
|
|
||||||
|
info!("Root window dimensions: {}, {}", wa.width, wa.height);
|
||||||
|
|
||||||
|
(wa.width, wa.height)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue