Xlib:如何向窗口管理器询问最大化的窗口大小? [英] Xlib: How to ask window manager for maximized window size?

查看:40
本文介绍了Xlib:如何向窗口管理器询问最大化的窗口大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的程序窗口尽可能大,而不与窗口管理器的各种小窗口重叠,例如寻呼机.在创建窗口之前,有什么方法可以询问 wm 最大化的窗口大小是多少?

I want my program's window to be as big as possible without overlapping the window manager's various small windows e.g. the pager. Is there any way to ask the wm what the maximized window size is, before I create my window?

推荐答案

_NET_WORKAREA 根窗口的属性可能最接近匹配.但是,在多头系统上,它将为您提供所有显示器上的组合工作区.

_NET_WORKAREA property of the root window is probably closest match. However on a multi-headed system it will give you the combined work area on all monitors.

如果这就是您想要的,那很好(但请参阅 此处关于使窗口跨越多个显示器).如果您想在单个监视器上最大化,那么就会出现问题,因为没有像 _NET_WORKAREA 这样的每个监视器 API.最好的办法是创建一个处于最大化状态的窗口,然后查询其大小.如果这不是一个选项,恐怕您将不得不查询可用监视器的数量和大小,然后通过从整个区域中减去支柱"来计算每个监视器的工作区域(请参阅 此处 关于 _NET_WM_STRUT_NET_WM_STRUT_PARTIAL).

If that's what you want, fine (but see here on making a window span multiple monitors). If you want to maximize over a single monitor, then there's a problem as there's no per-monitor API like _NET_WORKAREA. Your best bet is creating a window in a maximized state and then querying its size. If that's not an option, I'm afraid you will have to query the number and sizes of available monitors, and then go and calculate the work area of each monitor by subtracting "struts" from the full area (see here about _NET_WM_STRUT and _NET_WM_STRUT_PARTIAL).

这篇关于Xlib:如何向窗口管理器询问最大化的窗口大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆