gtk+ r19346 - in trunk: . gdk/win32



Author: tml
Date: Thu Jan 10 21:40:48 2008
New Revision: 19346
URL: http://svn.gnome.org/viewvc/gtk+?rev=19346&view=rev

Log:
2008-01-10  Tor Lillqvist  <tml novell com>

	* gdk/win32/gdkdisplay-win32.c
	* gdk/win32/gdkglobals-win32.c
	* gdk/win32/gdkprivate-win32.h
	* gdk/win32/gdkscreen-win32.c
	* gdk/win32/gdkwindow-win32.c: Implement
	gdk_screen_get_monitor_width_mm(), gdk_screen_get_monitor_height_mm()
	and gdk_screen_get_monitor_plug_name(). Thanks to Kazuki
	Iwamoto. (#505753)



Modified:
   trunk/ChangeLog
   trunk/gdk/win32/gdkdisplay-win32.c
   trunk/gdk/win32/gdkglobals-win32.c
   trunk/gdk/win32/gdkprivate-win32.h
   trunk/gdk/win32/gdkscreen-win32.c
   trunk/gdk/win32/gdkwindow-win32.c

Modified: trunk/gdk/win32/gdkdisplay-win32.c
==============================================================================
--- trunk/gdk/win32/gdkdisplay-win32.c	(original)
+++ trunk/gdk/win32/gdkdisplay-win32.c	Thu Jan 10 21:40:48 2008
@@ -65,9 +65,10 @@
 	      LPARAM   data)
 {
   MONITORINFOEX monitor_info;
+  HDC hDC;
 
   gint *index = (gint *) data;
-  GdkRectangle *monitor;
+  GdkWin32Monitor *monitor;
 
   g_assert (*index < _gdk_num_monitors);
 
@@ -80,10 +81,15 @@
 #define MONITORINFOF_PRIMARY 1
 #endif
 
-  monitor->x = monitor_info.rcMonitor.left;
-  monitor->y = monitor_info.rcMonitor.top;
-  monitor->width = monitor_info.rcMonitor.right - monitor_info.rcMonitor.left;
-  monitor->height = monitor_info.rcMonitor.bottom - monitor_info.rcMonitor.top;
+  monitor->name = g_strdup (monitor_info.szDevice);
+  hDC = CreateDCA ("DISPLAY", monitor_info.szDevice, NULL, NULL);
+  monitor->width_mm = GetDeviceCaps (hDC, HORZSIZE);
+  monitor->height_mm = GetDeviceCaps (hDC, VERTSIZE);
+  DeleteDC (hDC);
+  monitor->rect.x = monitor_info.rcMonitor.left;
+  monitor->rect.y = monitor_info.rcMonitor.top;
+  monitor->rect.width = monitor_info.rcMonitor.right - monitor_info.rcMonitor.left;
+  monitor->rect.height = monitor_info.rcMonitor.bottom - monitor_info.rcMonitor.top;
 
   if (monitor_info.dwFlags & MONITORINFOF_PRIMARY &&
       *index != 0)
@@ -91,7 +97,7 @@
       /* Put primary monitor at index 0, just in case somebody needs
        * to know which one is the primary.
        */
-      GdkRectangle temp = *monitor;
+      GdkWin32Monitor temp = *monitor;
       *monitor = _gdk_monitors[0];
       _gdk_monitors[0] = temp;
     }
@@ -126,7 +132,7 @@
 
       (*p_EnumDisplayMonitors) (NULL, NULL, count_monitor, (LPARAM) &_gdk_num_monitors);
 
-      _gdk_monitors = g_renew (GdkRectangle, _gdk_monitors, _gdk_num_monitors);
+      _gdk_monitors = g_renew (GdkWin32Monitor, _gdk_monitors, _gdk_num_monitors);
 
       index = 0;
       (*p_EnumDisplayMonitors) (NULL, NULL, enum_monitor, (LPARAM) &index);
@@ -136,39 +142,42 @@
 
       /* Calculate offset */
       for (i = 0; i < _gdk_num_monitors; i++)
-	{
-	  _gdk_offset_x = MAX (_gdk_offset_x, -_gdk_monitors[i].x);
-	  _gdk_offset_y = MAX (_gdk_offset_y, -_gdk_monitors[i].y);
-	}
+        {
+          _gdk_offset_x = MAX (_gdk_offset_x, -_gdk_monitors[i].rect.x);
+          _gdk_offset_y = MAX (_gdk_offset_y, -_gdk_monitors[i].rect.y);
+        }
       GDK_NOTE (MISC, g_print ("Multi-monitor offset: (%d,%d)\n",
-			       _gdk_offset_x, _gdk_offset_y));
+                               _gdk_offset_x, _gdk_offset_y));
 
       /* Translate monitor coords into GDK coordinate space */
       for (i = 0; i < _gdk_num_monitors; i++)
-	{
-	  _gdk_monitors[i].x += _gdk_offset_x;
-	  _gdk_monitors[i].y += _gdk_offset_y;
-	  GDK_NOTE (MISC, g_print ("Monitor %d: %dx%d %+d%+d\n",
-				   i, _gdk_monitors[i].width,
-				   _gdk_monitors[i].height,
-				   _gdk_monitors[i].x, _gdk_monitors[i].y));
-	}
+        {
+          _gdk_monitors[i].rect.x += _gdk_offset_x;
+          _gdk_monitors[i].rect.y += _gdk_offset_y;
+          GDK_NOTE (MISC, g_print ("Monitor %d: %dx%d %+d%+d\n",
+                                   i, _gdk_monitors[i].rect.width,
+                                   _gdk_monitors[i].rect.height,
+                                   _gdk_monitors[i].rect.x,
+                                   _gdk_monitors[i].rect.y));
+        }
     }
   else
 #endif /* HAVE_MONITOR_INFO */
     {
-      unsigned int width, height;
+      HDC hDC;
 
       _gdk_num_monitors = 1;
-      _gdk_monitors = g_renew (GdkRectangle, _gdk_monitors, 1);
-
-      width = GetSystemMetrics (SM_CXSCREEN);
-      height = GetSystemMetrics (SM_CYSCREEN);
+      _gdk_monitors = g_renew (GdkWin32Monitor, _gdk_monitors, 1);
 
-      _gdk_monitors[0].x = 0;
-      _gdk_monitors[0].y = 0;
-      _gdk_monitors[0].width = width;
-      _gdk_monitors[0].height = height;
+      _gdk_monitors[0].name = g_strdup ("DISPLAY");
+      hDC = GetDC (NULL);
+      _gdk_monitors[0].width_mm = GetDeviceCaps (hDC, HORZSIZE);
+      _gdk_monitors[0].height_mm = GetDeviceCaps (hDC, VERTSIZE);
+      ReleaseDC (NULL, hDC);
+      _gdk_monitors[0].rect.x = 0;
+      _gdk_monitors[0].rect.y = 0;
+      _gdk_monitors[0].rect.width = GetSystemMetrics (SM_CXSCREEN);
+      _gdk_monitors[0].rect.height = GetSystemMetrics (SM_CYSCREEN);
       _gdk_offset_x = 0;
       _gdk_offset_y = 0;
     }

Modified: trunk/gdk/win32/gdkglobals-win32.c
==============================================================================
--- trunk/gdk/win32/gdkglobals-win32.c	(original)
+++ trunk/gdk/win32/gdkglobals-win32.c	Thu Jan 10 21:40:48 2008
@@ -34,7 +34,7 @@
 GdkWindow	 *_gdk_root = NULL;
 
 gint		  _gdk_num_monitors;
-GdkRectangle     *_gdk_monitors = NULL;
+GdkWin32Monitor  *_gdk_monitors = NULL;
 
 gint		  _gdk_offset_x, _gdk_offset_y;
 

Modified: trunk/gdk/win32/gdkprivate-win32.h
==============================================================================
--- trunk/gdk/win32/gdkprivate-win32.h	(original)
+++ trunk/gdk/win32/gdkprivate-win32.h	Thu Jan 10 21:40:48 2008
@@ -346,7 +346,14 @@
 extern GdkScreen        *_gdk_screen;
 
 extern gint		 _gdk_num_monitors;
-extern GdkRectangle     *_gdk_monitors;
+typedef struct _GdkWin32Monitor GdkWin32Monitor;
+struct _GdkWin32Monitor
+{
+  gchar *name;
+  gint width_mm, height_mm;
+  GdkRectangle rect;
+};
+extern GdkWin32Monitor  *_gdk_monitors;
 
 /* Offsets to add to Windows coordinates (which are relative to the
  * primary monitor's origin, and thus might be negative for monitors

Modified: trunk/gdk/win32/gdkscreen-win32.c
==============================================================================
--- trunk/gdk/win32/gdkscreen-win32.c	(original)
+++ trunk/gdk/win32/gdkscreen-win32.c	Thu Jan 10 21:40:48 2008
@@ -66,6 +66,39 @@
   return _gdk_num_monitors;
 }
 
+gint
+gdk_screen_get_monitor_width_mm (GdkScreen *screen,
+                                 gint       num_monitor)
+{
+  g_return_val_if_fail (screen == _gdk_screen, 0);
+  g_return_val_if_fail (num_monitor < _gdk_num_monitors, 0);
+  g_return_val_if_fail (num_monitor >= 0, 0);
+
+  return _gdk_monitors[num_monitor].width_mm;
+}
+
+gint
+gdk_screen_get_monitor_height_mm (GdkScreen *screen,
+                                  gint       num_monitor)
+{
+  g_return_val_if_fail (screen == _gdk_screen, 0);
+  g_return_val_if_fail (num_monitor < _gdk_num_monitors, 0);
+  g_return_val_if_fail (num_monitor >= 0, 0);
+
+  return _gdk_monitors[num_monitor].height_mm;
+}
+
+gchar *
+gdk_screen_get_monitor_plug_name (GdkScreen *screen,
+                                  gint       num_monitor)
+{
+  g_return_val_if_fail (screen == _gdk_screen, 0);
+  g_return_val_if_fail (num_monitor < _gdk_num_monitors, 0);
+  g_return_val_if_fail (num_monitor >= 0, 0);
+
+  return g_strdup (_gdk_monitors[num_monitor].name);
+}
+
 void
 gdk_screen_get_monitor_geometry (GdkScreen    *screen, 
 				 gint          num_monitor,
@@ -75,7 +108,7 @@
   g_return_if_fail (num_monitor < _gdk_num_monitors);
   g_return_if_fail (num_monitor >= 0);
 
-  *dest = _gdk_monitors[num_monitor];
+  *dest = _gdk_monitors[num_monitor].rect;
 }
 
 GdkColormap *

Modified: trunk/gdk/win32/gdkwindow-win32.c
==============================================================================
--- trunk/gdk/win32/gdkwindow-win32.c	(original)
+++ trunk/gdk/win32/gdkwindow-win32.c	Thu Jan 10 21:40:48 2008
@@ -260,9 +260,9 @@
   int i;
 
   impl = GDK_WINDOW_IMPL_WIN32 (((GdkWindowObject *) _gdk_root)->impl);
-  rect = _gdk_monitors[0];
+  rect = _gdk_monitors[0].rect;
   for (i = 1; i < _gdk_num_monitors; i++)
-    gdk_rectangle_union (&rect, _gdk_monitors+i, &rect);
+    gdk_rectangle_union (&rect, &_gdk_monitors[i].rect, &rect);
 
   impl->width = rect.width;
   impl->height = rect.height;



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