]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix error trapping in x_focus_frame
authorPo Lu <luangruo@yahoo.com>
Wed, 16 Nov 2022 02:37:14 +0000 (10:37 +0800)
committerPo Lu <luangruo@yahoo.com>
Wed, 16 Nov 2022 02:37:14 +0000 (10:37 +0800)
* src/xterm.c (x_focus_frame): Improve commentary.  Dno not trap
errors around x_get_server_time.

src/xterm.c

index 7a1fd6086cffa938ee65e15bb643ea4efbeb5f3d..d6ba532f16e1fbaa49622514ba8751af3ce4bf82 100644 (file)
@@ -27632,8 +27632,6 @@ x_focus_frame (struct frame *f, bool noactivate)
          return;
        }
 
-      /* Ignore any BadMatch error this request might result in.  */
-      x_ignore_errors_for_next_request (dpyinfo);
       if (NILP (Vx_no_window_manager))
        {
          /* Use the last user time.  It is invalid to use CurrentTime
@@ -27651,15 +27649,24 @@ x_focus_frame (struct frame *f, bool noactivate)
              && !dpyinfo->x_focus_frame)
            time = x_get_server_time (f);
 
+         /* Ignore any BadMatch error this request might result in.
+            A BadMatch error can occur if the window was obscured
+            after the time of the last user interaction without
+            changing the last-focus-change-time.  */
+         x_ignore_errors_for_next_request (dpyinfo);
          XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
                          RevertToParent, time);
+         x_stop_ignoring_errors (dpyinfo);
        }
       else
-       XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
-                       /* But when no window manager is in use, we
-                          don't care.  */
-                       RevertToParent, CurrentTime);
-      x_stop_ignoring_errors (dpyinfo);
+       {
+         x_ignore_errors_for_next_request (dpyinfo);
+         XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
+                         /* But when no window manager is in use, we
+                            don't care.  */
+                         RevertToParent, CurrentTime);
+         x_stop_ignoring_errors (dpyinfo);
+       }
     }
 }