GNU bug report logs - #6888
mouse-autoselect-window on OS X

Previous Next

Packages: emacs, ns;

Reported by: Éric Martin <emartin <at> cse.unsw.edu.au>

Date: Fri, 20 Aug 2010 13:53:02 UTC

Severity: normal

Tags: help, patch

Found in version 23.2

Done: Jan Djärv <jan.h.d <at> swipnet.se>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 6888 in the body.
You can then email your comments to 6888 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6888; Package emacs. (Fri, 20 Aug 2010 13:53:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Éric Martin <emartin <at> cse.unsw.edu.au>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 20 Aug 2010 13:53:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Éric Martin <emartin <at> cse.unsw.edu.au>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.2; Problem with focus-follows-mouse on OS X
Date: Fri, 20 Aug 2010 15:34:52 +0200
[Message part 1 (text/plain, inline)]
With .emacs containing:

(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
'(focus-follows-mouse t)
'(mouse-autoselect-window t))
(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
)

it is still necessary to click on a window to select it.
This is a problem that is new in Emacs 23 in contrast to Emacs 22.

Best regards,

Eric Martin.




In GNU Emacs 23.2.1 (x86_64-apple-darwin10.4.0, NS apple-appkit-1038.32)
of 2010-08-20 on new-host.home
Windowing system distributor `Apple', version 10.3.1038
configured using `configure  '--with-ns''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: nil
  value of $XMODIFIERS: nil
  locale-coding-system: nil
  default enable-multibyte-characters: t

Major mode: Fundamental

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
C-x 2 <help-echo> <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <help-echo> <help-echo> <down-mouse-1> 
<mouse-1> <help-echo> <down-mouse-1> <mouse-1> <down-mouse-1> 
<mouse-1> <help-echo> <down-mouse-1> <mouse-1> <menu-bar> 
<help-menu> <send-emacs-bug-report>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.

Load-path shadows:
None found.

Features:
(shadow sort mail-extr message ecomplete rfc822 mml mml-sec
password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231
rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc
time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock sha1
hex-util hashcash mail-utils emacsbug tooltip ediff-hook vc-hooks
lisp-float-type mwheel ns-win easymenu tool-bar dnd fontset image fringe
lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar
mldrag mouse jit-lock font-lock syntax facemenu font-core frame cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese hebrew greek romanian slovak czech european ethiopic
indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple
abbrev loaddefs button minibuffer faces cus-face files text-properties
overlay md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process ns multi-tty
emacs)


Eric Martin
School of Computer Science and Engineering
UNSW Sydney NSW 2052 Australia
Building K17 Room 409
Email: emartin <at> cse.unsw.edu.au
Phone: +61 2 9385 6936
Fax: +61 2 9385 4936

Disclaimer: http://www.eng.unsw.edu.au/emaildis.htm
Cricos Provider No. 00098G

[Message part 2 (text/html, inline)]

Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6888; Package emacs. (Fri, 20 Aug 2010 18:03:02 GMT) Full text and rfc822 format available.

Message #8 received at 6888 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Éric Martin <emartin <at> cse.unsw.edu.au>
Cc: 6888 <at> debbugs.gnu.org
Subject: Re: bug#6888: 23.2; Problem with focus-follows-mouse on OS X
Date: Fri, 20 Aug 2010 14:03:57 -0400
Éric Martin wrote:

> '(focus-follows-mouse t)
> '(mouse-autoselect-window t))
[...]
> it is still necessary to click on a window to select it.

Your subject says "problem with focus-follows-mouse", but your use of
the word "window" above suggests a problem with mouse-autoselect-window.

There appears to be no code in src/ns*.m that does anything with
mouse_autoselect_window, so it looks to me like this feature is not
implemented for NS.

> In GNU Emacs 23.2.1 (x86_64-apple-darwin10.4.0, NS apple-appkit-1038.32)
> of 2010-08-20 on new-host.home
> Windowing system distributor `Apple', version 10.3.1038
> configured using `configure  '--with-ns''




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6888; Package emacs. (Fri, 20 Aug 2010 18:14:01 GMT) Full text and rfc822 format available.

Message #11 received at 6888 <at> debbugs.gnu.org (full text, mbox):

From: Éric Martin <emartin <at> cse.unsw.edu.au>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 6888 <at> debbugs.gnu.org
Subject: Re: bug#6888: 23.2; Problem with focus-follows-mouse on OS X
Date: Fri, 20 Aug 2010 20:12:02 +0200
On 20/08/2010, at 8:03 PM, Glenn Morris wrote:

> Éric Martin wrote:
> 
>> '(focus-follows-mouse t)
>> '(mouse-autoselect-window t))
> [...]
>> it is still necessary to click on a window to select it.
> 
> Your subject says "problem with focus-follows-mouse", but your use of
> the word "window" above suggests a problem with mouse-autoselect-window.
> 

Sorry, I should have written "problem with mouse_autoselect_window or focus-follows-mouse", as it seems that both variables need to be set properly for the feature to work.

> There appears to be no code in src/ns*.m that does anything with
> mouse_autoselect_window, so it looks to me like this feature is not
> implemented for NS.

Ok, so some features implemented in Emacs 22 have been dropped in Emacs 23?

> 
>> In GNU Emacs 23.2.1 (x86_64-apple-darwin10.4.0, NS apple-appkit-1038.32)
>> of 2010-08-20 on new-host.home
>> Windowing system distributor `Apple', version 10.3.1038
>> configured using `configure  '--with-ns''






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#6888; Package emacs,ns. (Wed, 21 Aug 2013 17:17:02 GMT) Full text and rfc822 format available.

Message #14 received at 6888 <at> debbugs.gnu.org (full text, mbox):

From: Davor Cubranic <cubranic <at> stat.ubc.ca>
To: 6888 <at> debbugs.gnu.org
Subject: Patch for mouse-autoselect-window on NextStep platforms
Date: Wed, 21 Aug 2013 10:08:19 -0700
[Message part 1 (text/plain, inline)]
FWIW, I was able to copy the SELECT_WINDOW_EVENT code from X (xterm.c) and Win32 (w32term.c) into nsterm.m, adjusting for a few minor differences in variable naming. Focus-follows-mouse on windows within the active frame when mouse-autoselect-window is not nil now works fine in my (not extensive) use of Emacs on my computer. Patch attached.

Davor
[ns-select-window-event.diff (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#6888; Package emacs,ns. (Fri, 23 Aug 2013 07:10:03 GMT) Full text and rfc822 format available.

Message #17 received at 6888 <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Davor Cubranic <cubranic <at> stat.ubc.ca>
Cc: 6888 <at> debbugs.gnu.org
Subject: Re: bug#6888: Patch for mouse-autoselect-window on NextStep platforms
Date: Fri, 23 Aug 2013 09:09:43 +0200
> FWIW, I was able to copy the SELECT_WINDOW_EVENT code from X (xterm.c)
> and Win32 (w32term.c) into nsterm.m, adjusting for a few minor
> differences in variable naming. Focus-follows-mouse on windows within
> the active frame when mouse-autoselect-window is not nil now works
> fine in my (not extensive) use of Emacs on my computer. Patch
> attached.

Thank you.  Can someone on NS please check whether Davor's patch
compiles cleanly?

Thanks, martin





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#6888; Package emacs,ns. (Sat, 24 Aug 2013 09:25:01 GMT) Full text and rfc822 format available.

Message #20 received at 6888 <at> debbugs.gnu.org (full text, mbox):

From: Jan Djärv <jan.h.d <at> swipnet.se>
To: martin rudalics <rudalics <at> gmx.at>
Cc: Davor Cubranic <cubranic <at> stat.ubc.ca>, 6888 <at> debbugs.gnu.org
Subject: Re: bug#6888: Patch for mouse-autoselect-window on NextStep platforms
Date: Sat, 24 Aug 2013 11:24:18 +0200
Hello.

23 aug 2013 kl. 09:09 skrev martin rudalics <rudalics <at> gmx.at>:

> > FWIW, I was able to copy the SELECT_WINDOW_EVENT code from X (xterm.c)
> > and Win32 (w32term.c) into nsterm.m, adjusting for a few minor
> > differences in variable naming. Focus-follows-mouse on windows within
> > the active frame when mouse-autoselect-window is not nil now works
> > fine in my (not extensive) use of Emacs on my computer. Patch
> > attached.
> 
> Thank you.  Can someone on NS please check whether Davor's patch
> compiles cleanly?

It does but I don't want to check it in as is.  It needs formatting fixes and there is some unfortunate code duplication that needs to be done in another way.

	Jan D.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#6888; Package emacs,ns. (Mon, 26 Aug 2013 13:17:01 GMT) Full text and rfc822 format available.

Message #23 received at 6888 <at> debbugs.gnu.org (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Jan Djärv <jan.h.d <at> swipnet.se>
Cc: Davor Cubranic <cubranic <at> stat.ubc.ca>, 6888 <at> debbugs.gnu.org
Subject: Re: bug#6888: Patch for mouse-autoselect-window on NextStep platforms
Date: Mon, 26 Aug 2013 15:16:25 +0200
> It does but I don't want to check it in as is.  It needs formatting fixes and there is some unfortunate code duplication that needs to be done in another way.

Can you please tell Davor how to rewrite it?

Thanks, martin





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#6888; Package emacs,ns. (Mon, 26 Aug 2013 15:08:02 GMT) Full text and rfc822 format available.

Message #26 received at 6888 <at> debbugs.gnu.org (full text, mbox):

From: Jan Djärv <jan.h.d <at> swipnet.se>
To: martin rudalics <rudalics <at> gmx.at>
Cc: Davor Cubranic <cubranic <at> stat.ubc.ca>, 6888 <at> debbugs.gnu.org
Subject: Re: bug#6888: Patch for mouse-autoselect-window on NextStep platforms
Date: Mon, 26 Aug 2013 17:07:14 +0200
26 aug 2013 kl. 15:16 skrev martin rudalics <rudalics <at> gmx.at>:

>> It does but I don't want to check it in as is.  It needs formatting fixes and there is some unfortunate code duplication that needs to be done in another way.
> 
> Can you please tell Davor how to rewrite it?
> 
> Thanks, martin

=== modified file 'src/nsterm.m'
--- src/nsterm.m	2013-08-23 04:03:25 +0000
+++ src/nsterm.m	2013-08-24 09:18:57 +0000
@@ -184,6 +184,9 @@
 Lisp_Object ns_display_name_list;
 long context_menu_value = 0;
 
+/* Last window where we saw the mouse.  Used by mouse-autoselect-window.  */
+static Lisp_Object last_window;
+
 /* display update */
 NSPoint last_mouse_motion_position;
 static NSRect last_mouse_glyph;
@@ -308,8 +311,13 @@
 /* This is a piece of code which is common to all the event handling
    methods.  Maybe it should even be a function.  */
 #define EV_TRAILER(e)                                                   \
-    {                                                                   \
-      XSETFRAME (emacs_event->frame_or_window, emacsframe);             \
+  {                                                                     \
+    XSETFRAME (emacs_event->frame_or_window, emacsframe);               \
+    EV_TRAILER2 (e);                                                    \
+  }
+
+#define EV_TRAILER2(e)                                                  \
+  {                                                                     \
       if (e) emacs_event->timestamp = EV_TIMESTAMP (e);                 \
       if (q_event_ptr)                                                  \
         {                                                               \
@@ -5490,6 +5498,27 @@
   previous_help_echo_string = help_echo_string;
   help_echo_string = Qnil;
 
+  if (!NILP (Vmouse_autoselect_window))
+    {
+      NSTRACE (mouse_autoselect_window);
+      Lisp_Object window;
+      window = window_from_coordinates(emacsframe, last_mouse_motion_position.x,
+                                       last_mouse_motion_position.y, 0, 0);
+      if (WINDOWP (window)
+          && !EQ (window, last_window)
+          && !EQ (window, selected_window)
+          && (focus_follows_mouse
+              || (EQ (XWINDOW (window)->frame,
+                      XWINDOW (selected_window)->frame))))
+        {
+          NSTRACE (in_window);
+          emacs_event->kind = SELECT_WINDOW_EVENT;
+          emacs_event->frame_or_window = window;
+          EV_TRAILER2 (e);
+        }
+      last_window = window;
+    }
+
   if (!note_mouse_movement (emacsframe, last_mouse_motion_position.x,
                             last_mouse_motion_position.y))
     help_echo_string = previous_help_echo_string;






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#6888; Package emacs,ns. (Mon, 26 Aug 2013 16:31:01 GMT) Full text and rfc822 format available.

Message #29 received at 6888 <at> debbugs.gnu.org (full text, mbox):

From: Davor Cubranic <cubranic <at> stat.ubc.ca>
To: Jan Djärv <jan.h.d <at> swipnet.se>
Cc: martin rudalics <rudalics <at> gmx.at>, 6888 <at> debbugs.gnu.org
Subject: Re: bug#6888: Patch for mouse-autoselect-window on NextStep platforms
Date: Mon, 26 Aug 2013 09:30:05 -0700
On 2013-08-24, at 2:24 AM, Jan Djärv wrote:

> 23 aug 2013 kl. 09:09 skrev martin rudalics <rudalics <at> gmx.at>:
> 
>> Thank you.  Can someone on NS please check whether Davor's patch
>> compiles cleanly?
> 
> It does but I don't want to check it in as is.  It needs formatting fixes and there is some unfortunate code duplication that needs to be done in another way.


Yes, I don't know enough about Emacs's source architecture, so I deliberately duplicated code from other platforms whenever I could. I just wanted a basic fix that I could submit to this list for further discussion and refinement. Thanks for taking it,

Davor






Reply sent to Jan Djärv <jan.h.d <at> swipnet.se>:
You have taken responsibility. (Wed, 28 Aug 2013 16:22:02 GMT) Full text and rfc822 format available.

Notification sent to Éric Martin <emartin <at> cse.unsw.edu.au>:
bug acknowledged by developer. (Wed, 28 Aug 2013 16:22:04 GMT) Full text and rfc822 format available.

Message #34 received at 6888-done <at> debbugs.gnu.org (full text, mbox):

From: Jan Djärv <jan.h.d <at> swipnet.se>
To: Davor Cubranic <cubranic <at> stat.ubc.ca>
Cc: 6888-done <at> debbugs.gnu.org
Subject: Re: bug#6888: Patch for mouse-autoselect-window on NextStep platforms
Date: Wed, 28 Aug 2013 18:21:22 +0200
Hello.

I've checked in a slightly modified version.

	Jan D.

21 aug 2013 kl. 19:08 skrev Davor Cubranic <cubranic <at> stat.ubc.ca>:

> FWIW, I was able to copy the SELECT_WINDOW_EVENT code from X (xterm.c) and Win32 (w32term.c) into nsterm.m, adjusting for a few minor differences in variable naming. Focus-follows-mouse on windows within the active frame when mouse-autoselect-window is not nil now works fine in my (not extensive) use of Emacs on my computer. Patch attached.
> 
> Davor
> <ns-select-window-event.diff>





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 26 Sep 2013 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 236 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.