In C, how to get the geometry (x, y, width, height) of the active monitor within the screen using X11

谁说我不能喝 提交于 2019-12-02 10:29:21
n.m.

You need to use the RandR extension API. Get the source code of the xrandr utility and steal what you need from there. You need XRRGetMonitors function and related data structures. You can also use xrandr to get the information you need on the command line.

I don't know if there's ever such thing as active monitor, because an active window can span several monitors, and a pointer can be in another monitor still. Anyway, the XRRMonitorInfo structure contains all the information about your monitor geometry, including its size (in pixels and mm) and its position on the logical screen, so you can extract a monitor description from a pair of screen coordinates.

See also this answer.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!