aboutsummaryrefslogtreecommitdiffstats
path: root/src/ephy-window.c
diff options
context:
space:
mode:
authorGustavo Noronha Silva <gns@gnome.org>2012-12-09 22:25:37 +0800
committerGustavo Noronha Silva <gns@gnome.org>2012-12-11 05:15:54 +0800
commitc968c68cabc319896ad4d2096940c9a34d4c13cd (patch)
treed9cde42306f750303d3d35ee701fe58c5040f878 /src/ephy-window.c
parent3573116d0473da1ca51d1766d412a97185addb9d (diff)
downloadgsoc2013-epiphany-c968c68cabc319896ad4d2096940c9a34d4c13cd.tar.gz
gsoc2013-epiphany-c968c68cabc319896ad4d2096940c9a34d4c13cd.tar.zst
gsoc2013-epiphany-c968c68cabc319896ad4d2096940c9a34d4c13cd.zip
Append new tab on the window with most tabs in the current workspace
This change uses a different heuristic to decide on what the best window to add a new tab is from the last window which has been interacted with, which might even be in a different workspace, to the window with the most tabs in the current workspace. If no window exists on the current workspace one will be created. Partial fix for https://bugzilla.gnome.org/show_bug.cgi?id=685976
Diffstat (limited to 'src/ephy-window.c')
-rw-r--r--src/ephy-window.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 64c7be8ee..d1c0170d1 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -61,10 +61,15 @@
#include "window-commands.h"
#include <gdk/gdkkeysyms.h>
+#include <gdk/gdkx.h>
#include <gio/gio.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <libsoup/soup.h>
+
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
+#include <libwnck/libwnck.h>
+
#ifdef HAVE_WEBKIT2
#include <webkit2/webkit2.h>
#else
@@ -4390,6 +4395,40 @@ ephy_window_get_location_controller (EphyWindow *window)
}
/**
+ * ephy_window_is_on_current_workspace:
+ * @window: an #EphyWindow
+ *
+ * Returns whether @window is on the current workspace
+ *
+ * Returns: %TRUE if the window is on the current workspace, %FALSE otherwise
+ **/
+gboolean
+ephy_window_is_on_current_workspace (EphyWindow *window)
+{
+ GdkWindow *gdk_window = NULL;
+ WnckWorkspace *workspace = NULL;
+ WnckWindow *wnck_window = NULL;
+
+ if (!gtk_widget_get_realized (GTK_WIDGET (window)))
+ return TRUE;
+
+ workspace = wnck_screen_get_active_workspace (wnck_screen_get_default ());
+
+ /* From WNCK docs:
+ * "May return NULL sometimes, if libwnck is in a weird state due to
+ * the asynchronous nature of the interaction with the window manager."
+ * In such a case we cannot really check, so assume we are.
+ */
+ if (!workspace)
+ return TRUE;
+
+ gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
+ wnck_window = wnck_window_get (GDK_WINDOW_XID (gdk_window));
+
+ return wnck_window_is_on_workspace (wnck_window, workspace);
+}
+
+/**
* ephy_window_close:
* @window: an #EphyWindow
*