是否有可靠的方法来以编程方式确定窗口管理器已完全初始化?
我想运行一个最小的 X 会话,仅使用一个窗口管理器和一个全屏程序。最明显的方法是在 .xinitrc 中添加类似的内容:
metacity & # this could be any window manager
exec my-fullscreen-app
但由于这些是并行启动的,因此存在一些竞争条件。我不希望我的应用程序在窗口管理器准备就绪之前出现,因为这样就会将其窗口大小明显调整为全屏模式。我想确保窗口管理器已首先完成初始化。
我想出的最好的办法是这样的:
metacity &
while ! xprop -root | grep -q _NET_SUPPORTING_WM_CHECK
do
sleep 0.1
done
sleep 0.3
exec my-fullscreen-app
但是仅仅因为在根窗口上设置了 _NET_SUPPORTING_WM_CHECK 并不一定意味着 WM 真正准备好了,并且之后的 0.3 秒睡眠是一个可能很严重的混乱在某些系统上过度杀伤,而在其他系统上可能完全不够。
那么有没有更好的方法来可靠地感知窗口管理器已完全初始化呢?
I want to run a minimal X session with just a window manager and a single fullscreen program. The obvious way to do this is by putting something like this in .xinitrc:
metacity & # this could be any window manager
exec my-fullscreen-app
But since these are launched in parallel, there's a bit of a race condition. I don't want my app to appear before the window manager is ready, because then there will be a visible resizing of its window to fullscreen mode. I want to make sure the window manager has finished initializing first.
The best I've come up with is something like this:
metacity &
while ! xprop -root | grep -q _NET_SUPPORTING_WM_CHECK
do
sleep 0.1
done
sleep 0.3
exec my-fullscreen-app
But just because _NET_SUPPORTING_WM_CHECK has been set on the root window doesn't necessarily mean that the WM is truly ready, and the 0.3 second sleep after it is a kludge that might be serious overkill on some systems and might be totally inadequate on others.
So is there a better way to reliably sense that the window manager is fully initialized?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简短的回答是否定的,没有办法。
在设置 _NET_SUPPORTING_WM_CHECK 属性后,metacity 尤其还有一些事情要做。
我认为你的方法已经是你能做到的最好的了。
从好的方面来说,除非存在错误,否则比赛不应该产生除装饰效果之外的任何影响。 (即显示的内容并非最终状态)
为了缓解这种情况,您可能需要在映射窗口之前手动将窗口设置为全屏大小。
然后让WM设置大小。
Short answer is no, there's no way.
metacity in particular still has stuff left to do after setting the _NET_SUPPORTING_WM_CHECK property.
I think your approach is about the best you can do.
On the plus side, unless there are bugs, the race should not have any effects other than cosmetic ones. (i.e. things are shown that aren't in their final state)
To mitigate, you might want to set your window to fullscreen size manually before mapping it.
Then let the WM set the size after that.