gdk_screen_get_monitor_width_mm returns -1

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

 



Hi,

I'm trying to get the size of a monitor via gdk, but I always get -1
when measuing the size of a single monitor.

With the attached code, I get this result when using multi-monitor

Display has 2 screens
    Screen 0: 524mm x 1200mm --  has 1 monitors
        Monitor 0: 1920 x 1200 -- -1mm x -1mm
    Screen 1: 382mm x 1024mm --  has 1 monitors
        Monitor 0: 1280 x 1024 -- -1mm x -1mm

And this result when using xinerama

Display has 1 screens
    Screen 0: 873mm x 1200mm --  has 2 monitors
        Monitor 0: 1920 x 1200 -- -1mm x -1mm
        Monitor 1: 1280 x 1024 -- -1mm x -1mm

This does not change when I put some DisplaySize in the monitors
section in xorg.conf.

Is this a known bug? Or am I missing something?

Thanks

Oscar Lazzarino
#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 nMonitors;

		screen = gdk_display_get_screen(display, i);
		screen_w = gdk_screen_get_width_mm(screen);
		screen_h = gdk_screen_get_height(screen);
		nMonitors = gdk_screen_get_n_monitors(screen);

		printf("    Screen %d: %dmm x %dmm --  has %d monitors\n", i, screen_w, screen_h, nMonitors);
		for (j=0; j<nMonitors; j++)
		{
			GdkRectangle monitor_rect;
			int monitor_w, monitor_h;
			gdk_screen_get_monitor_geometry(screen, j, &monitor_rect);
			monitor_w = gdk_screen_get_monitor_width_mm(screen, j);
			monitor_h = gdk_screen_get_monitor_height_mm(screen, j);

			printf("        Monitor %d: %d x %d -- %dmm x %dmm\n", j,
					monitor_rect.width, monitor_rect.height,
					monitor_w, monitor_h);
		}
	}
}
_______________________________________________
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