fullscreen windows can no longer be resized or moved

This commit is contained in:
Janis 2021-12-02 22:16:57 +01:00
parent 192f865fec
commit 2c6d4fd465
2 changed files with 108 additions and 62 deletions

View file

@ -2,6 +2,7 @@ use std::{ops::Rem, usize};
use indexmap::IndexMap; use indexmap::IndexMap;
use log::error; use log::error;
use num_traits::Zero;
use crate::util::BuildIdentityHasher; use crate::util::BuildIdentityHasher;
use crate::util::{Point, Size}; use crate::util::{Point, Size};
@ -457,13 +458,20 @@ impl ClientState {
where where
K: ClientKey, K: ClientKey,
{ {
self.get_mut(key) let fullscreen_size = self.screen_size
.into_option() - Size::new(self.border_size * 2, self.border_size * 2);
.map(|client| {
client.toggle_fullscreen(); match self.get_mut(key).into_option() {
Some(client) => {
if client.toggle_fullscreen() {
client.size = fullscreen_size;
client.position = Point::zero();
}
true true
}) }
.unwrap_or(false) None => false,
}
} }
/** /**
@ -490,6 +498,16 @@ impl ClientState {
pub fn toggle_floating<K>(&mut self, key: &K) pub fn toggle_floating<K>(&mut self, key: &K)
where where
K: ClientKey, K: ClientKey,
{
// do nothing if either no client matches the key or the client is fullscreen.
// FIXME: this should probably disable fullscreen mode (but that has to
// be handled in the wm state so that the backend can notify the client
// that it is no longer fullscreen)
if !self
.get(key)
.into_option()
.map(|c| c.is_fullscreen())
.unwrap_or(true)
{ {
let key = key.key(); let key = key.key();
let client = self.clients.remove(&key); let client = self.clients.remove(&key);
@ -514,13 +532,16 @@ impl ClientState {
} }
} }
_ => { _ => {
error!("wtf? Client was present in tiled and floating list.") error!(
"wtf? Client was present in tiled and floating list."
)
} }
}; };
// we added or removed a client from the tiling so the layout changed, rearrange // we added or removed a client from the tiling so the layout changed, rearrange
self.arrange_virtual_screen(); self.arrange_virtual_screen();
} }
}
fn remove_from_virtual_screens<K>(&mut self, key: &K) fn remove_from_virtual_screens<K>(&mut self, key: &K)
where where
@ -1007,3 +1028,25 @@ impl<T> ClientEntry<T> {
!self.is_vacant() !self.is_vacant()
} }
} }
impl ClientEntry<&client::Client> {
pub fn is_fullscreen(&self) -> bool {
match self {
ClientEntry::Tiled(c) | ClientEntry::Floating(c) => {
c.is_fullscreen()
}
ClientEntry::Vacant => false,
}
}
}
impl ClientEntry<&mut client::Client> {
pub fn is_fullscreen(&self) -> bool {
match self {
ClientEntry::Tiled(c) | ClientEntry::Floating(c) => {
c.is_fullscreen()
}
ClientEntry::Vacant => false,
}
}
}

View file

@ -758,13 +758,15 @@ where
fn start_move_resize_window(&mut self, event: &ButtonEvent<B::Window>) { fn start_move_resize_window(&mut self, event: &ButtonEvent<B::Window>) {
let window = event.window; // xev.subwindow let window = event.window; // xev.subwindow
if !self.clients.get(&window).is_fullscreen() {
match event.keycode { match event.keycode {
MouseButton::Left => { MouseButton::Left => {
if self.clients.set_floating(&window) { if self.clients.set_floating(&window) {
self.arrange_clients(); self.arrange_clients();
} }
self.move_resize_window = MoveResizeInfo::Move(MoveInfoInner { self.move_resize_window =
MoveResizeInfo::Move(MoveInfoInner {
window, window,
starting_cursor_pos: event.cursor_position, starting_cursor_pos: event.cursor_position,
starting_window_pos: self starting_window_pos: self
@ -796,6 +798,7 @@ where
_ => {} _ => {}
} }
} }
}
fn end_move_resize_window(&mut self, event: &ButtonEvent<B::Window>) { fn end_move_resize_window(&mut self, event: &ButtonEvent<B::Window>) {
match event.keycode { match event.keycode {