summaryrefslogtreecommitdiff
path: root/gdk
diff options
context:
space:
mode:
authorTor Lillqvist <tml@novell.com>2008-01-10 21:40:48 +0000
committerTor Lillqvist <tml@src.gnome.org>2008-01-10 21:40:48 +0000
commit8dab0b93608c121e96e97d45a6bb00672df262b9 (patch)
tree792f4a376f612df3e9500a577f2a71aa60c6ae36 /gdk
parent4dc47ed7005834de5af42e26987edb703b788506 (diff)
downloadgtk+-8dab0b93608c121e96e97d45a6bb00672df262b9.tar.gz
gdk/win32/gdkdisplay-win32.c gdk/win32/gdkglobals-win32.c
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) svn path=/trunk/; revision=19346
Diffstat (limited to 'gdk')
-rw-r--r--gdk/win32/gdkdisplay-win32.c69
-rw-r--r--gdk/win32/gdkglobals-win32.c2
-rw-r--r--gdk/win32/gdkprivate-win32.h9
-rw-r--r--gdk/win32/gdkscreen-win32.c35
-rw-r--r--gdk/win32/gdkwindow-win32.c4
5 files changed, 84 insertions, 35 deletions
diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c
index 78c26bf779..0794dfafb4 100644
--- a/gdk/win32/gdkdisplay-win32.c
+++ b/gdk/win32/gdkdisplay-win32.c
@@ -65,9 +65,10 @@ enum_monitor (HMONITOR hmonitor,
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 @@ enum_monitor (HMONITOR hmonitor,
#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 @@ enum_monitor (HMONITOR hmonitor,
/* 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 @@ _gdk_monitor_init (void)
(*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 @@ _gdk_monitor_init (void)
/* 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[0].x = 0;
- _gdk_monitors[0].y = 0;
- _gdk_monitors[0].width = width;
- _gdk_monitors[0].height = height;
+ _gdk_monitors = g_renew (GdkWin32Monitor, _gdk_monitors, 1);
+
+ _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;
}
diff --git a/gdk/win32/gdkglobals-win32.c b/gdk/win32/gdkglobals-win32.c
index 621ff6f2ea..7e6cd2d4bd 100644
--- a/gdk/win32/gdkglobals-win32.c
+++ b/gdk/win32/gdkglobals-win32.c
@@ -34,7 +34,7 @@ GdkScreen *_gdk_screen = NULL;
GdkWindow *_gdk_root = NULL;
gint _gdk_num_monitors;
-GdkRectangle *_gdk_monitors = NULL;
+GdkWin32Monitor *_gdk_monitors = NULL;
gint _gdk_offset_x, _gdk_offset_y;
diff --git a/gdk/win32/gdkprivate-win32.h b/gdk/win32/gdkprivate-win32.h
index 79202631e1..419e6fc399 100644
--- a/gdk/win32/gdkprivate-win32.h
+++ b/gdk/win32/gdkprivate-win32.h
@@ -346,7 +346,14 @@ extern GdkDisplay *_gdk_display;
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
diff --git a/gdk/win32/gdkscreen-win32.c b/gdk/win32/gdkscreen-win32.c
index ea16a64046..c9b873bc80 100644
--- a/gdk/win32/gdkscreen-win32.c
+++ b/gdk/win32/gdkscreen-win32.c
@@ -66,6 +66,39 @@ gdk_screen_get_n_monitors (GdkScreen *screen)
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 @@ gdk_screen_get_monitor_geometry (GdkScreen *screen,
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 *
diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c
index 8f72780b56..09a54de192 100644
--- a/gdk/win32/gdkwindow-win32.c
+++ b/gdk/win32/gdkwindow-win32.c
@@ -260,9 +260,9 @@ _gdk_root_window_size_init (void)
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;