unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Focus follows mouse mode for 21.2.95
       [not found] <mailman.9581.1045649384.21481.emacs-devel@gnu.org>
@ 2003-02-19 10:45 ` Dmitry Antipov
  0 siblings, 0 replies; only message in thread
From: Dmitry Antipov @ 2003-02-19 10:45 UTC (permalink / raw)
  Cc: bug-gnu-emacs

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

Hello all,

 I'm implemented the "focus follows mouse" mode - the window can be selected
when the mouse enters it's text area. Code is currently works on X displays
only, but it should be easy to support W32 and MAC displays as well (if the
conception itself is right).

TIA,
Dmitry


[-- Attachment #2: emacs-21.2.95-focus-follows-mouse-x.patch --]
[-- Type: text/plain, Size: 2837 bytes --]

diff -ur --exclude-from=exclude.txt emacs-21.2.95-vanilla/src/window.c emacs-21.2.95/src/window.c
--- emacs-21.2.95-vanilla/src/window.c	Wed Jun  5 20:56:50 2002
+++ emacs-21.2.95/src/window.c	Wed Feb 19 13:06:41 2003
@@ -216,6 +216,10 @@
 
 Lisp_Object Vscroll_preserve_screen_position;
 
+/* Nonzero if focus follows mouse mode is on.  */
+
+int focus_follows_mouse;
+
 #if 0 /* This isn't used anywhere.  */
 /* Nonzero means we can split a frame even if it is "unsplittable".  */
 static int inhibit_frame_unsplittable;
@@ -5582,6 +5586,28 @@
   foreach_window (f, freeze_window_start, (void *) (freeze_p ? f : 0));
 }
 
+/* Try to select the window on frame FRAME when the
+   mouse pointer position at (X, Y) enters it.  */
+
+void
+select_mouse_entered_window (frame, x, y)
+     FRAME_PTR frame;
+     int x;
+     int y;
+{
+  if (focus_follows_mouse)
+    {
+      int part;
+      Lisp_Object window;
+      
+      window = window_from_coordinates (frame, x, y, &part, 0);
+      if (WINDOW_LIVE_P (window) &&
+	  (window != FRAME_SELECTED_WINDOW (frame)) &&
+	  !MINI_WINDOW_P (XWINDOW (window)) &&
+	  (++part == ON_TEXT)) 
+	Fselect_window (window);
+    }
+}
 \f
 /***********************************************************************
 			    Initialization
@@ -5917,6 +5943,10 @@
 This variable automatically becomes buffer-local when set.");
   Fmake_variable_buffer_local (Qwindow_size_fixed);
   window_size_fixed = 0;
+
+  DEFVAR_BOOL ("focus-follows-mouse", &focus_follows_mouse,
+    "Non-nil means select a window when the mouse enters it's text area.");
+  focus_follows_mouse = 1;
 
   defsubr (&Sselected_window);
   defsubr (&Sminibuffer_window);
diff -ur --exclude-from=exclude.txt emacs-21.2.95-vanilla/src/window.h emacs-21.2.95/src/window.h
--- emacs-21.2.95-vanilla/src/window.h	Thu Jan 18 17:09:39 2001
+++ emacs-21.2.95/src/window.h	Wed Feb 19 13:07:20 2003
@@ -386,6 +386,7 @@
 				void *));
 extern void grow_mini_window P_ ((struct window *, int));
 extern void shrink_mini_window P_ ((struct window *));
+extern void select_mouse_entered_window P_ ((struct frame *, int, int));
 
 
 /* Make WINDOW display BUFFER as its contents.  RUN_HOOKS_P non-zero
diff -ur --exclude-from=exclude.txt emacs-21.2.95-vanilla/src/xterm.c emacs-21.2.95/src/xterm.c
--- emacs-21.2.95-vanilla/src/xterm.c	Tue Oct 15 18:21:45 2002
+++ emacs-21.2.95/src/xterm.c	Wed Feb 19 13:08:40 2003
@@ -6658,6 +6658,11 @@
       last_mouse_scroll_bar = Qnil;
       note_mouse_highlight (frame, event->x, event->y);
     }
+
+  if (!event->state)
+    /* Clean mouse movement without any keys or buttons pressed. Select
+       the window under mouse pointer if focus follows mouse is on.  */
+    select_mouse_entered_window (frame, event->x, event->y);
 }
 
 /* This is used for debugging, to turn off note_mouse_highlight.  */

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-02-19 10:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.9581.1045649384.21481.emacs-devel@gnu.org>
2003-02-19 10:45 ` Focus follows mouse mode for 21.2.95 Dmitry Antipov

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).