window border for focused client
This commit is contained in:
parent
1052aa13e0
commit
61dbfc3a3d
|
@ -142,6 +142,7 @@ pub struct ClientState {
|
||||||
pub(self) gap: i32,
|
pub(self) gap: i32,
|
||||||
pub(self) screen_size: (i32, i32),
|
pub(self) screen_size: (i32, i32),
|
||||||
pub(self) master_size: f32,
|
pub(self) master_size: f32,
|
||||||
|
border_size: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -166,6 +167,7 @@ impl Default for ClientState {
|
||||||
gap: 0,
|
gap: 0,
|
||||||
screen_size: (1, 1),
|
screen_size: (1, 1),
|
||||||
master_size: 1.0,
|
master_size: 1.0,
|
||||||
|
border_size: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,6 +181,13 @@ impl ClientState {
|
||||||
Self { gap, ..self }
|
Self { gap, ..self }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn with_border(self, border: i32) -> Self {
|
||||||
|
Self {
|
||||||
|
border_size: border,
|
||||||
|
..self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn with_screen_size(self, screen_size: (i32, i32)) -> Self {
|
pub fn with_screen_size(self, screen_size: (i32, i32)) -> Self {
|
||||||
Self {
|
Self {
|
||||||
screen_size,
|
screen_size,
|
||||||
|
@ -193,6 +202,14 @@ impl ClientState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_border(&self) -> i32 {
|
||||||
|
self.border_size
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_border_mut(&mut self, new: i32) {
|
||||||
|
self.border_size = new;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn insert(&mut self, mut client: Client) -> Option<&Client> {
|
pub fn insert(&mut self, mut client: Client) -> Option<&Client> {
|
||||||
let key = client.key();
|
let key = client.key();
|
||||||
|
|
||||||
|
@ -634,7 +651,11 @@ impl ClientState {
|
||||||
|
|
||||||
// Master
|
// Master
|
||||||
for (i, key) in vs.master.iter().enumerate() {
|
for (i, key) in vs.master.iter().enumerate() {
|
||||||
let size = (master_width - gap * 2, master_height - gap * 2);
|
let size = (
|
||||||
|
master_width - gap * 2 - self.border_size * 2,
|
||||||
|
master_height - gap * 2 - self.border_size * 2,
|
||||||
|
);
|
||||||
|
|
||||||
let position = (gap * 2, master_height * i as i32 + gap * 2);
|
let position = (gap * 2, master_height * i as i32 + gap * 2);
|
||||||
|
|
||||||
if let Some(client) = self.clients.get_mut(key) {
|
if let Some(client) = self.clients.get_mut(key) {
|
||||||
|
@ -648,7 +669,11 @@ impl ClientState {
|
||||||
|
|
||||||
// Aux
|
// Aux
|
||||||
for (i, key) in vs.aux.iter().enumerate() {
|
for (i, key) in vs.aux.iter().enumerate() {
|
||||||
let size = (aux_width - gap * 2, aux_height - gap * 2);
|
let size = (
|
||||||
|
aux_width - gap * 2 - self.border_size * 2,
|
||||||
|
aux_height - gap * 2 - self.border_size * 2,
|
||||||
|
);
|
||||||
|
|
||||||
let position =
|
let position =
|
||||||
(master_width + gap * 2, aux_height * i as i32 + gap * 2);
|
(master_width + gap * 2, aux_height * i as i32 + gap * 2);
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,7 @@ fn log_prologue() {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_logger() {
|
fn test_logger() {
|
||||||
init_logger();
|
init_logger();
|
||||||
|
// asdf
|
||||||
|
|
||||||
log_prologue();
|
log_prologue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,7 @@ impl WindowManager {
|
||||||
let clients = ClientState::new()
|
let clients = ClientState::new()
|
||||||
.with_virtualscreens(config.num_virtualscreens)
|
.with_virtualscreens(config.num_virtualscreens)
|
||||||
.with_gap(config.gap.unwrap_or(1))
|
.with_gap(config.gap.unwrap_or(1))
|
||||||
|
.with_border(1)
|
||||||
.with_screen_size(xlib.dimensions());
|
.with_screen_size(xlib.dimensions());
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
@ -549,6 +550,8 @@ impl WindowManager {
|
||||||
Client::new_default(window)
|
Client::new_default(window)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self.xlib
|
||||||
|
.configure_client(&client, self.clients.get_border());
|
||||||
self.clients.insert(client).unwrap();
|
self.clients.insert(client).unwrap();
|
||||||
self.arrange_clients();
|
self.arrange_clients();
|
||||||
|
|
||||||
|
@ -585,7 +588,9 @@ impl WindowManager {
|
||||||
let event: &XConfigureRequestEvent = event.as_ref();
|
let event: &XConfigureRequestEvent = event.as_ref();
|
||||||
|
|
||||||
match self.clients.get(&event.window).into_option() {
|
match self.clients.get(&event.window).into_option() {
|
||||||
Some(client) => self.xlib.configure_client(client),
|
Some(client) => self
|
||||||
|
.xlib
|
||||||
|
.configure_client(client, self.clients.get_border()),
|
||||||
None => self.xlib.configure_window(event),
|
None => self.xlib.configure_window(event),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
32
src/xlib.rs
32
src/xlib.rs
|
@ -212,6 +212,16 @@ impl XLib {
|
||||||
xlib::CurrentTime,
|
xlib::CurrentTime,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let screen = xlib::XDefaultScreenOfDisplay(self.dpy()).as_ref();
|
||||||
|
|
||||||
|
if let Some(screen) = screen {
|
||||||
|
xlib::XSetWindowBorder(
|
||||||
|
self.dpy(),
|
||||||
|
client.window,
|
||||||
|
screen.white_pixel,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
xlib::XChangeProperty(
|
xlib::XChangeProperty(
|
||||||
self.dpy(),
|
self.dpy(),
|
||||||
self.root,
|
self.root,
|
||||||
|
@ -227,7 +237,7 @@ impl XLib {
|
||||||
self.send_event(client, self.atoms.take_focus);
|
self.send_event(client, self.atoms.take_focus);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unfocus_client(&self, _client: &Client) {
|
pub fn unfocus_client(&self, client: &Client) {
|
||||||
//info!("unfocusing client: {:?}", client);
|
//info!("unfocusing client: {:?}", client);
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -238,6 +248,16 @@ impl XLib {
|
||||||
xlib::CurrentTime,
|
xlib::CurrentTime,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let screen = xlib::XDefaultScreenOfDisplay(self.dpy()).as_ref();
|
||||||
|
|
||||||
|
if let Some(screen) = screen {
|
||||||
|
xlib::XSetWindowBorder(
|
||||||
|
self.dpy(),
|
||||||
|
client.window,
|
||||||
|
screen.black_pixel,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// xlib::XDeleteProperty(
|
// xlib::XDeleteProperty(
|
||||||
// self.dpy(),
|
// self.dpy(),
|
||||||
// self.root,
|
// self.root,
|
||||||
|
@ -404,7 +424,7 @@ impl XLib {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn configure_client(&self, client: &Client) {
|
pub fn configure_client(&self, client: &Client, border: i32) {
|
||||||
let mut event = xlib::XConfigureEvent {
|
let mut event = xlib::XConfigureEvent {
|
||||||
type_: xlib::ConfigureNotify,
|
type_: xlib::ConfigureNotify,
|
||||||
display: self.dpy(),
|
display: self.dpy(),
|
||||||
|
@ -414,7 +434,7 @@ impl XLib {
|
||||||
y: client.position.1,
|
y: client.position.1,
|
||||||
width: client.size.0,
|
width: client.size.0,
|
||||||
height: client.size.1,
|
height: client.size.1,
|
||||||
border_width: 0,
|
border_width: border,
|
||||||
override_redirect: 0,
|
override_redirect: 0,
|
||||||
send_event: 0,
|
send_event: 0,
|
||||||
serial: 0,
|
serial: 0,
|
||||||
|
@ -422,6 +442,12 @@ impl XLib {
|
||||||
};
|
};
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
xlib::XSetWindowBorderWidth(
|
||||||
|
self.dpy(),
|
||||||
|
event.window,
|
||||||
|
event.border_width as u32,
|
||||||
|
);
|
||||||
|
|
||||||
xlib::XSendEvent(
|
xlib::XSendEvent(
|
||||||
self.dpy(),
|
self.dpy(),
|
||||||
event.window,
|
event.window,
|
||||||
|
|
1
xinitrc
1
xinitrc
|
@ -3,5 +3,6 @@
|
||||||
/usr/bin/xset b off
|
/usr/bin/xset b off
|
||||||
/usr/bin/xsetroot -solid darkslategrey
|
/usr/bin/xsetroot -solid darkslategrey
|
||||||
/usr/bin/feh --bg-fill "/mnt/storage/rust/wm/starship.jpg"
|
/usr/bin/feh --bg-fill "/mnt/storage/rust/wm/starship.jpg"
|
||||||
|
xset r rate 250 30
|
||||||
export RUST_BACKTRACE=1
|
export RUST_BACKTRACE=1
|
||||||
exec /mnt/storage/rust/wm/target/release/wm >& /home/user/.local/portlights.log
|
exec /mnt/storage/rust/wm/target/release/wm >& /home/user/.local/portlights.log
|
||||||
|
|
Loading…
Reference in a new issue