I'm using the x11cb library, used to interact with the x11 server using Rust.
use std::error::Error;
use x11rb::connection::Connection;
use x11rb::protocol::xproto::*;
use x11rb::COPY_DEPTH_FROM_PARENT;
fn main() -> Result<(), Box<dyn Error>> {
// Open the connection to the X server. Use the DISPLAY environment variable.
let (conn, screen_num) = x11rb::connect(None)?;
// Get the screen #screen_num
let screen = &conn.setup().roots[screen_num];
// Ask for our window's Id
let win = conn.generate_id()?;
// Create the window
conn.create_window(
COPY_DEPTH_FROM_PARENT, // depth (same as root)
win, // window Id
screen.root, // parent window
200, // x
200, // y
150, // width
150, // height
10, // border width
WindowClass::INPUT_OUTPUT, // class
screen.root_visual, // visual
&Default::default(),
)?; // masks, not used yet
// Map the window on the screen
conn.map_window(win)?;
// Make sure commands are sent before the sleep, so window is shown
conn.flush()?;
std::thread::sleep(std::time::Duration::from_secs(10));
Ok(())
}
The window resizes if I change the width
and height
parameters. However, the window doesn't change positions if I modify the x
and y
parameters.
What could be the reason?
Note: I'm using Ubuntu 22.10 with X11 and NVIDIA propetary drivers.
Update:
For some reason, this successfully repositions the window (but don't know why modifying x
and y
in create_window
doesn't):
let values = ConfigureWindowAux::default().x(500).y(200);
conn.configure_window(win, &values)?;