x11 - how to keep window at fixed position

2019-09-09 22:15发布

问题:

I develop a plugin for Compiz (window manager). A window manager is run by xfce on my test machine. I have two monitors which are set vertically (top 1920x1080+0+0, bottom 1920x1080+0+1080). A bottom monitor is set as a primary monitor. This option (primary monitor) is available for example in nvidia-settings. In my code I can use xlib function XConfigureWindow when I want to set a top left corner of the game window at position [0,0]. This works fine, but when a window is in the fullscreen mode (covers two monitors) and get a focus it sometimes changes a position. Then the new position of the top left corner starts at 0, 1080 and I can only see half of the window. Maybe that behaviour is connected with the primary screen option. What the primary screen mean for x11 window system ? I'm not allowed to change that option. How to keep a window at fixed position ? Is there any xlib function or a flag which I can use ?

回答1:

Window manager will not be able to do anything to a window created with this option.

// Create a window : 
window = XCreateSimpleWindow(dpy, RootWindow(dpy, 0), 
            win_X, win_Y, win_width,
            win_height, 0, 0, 0);

// Set non managed window
XSetWindowAttributes set_attr;
set_attr.override_redirect = True;
XChangeWindowAttributes(dpy, window, CWOverrideRedirect, &set_attr);

// Map the window on screen
XMapWindow(dpy, window);


标签: x11 xfce compiz