summaryrefslogtreecommitdiff
path: root/src/terminal-window.c
diff options
context:
space:
mode:
authorMartin Wimpress <[email protected]>2014-02-24 14:44:24 +0000
committerMartin Wimpress <[email protected]>2014-02-24 15:21:21 +0000
commit71204c2db80348c92b42c5cca08fc8c1166ab40d (patch)
tree2ad75ebaf8881f55efba8a34421d6a36929d337d /src/terminal-window.c
parent5a3a92147af024c32f503f0c55a5a918386543ce (diff)
downloadmate-terminal-71204c2db80348c92b42c5cca08fc8c1166ab40d.tar.bz2
mate-terminal-71204c2db80348c92b42c5cca08fc8c1166ab40d.tar.xz
Opening new terminal in a tab now works. The new intended behaviour is desbribed
in https://bugzilla.gnome.org/show_bug.cgi?id=83203#c57 Fixes #45.
Diffstat (limited to 'src/terminal-window.c')
-rw-r--r--src/terminal-window.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/terminal-window.c b/src/terminal-window.c
index 43333bf..d15a90c 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -97,6 +97,7 @@ struct _TerminalWindowPrivate
/* Workaround until gtk+ bug #535557 is fixed */
guint icon_title_set : 1;
+ time_t focus_time;
};
#define PROFILE_DATA_KEY "GT::Profile"
@@ -139,6 +140,9 @@ static gboolean terminal_window_state_event (GtkWidget *widget,
static gboolean terminal_window_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer data);
+static gboolean terminal_window_focus_in_event (GtkWidget *widget,
+ GdkEventFocus *event,
+ gpointer data);
static gboolean notebook_button_press_cb (GtkWidget *notebook,
GdkEventButton *event,
@@ -2136,6 +2140,10 @@ terminal_window_init (TerminalWindow *window)
g_signal_connect (G_OBJECT (window), "delete_event",
G_CALLBACK(terminal_window_delete_event),
NULL);
+ g_signal_connect (G_OBJECT (window), "focus_in_event",
+ G_CALLBACK(terminal_window_focus_in_event),
+ NULL);
+
#ifdef MATE_ENABLE_DEBUG
_TERMINAL_DEBUG_IF (TERMINAL_DEBUG_GEOMETRY)
{
@@ -2383,6 +2391,20 @@ terminal_window_delete_event (GtkWidget *widget,
return confirm_close_window_or_tab (TERMINAL_WINDOW (widget), NULL);
}
+static gboolean
+terminal_window_focus_in_event (GtkWidget *widget,
+ GdkEventFocus *event,
+ gpointer data)
+{
+ TerminalWindow *window = TERMINAL_WINDOW (widget);
+ TerminalWindowPrivate *priv = window->priv;
+
+ if (event->in)
+ priv->focus_time = time(NULL);
+
+ return FALSE;
+}
+
static void
terminal_window_show (GtkWidget *widget)
{
@@ -4264,3 +4286,26 @@ terminal_window_save_state (TerminalWindow *window,
g_key_file_set_string_list (key_file, group, TERMINAL_CONFIG_WINDOW_PROP_TABS, (const char * const *) tab_names, len);
g_strfreev (tab_names);
}
+
+
+TerminalWindow *
+terminal_window_get_latest_focused (TerminalWindow *window1,
+ TerminalWindow *window2)
+{
+ TerminalWindowPrivate *priv1 = NULL;
+ TerminalWindowPrivate *priv2 = NULL;
+
+ if (!window1)
+ return window2;
+
+ if (!window2)
+ return window1;
+
+ priv1 = window1->priv;
+ priv2 = window2->priv;
+
+ if (priv2->focus_time > priv1->focus_time)
+ return window2;
+
+ return window1;
+}