position dock on primary monitor
This commit is contained in:
parent
09bdb53f8e
commit
40b89dffca
1 changed files with 11 additions and 9 deletions
|
|
@ -102,18 +102,17 @@ impl Window {
|
||||||
&[x::Atom::new(&display, "_NET_WM_WINDOW_TYPE_DOCK").unwrap()],
|
&[x::Atom::new(&display, "_NET_WM_WINDOW_TYPE_DOCK").unwrap()],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let s = window.surface().unwrap();
|
let s = window.surface().expect("Failed to get Surface for Window");
|
||||||
|
let surface_resize_handler = glib::clone!(@weak window => move |s: &Surface| {
|
||||||
s.connect_height_notify(glib::clone!(@weak window => move |s| {
|
|
||||||
if let Some((display, _surface)) = x::get_window_x11(&window) {
|
if let Some((display, _surface)) = x::get_window_x11(&window) {
|
||||||
let width = s.width() * s.scale_factor();
|
let width = s.width() * s.scale_factor();
|
||||||
let height = s.height() * s.scale_factor();
|
let height = s.height() * s.scale_factor();
|
||||||
let monitor = display
|
let monitor = display
|
||||||
.monitor_at_surface(s)
|
.primary_monitor()
|
||||||
.expect("Failed to get Monitor");
|
.expect("Failed to get Monitor");
|
||||||
let Rectangle {
|
let Rectangle {
|
||||||
x: _,
|
x: monitor_x,
|
||||||
y: _,
|
y: monitor_y,
|
||||||
width: monitor_width,
|
width: monitor_width,
|
||||||
height: monitor_height,
|
height: monitor_height,
|
||||||
} = monitor.geometry();
|
} = monitor.geometry();
|
||||||
|
|
@ -122,8 +121,8 @@ impl Window {
|
||||||
dbg!(width);
|
dbg!(width);
|
||||||
dbg!(height);
|
dbg!(height);
|
||||||
let w_conf = xproto::ConfigureWindowAux::default()
|
let w_conf = xproto::ConfigureWindowAux::default()
|
||||||
.x(monitor_width / 2 - width / 2)
|
.x(monitor_x + monitor_width / 2 - width / 2)
|
||||||
.y(monitor_height - height);
|
.y(monitor_y + monitor_height - height);
|
||||||
let conn = X11_CONN.get().expect("Failed to get X11_CONN");
|
let conn = X11_CONN.get().expect("Failed to get X11_CONN");
|
||||||
|
|
||||||
let x11surface = gdk4_x11::X11Surface::xid(
|
let x11surface = gdk4_x11::X11Surface::xid(
|
||||||
|
|
@ -140,7 +139,10 @@ impl Window {
|
||||||
} else {
|
} else {
|
||||||
println!("failed to get X11 window");
|
println!("failed to get X11 window");
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
s.connect_height_notify(surface_resize_handler.clone());
|
||||||
|
s.connect_width_notify(surface_resize_handler.clone());
|
||||||
|
s.connect_scale_factor_notify(surface_resize_handler);
|
||||||
} else {
|
} else {
|
||||||
println!("failed to get X11 window");
|
println!("failed to get X11 window");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue