diff --git a/src/window.rs b/src/window.rs index 02bdc187..ee43cc8f 100644 --- a/src/window.rs +++ b/src/window.rs @@ -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, diff --git a/src/x.rs b/src/x.rs index 0970f9b3..74ef039e 100644 --- a/src/x.rs +++ b/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( 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 _); +}