unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: martin rudalics <rudalics@gmx.at>
Cc: 13225@debbugs.gnu.org
Subject: bug#13225: 24.3.50; Non-selected window has not mode-line-inactive face
Date: Wed, 19 Dec 2012 18:07:18 +0200	[thread overview]
Message-ID: <83zk1anhzd.fsf@gnu.org> (raw)
In-Reply-To: <50D176DF.4080102@gmx.at>

> Date: Wed, 19 Dec 2012 09:12:15 +0100
> From: martin rudalics <rudalics@gmx.at>
> 
> With emacs -Q do C-x 5 2.  The mode lines of both windows appear in
> `mode-line' face, regardless of which window is selected.
> 
> This contradicts the Elisp manual which says:
> 
>        The selected window's mode line is usually displayed in a different
>     color using the face `mode-line'.  Other windows' mode lines appear in
>     the face `mode-line-inactive' instead.

We are shooting ourselves in the foot.  At some point during
redisplay, it loops over all the frames and redisplays every window of
every visible frame.  Here's the beginning of that loop:

      FOR_EACH_FRAME (tail, frame)
	{
	  struct frame *f = XFRAME (frame);

	  /* We don't have to do anything for unselected terminal
	     frames.  */
	  if ((FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f))
	      && !EQ (FRAME_TTY (f)->top_frame, frame))
	    continue;

	  if (FRAME_WINDOW_P (f) || FRAME_TERMCAP_P (f) || f == sf)
	    {
	      /* Select the frame, for the sake of frame-local variables.  */
	      ensure_selected_frame (frame);

	      /* Mark all the scroll bars to be removed; we'll redeem
		 the ones we want when we redisplay their windows.  */
	      if (FRAME_TERMINAL (f)->condemn_scroll_bars_hook)
		FRAME_TERMINAL (f)->condemn_scroll_bars_hook (f);

	      if (FRAME_VISIBLE_P (f) && !FRAME_OBSCURED_P (f))
		redisplay_windows (FRAME_ROOT_WINDOW (f));

Where we now call ensure_selected_frame, originally there was a call
to select_frame_for_redisplay, which arranged for all the frame-local
variables to appear in C variables.  But now it does this in addition:

  selected_frame = frame;
  /* If redisplay causes scrolling, it sets point in the window, so we need to
     be careful with the selected-window's point handling.  */
  select_window_1 (XFRAME (frame)->selected_window, 0);

This selects the frame, and _also_ makes that frame's selected window
be the global selected_window.  Therefore, when display_mode_lines
comes to select a proper face for the mode line, it always finds the
frame's selected window in selected_window, and thus always uses the
face for selected windows.

I can fix this with the kludge shown below, but do we care about yet
another global variable, in addition to selected_window?  If we don't
want this, then the only other way I see is to drag this window all
the way down to display_mode_lines through the calling sequences.
(That's assuming that only the mode-line display wants to know about
the _real_ selected_window.)

=== modified file 'src/xdisp.c'
--- src/xdisp.c	2012-12-17 19:17:06 +0000
+++ src/xdisp.c	2012-12-19 16:02:53 +0000
@@ -13006,6 +13006,8 @@ do { if (polling_stopped_here) start_pol
 /* Perhaps in the future avoid recentering windows if it
    is not necessary; currently that causes some problems.  */
 
+static struct window *sw_on_sf;
+
 static void
 redisplay_internal (void)
 {
@@ -13491,6 +13493,8 @@ redisplay_internal (void)
 
 	  if (FRAME_WINDOW_P (f) || FRAME_TERMCAP_P (f) || f == sf)
 	    {
+	      sw_on_sf = sw;
+
 	      /* Select the frame, for the sake of frame-local variables.  */
 	      ensure_selected_frame (frame);
 
@@ -20371,7 +20375,7 @@ display_mode_lines (struct window *w)
 
   if (WINDOW_WANTS_MODELINE_P (w))
     {
-      struct window *sel_w = XWINDOW (old_selected_window);
+      struct window *sel_w = sw_on_sf;
 
       /* Select mode line face based on the real selected window.  */
       display_mode_line (w, CURRENT_MODE_LINE_FACE_ID_3 (sel_w, sel_w, w),






  reply	other threads:[~2012-12-19 16:07 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-19  8:12 bug#13225: 24.3.50; Non-selected window has not mode-line-inactive face martin rudalics
2012-12-19 16:07 ` Eli Zaretskii [this message]
2012-12-19 18:30   ` Stefan Monnier
2012-12-19 19:16     ` Drew Adams
2012-12-19 19:28       ` Drew Adams
2012-12-19 20:07         ` Stefan Monnier
2012-12-19 20:56           ` Drew Adams
2012-12-20  0:52             ` Stefan Monnier
2012-12-19 21:36     ` Eli Zaretskii
2012-12-20  2:08       ` Stefan Monnier
2012-12-20  9:59     ` martin rudalics
2012-12-20 14:03       ` Stefan Monnier
2012-12-20 16:28         ` Eli Zaretskii
2012-12-20 17:24           ` martin rudalics
2012-12-20 17:37             ` Eli Zaretskii
2012-12-21  9:15               ` martin rudalics
2012-12-21  9:35                 ` Eli Zaretskii
2012-12-21 14:24                   ` martin rudalics
2012-12-21 14:43                     ` Eli Zaretskii
2012-12-20 17:25         ` martin rudalics
2012-12-20 18:07           ` Stefan Monnier
2012-12-21  9:16             ` martin rudalics
2012-12-22 15:52               ` Stefan Monnier
2012-12-22 16:05                 ` martin rudalics
2012-12-22 16:56                   ` Stefan Monnier
2012-12-22 17:42                     ` martin rudalics
2012-12-23 13:41                       ` Stefan Monnier
2012-12-23 14:03                         ` martin rudalics
2012-12-23 15:40                           ` Stefan Monnier
2012-12-20  9:59   ` martin rudalics
2012-12-20 17:09     ` Eli Zaretskii
2012-12-20 17:24       ` martin rudalics
2013-01-04  8:28 ` Glenn Morris

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=83zk1anhzd.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=13225@debbugs.gnu.org \
    --cc=rudalics@gmx.at \
    /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).