如何让 X11 窗口跨越多个显示器 [英] How to make X11 window span multiple monitors

查看:23
本文介绍了如何让 X11 窗口跨越多个显示器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 XResizeWindow() 来创建一个跨越 2 个显示器的窗口,但是?窗口管理器?将其限制为一个.

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

有没有我可以与窗口关联的提示或属性来告诉 WM 不要限制它?

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

对于我的测试用例,我有两个 1600x1200 显示器,nVidia 将它们作为一个 3200x1200 屏幕呈现给 KDE4.XDisplayWidth(display, 0);返回 3200 和 XDisplayHeight(display, 0);返回 1200.

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.

当我打电话

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

对于 220,0 处的 1700x930 窗口,我在 0,0 处得到一个 1593x930 的窗口,将其完全保留在左侧监视器上.任何大于它的 XResizeWindow 都会缩小到 1593.(我假设 7 个像素是窗口装饰,这很好.)

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.)

但是,如果我然后 XMoveWindow(display, win, 800, 0),它将移动窗口以跨越屏幕,然后我可以将其放大到 3200 宽(减去几个像素).

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?

谢谢!

%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

推荐答案

一般来说,应用程序不应试图严格控制其窗口大小和位置,因为 WM 应该是智能的,并以最佳方式放置窗口.如果您仍然想要控制,请尝试像这样使用 XSizeHints:

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 会尊重 min_width 并且不会缩小比这个更小的窗口.

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

如果您需要跨多个显示器的全屏窗口,则使用_NET_WM_FULLSCREEN_MONITORS 属性进行不同的处理.请参阅此处.

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

这篇关于如何让 X11 窗口跨越多个显示器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆