Re: What is a GdkScreen?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/02/2010 08:01 PM, Robert Pearce wrote:
Hi Johannes,

On Tue, 2 Nov 2010 20:25:12 +1000 you wrote:

If I understand correctly, a GdkDisplay is basically an X server
instance. A monitor is, well, a monitor. GdkScreen is supposed to be
somewhere in the middle.

So, if I understand right (which is by no means certain), a GdkScreen
is the display area you can drag a window over, rather than having to
plonk it onto another screen by other means.


That's correct. A GdkDisplay is an X server instance. A single display can manage more than one GdkScreen, and a screen can overlap more than one GdkMonitor.

With two monitors you can have one X server with "traditional" multi-monitor, which is two screens, one for each monitor, or you can configure it with Xinerama, which will give you a single screen spanning the two monitors.

By running the attached code on a dual monitor setup (two 1920x1200 monitors), you can obtain the following results, depending on whether you have Xinerama or not

Display has 2 screens
    Screen 0: 1920 x 1200 -- has 1 monitors
        Monitor 0: 1920 x 1200
    Screen 1: 1920 x 1200 -- has 1 monitors
        Monitor 0: 1920 x 1200

And this result when using xinerama

Display has 1 screens
    Screen 0: 3840 x 1200 --  has 2 monitors
        Monitor 0: 1920 x 1200
        Monitor 1: 1920 x 1200

O.
#include <gtk/gtk.h>
#include <stdio.h>

int main(int argc, char *argv[])
{
	int nScreens;
	int i, j;
	GdkDisplay *display;

	gtk_init (&argc, &argv);

	display = gdk_display_get_default();
	nScreens = gdk_display_get_n_screens(display);
	printf("Display has %d screens\n", nScreens);

	for (i=0; i<nScreens; i++)
	{
		GdkScreen *screen;
		GdkRectangle screen_rect;
		int screen_w, screen_h;
		int screen_w_px, screen_h_px;
		int nMonitors;

		screen = gdk_display_get_screen(display, i);
		screen_w_px = gdk_screen_get_width(screen);
		screen_h_px = gdk_screen_get_height(screen);
		nMonitors = gdk_screen_get_n_monitors(screen);

		printf("    Screen %d: %d x %d -- has %d monitors\n",
				i,
				screen_w_px, screen_h_px,
				nMonitors);
		for (j=0; j<nMonitors; j++)
		{
			GdkRectangle monitor_rect;
			gdk_screen_get_monitor_geometry(screen, j, &monitor_rect);

			printf("        Monitor %d: %d x %d\n",
				   	j,
					monitor_rect.width, monitor_rect.height);
		}
	}
}

_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux