How to Query X11 Display Resolution

How to query X11 display resolution?

Check out display macros and screen macros from the Xlib manual.

Specifically:

  • From the first link: ScreenCount(), ScreenOfDisplay()
  • From the second link: WidthOfScreen(), HeightOfScreen()

What values do root_x_return and root_y_return in XQueryPointer function represent?

Yes. From the Xlib documentation:

Each window and pixmap has its own coordinate system. The coordinate system has the X axis horizontal and the Y axis vertical with the origin [0, 0] at the upper-left corner. Coordinates are integral, in terms of pixels, and coincide with pixel centers. For a window, the origin is inside the border at the inside, upper-left corner.

Is a monitor in Gtk3 the same as a Screen in X11?

A monitor is a physical device. A screen is a logical device, possibly complete with its own keyboard and pointer (mouse). A screen can span multiple monitors.

Normally there is only one screen (one keyboard, one mouse) on a personal computer, even if there are multiple monitors. Multiple screens are of limited utility for a PC as it is not possible to move windows between screens. A multi-screen setup works best for a multi-user machine where each user gets his own monitor, keyboard and mouse.

There is another variant of multi-screen setup where one can move the mouse pointers between screens (and so there is one mouse and one keyboard), but windows are still confined to their screens. This variant us thoroughly obsolete.

A display is a network server that can manage one or more screens (on a typical PC, just one screen).

How to get screen resolution in C++?

#include "wtypes.h"
#include <iostream>
using namespace std;

// Get the horizontal and vertical screen sizes in pixel
void GetDesktopResolution(int& horizontal, int& vertical)
{
RECT desktop;
// Get a handle to the desktop window
const HWND hDesktop = GetDesktopWindow();
// Get the size of screen to the variable desktop
GetWindowRect(hDesktop, &desktop);
// The top left corner will have coordinates (0,0)
// and the bottom right corner will have coordinates
// (horizontal, vertical)
horizontal = desktop.right;
vertical = desktop.bottom;
}

int main()
{
int horizontal = 0;
int vertical = 0;
GetDesktopResolution(horizontal, vertical);
cout << horizontal << '\n' << vertical << '\n';
return 0;
}

Source: http://cppkid.wordpress.com/2009/01/07/how-to-get-the-screen-resolution-in-pixels/

How to get the screen & height width using c?

That is simply not possible to answer as a "pure C" question; there is no "screen" in C, i.e. the language and its standard library never assumes that there is any kind of screen-like output device available.

You need to settle for a suitable library for a portable solution, or figure out how to talk directly to your target environment.

Identifying that a resolution is virtual on a X11 screen by it's API (or extensions)

Read this: http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt

You need to learn the difference between "screen", "output" and "crtc". You need to check the modes available for each of the outputs you want to use, and then properly set the modes you want on the CRTCs, associate the CRTCs with the outputs, and then make the screen size fit the values you set on each output.

Take a look at the xrandr source code for examples: http://cgit.freedesktop.org/xorg/app/xrandr/tree/xrandr.c

How do I get monitor resolution in Python?

On Windows:

from win32api import GetSystemMetrics

print("Width =", GetSystemMetrics(0))
print("Height =", GetSystemMetrics(1))

If you are working with high resolution screen, make sure your python interpreter is HIGHDPIAWARE.

Based on this post.

Recreating display output from X11 Stream

What you see from your connection is only your connection requests + events relevant to the windows created by you ( or other's client windows where your connection sets an event mask ), and because of that quite a lot is lost. I'm not aware of the programs that can reconstruct best possible version of the screen from one client traffic but it's certainly not possible to have 100% accurate copy of the screen and best possible model will be far away from real screen (unless your connection periodically polls for backing store content of each mapped window).



Related Topics



Leave a reply



Submit