made gaps prettier

This commit is contained in:
NoOneBtw 2021-05-04 10:50:23 +02:00
parent 019ce4e350
commit 95d7740119
2 changed files with 17 additions and 22 deletions

View file

@ -3,7 +3,7 @@
use std::collections::HashMap;
use std::num::NonZeroI32;
use log::{debug, error};
use log::{error, info};
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
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
if let Some(vs) = self.virtual_screens.front_mut() {
// 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
// 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) {
Some(i) => i.get(),
None => 1,
};
// 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) {
Some(i) => i.get(),
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
.master
.iter()
@ -690,7 +680,7 @@ impl ClientState {
)
{
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) {
*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

View file

@ -443,10 +443,15 @@ impl XLib {
pub fn dimensions(&self) -> (i32, i32) {
unsafe {
(
xlib::XDisplayWidth(self.dpy(), self.screen),
xlib::XDisplayHeight(self.dpy(), self.screen),
)
let mut wa =
std::mem::MaybeUninit::<xlib::XWindowAttributes>::zeroed()
.assume_init();
xlib::XGetWindowAttributes(self.dpy(), self.root, &mut wa);
info!("Root window dimensions: {}, {}", wa.width, wa.height);
(wa.width, wa.height)
}
}