From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Pavel@Janik.cz (Pavel =?iso-8859-2?q?Jan=EDk?=) Newsgroups: gmane.emacs.devel Subject: Re: x_autoselect_window_p Date: Sun, 31 Mar 2002 21:57:24 +0200 Sender: emacs-devel-admin@gnu.org Message-ID: References: <200203131058.g2DAwnL05479@wijiji.santafe.edu> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 8bit X-Trace: main.gmane.org 1017604656 601 127.0.0.1 (31 Mar 2002 19:57:36 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 31 Mar 2002 19:57:36 +0000 (UTC) Cc: emacs-devel@gnu.org, gerd@gnu.org Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 16rlSK-00009a-00 for ; Sun, 31 Mar 2002 21:57:36 +0200 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 16rldC-00065J-00 for ; Sun, 31 Mar 2002 22:08:50 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 16rlS4-0003pe-00; Sun, 31 Mar 2002 14:57:20 -0500 Original-Received: from p0159.as-l043.contactel.cz ([194.108.242.159] helo=SnowWhite.SuSE.cz) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 16rlQW-0003mQ-00; Sun, 31 Mar 2002 14:55:45 -0500 Original-Received: by SnowWhite.SuSE.cz (PJ, from userid 500) id 1B3F218F6F; Sun, 31 Mar 2002 21:58:00 +0200 (CEST) Original-To: rms@gnu.org Mail-Copies-To: never X-Face: $"d&^B_IKlTHX!y2d,3;grhwjOBqOli]LV`6d]58%5'x/kBd7.MO&n3bJ@Zkf&RfBu|^qL+ ?/Re{MpTqanXS2'~Qp'J2p^M7uM:zp[1Xq#{|C!*'&NvCC[9!|=>#qHqIhroq_S"MH8nSH+d^9*BF: iHiAs(t(~b#1.{w.d[=Z In-Reply-To: <200203131058.g2DAwnL05479@wijiji.santafe.edu> (Richard Stallman's message of "Wed, 13 Mar 2002 03:58:49 -0700 (MST)") User-Agent: Gnus/5.090006 (Oort Gnus v0.06) Emacs/21.2.50 (i386-suse-linux-gnu) Original-Lines: 171 Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.8 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:2286 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:2286 From: Richard Stallman 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