WIP set position (not working)
This commit is contained in:
parent
7fbbefa134
commit
2020885cce
2 changed files with 24 additions and 3 deletions
|
|
@ -40,10 +40,15 @@ pub fn window(monitor: gdk::Monitor) -> gtk4::Window {
|
|||
window.set_size_request(geometry.width, 0);
|
||||
|
||||
if let Some((display, surface)) = x::get_window_x11(&window) {
|
||||
let top: x::c_ulong = 32;
|
||||
let top: x::c_ulong = 32; // XXX arbitrary
|
||||
let top_start_x = geometry.x as x::c_ulong;
|
||||
let top_end_x = top_start_x + geometry.width as x::c_ulong;
|
||||
let top_end_x = top_start_x + geometry.width as x::c_ulong - 1;
|
||||
|
||||
println!("{} {}", top_start_x, top_end_x);
|
||||
|
||||
unsafe {
|
||||
x::set_position(&display, &surface, top_start_x as _, 0);
|
||||
|
||||
x::change_property(
|
||||
&display,
|
||||
&surface,
|
||||
|
|
|
|||
18
src/x.rs
18
src/x.rs
|
|
@ -3,7 +3,7 @@ use glib::translate::ToGlibPtr;
|
|||
use gtk4::{glib, prelude::*};
|
||||
use std::{
|
||||
ffi::{CString, NulError},
|
||||
os::raw::c_int,
|
||||
os::raw::{c_int, c_long},
|
||||
};
|
||||
|
||||
pub use std::os::raw::{c_uchar, c_ulong, c_ushort};
|
||||
|
|
@ -135,3 +135,19 @@ pub unsafe fn change_property<T: XProp>(
|
|||
value.nelements(),
|
||||
);
|
||||
}
|
||||
|
||||
pub unsafe fn set_position(
|
||||
display: &gdk4_x11::X11Display,
|
||||
surface: &gdk4_x11::X11Surface,
|
||||
x: c_int,
|
||||
y: c_int,
|
||||
) {
|
||||
// XXX check error return value
|
||||
let hints = xlib::XAllocSizeHints();
|
||||
let mut supplied: c_long = 0;
|
||||
xlib::XGetWMNormalHints(display.xdisplay(), surface.xid(), hints, &mut supplied);
|
||||
(*hints).x = x;
|
||||
(*hints).y = y;
|
||||
xlib::XSetWMNormalHints(display.xdisplay(), surface.xid(), hints);
|
||||
xlib::XFree(hints as *mut _);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue