diff options
author | Gerald Combs <gerald@wireshark.org> | 2016-06-07 15:26:03 -0700 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2016-06-08 03:41:32 +0000 |
commit | 502335612c4c35a4bf7f19ffa7500ea1aac7d43f (patch) | |
tree | 8979d9cea502a7d18c4caccaf5d690e275522918 /ui | |
parent | 73286c417eebe975edb24a024eb0230bbca29acc (diff) | |
download | wireshark-502335612c4c35a4bf7f19ffa7500ea1aac7d43f.tar.gz |
Use separate main geometry settings for Qt and GTK+.
Qt and GTK+ can have wildly different notions about the top-left
position of the main window, particularly in multiple-screen
configurations. For example, on OS X with the following monitor
arrangment:
g .---------.
| |
| |
q--------.| |
| |`---------'
| |
`--------'
GTK+ positions windows relative to 'g' and Qt positions windows relative
to 'q'. As a result it's easy for one UI to clobber the settings of the
other.
Split the geometry_main_x and geometry_main_y recent settings into Qt
and GTK+ versions.
In the Qt UI, try moving the main window onscreen before falling back to
the default geometry. This keeps us from losing our size settings.
Add a link to a Qt geometry bug.
Change-Id: If7ae0dcc1719e646299ee3bbf1c88743f655c9a0
Ping-Bug: 12389
Reviewed-on: https://code.wireshark.org/review/15775
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gtk/main.c | 8 | ||||
-rw-r--r-- | ui/qt/main_window.cpp | 11 | ||||
-rw-r--r-- | ui/recent.c | 16 | ||||
-rw-r--r-- | ui/recent.h | 2 |
4 files changed, 32 insertions, 5 deletions
diff --git a/ui/gtk/main.c b/ui/gtk/main.c index 863d16f372..378d4ab37a 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -1088,8 +1088,8 @@ main_load_window_geometry(GtkWidget *widget) window_geometry_t geom; geom.set_pos = prefs.gui_geometry_save_position; - geom.x = recent.gui_geometry_main_x; - geom.y = recent.gui_geometry_main_y; + geom.x = recent.gui_gtk_geometry_main_x; + geom.y = recent.gui_gtk_geometry_main_y; geom.set_size = prefs.gui_geometry_save_size; if (recent.gui_geometry_main_width > 0 && recent.gui_geometry_main_height > 0) { @@ -1121,8 +1121,8 @@ main_save_window_geometry(GtkWidget *widget) window_get_geometry(widget, &geom); if (prefs.gui_geometry_save_position) { - recent.gui_geometry_main_x = geom.x; - recent.gui_geometry_main_y = geom.y; + recent.gui_gtk_geometry_main_x = geom.x; + recent.gui_gtk_geometry_main_y = geom.y; } if (prefs.gui_geometry_save_size) { diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index 1c06bf7508..bf2be3b3c6 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -847,6 +847,9 @@ void MainWindow::dropEvent(QDropEvent *event) // Apply recent settings to the main window geometry. // We haven't loaded the preferences at this point so we assume that the // position and size preference are enabled. +// Note we might end up with unexpected screen geometries if the user +// unplugs or plugs in a monitor: +// https://bugreports.qt.io/browse/QTBUG-44213 void MainWindow::loadWindowGeometry() { int min_sensible_dimension = 200; @@ -860,7 +863,13 @@ void MainWindow::loadWindowGeometry() QRect recent_geom(recent.gui_geometry_main_x, recent.gui_geometry_main_y, recent.gui_geometry_main_width, recent.gui_geometry_main_height); if (!rect_on_screen(recent_geom)) { - // We're not visible on any screens. Give up and use the default geometry. + // We're not visible on any screens. See if we can move onscreen + // without resizing. + recent_geom.moveTo(50, 50); // recent.c defaults to 20. + } + + if (!rect_on_screen(recent_geom)) { + // Give up and use the default geometry. return; } diff --git a/ui/recent.c b/ui/recent.c index 566acabbc8..4ea4bb1600 100644 --- a/ui/recent.c +++ b/ui/recent.c @@ -57,6 +57,8 @@ #define RECENT_GUI_BYTES_VIEW "gui.bytes_view" #define RECENT_GUI_GEOMETRY_MAIN_X "gui.geometry_main_x" #define RECENT_GUI_GEOMETRY_MAIN_Y "gui.geometry_main_y" +#define RECENT_GUI_GTK_GEOMETRY_MAIN_X "gui.gtk.geometry_main_x" +#define RECENT_GUI_GTK_GEOMETRY_MAIN_Y "gui.gtk.geometry_main_y" #define RECENT_GUI_GEOMETRY_MAIN_WIDTH "gui.geometry_main_width" #define RECENT_GUI_GEOMETRY_MAIN_HEIGHT "gui.geometry_main_height" #define RECENT_GUI_GEOMETRY_MAIN_MAXIMIZED "gui.geometry_main_maximized" @@ -650,6 +652,8 @@ write_recent(void) fprintf(rf, "# Decimal numbers.\n"); fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_X ": %d\n", recent.gui_geometry_main_x); fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_Y ": %d\n", recent.gui_geometry_main_y); + fprintf(rf, RECENT_GUI_GTK_GEOMETRY_MAIN_X ": %d\n", recent.gui_gtk_geometry_main_x); + fprintf(rf, RECENT_GUI_GTK_GEOMETRY_MAIN_Y ": %d\n", recent.gui_gtk_geometry_main_y); fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_WIDTH ": %d\n", recent.gui_geometry_main_width); fprintf(rf, RECENT_GUI_GEOMETRY_MAIN_HEIGHT ": %d\n", @@ -878,6 +882,16 @@ read_set_recent_common_pair_static(gchar *key, const gchar *value, if (p == value || *p != '\0') return PREFS_SET_SYNTAX_ERR; /* number was bad */ recent.gui_geometry_main_y = (gint)num; + } else if (strcmp(key, RECENT_GUI_GTK_GEOMETRY_MAIN_X) == 0) { + num = strtol(value, &p, 0); + if (p == value || *p != '\0') + return PREFS_SET_SYNTAX_ERR; /* number was bad */ + recent.gui_gtk_geometry_main_x = (gint)num; + } else if (strcmp(key, RECENT_GUI_GTK_GEOMETRY_MAIN_Y) == 0) { + num = strtol(value, &p, 0); + if (p == value || *p != '\0') + return PREFS_SET_SYNTAX_ERR; /* number was bad */ + recent.gui_gtk_geometry_main_y = (gint)num; } else if (strcmp(key, RECENT_GUI_GEOMETRY_MAIN_WIDTH) == 0) { num = strtol(value, &p, 0); if (p == value || *p != '\0') @@ -1177,6 +1191,8 @@ recent_read_static(char **rf_path_return, int *rf_errno_return) /* set defaults */ recent.gui_geometry_main_x = 20; recent.gui_geometry_main_y = 20; + recent.gui_gtk_geometry_main_x = 20; + recent.gui_gtk_geometry_main_y = 20; recent.gui_geometry_main_width = DEF_WIDTH; recent.gui_geometry_main_height = DEF_HEIGHT; recent.gui_geometry_main_maximized= FALSE; diff --git a/ui/recent.h b/ui/recent.h index 9b2052d7c8..20b4701262 100644 --- a/ui/recent.h +++ b/ui/recent.h @@ -87,6 +87,8 @@ typedef struct recent_settings_tag { gint gui_geometry_main_x; gint gui_geometry_main_y; + gint gui_gtk_geometry_main_x; + gint gui_gtk_geometry_main_y; gint gui_geometry_main_width; gint gui_geometry_main_height; |