X11 / GLX - 全屏模式? [英] X11/GLX - Fullscreen mode?
问题描述
我正在尝试创建一个Linux应用程序 - 在这种情况下是一个屏幕保护程序 - 并且显然难以找到关于使窗口全屏的简单任务的信息。即使现有屏幕的代码也没有提到它们如何管理它,我还没有看到任何明显的功能,如 XRemoveDecoration()
。
I am trying to create a Linux application - a screensaver, in this case - and it is proving remarkably difficult to find information on the simple task of making a window full-screen. Even the code of existing screensavers makes no mention of how they manage it, and I've yet to see any obvious function like XRemoveDecoration()
.
经过多次摸索,我设法创建一个与桌面大小相同的窗口,具有:
After much fumbling around, I did manage to create a window that's the same size as the desktop, with this:
Window win = DefaultRootWindow(disp);
XWindowAttributes getWinAttr;
XGetWindowAttributes(disp, win, &getWinAttr);
win = XCreateWindow(disp, win, 0, 0, getWinAttr.width, getWinAttr.height, 0, vInfo->depth, InputOutput, vInfo->visual, CWBorderPixel|CWColormap|CWEventMask|CWOverrideRedirect, &winAttr );
但是,这不会消除标题栏和边框。我知道有一种方式,显然 - 但我还没有找到任何东西,甚至指向那个方向,不依赖于一些其他大规模的图书馆被抛在顶部(现有的屏保绝对不使用)。
But that doesn't do anything to get rid of the titlebar and borders. I know there's a way, obviously - but I have yet to find anything even pointing in that direction that doesn't rely on some other massive library being thrown on top (which existing screensavers are definitely not using).
编辑:请不要从我的信息中删除信息。有一个很好的理由,我明确指出,现有的屏幕保护程序没有使用可选的库,这是因为我一直在分析源代码大多数的过去一天。
Please don't remove information from my posts. There is a very good reason I explicitly pointed out that existing screensavers aren't using optional libraries, and that is because I have been analyzing source code for most of the past day.
我选择了最直接回答问题的答案,并且适用于一般的应用程序。
I have chosen the answer that most directly answers the question, and applies to applications in general.
如果您发现此问题研究xscreensavers ...适用。是的,xscreensaver有自己的API - 这是复杂的,实际上涉及编写更多的代码行(是的,认真)。如果您希望在屏幕保护程序中使用OpenGL,则需要通过另一个 API(xlockmore,竞争系统)和兼容层,将其转换为xscreensaver。
If you have found this question researching xscreensavers... the same still applies. Yes, xscreensaver has its own API - which is complicated, and actually involves writing more lines of code (yes, seriously). If you want OpenGL in your screensaver, you'll need to go through another API (xlockmore, a competing system) and a compatibility layer that translates it to xscreensaver.
但是,xscreensaver能够运行任何可以使用虚拟根窗口(查看vroot.h)作为屏幕保护程序的任何程序。所以我的建议是,只是这样做 - 你会有更多的控制,没有限制的API,更大的可移植性。 (一个例子我看了甚至可以编译为Linux或Windows,用同一个文件!)
However, xscreensaver is capable of running any program that can use virtual root windows (look into vroot.h) as a screensaver. So my advice is to just do that - you'll have more control, no limiting API, and greater portability. (One example I looked at can even compile for Linux or Windows, with the same file!)
推荐答案
窗口管理器:
XSetWindowAttributes wa;
wa.override_redirect = True;
XCreateWindow( ..., &wa );
这篇关于X11 / GLX - 全屏模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!