x11: allow disabling the titlebar
I've kept resizing in there because it doesn't appear to render a border in mutter and seems useful. I think I'll probably change WindowDecorations to bitflags so that the user can control this, but first need to verify what windows supports for this.
This commit is contained in:
1 parent
3356a3a149
commit
1ca9fb3555
2 files changed
+31
-5
No files matched your search
@@ -1,11 +1,12 @@
|
||||
use super::*;
|
||||
use crate::bitmaps::*;
|
||||
use crate::configuration::config;
|
||||
use crate::connection::ConnectionOps;
|
||||
use crate::os::xkeysyms;
|
||||
use crate::os::{Connection, Window};
|
||||
use crate::{
|
||||
Clipboard, Dimensions, MouseButtons, MouseCursor, MouseEvent, MouseEventKind, MousePress,
|
||||
Point, Rect, ScreenPoint, Size, WindowCallbacks, WindowOps, WindowOpsMut,
|
||||
Point, Rect, ScreenPoint, Size, WindowCallbacks, WindowDecorations, WindowOps, WindowOpsMut,
|
||||
};
|
||||
use anyhow::{anyhow, Context as _};
|
||||
use promise::{Future, Promise};
|
||||
@@ -610,11 +611,12 @@ impl XWindowInner {
|
||||
xcb::ClientMessageData::from_data32(data),
|
||||
),
|
||||
);
|
||||
self.adjust_decorations(config().decorations() == WindowDecorations::Full)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(dead_code, clippy::identity_op)]
|
||||
#[allow(clippy::identity_op)]
|
||||
fn adjust_decorations(&mut self, enable: bool) -> anyhow::Result<()> {
|
||||
// Set the motif hints to disable decorations.
|
||||
// See https://stackoverflow.com/a/1909708
|
||||
@@ -627,19 +629,21 @@ impl XWindowInner {
|
||||
status: u32,
|
||||
}
|
||||
|
||||
const HINTS_FUNCTIONS: u32 = 1 << 0;
|
||||
const HINTS_DECORATIONS: u32 = 1 << 1;
|
||||
const FUNC_ALL: u32 = 1 << 0;
|
||||
const FUNC_RESIZE: u32 = 1 << 1;
|
||||
/*
|
||||
const HINTS_FUNCTIONS: u32 = 1 << 0;
|
||||
const FUNC_MOVE: u32 = 1 << 2;
|
||||
const FUNC_MINIMIZE: u32 = 1 << 3;
|
||||
const FUNC_MAXIMIZE: u32 = 1 << 4;
|
||||
const FUNC_CLOSE: u32 = 1 << 5;
|
||||
*/
|
||||
|
||||
let hints = MwmHints {
|
||||
flags: HINTS_DECORATIONS,
|
||||
functions: 0,
|
||||
decorations: if enable { FUNC_ALL } else { 0 },
|
||||
decorations: if enable { FUNC_ALL } else { FUNC_RESIZE },
|
||||
input_mode: 0,
|
||||
status: 0,
|
||||
};
|
||||
@@ -785,7 +789,10 @@ impl XWindow {
|
||||
&[conn.atom_delete],
|
||||
);
|
||||
|
||||
// window.lock().unwrap().disable_decorations()?;
|
||||
window
|
||||
.lock()
|
||||
.unwrap()
|
||||
.adjust_decorations(config().decorations() == WindowDecorations::Full)?;
|
||||
|
||||
let window_handle = Window::X11(XWindow::from_id(window_id));
|
||||
|
||||
@@ -832,6 +839,10 @@ impl WindowOpsMut for XWindowInner {
|
||||
self.set_fullscreen_hint(!fullscreen).ok();
|
||||
}
|
||||
|
||||
fn config_did_change(&mut self) {
|
||||
let _ = self.adjust_decorations(config().decorations() == WindowDecorations::Full);
|
||||
}
|
||||
|
||||
fn set_inner_size(&mut self, width: usize, height: usize) {
|
||||
xcb::configure_window(
|
||||
self.conn().conn(),
|
||||
@@ -914,6 +925,13 @@ impl WindowOps for XWindow {
|
||||
})
|
||||
}
|
||||
|
||||
fn config_did_change(&self) -> Future<()> {
|
||||
XConnection::with_window_inner(self.0, |inner| {
|
||||
inner.config_did_change();
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
fn show(&self) -> Future<()> {
|
||||
XConnection::with_window_inner(self.0, |inner| {
|
||||
inner.show();
|
||||
|
||||
@@ -142,6 +142,14 @@ impl WindowOps for Window {
|
||||
}
|
||||
}
|
||||
|
||||
fn config_did_change(&self) -> Future<()> {
|
||||
match self {
|
||||
Self::X11(x) => x.config_did_change(),
|
||||
#[cfg(feature = "wayland")]
|
||||
Self::Wayland(w) => w.config_did_change(),
|
||||
}
|
||||
}
|
||||
|
||||
fn show(&self) -> Future<()> {
|
||||
match self {
|
||||
Self::X11(x) => x.show(),
|
||||
|
||||
Reference in new issue
Block a user