diff options
author | Chris Maynard <Christopher.Maynard@GTECH.COM> | 2013-06-14 17:47:54 +0000 |
---|---|---|
committer | Chris Maynard <Christopher.Maynard@GTECH.COM> | 2013-06-14 17:47:54 +0000 |
commit | 14b65f91a44b89ef460df391717b2a6ac317980d (patch) | |
tree | 09806fd9a86c5085b057f52c6b36f058b0e0d30e /ui/gtk/gui_utils.c | |
parent | 48dccb60ad080bd8f61637a903dd1defbbc882fe (diff) |
Ensure that Wireshark isn't obscured by the system taskbar or by any other desktop toolbars. Fixes https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=3034
#BACKPORT(1.10,1.8)
svn path=/trunk/; revision=49937
Diffstat (limited to 'ui/gtk/gui_utils.c')
-rw-r--r-- | ui/gtk/gui_utils.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/ui/gtk/gui_utils.c b/ui/gtk/gui_utils.c index ba04760723..d258048113 100644 --- a/ui/gtk/gui_utils.c +++ b/ui/gtk/gui_utils.c @@ -373,6 +373,37 @@ window_get_geometry(GtkWidget *widget, } +#ifdef _WIN32 +/* Ensure Wireshark isn't obscured by the system taskbar (or other desktop toolbars). + * Resolves https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=3034 */ +static void +window_adjust_if_obscured(window_geometry_t *geom) +{ + MONITORINFO MonitorInfo; + HMONITOR hMonitor; + POINT pt, vs; + DWORD dwFlags = MONITOR_DEFAULTTONEAREST; /* MONITOR_DEFAULTTOPRIMARY? */ + + /* + * Get the virtual screen's top-left coordinates so we can reliably + * determine which monitor we're dealing with. See also: + * http://msdn.microsoft.com/en-us/library/windows/desktop/dd145136%28v=vs.85%29.aspx + */ + vs.x = GetSystemMetrics(SM_XVIRTUALSCREEN); + vs.y = GetSystemMetrics(SM_YVIRTUALSCREEN); + pt.x = geom->x + vs.x; + pt.y = geom->y + vs.y; + MonitorInfo.cbSize = sizeof(MONITORINFO); + hMonitor = MonitorFromPoint(pt, dwFlags); + if (GetMonitorInfo(hMonitor, &MonitorInfo)) { + if (pt.x < MonitorInfo.rcWork.left) + geom->x += MonitorInfo.rcWork.left - pt.x; + if (pt.y < MonitorInfo.rcWork.top) + geom->y += MonitorInfo.rcWork.top - pt.y; + } +} +#endif + /* set the geometry of a window from window_new() */ void window_set_geometry(GtkWidget *widget, @@ -404,6 +435,10 @@ window_set_geometry(GtkWidget *widget, if(geom->y < viewable_area.y || geom->y > (viewable_area.y + viewable_area.height)) geom->y = viewable_area.y; + #ifdef _WIN32 + window_adjust_if_obscured(geom); + #endif + gtk_window_move(GTK_WINDOW(widget), geom->x, geom->y); |