diff options
author | Руслан Ижбулатов <lrn1986@gmail.com> | 2018-06-06 19:15:32 +0000 |
---|---|---|
committer | Руслан Ижбулатов <lrn1986@gmail.com> | 2018-06-06 19:15:32 +0000 |
commit | 2c13b00bc1c64183b1c73202610c0ce4d0d77f6f (patch) | |
tree | b34ed83c70be31a342beed4d8a6097f9dec0a61d | |
parent | 48821a76c63eea7b7f85e241787cc3f27b4763e8 (diff) | |
download | gtk+-lrn/gtk224-w32-monitor-enum.tar.gz |
GDK W32: ensure that monitor enumeration matches uplrn/gtk224-w32-monitor-enum
In case something happens between monitor counting and monitor
enumeration, repeat until the count matches up.
enum_monitor is changed to ignore any monitors past _gdk_num_monitors
and just keep increasing the count past that number.
-rw-r--r-- | gdk/win32/gdkdisplay-win32.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/gdk/win32/gdkdisplay-win32.c b/gdk/win32/gdkdisplay-win32.c index cef60721a1..7447525f72 100644 --- a/gdk/win32/gdkdisplay-win32.c +++ b/gdk/win32/gdkdisplay-win32.c @@ -82,7 +82,12 @@ enum_monitor (HMONITOR hmonitor, gint *index = (gint *) data; GdkWin32Monitor *monitor; - g_assert (*index < _gdk_num_monitors); + if (*index >= _gdk_num_monitors) + { + (*index) += 1; + + return TRUE; + } monitor = _gdk_monitors + *index; @@ -126,14 +131,21 @@ _gdk_monitor_init (void) #ifdef HAVE_MONITOR_INFO gint i, index; - _gdk_num_monitors = 0; + /* In case something happens between monitor counting and monitor + * enumeration, repeat until the count matches up. + * enum_monitor is coded to ignore any monitors past _gdk_num_monitors. + */ + do + { + _gdk_num_monitors = 0; - EnumDisplayMonitors (NULL, NULL, count_monitor, (LPARAM) &_gdk_num_monitors); + EnumDisplayMonitors (NULL, NULL, count_monitor, (LPARAM) &_gdk_num_monitors); - _gdk_monitors = g_renew (GdkWin32Monitor, _gdk_monitors, _gdk_num_monitors); + _gdk_monitors = g_renew (GdkWin32Monitor, _gdk_monitors, _gdk_num_monitors); - index = 0; - EnumDisplayMonitors (NULL, NULL, enum_monitor, (LPARAM) &index); + index = 0; + EnumDisplayMonitors (NULL, NULL, enum_monitor, (LPARAM) &index); + } while (index != _gdk_num_monitors); _gdk_offset_x = G_MININT; _gdk_offset_y = G_MININT; |