ratpoison-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RP] [PATCH 2/2] Fix frozen state when a new screen appears after all sc


From: Mathieu OTHACEHE
Subject: [RP] [PATCH 2/2] Fix frozen state when a new screen appears after all screens have been removed
Date: Wed, 14 Dec 2016 19:54:00 +0100

Handle correctly the fact that the deleted screen could be the last one.
If a screen is plugged, and no other screens are present, give focus to
it's key window.
---
 src/screen.c | 45 ++++++++++++++++++++++++++-------------------
 1 file changed, 26 insertions(+), 19 deletions(-)

diff --git a/src/screen.c b/src/screen.c
index d8f580f..cfcf2f8 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -635,11 +635,6 @@ screen_add (int rr_output)
 
   screen->number = numset_request (rp_glob_screen.numset);
 
-  if (!rp_current_screen)
-    rp_current_screen = screen;
-
-  change_windows_screen (NULL, screen);
-
 #ifdef HAVE_XRANDR
   if (rp_have_xrandr)
     xrandr_fill_screen (rr_output, screen);
@@ -647,30 +642,42 @@ screen_add (int rr_output)
   init_screen (screen);
   init_frame_list (screen);
 
+  if (screen_count () == 1)
+    {
+      rp_current_screen = screen;
+      change_windows_screen (NULL, rp_current_screen);
+      set_window_focus (rp_current_screen->key_window);
+    }
+
   return screen;
 }
 
 void
 screen_del (rp_screen *s)
 {
-  /*
-   * The deleted screen cannot be the current screen anymore,
-   * focus the next one.
-   */
-  if (s == rp_current_screen) {
-    screen_remove_current ();
-  } else {
-    rp_frame *cur_frame;
-    rp_window *cur_win;
+  if (screen_count () == 1)
+    {
+      hide_screen_windows (s);
+      rp_current_screen = NULL;
+    }
+  else if (s == rp_current_screen)
+    {
+      /*
+       * The deleted screen cannot be the current screen anymore,
+       * focus the next one.
+       */
+      screen_remove_current ();
+    }
+  else
+    {
+      hide_screen_windows (s);
+    }
 
-    cur_frame = screen_get_frame (s, s->current_frame);
-    cur_win = find_window_number (cur_frame->win_number);
-    hide_window (cur_win);
-  }
+  /* Affect window's screen backpointer to the new current screen */
+  change_windows_screen (s, rp_current_screen);
 
   numset_release (rp_glob_screen.numset, s->number);
 
-  change_windows_screen (s, rp_current_screen);
   screen_free (s);
 
   list_del (&s->node);
-- 
2.10.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]