unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#30207: 27.0.50; [PATCH] other-window-for-scrolling returns window on daemon frame
@ 2018-01-22 15:57 Basil L. Contovounesios
  2018-01-22 18:59 ` martin rudalics
  0 siblings, 1 reply; 13+ messages in thread
From: Basil L. Contovounesios @ 2018-01-22 15:57 UTC (permalink / raw)
  To: 30207

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-Do-not-scroll-other-window-in-daemon-frame.patch --]
[-- Type: text/x-diff, Size: 1506 bytes --]

From 0471afc8da07d2dc397f2cf833d9f8bccfbe31c1 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Mon, 22 Jan 2018 02:57:08 +0000
Subject: [PATCH] Do not scroll other window in daemon frame

* src/window.c (Fother_window_for_scrolling): Ignore daemon frame
when searching other frames for a window.
---
 src/window.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/window.c b/src/window.c
index 08c3f32dff..c050b4e6c9 100644
--- a/src/window.c
+++ b/src/window.c
@@ -5704,6 +5704,7 @@ specifies the window.  This takes precedence over
   (void)
 {
   Lisp_Object window;
+  struct frame *f;
 
   if (MINI_WINDOW_P (XWINDOW (selected_window))
       && !NILP (Vminibuf_scroll_window))
@@ -5725,11 +5726,14 @@ specifies the window.  This takes precedence over
 
       if (EQ (window, selected_window))
 	/* That didn't get us anywhere; look for a window on another
-           visible frame.  */
+           visible frame, ignoring the daemon's frame.  */
 	do
-	  window = Fnext_window (window, Qnil, Qt);
-	while (! FRAME_VISIBLE_P (XFRAME (WINDOW_FRAME (XWINDOW (window))))
-	       && ! EQ (window, selected_window));
+          {
+            window = Fnext_window (window, Qnil, Qt);
+            f = WINDOW_XFRAME (XWINDOW (window));
+          }
+        while (! ((FRAME_VISIBLE_P (f) && ! (IS_DAEMON && FRAME_INITIAL_P (f)))
+                  || EQ (window, selected_window)));
     }
 
   CHECK_LIVE_WINDOW (window);
-- 
2.15.1


[-- Attachment #2: Type: text/plain, Size: 1408 bytes --]


Consider the following:

1. emacs -Q --daemon

2. emacsclient --create-frame

3. (selected-window)
     => #<window 3 on *scratch*>

4. (other-window-for-scrolling)
     => #<window 1 on *scratch*>

5. (frame-terminal (window-frame (other-window-for-scrolling)))
     => #<terminal 0 on initial_terminal>

This can result in commands scroll-other-window and
scroll-other-window-down scrolling the "phantom" initial frame of the
daemon instead of signalling a "no other window" error.  I imagine this
behaviour is never desirable.

I believe this issue and its potential resolution share some ground with
bug#27210 in that the daemon frame is counterintuitively considered
visible in the following repeat-until condition in
Fother_window_for_scrolling:

  do
    window = Fnext_window (window, Qnil, Qt);
  while (! FRAME_VISIBLE_P (XFRAME (WINDOW_FRAME (XWINDOW (window))))
         && ! EQ (window, selected_window));

Until a more thorough review of the visibility of the initial daemon
frame is reached, I propose the attached patch to additionally ignore
the daemon frame in the aforementioned repeat-until condition.  I assume
the overhead of the additional loop logic and IS_DAEMON invariant is
negligible compared to the rest of the function.

An alternative approach to the attached patch would be to limit "other
window scrolling" to frames in the current terminal, as per the spirit
of bug#5616:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: diff.diff --]
[-- Type: text/x-diff, Size: 643 bytes --]

diff --git a/src/window.c b/src/window.c
index 08c3f32dff..328fcb3829 100644
--- a/src/window.c
+++ b/src/window.c
@@ -5725,11 +5725,8 @@ specifies the window.  This takes precedence over
 
       if (EQ (window, selected_window))
 	/* That didn't get us anywhere; look for a window on another
-           visible frame.  */
-	do
-	  window = Fnext_window (window, Qnil, Qt);
-	while (! FRAME_VISIBLE_P (XFRAME (WINDOW_FRAME (XWINDOW (window))))
-	       && ! EQ (window, selected_window));
+           visible frame on the current terminal.  */
+        window = Fnext_window (window, Qnil, Qvisible);
     }
 
   CHECK_LIVE_WINDOW (window);

[-- Attachment #4: Type: text/plain, Size: 1016 bytes --]


or at least prioritise the current terminal's frames.  WDYT?

Thanks,

-- 
Basil

In GNU Emacs 27.0.50 (build 25, x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2018-01-22 built on thunk
Repository revision: c42959cc206bcb52baffd45f892da1b767f0f8c1
Windowing system distributor 'The X.Org Foundation', version 11.0.11905000
System Description: Debian GNU/Linux testing (buster)

Configured using:
 'configure --config-cache --prefix=/home/blc/.local --with-mailutils
 --with-x-toolkit=lucid --with-modules --with-file-notification=yes
 --with-x 'CFLAGS=-flto -fomit-frame-pointer -march=native -maes -mavx
 -mcrc32 -mf16c -mfpmath=sse -mfsgsbase -mfxsr -minline-all-stringops
 -mmmx -mpclmul -mpopcnt -msahf -msse4.2 -mxsave -mxsaveopt -mvzeroupper
 -O2 -pipe' LDFLAGS=-flto'

Configured features:
XAW3D XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS
NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS LUCID X11 MODULES THREADS LIBSYSTEMD JSON LCMS2

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-05-10 23:48 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-22 15:57 bug#30207: 27.0.50; [PATCH] other-window-for-scrolling returns window on daemon frame Basil L. Contovounesios
2018-01-22 18:59 ` martin rudalics
2018-01-23  0:07   ` Basil L. Contovounesios
2018-01-23  0:29     ` Noam Postavsky
2018-01-23  1:06       ` Basil L. Contovounesios
2018-01-23  1:29         ` Noam Postavsky
2018-01-23 13:28     ` Basil L. Contovounesios
2018-05-02 18:57       ` Basil L. Contovounesios
2018-05-02 19:44         ` Eli Zaretskii
2018-05-03 13:03           ` Basil L. Contovounesios
2018-05-03 19:00             ` Eli Zaretskii
2018-05-03 22:44               ` Basil L. Contovounesios
2018-05-10 23:48                 ` Noam Postavsky

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