[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: x_autoselect_window_p
From: |
Pavel Janík |
Subject: |
Re: x_autoselect_window_p |
Date: |
Sun, 31 Mar 2002 21:57:24 +0200 |
User-agent: |
Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.2.50 (i386-suse-linux-gnu) |
From: Richard Stallman <address@hidden>
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