Support panel at bottom
Since there's no configuration to read, hardcoded constant for now.
This commit is contained in:
parent
01a1f5e132
commit
4b942c1b92
2 changed files with 21 additions and 7 deletions
|
|
@ -8,6 +8,8 @@ use crate::status_area::StatusArea;
|
||||||
use crate::time_button::TimeButton;
|
use crate::time_button::TimeButton;
|
||||||
use crate::x;
|
use crate::x;
|
||||||
|
|
||||||
|
const BOTTOM: bool = false;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct PanelWindowInner {
|
pub struct PanelWindowInner {
|
||||||
size: Cell<Option<(i32, i32)>>,
|
size: Cell<Option<(i32, i32)>>,
|
||||||
|
|
@ -127,25 +129,37 @@ impl PanelWindow {
|
||||||
let geometry = self.inner().monitor.geometry();
|
let geometry = self.inner().monitor.geometry();
|
||||||
self.set_size_request(geometry.width, 0);
|
self.set_size_request(geometry.width, 0);
|
||||||
|
|
||||||
let top = if let Some((_width, height)) = self.inner().size.get() {
|
let height = if let Some((_width, height)) = self.inner().size.get() {
|
||||||
height as x::c_ulong
|
height as x::c_ulong
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some((display, surface)) = x::get_window_x11(self) {
|
if let Some((display, surface)) = x::get_window_x11(self) {
|
||||||
let top_start_x = geometry.x as x::c_ulong;
|
let start_x = geometry.x as x::c_ulong;
|
||||||
let top_end_x = top_start_x + geometry.width as x::c_ulong - 1;
|
let end_x = start_x + geometry.width as x::c_ulong - 1;
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
x::set_position(&display, &surface, top_start_x as _, 0);
|
let y = if BOTTOM {
|
||||||
|
geometry.height as x::c_int - height as x::c_int
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
x::set_position(&display, &surface, start_x as _, y);
|
||||||
|
|
||||||
|
let strut = if BOTTOM {
|
||||||
|
[0, 0, 0, height, 0, 0, 0, 0, 0, 0, start_x, end_x]
|
||||||
|
} else {
|
||||||
|
[0, 0, height, 0, 0, 0, 0, 0, start_x, end_x, 0, 0]
|
||||||
|
};
|
||||||
|
|
||||||
x::change_property(
|
x::change_property(
|
||||||
&display,
|
&display,
|
||||||
&surface,
|
&surface,
|
||||||
"_NET_WM_STRUT_PARTIAL",
|
"_NET_WM_STRUT_PARTIAL",
|
||||||
x::PropMode::Replace,
|
x::PropMode::Replace,
|
||||||
&[0, 0, top, 0, 0, 0, 0, 0, top_start_x, top_end_x, 0, 0],
|
&strut,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
4
src/x.rs
4
src/x.rs
|
|
@ -4,11 +4,11 @@ use glib::translate::ToGlibPtr;
|
||||||
use gtk4::{glib, prelude::*};
|
use gtk4::{glib, prelude::*};
|
||||||
use std::{
|
use std::{
|
||||||
ffi::{CString, NulError},
|
ffi::{CString, NulError},
|
||||||
os::raw::{c_int, c_long},
|
os::raw::c_long,
|
||||||
ptr,
|
ptr,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use std::os::raw::{c_uchar, c_ulong, c_ushort};
|
pub use std::os::raw::{c_int, c_uchar, c_ulong, c_ushort};
|
||||||
|
|
||||||
pub fn get_window_x11<T: IsA<gtk4::Window>>(
|
pub fn get_window_x11<T: IsA<gtk4::Window>>(
|
||||||
window: &T,
|
window: &T,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue