简体   繁体   English

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

[英]x11/xlib XCreateSimpleWindow over multiple X servers

I'm trying to follow this tutorial for programming with xlib http://tronche.com/gui/x/xlib/ 我正在尝试按照本教程使用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? 但是我不明白这一点:在具有两个X11服务器(两个GPU)且没有xinerama的系统上,如果我希望window [0]转到第一个xserver和第二个xserver,我应该调用什么功能? I think i'm confused about display, screen, window.... 我认为我对显示,屏幕,窗口感到困惑。

thanks for any help 谢谢你的帮助

The nesting is as follows: 嵌套如下:

  • X server (also known as a display) is the thing you talk to with the X11 protocol. X服务器(也称为显示器)是您与X11协议进行对话的对象。 An XID (such as a window ID, GC ID, pixmap ID, etc.) will be unique within a display. XID(例如窗口ID,GC ID,像素图ID等)在显示器中将是唯一的。 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. X屏幕与根窗口一对一对应。 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. TwinView和Xinerama是将一个屏幕延伸到两个或更多显示器的功能的名称。 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. 使用TwinView或Xinerama,您可以在监视器之间移动窗口,而不能使用每个监视器的屏幕。 All screens on a display share the same input devices though (mouse and keyboard). 显示屏上的所有屏幕都共享相同的输入设备(鼠标和键盘)。

If they are indeed two different X servers (see Havoc's explanation for that), then you would need to do something like: 如果它们确实是两个不同的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);

If they're different X screens on the same X server, then the displays would be :0.0 and :0.1 instead. 如果它们是同一台X服务器上的不同X屏幕,则显示将改为:0.0:0.1 (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.) (这全都是假设最简单的情况,即那些X服务器,而其他VT或虚拟X服务器(例如Xvfb,Xnest或Xephyr)上没有其他X服务器。)

Of course, any serious GUI programming would be done with a toolkit such as GTK+ or Qt, not raw Xlib calls. 当然,任何认真的GUI编程都可以使用GTK +或Qt之类的工具包完成,而不是原始Xlib调用。

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. 在给出的答案上方,看一下DMX(分布式多头),它允许将多个X服务器/屏幕组合成一个大屏幕,并由单独的X服务器提供服务,该X服务器将命令分发给其从属服务器。

http://dmx.sourceforge.net/ http://dmx.sourceforge.net/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM