emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: Carbon: display-buffer can leave wrong frame with input focus


From: YAMAMOTO Mitsuharu
Subject: Re: Carbon: display-buffer can leave wrong frame with input focus
Date: Thu, 09 Feb 2006 17:04:26 +0900
User-agent: Wanderlust/2.14.0 (Africa) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/22.0.50 (sparc-sun-solaris2.8) MULE/5.0 (SAKAKI)

>>>>> On Wed, 8 Feb 2006 19:59:22 +0000, David Reitter <address@hidden> said:

> The below issue is reproducible in a plain GNU Emacs (Carbon). Note
> that the X11 version is reported to work fine, but not Carbon Emacs.
> This might not be considered a bug by some of you (for example
> because the window manager selects the new frame), but I still think
> synchronizing the behavior of the X11 version and the Carbon
> implementation could be advantageous.

Could you try the following patch that prevents raise-frame from
giving focus to a raised frame that is already visible?  Note that a
newly created or previously iconified frame still gets focus when the
frame is popped up by display-buffer, but this behavior is also
observed with some X11 window managers.

                                     YAMAMOTO Mitsuharu
                                address@hidden

Index: lisp/frame.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/frame.el,v
retrieving revision 1.234
diff -c -r1.234 frame.el
*** lisp/frame.el       6 Feb 2006 14:33:33 -0000       1.234
--- lisp/frame.el       9 Feb 2006 07:38:16 -0000
***************
*** 695,701 ****
      (select-frame frame)
      (raise-frame frame)
      ;; Ensure, if possible, that frame gets input focus.
!     (cond ((eq window-system 'x)
           (x-focus-frame frame))
          ((eq window-system 'w32)
           (w32-focus-frame frame)))
--- 695,701 ----
      (select-frame frame)
      (raise-frame frame)
      ;; Ensure, if possible, that frame gets input focus.
!     (cond ((memq window-system '(x mac))
           (x-focus-frame frame))
          ((eq window-system 'w32)
           (w32-focus-frame frame)))
Index: src/macfns.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macfns.c,v
retrieving revision 1.75
diff -c -r1.75 macfns.c
*** src/macfns.c        6 Feb 2006 15:23:21 -0000       1.75
--- src/macfns.c        9 Feb 2006 07:38:17 -0000
***************
*** 2714,2719 ****
--- 2714,2752 ----
    XSETFRAME (xfocus, dpyinfo->x_focus_frame);
    return xfocus;
  }
+ 
+ 
+ DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0,
+        doc: /* Set the input focus to FRAME.
+ FRAME nil means use the selected frame.  */)
+      (frame)
+      Lisp_Object frame;
+ {
+   struct frame *f = check_x_frame (frame);
+   struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
+ 
+   if (dpyinfo->x_focus_frame != f)
+     {
+       BLOCK_INPUT;
+ #ifdef MAC_OSX
+       ActivateWindow (ActiveNonFloatingWindow (), false);
+       ActivateWindow (FRAME_MAC_WINDOW (f), true);
+ #else
+ #if !TARGET_API_MAC_CARBON
+       /* SelectWindow (Non-Carbon) does not issue deactivate events if
+        the possibly inactive window that is to be selected is
+        already the frontmost one.  */
+       SendBehind (FRAME_MAC_WINDOW (f), NULL);
+ #endif
+       /* This brings the window to the front.  */
+       SelectWindow (FRAME_MAC_WINDOW (f));
+ #endif
+       UNBLOCK_INPUT;
+     }
+ 
+   return Qnil;
+ }
+ 
  
  DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 
0,
         doc: /* Internal function called by `color-defined-p', which see.  */)
***************
*** 4513,4518 ****
--- 4546,4552 ----
    defsubr (&Sx_close_connection);
    defsubr (&Sx_display_list);
    defsubr (&Sx_synchronize);
+   defsubr (&Sx_focus_frame);
  
    /* Setting callback functions for fontset handler.  */
    get_font_info_func = x_get_font_info;
Index: src/macterm.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macterm.c,v
retrieving revision 1.152
diff -c -r1.152 macterm.c
*** src/macterm.c       6 Feb 2006 15:23:21 -0000       1.152
--- src/macterm.c       9 Feb 2006 07:38:17 -0000
***************
*** 5837,5843 ****
    if (f->async_visible)
      {
        BLOCK_INPUT;
!       SelectWindow (FRAME_MAC_WINDOW (f));
        UNBLOCK_INPUT;
      }
  }
--- 5837,5843 ----
    if (f->async_visible)
      {
        BLOCK_INPUT;
!       BringToFront (FRAME_MAC_WINDOW (f));
        UNBLOCK_INPUT;
      }
  }
***************
*** 5964,5970 ****
  
        f->output_data.mac->asked_for_visible = 1;
  
-       SelectWindow (FRAME_MAC_WINDOW (f));
        CollapseWindow (FRAME_MAC_WINDOW (f), false);
        ShowWindow (FRAME_MAC_WINDOW (f));
      }
--- 5964,5969 ----




reply via email to

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