x11/xlib XCreateSimpleWindow 在多个 X 服务器上

发布于 2024-10-17 21:54:29 字数 737 浏览 6 评论 0原文

我正在尝试按照本教程使用 xlib 进行编程 http://tronche.com/gui/x/ xlib/

这是我到目前为止编写的代码

  display = XOpenDisplay(NULL);
  screen  = XDefaultScreen(display);
  width   = 640;
  height  = 480;

  XLockDisplay(display);
  fullscreen = 0;
  window[0] = XCreateSimpleWindow(display, XDefaultRootWindow(display),
                                  0, 0, width, height, 0, 0, 0);
  window[1] = XCreateSimpleWindow(display, XDefaultRootWindow(display),
                                  0, 0, width, height, 0, 0, 0);

,但我不明白这一点:在具有两个 X11 服务器(两个 GPU)而没有 xinerama 的系统上,如果我希望 window[0] 转到第一个xserver和第二个xserver,我应该调用什么函数? 我想我对显示器、屏幕、窗口感到困惑......

感谢您的帮助

I'm trying to follow this tutorial for programming with xlib http://tronche.com/gui/x/xlib/

this is the code i've written so far

  display = XOpenDisplay(NULL);
  screen  = XDefaultScreen(display);
  width   = 640;
  height  = 480;

  XLockDisplay(display);
  fullscreen = 0;
  window[0] = XCreateSimpleWindow(display, XDefaultRootWindow(display),
                                  0, 0, width, height, 0, 0, 0);
  window[1] = XCreateSimpleWindow(display, XDefaultRootWindow(display),
                                  0, 0, width, height, 0, 0, 0);

however i don't understand this: on a system with two X11 servers (two gpus) without xinerama, if i want that window[0] goes to the first xserver and the second xserver, what functions should i call?
I think i'm confused about display, screen, window....

thanks for any help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

绮筵 2024-10-24 21:54:29

嵌套如下:

  • X 服务器(也称为显示器)是您使用 X11 协议进行通信的对象。 XID(例如窗口 ID、GC ID、像素图 ID 等)在显示器内是唯一的。传统上,显示器有一个键盘和一个鼠标,但现在变得更加复杂。

  • X 屏幕与根窗口一一对应。根窗口是没有父窗口(窗口树的根)的窗口。所有非根窗口都是根窗口的子窗口(或子窗口的子窗口等)。

  • 窗口是屏幕内的矩形区域。窗口以分层树的形式排列,其中父窗口剪切其子窗口(子窗口可以完全或部分位于父窗口的范围之外,但只有父窗口内部的部分可见)。 (“矩形”是一个小谎言,您确实可以应用形状蒙版,但暂时忘记它。)

  • 物理显示器可能对应也可能不对应于屏幕。 TwinView 和 Xinerama 是将一个屏幕扩展到两个或多个显示器的功能的名称。每个监视器可以是它自己的屏幕,也可以是多监视器屏幕的一部分。

传统上,窗口不能移动到不同的屏幕,因为屏幕可能具有不同的硬件属性(例如不同的位深度)。使用 TwinView 或 Xinerama,您可以在显示器之间移动窗口,但不能在每个显示器上移动一个屏幕。显示器上的所有屏幕共享相同的输入设备(鼠标和键盘)。

The nesting is as follows:

  • X server (also known as a display) is the thing you talk to with the X11 protocol. An XID (such as a window ID, GC ID, pixmap ID, etc.) will be unique within a display. Traditionally a display has one keyboard and one mouse, though it's more complex these days.

  • an X screen corresponds 1-to-1 with a Root Window. A root window is a window with no parent (root of the window tree). All non-root windows are children (or children of children, etc.) of the root window.

  • a window is a rectangular area within a screen. Windows are arranged in a hierarchical tree, where parent windows clip their children (child windows can be located entirely or partially outside the extents of the parent, but only the part inside the parent is visible). ("Rectangular" is a slight lie, you can really apply a shape mask, but forget it for now.)

  • a physical monitor may or may not correspond to a screen. TwinView and Xinerama are names for features that extend one screen across two or more monitors. Each monitor can be its own screen or can be a part of a multi-monitor screen.

Traditionally, windows cannot be moved to a different screen, because screens could have different hardware properties (such as different bit depths). With TwinView or Xinerama you can move windows around among monitors, with screen-per-monitor you can't. All screens on a display share the same input devices though (mouse and keyboard).

蓝咒 2024-10-24 21:54:29

如果它们确实是两个不同的 X 服务器(请参阅 Havoc 的解释),那么您需要执行以下操作:

Display displays[2];

displays[0] = XOpenDisplay(":0.0");
displays[1] = XOpenDisplay(":1.0");

[...]

window[0] = XCreateSimpleWindow(displays[0], XDefaultRootWindow(displays[0]),
                                0, 0, width, height, 0, 0, 0);
window[1] = XCreateSimpleWindow(displays[1], XDefaultRootWindow(displays[1]),
                                0, 0, width, height, 0, 0, 0);

如果它们是同一 X 服务器上的不同 X 屏幕,则显示将为 :0.0 和 :0.1 代替。 (这都是假设最简单的情况,只有这些 X 服务器,其他 VT 上没有额外的 X 服务器或 Xvfb、Xnest 或 Xephyr 等虚拟 X 服务器。)

当然,任何严肃的 GUI 编程都可以使用 GTK+ 等工具包来完成或 Qt,
不是原始 Xlib 调用。

If they are indeed two different X servers (see Havoc's explanation for that), then you would need to do something like:

Display displays[2];

displays[0] = XOpenDisplay(":0.0");
displays[1] = XOpenDisplay(":1.0");

[...]

window[0] = XCreateSimpleWindow(displays[0], XDefaultRootWindow(displays[0]),
                                0, 0, width, height, 0, 0, 0);
window[1] = XCreateSimpleWindow(displays[1], XDefaultRootWindow(displays[1]),
                                0, 0, width, height, 0, 0, 0);

If they're different X screens on the same X server, then the displays would be :0.0 and :0.1 instead. (And that's all assuming the simplest case of just those X servers, without additional X servers on other VT's or virtual X servers like Xvfb, Xnest, or Xephyr.)

Of course, any serious GUI programming would be done with a toolkit such as GTK+ or Qt,
not raw Xlib calls.

谷夏 2024-10-24 21:54:29

在给出的答案之上,看一下 DMX(分布式多头),它允许将多个 X 服务器/屏幕组合成一个大屏幕,由一个单独的 X 服务器提供服务,该服务器将命令分派到其从属服务器。

http://dmx.sourceforge.net/

Above the given answers, take a look on DMX (distributed multihead) which allows one to combine multiple X servers/screens into one large screen, served by a separate X server that dispatches the commands to its slave servers.

http://dmx.sourceforge.net/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文