From: Pavel@Janik.cz (Pavel Janík)
Cc: emacs-devel@gnu.org, gerd@gnu.org
Subject: Re: x_autoselect_window_p
Date: Sun, 31 Mar 2002 21:57:24 +0200 [thread overview]
Message-ID: <m3bsd4zf17.fsf@Janik.cz> (raw)
In-Reply-To: <200203131058.g2DAwnL05479@wijiji.santafe.edu> (Richard Stallman's message of "Wed, 13 Mar 2002 03:58:49 -0700 (MST)")
From: Richard Stallman <rms@gnu.org>
Date: Wed, 13 Mar 2002 03:58:49 -0700 (MST)
> Gerd commented out the code for x_autoselect_window_p because he
> saw it was running Lisp code from a signal handler.
> ISTR that shortly after the code was installed I pointed
> out that it had to be rewritten for this reason, but that
> apparently was not done. It is best for it to stay
> commented out until someone rewrites it the right way.
I found some time today and tried to rewrote it. But failed :-( I patched
four files:
/home/pavel/.Emacs/Work/emacs/src:
-rw-r--r-- (modified) bře 31 21:23 keyboard.c
-rw-r--r-- (modified) bře 31 20:59 keyboard.h
-rw-r--r-- (modified) bře 31 20:55 termhooks.h
-rw-r--r-- (modified) bře 31 20:58 xterm.c
termhooks.h only adds new event type:
--- termhooks.h.~1.57.~ Sun Mar 10 19:22:28 2002
+++ termhooks.h Sun Mar 31 20:55:30 2002
@@ -325,6 +325,9 @@
`switch-frame' events in kbd_buffer_get_event, if necessary. */
FOCUS_IN_EVENT,
+ /* Generated when mouse moves over window not currently selected. */
+ WINDOW_IN_EVENT,
+
/* Queued from XTread_socket when session manager sends
save yourself before shutdown. */
save_session_event
xterm.c now generates this event when it should:
--- xterm.c.~1.716.~ Sun Mar 31 18:32:34 2002
+++ xterm.c Sun Mar 31 20:58:44 2002
@@ -10894,8 +10894,39 @@
clear_mouse_face (dpyinfo);
}
- if (f)
+ if (f) {
+
+ /* Generate WINDOW_IN_EVENTs when needed. */
+ if (x_autoselect_window_p)
+ {
+ Lisp_Object window;
+ int area;
+ static Lisp_Object last_window;
+
+ window = window_from_coordinates (f,
+ XINT (event.xmotion.x), XINT (event.xmotion.y),
+ &area, 0);
+
+ /* Window will be selected only when it is not selected now and
+ last mouse movement event was not in it. Minibuffer window
+ will be selected iff it is active. */
+ if (!EQ (window, last_window)
+ && !EQ (window, selected_window)
+ && (!MINI_WINDOW_P (XWINDOW (window))
+ || (EQ (window, minibuf_window) && minibuf_level > 0)))
+ {
+ fprintf(stderr, "WINDOW_IN_EVENT generated!\n");
+
+ bufp->kind = WINDOW_IN_EVENT;
+ XSETFRAME (bufp->frame_or_window, window);
+ bufp->arg = Qnil;
+ ++bufp, ++count, --numchars;
+ }
+
+ last_window=window;
+ }
note_mouse_movement (f, &event.xmotion);
+ }
else
{
#ifndef USE_TOOLKIT_SCROLL_BARS
So far, it is without problems, WINDOW_IN_EVENT is generated and seen in
keyboard.c without problems. Now, we should process it:
--- keyboard.h.~1.57.~ Wed Mar 6 17:03:10 2002
+++ keyboard.h Sun Mar 31 20:59:52 2002
@@ -181,6 +181,9 @@
/* Total number of times read_char has returned. */
extern int num_input_events;
+/* Defined in xterm.c */
+extern int x_autoselect_window_p;
+
/* Total number of times read_char has returned, outside of macros. */
extern EMACS_INT num_nonmacro_input_events;
--- keyboard.c.~1.665.~ Sun Mar 24 21:28:14 2002
+++ keyboard.c Sun Mar 31 21:23:08 2002
@@ -544,6 +544,7 @@
Lisp_Object Qdelete_frame;
Lisp_Object Qiconify_frame;
Lisp_Object Qmake_frame_visible;
+Lisp_Object Qselect_window;
Lisp_Object Qhelp_echo;
/* Symbols to denote kinds of events. */
@@ -3791,6 +3792,17 @@
internal_last_event_frame = frame;
kbd_fetch_ptr = event + 1;
}
+ else if (event->kind == WINDOW_IN_EVENT)
+ {
+
+ fprintf(stderr, "WINDOW_IN_EVENT received!\n");
+
+ /* Make an event (select-window (WINDOW)). */
+ obj = Fcons (event->frame_or_window, Qnil);
+ obj = Fcons (Qselect_window, Fcons (obj, Qnil));
+
+ kbd_fetch_ptr = event + 1;
+ }
else
{
/* If this event is on a different frame, return a switch-frame this
@@ -10302,7 +10314,8 @@
{&Qswitch_frame, "switch-frame", &Qswitch_frame},
{&Qdelete_frame, "delete-frame", &Qdelete_frame},
{&Qiconify_frame, "iconify-frame", &Qiconify_frame},
- {&Qmake_frame_visible, "make-frame-visible", &Qmake_frame_visible}
+ {&Qmake_frame_visible, "make-frame-visible", &Qmake_frame_visible},
+ {&Qselect_window, "select-window", &Qselect_window}
};
void
@@ -10968,6 +10981,8 @@
"ignore-event");
initial_define_lispy_key (Vspecial_event_map, "make-frame-visible",
"ignore-event");
+ initial_define_lispy_key (Vspecial_event_map, "select-window",
+ "handle-select-window");
initial_define_lispy_key (Vspecial_event_map, "save-session",
"handle-save-session");
}
I use this fake function to do the real work:
(defun handle-select-window (event)
"Handle delete-frame events from the X server."
(interactive "e")
(message "Switching to: %s" (car (event-start event)))
(select-window (car (event-start event))))
To test this, I run emacs -q -eval '(setq x-autoselect-window t)', C-x
2 and move between those two windows. After about 20 calls to
select-window, Emacs will crash in mark_font_cache. There is a problem
somewhere, but I do not see it :-( Can you please help me so we can clear
this issue?
--
Pavel Janík
/* These are the most dangerous and useful defines. They do printk() during
* the interrupt processing routine(s), so if you manage to get "flooded" by
* irq's, start thinking about the "Power off/on" button... */
-- 2.2.16 drivers/sbus/char/aurora.h
next prev parent reply other threads:[~2002-03-31 19:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-03-13 10:58 x_autoselect_window_p Richard Stallman
2002-03-13 23:01 ` x_autoselect_window_p Pavel Janík
2002-03-31 19:57 ` Pavel Janík [this message]
2002-03-31 20:38 ` x_autoselect_window_p Gerd Moellmann
2002-03-31 21:48 ` x_autoselect_window_p Gerd Moellmann
2002-03-31 22:44 ` x_autoselect_window_p Pavel Janík
2002-04-01 9:25 ` x_autoselect_window_p Gerd Moellmann
2002-04-01 10:47 ` x_autoselect_window_p Pavel Janík
2002-04-01 14:55 ` x_autoselect_window_p Gerd Moellmann
2002-04-01 16:55 ` x_autoselect_window_p Pavel Janík
2002-04-02 6:44 ` x_autoselect_window_p Eli Zaretskii
2002-04-03 4:55 ` x_autoselect_window_p Richard Stallman
2002-04-03 8:33 ` x_autoselect_window_p Pavel Janík
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3bsd4zf17.fsf@Janik.cz \
--to=pavel@janik.cz \
--cc=emacs-devel@gnu.org \
--cc=gerd@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).