unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#6888: 23.2; Problem with focus-follows-mouse on OS X
@ 2010-08-20 13:34 Éric Martin
  2010-08-20 18:03 ` Glenn Morris
  2013-08-21 17:08 ` bug#6888: Patch for mouse-autoselect-window on NextStep platforms Davor Cubranic
  0 siblings, 2 replies; 10+ messages in thread
From: Éric Martin @ 2010-08-20 13:34 UTC (permalink / raw)
  To: 6888

[-- Attachment #1: Type: text/plain, Size: 3168 bytes --]

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@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


[-- Attachment #2: Type: text/html, Size: 10691 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#6888: 23.2; Problem with focus-follows-mouse on OS X
  2010-08-20 13:34 bug#6888: 23.2; Problem with focus-follows-mouse on OS X Éric Martin
@ 2010-08-20 18:03 ` Glenn Morris
  2010-08-20 18:12   ` Éric Martin
  2013-08-21 17:08 ` bug#6888: Patch for mouse-autoselect-window on NextStep platforms Davor Cubranic
  1 sibling, 1 reply; 10+ messages in thread
From: Glenn Morris @ 2010-08-20 18:03 UTC (permalink / raw)
  To: Éric Martin; +Cc: 6888

É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''





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#6888: 23.2; Problem with focus-follows-mouse on OS X
  2010-08-20 18:03 ` Glenn Morris
@ 2010-08-20 18:12   ` Éric Martin
  0 siblings, 0 replies; 10+ messages in thread
From: Éric Martin @ 2010-08-20 18:12 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 6888


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''







^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#6888: Patch for mouse-autoselect-window on NextStep platforms
  2010-08-20 13:34 bug#6888: 23.2; Problem with focus-follows-mouse on OS X Éric Martin
  2010-08-20 18:03 ` Glenn Morris
@ 2013-08-21 17:08 ` Davor Cubranic
  2013-08-23  7:09   ` martin rudalics
  2013-08-28 16:21   ` Jan Djärv
  1 sibling, 2 replies; 10+ messages in thread
From: Davor Cubranic @ 2013-08-21 17:08 UTC (permalink / raw)
  To: 6888

[-- Attachment #1: Type: text/plain, Size: 353 bytes --]

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

[-- Attachment #2: ns-select-window-event.diff --]
[-- Type: application/octet-stream, Size: 2109 bytes --]

diff --git a/src/ChangeLog b/src/ChangeLog
index f62c8ab..6c7ef59 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2013-08-21  Davor Cubranic  <cubranic@stat.ubc.ca>
+
+	* nsterm.m (mouseMoved): Add support for mouse-autoselect-window
+	on nextstep (Bug#6888).
+
 2013-07-15  Glenn Morris  <rgm@gnu.org>
 
 	* image.c (Fimage_flush): Fix doc typo.
diff --git a/src/nsterm.m b/src/nsterm.m
index a57e744..217272e 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -169,6 +169,9 @@ struct ns_display_info *x_display_list; /* Chain of existing displays */
 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;
@@ -5316,6 +5319,34 @@ not_in_argv (NSString *arg)
   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;
+      emacs_event->timestamp = EV_TIMESTAMP(e);
+      if (q_event_ptr)
+        {
+          n_emacs_events_pending++;
+          kbd_buffer_store_event_hold (emacs_event, q_event_ptr);
+        }
+      else
+        hold_event (emacs_event);
+      
+      EVENT_INIT (*emacs_event);
+    }
+    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;

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#6888: Patch for mouse-autoselect-window on NextStep platforms
  2013-08-21 17:08 ` bug#6888: Patch for mouse-autoselect-window on NextStep platforms Davor Cubranic
@ 2013-08-23  7:09   ` martin rudalics
  2013-08-24  9:24     ` Jan Djärv
  2013-08-28 16:21   ` Jan Djärv
  1 sibling, 1 reply; 10+ messages in thread
From: martin rudalics @ 2013-08-23  7:09 UTC (permalink / raw)
  To: Davor Cubranic; +Cc: 6888

 > 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






^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#6888: Patch for mouse-autoselect-window on NextStep platforms
  2013-08-23  7:09   ` martin rudalics
@ 2013-08-24  9:24     ` Jan Djärv
  2013-08-26 13:16       ` martin rudalics
  2013-08-26 16:30       ` Davor Cubranic
  0 siblings, 2 replies; 10+ messages in thread
From: Jan Djärv @ 2013-08-24  9:24 UTC (permalink / raw)
  To: martin rudalics; +Cc: Davor Cubranic, 6888

Hello.

23 aug 2013 kl. 09:09 skrev martin rudalics <rudalics@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.






^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#6888: Patch for mouse-autoselect-window on NextStep platforms
  2013-08-24  9:24     ` Jan Djärv
@ 2013-08-26 13:16       ` martin rudalics
  2013-08-26 15:07         ` Jan Djärv
  2013-08-26 16:30       ` Davor Cubranic
  1 sibling, 1 reply; 10+ messages in thread
From: martin rudalics @ 2013-08-26 13:16 UTC (permalink / raw)
  To: Jan Djärv; +Cc: Davor Cubranic, 6888

> 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






^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#6888: Patch for mouse-autoselect-window on NextStep platforms
  2013-08-26 13:16       ` martin rudalics
@ 2013-08-26 15:07         ` Jan Djärv
  0 siblings, 0 replies; 10+ messages in thread
From: Jan Djärv @ 2013-08-26 15:07 UTC (permalink / raw)
  To: martin rudalics; +Cc: Davor Cubranic, 6888


26 aug 2013 kl. 15:16 skrev martin rudalics <rudalics@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;







^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#6888: Patch for mouse-autoselect-window on NextStep platforms
  2013-08-24  9:24     ` Jan Djärv
  2013-08-26 13:16       ` martin rudalics
@ 2013-08-26 16:30       ` Davor Cubranic
  1 sibling, 0 replies; 10+ messages in thread
From: Davor Cubranic @ 2013-08-26 16:30 UTC (permalink / raw)
  To: Jan Djärv; +Cc: 6888

On 2013-08-24, at 2:24 AM, Jan Djärv wrote:

> 23 aug 2013 kl. 09:09 skrev martin rudalics <rudalics@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







^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#6888: Patch for mouse-autoselect-window on NextStep platforms
  2013-08-21 17:08 ` bug#6888: Patch for mouse-autoselect-window on NextStep platforms Davor Cubranic
  2013-08-23  7:09   ` martin rudalics
@ 2013-08-28 16:21   ` Jan Djärv
  1 sibling, 0 replies; 10+ messages in thread
From: Jan Djärv @ 2013-08-28 16:21 UTC (permalink / raw)
  To: Davor Cubranic; +Cc: 6888-done

Hello.

I've checked in a slightly modified version.

	Jan D.

21 aug 2013 kl. 19:08 skrev Davor Cubranic <cubranic@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>






^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-08-28 16:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-20 13:34 bug#6888: 23.2; Problem with focus-follows-mouse on OS X Éric Martin
2010-08-20 18:03 ` Glenn Morris
2010-08-20 18:12   ` Éric Martin
2013-08-21 17:08 ` bug#6888: Patch for mouse-autoselect-window on NextStep platforms Davor Cubranic
2013-08-23  7:09   ` martin rudalics
2013-08-24  9:24     ` Jan Djärv
2013-08-26 13:16       ` martin rudalics
2013-08-26 15:07         ` Jan Djärv
2013-08-26 16:30       ` Davor Cubranic
2013-08-28 16:21   ` Jan Djärv

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).