如何在不同的 X11 会话中打开窗口?

发布于 2024-07-21 12:40:55 字数 1459 浏览 15 评论 0原文

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

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

发布评论

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

评论(4

风吹雨成花 2024-07-28 12:40:55

我对这个问题有点不清楚,但这里有一个假设的设置:

我坐在我的计算机上(我们将其称为根会话)并且我有一个 shell。 在本例中,环境变量 DISPLAY 的值为“127.0.0.1:0.0”。

第二次会议开始。 您需要知道这台机器上的显示变量是什么。 如果它也在本地主机上,则可能类似于“127.0.0.1:1.0”。 如果您在另一台主机上执行“echo $DISPLAY”,它会告诉您这一点。 如果它报告“:1.0”或没有“127.0.0.1”的内容,那没关系。 如果未指定地址,则隐含本地主机。

接下来,在返回根会话之前,您需要运行“xhost”以允许其他源在此主机上显示窗口。 (免责声明:我要告诉您做的事情非常不安全,因此如果您位于不安全的网络上,您可能需要阅读 xhost 的手册页)。 在另一个显示器上的 xterm 中键入“xhost +”。 该命令(特别是“+”选项)允许任何主机在此显示器上弹出窗口。

因此,您所要做的就是返回根会话 shell 并(我假设是 bash)运行“export DISPLAY="127.0.0.1:1.0”。然后运行“xterm”,这应该会在另一个窗口中弹出窗口 我希望

这会有所帮助。

如果其中任何一个不清楚,

I am a little unclear on the question, but here's a hypothetical setup:

I am sitting on my computer (we'll call that the root session) and I have a shell. In this case there is an environment variable DISPLAY with the value "127.0.0.1:0.0".

A second session is started. You'll need to know what the display variable is on this machine. If it's also on the localhost it may be something like "127.0.0.1:1.0". If you do an "echo $DISPLAY" on the other host it will tell you this. If it reports ":1.0" or something without the "127.0.0.1" that's okay. The localhost is implied if an address is not specified.

Next, before going back to the root session you'll need to run "xhost" to allow other sources to display windows on this host. (Disclaimer: What I'm going to tell you to do is horribly insecure so you may want to read the man page for xhost if you are on an insecure network). Type "xhost +" in an xterm on the other display. This command (in particular the "+" option) allows any host to pop up windows on this display.

So then all you have to do is go back to your root session shell and (I assume bash) run "export DISPLAY="127.0.0.1:1.0". Then run "xterm", which should have the window popping up in the other session.

I hope this helps.

You might do a search for "X windows DISPLAY variable" if any of this is unclear.

暮光沉寂 2024-07-28 12:40:55

这取决于您正在编程的级别 - 如果您直接调用 Xlib,我想您知道 XCreateWindow 的第一个参数是 Display * 并且当然,这就是告诉 X11 在哪里创建窗口的方式。 http://tronche.com/gui/x/xlib/window/XCreateWindow。 html 了解详细信息,以防有帮助。

如果您正在使用其他语言/框架/等,那么如果您提到它们是哪些,将会有所帮助。

It depends at what level you're programming -- if you're calling directly into Xlib, I imagine you know that the first argument to XCreateWindow is a Display * and of course that's how you tell X11 where to create the window. http://tronche.com/gui/x/xlib/window/XCreateWindow.html for details in case it helps.

If it's other languages/frameworks/etc that you're using, it would help if you mentioned which ones they are.

眼泪也成诗 2024-07-28 12:40:55

您需要像这样设置DISPLAY环境变量:

DISPLAY=host:0.0

请参阅 X 联机帮助页 了解更多详细信息。

You need to set the DISPLAY environment variable like this:

DISPLAY=host:0.0

See the X manpage for more details.

微凉 2024-07-28 12:40:55

$DISPLAY 功能的 编程接口>xlib 似乎被称为 XOpenDisplay()。 您需要管理两个(或更多)Display 对象。

各种更高级别的接口工具包(qt,...)可能提供更抽象的接口。 这将为您省去相当大的痛苦。

祝你好运。

The programmatic interface to this $DISPLAY functionality in xlib appears to be called XOpenDisplay(). You'll need to manage two (or more) Display objects.

It is possible that the various higher level interface toolkits (qt, ...) provide a more abstracted interface. That would save you considerable pain.

Good luck.

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