aboutsummaryrefslogtreecommitdiffstats
path: root/ui/gtk/gui_utils.c
diff options
context:
space:
mode:
authorChris Maynard <Christopher.Maynard@GTECH.COM>2012-10-07 17:16:51 +0000
committerChris Maynard <Christopher.Maynard@GTECH.COM>2012-10-07 17:16:51 +0000
commit62169cf31241809dcc2fc8fcebc9f88f10487437 (patch)
treee6b45e68e37179166e58a8ce1997ece8701910d1 /ui/gtk/gui_utils.c
parentc8308c7c40cee34bff1e255ac84a30d4c6928cac (diff)
This is an attempt to improve the default window placement position when there's more than one monitor and Wireshark's main window isn't located on the primary monitor. New windows will now open on the same monitor as Wireshark's main window, at a fixed location slightly offset from the main window. Previously, new windows would always open on the primary monitor regardless of the monitor that Wireshark was on. Note that this is only the default position and future patches will likely cause many windows to change this position. Further usage/feedback will determine if this is a good temporary stategy or not. It *may* help obviate the need to save every window's x,y & size though.
svn path=/trunk/; revision=45370
Diffstat (limited to 'ui/gtk/gui_utils.c')
-rw-r--r--ui/gtk/gui_utils.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/ui/gtk/gui_utils.c b/ui/gtk/gui_utils.c
index fb429c83aa..c53e56866b 100644
--- a/ui/gtk/gui_utils.c
+++ b/ui/gtk/gui_utils.c
@@ -159,9 +159,33 @@ window_new(GtkWindowType type,
/* a lot of people dislike GTK_WIN_POS_MOUSE */
/* set the initial position (must be done, before show is called!) */
-/* gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER_ON_PARENT);*/
gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_NONE);
+ if (top_level) {
+ GdkScreen *default_screen;
+ gint x, y, n;
+
+ /* Ideally, new windows would open on the same monitor where the main
+ * window is located, but this doesn't happen when the main window is
+ * not located on the primary monitor. So, if there's more than 1
+ * monitor and Wireshark's main window isn't located on the primary
+ * one, attempt to improve the situation by at least displaying the new
+ * window somewhere on the same monitor, even if it won't be positioned
+ * the same way as it would be when it's on the primary monitor. Don't
+ * attempt to influence the placement on the primary monitor though,
+ * because that's probably the preferred placement strategy. But how
+ * to make window placement behave the same way on any monitor?
+ */
+ default_screen = gdk_screen_get_default();
+ n = gdk_screen_get_n_monitors(default_screen);
+ if (n > 1) {
+ gtk_window_get_position(GTK_WINDOW(top_level), &x, &y);
+ n = gdk_screen_get_monitor_at_point(default_screen, x, y);
+ if (n > 0)
+ gtk_window_move(GTK_WINDOW(win), x + 40, y + 30);
+ }
+ }
+
return win;
}