Xlib: DisplayWidth / DisplayHeight

Zbigniew zbigniew2011 at gmail.com
Fri Sep 8 18:59:37 UTC 2023

> If you are doing this for open source project, you should change your code
> to:
>  [..]

The code you've pasted doesn't work properly; it returns the size of
virtual screen — so you added 3x as much lines to get, in effect, the
same (incorrect) result as the few lines I pasted.

> Oh, and no I don't actually know what you mean, because it depends on what
> application you are writing.

Whatever it could be — an useful tool, or a silly game, open-source,
or commercial — it needs to find out the exact physical screen's
dimensions (in pixels), to learn how big is the working area.

> If you do teleconferencing, you might want to capture either the entire
> screen, or some window.
> If you want to record a movie of a game playing fullscreen, than you
> probably need the position and dimensions of the game window, because
> games often change video mode while keeping original virtual screen
> intact.
> If you want to make a better Xvnc, you probably need the code above and
> you might not need xrandr.
> If you are doing something else - who knows what you mean ?

So now you see (I hope that you see): „if… if… if… if… else…” etc. A
whole lot of checks and decisions that could be avoided, _IF_ the two
macros were working properly

More information about the xorg mailing list