diff options
Diffstat (limited to 'tp-account-widgets')
-rw-r--r-- | tp-account-widgets/tpaw-irc-network-chooser.c | 2 | ||||
-rw-r--r-- | tp-account-widgets/tpaw-utils.c | 53 | ||||
-rw-r--r-- | tp-account-widgets/tpaw-utils.h | 9 |
3 files changed, 63 insertions, 1 deletions
diff --git a/tp-account-widgets/tpaw-irc-network-chooser.c b/tp-account-widgets/tpaw-irc-network-chooser.c index 6e6aeb73b..5339e1ba5 100644 --- a/tp-account-widgets/tpaw-irc-network-chooser.c +++ b/tp-account-widgets/tpaw-irc-network-chooser.c @@ -333,7 +333,7 @@ clicked_cb (GtkButton *button, G_CALLBACK (dialog_response_cb), button, 0); out: - empathy_window_present (GTK_WINDOW (priv->dialog)); + tpaw_window_present (GTK_WINDOW (priv->dialog)); } static void diff --git a/tp-account-widgets/tpaw-utils.c b/tp-account-widgets/tpaw-utils.c index 7c0a03082..933b8570e 100644 --- a/tp-account-widgets/tpaw-utils.c +++ b/tp-account-widgets/tpaw-utils.c @@ -1,11 +1,17 @@ /* * Copyright (C) 2007-2013 Collabora Ltd. + * Copyright (C) 2005-2006 Imendio AB * Copyright (C) 2006 Xavier Claessens <xavier.claessens@gmail.com> + * Copyright (C) 2009 Steve Frécinaux <code@istique.net> * * Authors: Marco Barisione <marco.barisione@collabora.co.uk> * Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> * Sjoerd Simons <sjoerd.simons@collabora.co.uk> * Xavier Claessens <xavier.claessens@collabora.co.uk> + * Mikael Hallendal <micke@imendio.com> + * Richard Hult <richard@imendio.com> + * Martyn Russell <martyn@imendio.com> + * Steve Frécinaux <code@istique.net> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -26,10 +32,16 @@ #include "tpaw-utils.h" #include <glib/gi18n-lib.h> +#include <gdk/gdkx.h> #define DEBUG_FLAG EMPATHY_DEBUG_OTHER #include "empathy-debug.h" +#define TPAW_RECT_IS_ON_SCREEN(x,y,w,h) ((x) + (w) > 0 && \ + (y) + (h) > 0 && \ + (x) < gdk_screen_width () && \ + (y) < gdk_screen_height ()) + /* Change the RequestedPresence of a newly created account to ensure that it * is actually connected. */ void @@ -169,6 +181,47 @@ tpaw_make_color_whiter (GdkRGBA *color) color->blue = (color->blue + white.blue) / 2; } +/* Takes care of moving the window to the current workspace. */ +void +tpaw_window_present_with_time (GtkWindow *window, + guint32 timestamp) +{ + GdkWindow *gdk_window; + + g_return_if_fail (GTK_IS_WINDOW (window)); + + /* Move the window to the current workspace before trying to show it. + * This is the behaviour people expect when clicking on the statusbar icon. */ + gdk_window = gtk_widget_get_window (GTK_WIDGET (window)); + + if (gdk_window) + { + gint x, y; + gint w, h; + + /* Has no effect if the WM has viewports, like compiz */ + gdk_x11_window_move_to_current_desktop (gdk_window); + + /* If window is still off-screen, hide it to force it to + * reposition on the current workspace. */ + gtk_window_get_position (window, &x, &y); + gtk_window_get_size (window, &w, &h); + if (!TPAW_RECT_IS_ON_SCREEN (x, y, w, h)) + gtk_widget_hide (GTK_WIDGET (window)); + } + + if (timestamp == GDK_CURRENT_TIME) + gtk_window_present (window); + else + gtk_window_present_with_time (window, timestamp); +} + +void +tpaw_window_present (GtkWindow *window) +{ + tpaw_window_present_with_time (window, gtk_get_current_event_time ()); +} + GtkWindow * tpaw_get_toplevel_window (GtkWidget *widget) { diff --git a/tp-account-widgets/tpaw-utils.h b/tp-account-widgets/tpaw-utils.h index 106c3b4e4..f82b5a6f7 100644 --- a/tp-account-widgets/tpaw-utils.h +++ b/tp-account-widgets/tpaw-utils.h @@ -1,11 +1,17 @@ /* * Copyright (C) 2007-2013 Collabora Ltd. + * Copyright (C) 2005-2006 Imendio AB * Copyright (C) 2006 Xavier Claessens <xavier.claessens@gmail.com> + * Copyright (C) 2009 Steve Frécinaux <code@istique.net> * * Authors: Marco Barisione <marco.barisione@collabora.co.uk> * Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> * Sjoerd Simons <sjoerd.simons@collabora.co.uk> * Xavier Claessens <xavier.claessens@collabora.co.uk> + * Mikael Hallendal <micke@imendio.com> + * Richard Hult <richard@imendio.com> + * Martyn Russell <martyn@imendio.com> + * Steve Frécinaux <code@istique.net> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -41,6 +47,9 @@ const gchar *tpaw_service_name_to_display_name (const gchar *proto_name); void tpaw_make_color_whiter (GdkRGBA *color); /* Windows */ +void tpaw_window_present (GtkWindow *window); +void tpaw_window_present_with_time (GtkWindow *window, + guint32 timestamp); GtkWindow * tpaw_get_toplevel_window (GtkWidget *widget); /* Copied from wocky/wocky-utils.h */ |