summaryrefslogtreecommitdiff
path: root/src/terminal-app.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-app.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-app.c')
-rw-r--r--src/terminal-app.c95
1 files changed, 76 insertions, 19 deletions
diff --git a/src/terminal-app.c b/src/terminal-app.c
index caf3533..71d14ee 100644
--- a/src/terminal-app.c
+++ b/src/terminal-app.c
@@ -219,6 +219,29 @@ terminal_app_get_screen_by_display_name (const char *display_name,
return screen;
}
+static int
+terminal_app_get_workspace_for_window (TerminalWindow *window)
+{
+ int ret = -1;
+ guchar *data = NULL;
+ GdkAtom atom;
+ GdkAtom cardinal_atom;
+
+ atom = gdk_atom_intern_static_string ("_NET_WM_DESKTOP");
+ cardinal_atom = gdk_atom_intern_static_string ("CARDINAL");
+
+ gdk_property_get (gtk_widget_get_window(GTK_WIDGET(window)),
+ atom, cardinal_atom, 0, 8, FALSE,
+ NULL, NULL, NULL, &data);
+
+ if (data)
+ ret = *(int *)data;
+
+ g_free (data);
+ return ret;
+}
+
+
/* Menubar mnemonics settings handling */
static int
@@ -1688,32 +1711,38 @@ terminal_app_handle_options (TerminalApp *app,
for (lw = options->initial_windows; lw != NULL; lw = lw->next)
{
InitialWindow *iw = lw->data;
- TerminalWindow *window;
+ TerminalWindow *window = NULL;
GList *lt;
g_assert (iw->tabs);
- /* Create & setup new window */
- window = terminal_app_new_window (app, gdk_screen);
+ if ( lw == options->initial_windows && ((InitialTab *)iw->tabs->data)->attach_window )
+ window = terminal_app_get_current_window(app, gdk_screen, options->initial_workspace);
- /* Restored windows shouldn't demand attention; see bug #586308. */
- if (iw->source_tag == SOURCE_SESSION)
- terminal_window_set_is_restored (window);
+ if (!window)
+ {
+ /* Create & setup new window */
+ window = terminal_app_new_window (app, gdk_screen);
- if (options->startup_id != NULL)
- gtk_window_set_startup_id (GTK_WINDOW (window), options->startup_id);
+ /* Restored windows shouldn't demand attention; see bug #586308. */
+ if (iw->source_tag == SOURCE_SESSION)
+ terminal_window_set_is_restored (window);
- /* Overwrite the default, unique window role set in terminal_window_init */
- if (iw->role)
- gtk_window_set_role (GTK_WINDOW (window), iw->role);
+ if (options->startup_id != NULL)
+ gtk_window_set_startup_id (GTK_WINDOW (window), options->startup_id);
- if (iw->force_menubar_state)
- terminal_window_set_menubar_visible (window, iw->menubar_state);
+ /* Overwrite the default, unique window role set in terminal_window_init */
+ if (iw->role)
+ gtk_window_set_role (GTK_WINDOW (window), iw->role);
- if (iw->start_fullscreen)
- gtk_window_fullscreen (GTK_WINDOW (window));
- if (iw->start_maximized)
- gtk_window_maximize (GTK_WINDOW (window));
+ if (iw->force_menubar_state)
+ terminal_window_set_menubar_visible (window, iw->menubar_state);
+
+ if (iw->start_fullscreen)
+ gtk_window_fullscreen (GTK_WINDOW (window));
+ if (iw->start_maximized)
+ gtk_window_maximize (GTK_WINDOW (window));
+ }
/* Now add the tabs */
for (lt = iw->tabs; lt != NULL; lt = lt->next)
@@ -1842,13 +1871,41 @@ terminal_app_edit_encodings (TerminalApp *app,
terminal_encoding_dialog_show (transient_parent);
}
+/*
+* Get the window in the given screen and workspace. If nothing is found,
+* a NULL is returned.
+*/
TerminalWindow *
-terminal_app_get_current_window (TerminalApp *app)
+terminal_app_get_current_window (TerminalApp *app,
+ GdkScreen *from_screen,
+ int workspace)
{
+ GList *res = NULL;
+ TerminalWindow *ret = NULL;
+
if (app->windows == NULL)
return NULL;
- return g_list_last (app->windows)->data;
+ res = g_list_last (app->windows);
+
+ g_assert (from_screen != NULL);
+
+ while (res)
+ {
+ int win_workspace;
+ if (gtk_window_get_screen(GTK_WINDOW(res->data)) != from_screen)
+ continue;
+
+ win_workspace = terminal_app_get_workspace_for_window(res->data);
+
+ /* Same workspace or if the window is set to show up on all workspaces */
+ if (win_workspace == workspace || win_workspace == -1)
+ ret = terminal_window_get_latest_focused (ret, TERMINAL_WINDOW(res->data));
+
+ res = g_list_previous (res);
+ }
+
+ return ret;
}
/**