[Window] Bugfixes in pull() code
[tilda-gobject.git] / tilda-window.c
index 6c41340..731739b 100644 (file)
@@ -167,19 +167,35 @@ tilda_window_keybinding_cb (const gchar *keystr, gpointer data)
 
        switch (self->state)
        {
-               case WINDOW_UP:
-                       /* Pull Down */
-                       tomboy_window_present_hardcore (GTK_WINDOW(self->window));
-                       self->state = WINDOW_DOWN;
-
-                       // Focusing the term here works perfectly, near as I can tell
+               case WINDOW_UP: /* Pull the window up */
+
+                       /* Bugfix: having this here keeps the tilda window from being
+                        * hidden if you turn off "stick", pull it down on workspace 1,
+                        * switch to workspace 2, then pull it up and back down. Without
+                        * this, something in metacity (at least) hides the window. Stupid. */
+                       gtk_window_deiconify (GTK_WINDOW(self->window));
+
+                       /* Re-set the window properties that do not linger after hiding the
+                        * window. I know this looks stupid, but it keeps all of the state-
+                        * changing code in the place it belongs: the property-setting code. */
+                       g_object_set (G_OBJECT(self),
+                                       "keep-above", self->keep_above,
+                                       "stick", self->stick,
+                                       NULL);
+                       gtk_window_present_with_time (GTK_WINDOW(self->window),
+                                                                                 tomboy_keybinder_get_current_event_time());
+
+                       /* Focusing the term here works perfectly, near as I can tell */
                        tt = tilda_window_find_current_terminal (self);
                        gtk_widget_grab_focus (GTK_WIDGET(tt->vte_term));
+
+                       self->state = WINDOW_DOWN;
                        break;
 
-               case WINDOW_DOWN:
-                       /* Pull Up */
+               case WINDOW_DOWN: /* Pull the window up */
+
                        gtk_widget_hide (GTK_WIDGET(self->window));
+
                        self->state = WINDOW_UP;
                        break;