How to make X11 window span multiple monitors

时光怂恿深爱的人放手 提交于 2019-12-28 04:20:49

问题


I'm trying to use XResizeWindow() to make a window which will span 2 monitors, but the ?window manager? is limiting it to one.

Is there a hint or property I can associate with the window to tell the WM not to limit it?

For my test case, I have two 1600x1200 monitors that nVidia is presenting as one 3200x1200 screen to KDE4. XDisplayWidth(display, 0); returns 3200 and XDisplayHeight(display, 0); returns 1200.

When I call

XCreateWindow(display, DefaultRootWindow(display),
              220, 0, 1700, 930,
              1, DefaultDepth(display,screen),
              InputOutput, CopyFromParent,
              CWCursor, &attributes);

for a window 1700x930 at 220,0 I get a window 1593x930 at 0,0, keeping it entirely on the left monitor. Any XResizeWindow larger than that gets shrunk to 1593. (I assume the 7 pixels are window decoration, which is fine.)

But, if I then XMoveWindow(display, win, 800, 0), it will move the window to span the screens, and I can then enlarge it up to 3200 wide (minus a few pixels).

Is there anything I can do to tell the window manager, or whoever is doing this, not to limit the window to a single monitor, and let me use the entire screen?

Thanks!

%xrandr -q --verbose
xrandr: Failed to get size of gamma for output default
Screen 0: minimum 3200 x 1200, current 3200 x 1200, maximum 3200 x 1200
default connected 3200x1200+0+0 (0x161) normal (normal) 0mm x 0mm
    Identifier: 0x160
    Timestamp:  64409661
    Subpixel:   unknown
    Clones:    
    CRTC:       0
    CRTCs:      0
    Transform:  1.000000 0.000000 0.000000
                0.000000 1.000000 0.000000
                0.000000 0.000000 1.000000
               filter: 
3200x1200 (0x161)  192.0MHz *current
    h: width  3200 start    0 end    0 total 3200 skew    0 clock   60.0KHz
    v: height 1200 start    0 end    0 total 1200           clock   50.0Hz

回答1:


In general, an application should not try to rigidly control its window size and position, as WM is supposed to be smart and place the windows in the best possible fashion. If you want control anyway, try using XSizeHints like this:

XSizeHints sh;
sh.width = sh.min_width = 1700;
sh.height = sh.min_height = 930;
sh.h = 220;
sh.y = 0;
sh.flags = PSize | PMinSize | PPosition;
XSetWMNormalHints(dpy, win, &sh);
XMapWindow(dpy, win);

WMs will respect min_width and will not shrink the window smaller than this.

If you need a fullscreen window spanning multiple monitors, this is done differently, with _NET_WM_FULLSCREEN_MONITORS property. See here.



来源:https://stackoverflow.com/questions/17114738/how-to-make-x11-window-span-multiple-monitors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!