mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-05 16:20:10 +00:00
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
This commit is contained in:
parent
4dc47ed700
commit
8dab0b9360
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
||||
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)
|
||||
|
||||
2008-01-10 Cody Russell <bratsche@gnome.org>
|
||||
|
||||
* gdk/win32/gdkwindow-win32.c: (gdk_window_set_transient_for),
|
||||
|
@ -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);
|
||||
_gdk_monitors = g_renew (GdkWin32Monitor, _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[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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 *
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user