Pārlūkot izejas kodu

Make sure focus is preserved when a session closes, restore back to global entry if focused window closed.

Signed-off-by: Bradley Smith <[email protected]>
Bradley Smith 15 gadi atpakaļ
vecāks
revīzija
2a5ebdaea9
2 mainītis faili ar 11 papildinājumiem un 0 dzēšanām
  1. 10 0
      src/mssh-window.c
  2. 1 0
      src/mssh-window.h

+ 10 - 0
src/mssh-window.c

@@ -192,12 +192,18 @@ void mssh_window_relayout(MSSHWindow *window)
 {
     GConfClient *client;
     GConfEntry *entry;
+    GtkWidget *focus;
     int i, len = window->terminals->len;
     int wcols = window->columns_override ? window->columns_override :
         window->columns;
     int cols = (len < wcols) ? len : wcols;
     int rows = (len + 0.5) / cols;
 
+    focus = gtk_window_get_focus(GTK_WINDOW(window));
+
+    if(!focus)
+        focus = window->global_entry;
+
     for(i = 0; i < len; i++)
     {
         MSSHTerminal *terminal = g_array_index(window->terminals,
@@ -241,6 +247,8 @@ void mssh_window_relayout(MSSHWindow *window)
     entry = gconf_client_get_entry(client, MSSH_GCONF_KEY_BG_COLOUR, NULL,
         TRUE, NULL);
     mssh_gconf_notify_bg_colour(client, 0, entry, window);
+
+    gtk_window_set_focus(GTK_WINDOW(window), GTK_WIDGET(focus));
 }
 
 static void mssh_window_add_session(MSSHWindow *window, char *hostname)
@@ -287,6 +295,8 @@ static void mssh_window_init(MSSHWindow* window)
 
     window->server_menu = gtk_menu_new();
 
+    window->global_entry = entry;
+
     window->terminals = g_array_new(FALSE, TRUE, sizeof(MSSHTerminal*));
 
     gtk_menu_item_set_submenu(GTK_MENU_ITEM(file_item), file_menu);

+ 1 - 0
src/mssh-window.h

@@ -23,6 +23,7 @@ typedef struct
     GtkWindow widget;
     GtkWidget *table;
     GtkWidget *server_menu;
+    GtkWidget *global_entry;
     GArray *terminals;
     char **env;
     int columns;