GNU bug report logs - #57468
29.0.50; Text cursor continues to blink when frame loses focus

Previous Next

Package: emacs;

Reported by: Bob Rogers <rogers <at> rgrjr.com>

Date: Sun, 28 Aug 2022 23:39:02 UTC

Severity: normal

Tags: moreinfo

Found in version 29.0.50

Done: Po Lu <luangruo <at> yahoo.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 57468 in the body.
You can then email your comments to 57468 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#57468; Package emacs. (Sun, 28 Aug 2022 23:39:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Bob Rogers <rogers <at> rgrjr.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 28 Aug 2022 23:39:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Bob Rogers <rogers <at> rgrjr.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.50; Text cursor continues to blink when frame loses focus
Date: Sun, 28 Aug 2022 16:38:24 -0700
   I have a number of independent emacs sessions, each with a single GUI
frame, some remote via SSH and some as root.  In the sessions using
emacs built recently from master with blink-cursor-mode enabled, the
cursor continues to blink even when the (single) frame loses focus, when
it should become a steady hollow box.  This also happens in "emacs -Q"
(somewhat intermittently, along with failure to start blinking, and some
stranger things).  The following test code:

	(let ((count 0))
	  (while t
	    (message "focus state at %d:  %S"
		     (cl-incf count) (frame-focus-state))
	    (sit-for 2)))

shows that the focus state never changes from `t'.  The problem appears
to be that handle-focus-out is never called, but I don't know the emacs
window system interface well enough to follow it any farther.

   FWIW, the problem doesn't happen in 28.1, or in an emacs built from
the master branch on 24-May.  I should also mention that one of my
sessions started behaving properly again while I was trying to debug
this, but I have no idea what, if anything, I did.  Also, this is under
KDE/Plasma on X11 in a recent openSUSE Leap 15.4 upgrade, so there may
be an underlying window system issue.

   TIA,

					-- Bob Rogers
					   http://www.rgrjr.com/

------------------------------------------------------------------------
In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.31, cairo version 1.16.0)
 of 2022-08-20 built on orion
Repository revision: 7e9d744033f07286c21f092f8ea3646a51e37a19
Repository branch: rgr-smtpmail-env-from
Windowing system distributor 'The X.Org Foundation', version 11.0.12003000
System Description: openSUSE Leap 15.4

Configured using:
 'configure --with-dbus=no --with-gsettings=no --with-gif=ifavailable
 --with-tiff=no --with-gnutls=yes --with-gconf=no'

Configured features:
ACL CAIRO FREETYPE GIF GLIB GMP GNUTLS HARFBUZZ JPEG LIBSELINUX LIBXML2
MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS
TOOLKIT_SCROLL_BARS X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57468; Package emacs. (Mon, 29 Aug 2022 15:22:01 GMT) Full text and rfc822 format available.

Message #8 received at 57468 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Bob Rogers <rogers <at> rgrjr.com>
Cc: 57468 <at> debbugs.gnu.org
Subject: Re: bug#57468: 29.0.50; Text cursor continues to blink when frame
 loses focus
Date: Mon, 29 Aug 2022 17:21:15 +0200
Bob Rogers <rogers <at> rgrjr.com> writes:

>    I have a number of independent emacs sessions, each with a single GUI
> frame, some remote via SSH and some as root.  In the sessions using
> emacs built recently from master with blink-cursor-mode enabled, the
> cursor continues to blink even when the (single) frame loses focus, when
> it should become a steady hollow box.  This also happens in "emacs -Q"
> (somewhat intermittently, along with failure to start blinking, and some
> stranger things).

I'm unable to reproduce this, and it doesn't fail to start blinking,
either.

> In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.31, cairo version 1.16.0)
>  of 2022-08-20 built on orion
> Repository revision: 7e9d744033f07286c21f092f8ea3646a51e37a19
> Repository branch: rgr-smtpmail-env-from
> Windowing system distributor 'The X.Org Foundation', version 11.0.12003000
> System Description: openSUSE Leap 15.4

This doesn't really say which Emacs repo version you're using --
7e9d744033f07286c21f092f8ea3646a51e37a19 isn't an Emacs git hash.

Could you try using the current version from the Emacs repo to see if
you see the problem there?

For reference, here's my build data:

In GNU Emacs 29.0.50 (build 4, x86_64-pc-linux-gnu, GTK+ Version
 3.24.33, cairo version 1.16.0) of 2022-08-29 built on joga
Repository revision: 6f57cb6d8141e35fee39ea31f08d4ce5cf6c51e5
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Ubuntu 22.04.1 LTS




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 29 Aug 2022 15:22:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57468; Package emacs. (Mon, 29 Aug 2022 18:05:01 GMT) Full text and rfc822 format available.

Message #13 received at 57468 <at> debbugs.gnu.org (full text, mbox):

From: Bob Rogers <rogers <at> rgrjr.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 57468 <at> debbugs.gnu.org
Subject: Re: bug#57468: 29.0.50; Text cursor continues to blink when frame
 loses focus
Date: Mon, 29 Aug 2022 11:04:44 -0700
   From: Lars Ingebrigtsen <larsi <at> gnus.org>
   Date: Mon, 29 Aug 2022 17:21:15 +0200

   Bob Rogers <rogers <at> rgrjr.com> writes:

   >    I have a number of independent emacs sessions, each with a single GUI
   > frame, some remote via SSH and some as root.  In the sessions using
   > emacs built recently from master with blink-cursor-mode enabled, the
   > cursor continues to blink even when the (single) frame loses focus, when
   > it should become a steady hollow box.  This also happens in "emacs -Q"
   > (somewhat intermittently, along with failure to start blinking, and some
   > stranger things).

   I'm unable to reproduce this, and it doesn't fail to start blinking,
   either.

I was afraid of that.

   > In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.31, cairo version 1.16.0)
   >  of 2022-08-20 built on orion
   > Repository revision: 7e9d744033f07286c21f092f8ea3646a51e37a19
   > Repository branch: rgr-smtpmail-env-from
   > Windowing system distributor 'The X.Org Foundation', version 11.0.12003000
   > System Description: openSUSE Leap 15.4

   This doesn't really say which Emacs repo version you're using --
   7e9d744033f07286c21f092f8ea3646a51e37a19 isn't an Emacs git hash.

Oops; that's for a local branch that just hacks lisp/mail/smtpmail.el.
It's based on 07c04da01016cd81e064a06b2449892eff7c8da0 on master.

   Could you try using the current version from the Emacs repo to see if
   you see the problem there?

Still happens, commit 9f692bcd84e2b6e450e154361e1058186e6481a8.

   FWIW, chromium also has a cursor that blinks if you click on page
elements, but stops when chromium loses focus.

					-- Bob




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57468; Package emacs. (Tue, 30 Aug 2022 10:28:01 GMT) Full text and rfc822 format available.

Message #16 received at 57468 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Bob Rogers <rogers <at> rgrjr.com>
Cc: 57468 <at> debbugs.gnu.org
Subject: Re: bug#57468: 29.0.50; Text cursor continues to blink when frame
 loses focus
Date: Tue, 30 Aug 2022 12:27:00 +0200
Bob Rogers <rogers <at> rgrjr.com> writes:

>    I'm unable to reproduce this, and it doesn't fail to start blinking,
>    either.
>
> I was afraid of that.

I tried on a couple machines, and the blinking stops reliably for me.

Anybody have any ideas how to debug this?  Could it be the window
manager that's not sending Emacs the de-focus event (or whatever it's
called)?





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57468; Package emacs. (Tue, 30 Aug 2022 12:03:02 GMT) Full text and rfc822 format available.

Message #19 received at 57468 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 57468 <at> debbugs.gnu.org, rogers <at> rgrjr.com
Subject: Re: bug#57468: 29.0.50;
 Text cursor continues to blink when frame loses focus
Date: Tue, 30 Aug 2022 15:02:17 +0300
> Cc: 57468 <at> debbugs.gnu.org
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Date: Tue, 30 Aug 2022 12:27:00 +0200
> 
> Could it be the window manager that's not sending Emacs the de-focus
> event (or whatever it's called)?

That should be easy to verify by binding a command to the event that
will display the event.  The focus-in "pseudo-key" is defined in the
special-event-map.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57468; Package emacs. (Tue, 30 Aug 2022 23:34:02 GMT) Full text and rfc822 format available.

Message #22 received at 57468 <at> debbugs.gnu.org (full text, mbox):

From: Bob Rogers <rogers <at> rgrjr.com>
To: Eli Zaretskii <eliz <at> gnu.org>, Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 57468 <at> debbugs.gnu.org
Subject: Re: bug#57468: 29.0.50;
 Text cursor continues to blink when frame loses focus
Date: Tue, 30 Aug 2022 16:33:44 -0700
   From: Eli Zaretskii <eliz <at> gnu.org>
   Date: Tue, 30 Aug 2022 15:02:17 +0300

   > Cc: 57468 <at> debbugs.gnu.org
   > From: Lars Ingebrigtsen <larsi <at> gnus.org>
   > Date: Tue, 30 Aug 2022 12:27:00 +0200
   > 
   > Could it be the window manager that's not sending Emacs the de-focus
   > event (or whatever it's called)?

   That should be easy to verify by binding a command to the event that
   will display the event.  The focus-in "pseudo-key" is defined in the
   special-event-map.

When I went back to my console, I found to my consternation that two
local emacs instances plus a new "src/emacs -Q" all behaved correctly,
despite not having touched anything since my last email that might
conceivably have an effect.  Persevering, I used the following code to
track events:

	(defun rgr-focus-in () (interactive) (message "focus in"))
	(define-key special-event-map [ focus-in ] 'rgr-focus-in)
	(defun rgr-focus-out () (interactive) (message "focus out"))
	(define-key special-event-map [ focus-out ] 'rgr-focus-out)

And got the expected correct behavior.

   Then I brought up a pre-existing emacs instance running as root
(which I had forgotten about) and found that its blinking cursor stays
on persistently, and the focus in/out code above shows that it's getting
neither event.  (I don't remember if I tested this instance when
reporting the bug two days ago, but I suspect I did and that it was
normal.)

					-- Bob




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57468; Package emacs. (Wed, 31 Aug 2022 10:04:01 GMT) Full text and rfc822 format available.

Message #25 received at 57468 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Bob Rogers <rogers <at> rgrjr.com>
Cc: 57468 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#57468: 29.0.50; Text cursor continues to blink when frame
 loses focus
Date: Wed, 31 Aug 2022 12:03:38 +0200
Bob Rogers <rogers <at> rgrjr.com> writes:

>    Then I brought up a pre-existing emacs instance running as root
> (which I had forgotten about) and found that its blinking cursor stays
> on persistently, and the focus in/out code above shows that it's getting
> neither event.

How was the root Emacs started?  Could it be in a way that stops the
window manager from delivering events to it?





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57468; Package emacs. (Wed, 31 Aug 2022 19:03:01 GMT) Full text and rfc822 format available.

Message #28 received at 57468 <at> debbugs.gnu.org (full text, mbox):

From: Bob Rogers <rogers <at> rgrjr.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 57468 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#57468: 29.0.50; Text cursor continues to blink when frame
 loses focus
Date: Wed, 31 Aug 2022 12:02:04 -0700
   From: Lars Ingebrigtsen <larsi <at> gnus.org>
   Date: Wed, 31 Aug 2022 12:03:38 +0200

   Bob Rogers <rogers <at> rgrjr.com> writes:

   >    Then I brought up a pre-existing emacs instance running as root
   > (which I had forgotten about) and found that its blinking cursor stays
   > on persistently, and the focus in/out code above shows that it's getting
   > neither event.

   How was the root Emacs started?  Could it be in a way that stops the
   window manager from delivering events to it?

Just "emacs &" after "su" in a shell.  I should emphasize that I've seen
nothing special about the root emacs; all instances save one switched
between working and nonworking at long but unpredictable intervals.  And
the other problematic instances were also spawned from shells, though
some were from a Konsole shell, some were via ssh with tunneled X11, and
some from an emacs shell window.

   I've also tried a slightly newer version of master (commit
136495f178ccd36b23ffc347fe2b6680fd689e34) on the previous openSUSE
release, and the cursor behaves normally WRT focus-in/out.  Here's what
report-emacs-bug says about the installation:

	Windowing system distributor 'The X.Org Foundation', version 11.0.12003000
	System Description: openSUSE Leap 15.3

This is under KDE/Plasma, apparently version 5.18.5.

					-- Bob




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57468; Package emacs. (Wed, 31 Aug 2022 19:25:02 GMT) Full text and rfc822 format available.

Message #31 received at 57468 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Bob Rogers <rogers <at> rgrjr.com>
Cc: 57468 <at> debbugs.gnu.org, larsi <at> gnus.org
Subject: Re: bug#57468: 29.0.50; Text cursor continues to blink when frame
 loses focus
Date: Wed, 31 Aug 2022 22:24:38 +0300
> From: Bob Rogers <rogers <at> rgrjr.com>
> Date: Wed, 31 Aug 2022 12:02:04 -0700
> CC: Eli Zaretskii <eliz <at> gnu.org>, 57468 <at> debbugs.gnu.org
> 
>    From: Lars Ingebrigtsen <larsi <at> gnus.org>
>    Date: Wed, 31 Aug 2022 12:03:38 +0200
> 
>    Bob Rogers <rogers <at> rgrjr.com> writes:
> 
>    >    Then I brought up a pre-existing emacs instance running as root
>    > (which I had forgotten about) and found that its blinking cursor stays
>    > on persistently, and the focus in/out code above shows that it's getting
>    > neither event.
> 
>    How was the root Emacs started?  Could it be in a way that stops the
>    window manager from delivering events to it?
> 
> Just "emacs &" after "su" in a shell.  I should emphasize that I've seen
> nothing special about the root emacs; all instances save one switched
> between working and nonworking at long but unpredictable intervals.  And
> the other problematic instances were also spawned from shells, though
> some were from a Konsole shell, some were via ssh with tunneled X11, and
> some from an emacs shell window.

I guess the next step is to set a breakpoint in every place where we
call x_focus_changed, and see whether the X events are delivered to
Emacs in the "su" Emacs.  If the events aren't delivered, this is not
an Emacs problem.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57468; Package emacs. (Wed, 31 Aug 2022 19:32:02 GMT) Full text and rfc822 format available.

Message #34 received at 57468 <at> debbugs.gnu.org (full text, mbox):

From: Bob Rogers <rogers <at> rgrjr.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>, Eli Zaretskii <eliz <at> gnu.org>,
 57468 <at> debbugs.gnu.org
Subject: Re: bug#57468: 29.0.50; Text cursor continues to blink when frame
 loses focus
Date: Wed, 31 Aug 2022 12:31:39 -0700
   From: Bob Rogers <rogers <at> rgrjr.com>
   Date: Wed, 31 Aug 2022 12:02:04 -0700

   . . .

   I've also tried a slightly newer version of master ... on the
   previous openSUSE release, and the cursor behaves normally WRT
   focus-in/out . . .

Minutes after I sent this email, I saw the bug rear its head in openSUSE
Leap 15.3.  To test, I had three instances, two with my initializations,
and one "emacs -Q".  Pretty much the only thing I did after sending the
email was to quit the "emacs -Q" and fire up another instance as root
(su and then "emacs &"), but curiously only one of the two instances
(the second one launched) was affected.  So I ran the following
augmented code in both the new root and the affected instance to see
what was going on:

	(defvar rgr-event-count 0)
	(defun rgr-focus-in ()
	  (interactive)
	  (message "focus in %d" (cl-incf rgr-event-count)))
	(define-key special-event-map [ focus-in ] 'rgr-focus-in)
	(defun rgr-focus-out ()
	  (interactive)
	  (message "focus out %d" (cl-incf rgr-event-count)))
	(define-key special-event-map [ focus-out ] 'rgr-focus-out)

As expected, the affected instance saw no in/out events, but the root
instance saw a single focus-out event when the other window caught the
focus, then a quick in/out/in sequence when the focus came back.  (I had
also seen this odd triplet when debugging under openSUSE Leap 15.4, but
at a higher level in the cursor blinking code, so I didn't mention it in
the initial bug report, thinking it might be a separate bug.)

					-- Bob




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57468; Package emacs. (Sat, 03 Sep 2022 09:45:01 GMT) Full text and rfc822 format available.

Message #37 received at 57468 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Bob Rogers <rogers <at> rgrjr.com>
Cc: Po Lu <luangruo <at> yahoo.com>, 57468 <at> debbugs.gnu.org,
 Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#57468: 29.0.50; Text cursor continues to blink when frame
 loses focus
Date: Sat, 03 Sep 2022 11:44:46 +0200
Now I'm seeing this phenomenon, too, but I don't have a recipe to
reproduce it either.  But this Emacs has two frames, and if I select one
of the frames, and then select a frame from a different Emacs that
covers this frame, then both the other Emacs and this Emacs has a
blinking cursor.

If I select the frames in a different sequence, then the non-selected
Emacs frame stops blinking.

So it seems like there some sort of interaction between frames being
hidden and frames not noticing that they've lost focus?  But I'm unable
to reproduce this from "emacs -Q".

I've added Po Lu to the CCs; perhaps he has some comments here.  In
particular -- have there been any changes in the code that notices
getting/losing focus lately?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57468; Package emacs. (Sat, 03 Sep 2022 11:24:02 GMT) Full text and rfc822 format available.

Message #40 received at 57468 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 57468 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Bob Rogers <rogers <at> rgrjr.com>
Subject: Re: bug#57468: 29.0.50; Text cursor continues to blink when frame
 loses focus
Date: Sat, 03 Sep 2022 19:23:28 +0800
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Now I'm seeing this phenomenon, too, but I don't have a recipe to
> reproduce it either.  But this Emacs has two frames, and if I select one
> of the frames, and then select a frame from a different Emacs that
> covers this frame, then both the other Emacs and this Emacs has a
> blinking cursor.
>
> If I select the frames in a different sequence, then the non-selected
> Emacs frame stops blinking.
>
> So it seems like there some sort of interaction between frames being
> hidden and frames not noticing that they've lost focus?  But I'm unable
> to reproduce this from "emacs -Q".
>
> I've added Po Lu to the CCs; perhaps he has some comments here.  In
> particular -- have there been any changes in the code that notices
> getting/losing focus lately?

Yes -- only under the GTK 3 and no toolkit builds, where the focus code
was rewritten from scratch in order to not crash under X environments
with multiple pointers.

I will look into this, thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57468; Package emacs. (Sat, 03 Sep 2022 11:53:02 GMT) Full text and rfc822 format available.

Message #43 received at 57468 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: 57468 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Bob Rogers <rogers <at> rgrjr.com>
Subject: Re: bug#57468: 29.0.50; Text cursor continues to blink when frame
 loses focus
Date: Sat, 03 Sep 2022 13:52:13 +0200
Po Lu <luangruo <at> yahoo.com> writes:

> Yes -- only under the GTK 3 and no toolkit builds, where the focus code
> was rewritten from scratch in order to not crash under X environments
> with multiple pointers.

I'm seeing this in under Gtk3 and with a Gtk toolkit (in both of the
Emacs instances), so perhaps it's not related.

> I will look into this, thanks.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57468; Package emacs. (Sat, 03 Sep 2022 11:58:01 GMT) Full text and rfc822 format available.

Message #46 received at 57468 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 57468 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Bob Rogers <rogers <at> rgrjr.com>
Subject: Re: bug#57468: 29.0.50; Text cursor continues to blink when frame
 loses focus
Date: Sat, 03 Sep 2022 19:56:45 +0800
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Thanks.

I installed something on master that should help.  (And hopefully I will
come up with a fix for the X server too, but that might take a while.)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57468; Package emacs. (Sat, 03 Sep 2022 12:10:02 GMT) Full text and rfc822 format available.

Message #49 received at 57468 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: 57468 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Bob Rogers <rogers <at> rgrjr.com>
Subject: Re: bug#57468: 29.0.50; Text cursor continues to blink when frame
 loses focus
Date: Sat, 03 Sep 2022 14:08:50 +0200
Po Lu <luangruo <at> yahoo.com> writes:

>> Thanks.
>
> I installed something on master that should help.  (And hopefully I will
> come up with a fix for the X server too, but that might take a while.)

I'm still seeing the problem after the update.  This is with:

In GNU Emacs 29.0.50 (build 39, x86_64-pc-linux-gnu, GTK+ Version
 3.24.33, cairo version 1.16.0) of 2022-09-03 built on joga
Repository revision: 91ba20fff159cc88c87e09f5a8256d6412c98990
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Ubuntu 22.04.1 LTS

Configured using:
 'configure -C'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB

And I now have a semi-reliable way to reproduce it.

emacs -Q
C-x 5 2

Then start another Emacs, and place that frame over frame 2.  Then give
frame 2 focus.  Then switch to the other Emacs (which is covering frame
2).  Then click on the title bar of frame 1.  Both frame 1 and the other
Emacs then have blinking cursors.

This is with Gnome Shell.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57468; Package emacs. (Sat, 03 Sep 2022 12:27:02 GMT) Full text and rfc822 format available.

Message #52 received at 57468 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 57468 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Bob Rogers <rogers <at> rgrjr.com>
Subject: Re: bug#57468: 29.0.50; Text cursor continues to blink when frame
 loses focus
Date: Sat, 03 Sep 2022 20:26:44 +0800
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> And I now have a semi-reliable way to reproduce it.
>
> emacs -Q
> C-x 5 2
>
> Then start another Emacs, and place that frame over frame 2.  Then give
> frame 2 focus.  Then switch to the other Emacs (which is covering frame
> 2).  Then click on the title bar of frame 1.  Both frame 1 and the other
> Emacs then have blinking cursors.
>
> This is with Gnome Shell.

I tried several times (also on GNOME Shell), but it didn't work.  So if
frame 2 means the frame that was created by C-x 5 2, I still can't
reproduce this, sorry.

Could you please add instrumentation to x_focus_changed, like this:

static void
x_focus_changed (int type, int state, struct x_display_info *dpyinfo, struct frame *frame,
		 struct input_event *bufp)
{
  fprintf (stderr, "x_focus_changed: %d %d %p %p\n", type, state, frame,
	   dpyinfo->x_focus_frame);

and also instrumentation to xi_handle_focus_change, like so:

	}
    }

  fprintf (stderr, "xi_handle_focus_change: %p %p\n", <== add this instrumentation
	   new, focus);                               <==

  if (new != focus && focus)
    {
#ifdef HAVE_X_I18N
      if (FRAME_XIC (focus))
	XUnsetICFocus (FRAME_XIC (focus));
#endif

and show what is printed once the cursor begins to blink in both frames?
Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57468; Package emacs. (Sat, 03 Sep 2022 12:38:01 GMT) Full text and rfc822 format available.

Message #55 received at 57468 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: 57468 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Bob Rogers <rogers <at> rgrjr.com>
Subject: Re: bug#57468: 29.0.50; Text cursor continues to blink when frame
 loses focus
Date: Sat, 03 Sep 2022 14:37:36 +0200
Po Lu <luangruo <at> yahoo.com> writes:

> I tried several times (also on GNOME Shell), but it didn't work.  So if
> frame 2 means the frame that was created by C-x 5 2, I still can't
> reproduce this, sorry.

Just to make sure -- I had two different Emacses open; one with two
frames and one with a single frame in this scenario.

> and show what is printed once the cursor begins to blink in both frames?
> Thanks.

This is what the one with two frames says:

xi_handle_focus_change: (nil) 0x55bb4bd32300
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: 0x55bb4c3ffdd0 (nil)
xi_handle_focus_change: 0x55bb4c3ffdd0 0x55bb4c3ffdd0
xi_handle_focus_change: (nil) 0x55bb4c3ffdd0
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: 0x55bb4c3ffdd0 (nil)
xi_handle_focus_change: 0x55bb4c3ffdd0 0x55bb4c3ffdd0
xi_handle_focus_change: 0x55bb4c3ffdd0 0x55bb4c3ffdd0
xi_handle_focus_change: 0x55bb4c3ffdd0 0x55bb4c3ffdd0
xi_handle_focus_change: (nil) 0x55bb4c3ffdd0
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: 0x55bb4bd32300 (nil)
xi_handle_focus_change: 0x55bb4bd32300 0x55bb4bd32300
xi_handle_focus_change: (nil) 0x55bb4bd32300
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: 0x55bb4bd32300 (nil)
xi_handle_focus_change: 0x55bb4bd32300 0x55bb4bd32300
xi_handle_focus_change: 0x55bb4bd32300 0x55bb4bd32300
xi_handle_focus_change: 0x55bb4bd32300 0x55bb4bd32300
xi_handle_focus_change: (nil) 0x55bb4bd32300
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: 0x55bb4c3ffdd0 (nil)
xi_handle_focus_change: 0x55bb4c3ffdd0 0x55bb4c3ffdd0
xi_handle_focus_change: (nil) 0x55bb4c3ffdd0
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: 0x55bb4c3ffdd0 (nil)
xi_handle_focus_change: (nil) 0x55bb4c3ffdd0
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: 0x55bb4c3ffdd0 (nil)
xi_handle_focus_change: (nil) 0x55bb4c3ffdd0
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: 0x55bb4c3ffdd0 (nil)
xi_handle_focus_change: 0x55bb4c3ffdd0 0x55bb4c3ffdd0
xi_handle_focus_change: 0x55bb4c3ffdd0 0x55bb4c3ffdd0
xi_handle_focus_change: (nil) 0x55bb4c3ffdd0
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: 0x55bb4bd32300 (nil)
xi_handle_focus_change: (nil) 0x55bb4bd32300
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: 0x55bb4bd32300 (nil)
xi_handle_focus_change: 0x55bb4bd32300 0x55bb4bd32300
xi_handle_focus_change: 0x55bb4bd32300 0x55bb4bd32300
xi_handle_focus_change: 0x55bb4bd32300 0x55bb4bd32300
xi_handle_focus_change: 0x55bb4bd32300 0x55bb4bd32300
xi_handle_focus_change: 0x55bb4bd32300 0x55bb4bd32300
xi_handle_focus_change: (nil) 0x55bb4bd32300

And this is what the other Emacs, with one frame, says:

xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: 0x559640421300 (nil)
xi_handle_focus_change: 0x559640421300 0x559640421300
xi_handle_focus_change: 0x559640421300 0x559640421300
xi_handle_focus_change: 0x559640421300 0x559640421300
xi_handle_focus_change: 0x559640421300 0x559640421300
xi_handle_focus_change: 0x559640421300 0x559640421300
xi_handle_focus_change: (nil) 0x559640421300
xi_handle_focus_change: 0x559640421300 (nil)
xi_handle_focus_change: (nil) 0x559640421300
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: 0x559640421300 (nil)
xi_handle_focus_change: 0x559640421300 0x559640421300
xi_handle_focus_change: 0x559640421300 0x559640421300
xi_handle_focus_change: (nil) 0x559640421300
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: 0x559640421300 (nil)
xi_handle_focus_change: 0x559640421300 0x559640421300
xi_handle_focus_change: (nil) 0x559640421300
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: (nil) (nil)
xi_handle_focus_change: 0x559640421300 (nil)
xi_handle_focus_change: (nil) 0x559640421300
xi_handle_focus_change: 0x559640421300 (nil)
xi_handle_focus_change: 0x559640421300 0x559640421300
xi_handle_focus_change: 0x559640421300 0x559640421300
xi_handle_focus_change: 0x559640421300 0x559640421300
xi_handle_focus_change: 0x559640421300 0x559640421300
xi_handle_focus_change: 0x559640421300 0x559640421300
xi_handle_focus_change: 0x559640421300 0x559640421300
xi_handle_focus_change: 0x559640421300 0x559640421300
xi_handle_focus_change: 0x559640421300 0x559640421300
xi_handle_focus_change: 0x559640421300 0x559640421300




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57468; Package emacs. (Sat, 03 Sep 2022 13:05:02 GMT) Full text and rfc822 format available.

Message #58 received at 57468 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 57468 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Bob Rogers <rogers <at> rgrjr.com>
Subject: Re: bug#57468: 29.0.50; Text cursor continues to blink when frame
 loses focus
Date: Sat, 03 Sep 2022 21:03:50 +0800
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> xi_handle_focus_change: 0x55bb4bd32300 (nil)
> xi_handle_focus_change: 0x55bb4bd32300 0x55bb4bd32300
> xi_handle_focus_change: 0x55bb4bd32300 0x55bb4bd32300
> xi_handle_focus_change: 0x55bb4bd32300 0x55bb4bd32300
> xi_handle_focus_change: 0x55bb4bd32300 0x55bb4bd32300
> xi_handle_focus_change: 0x55bb4bd32300 0x55bb4bd32300
> xi_handle_focus_change: (nil) 0x55bb4bd32300

This looks fine, so far.

> And this is what the other Emacs, with one frame, says:

[...]

> xi_handle_focus_change: 0x559640421300 0x559640421300
> xi_handle_focus_change: 0x559640421300 0x559640421300
> xi_handle_focus_change: 0x559640421300 0x559640421300
> xi_handle_focus_change: 0x559640421300 0x559640421300
> xi_handle_focus_change: 0x559640421300 0x559640421300
> xi_handle_focus_change: 0x559640421300 0x559640421300
> xi_handle_focus_change: 0x559640421300 0x559640421300
> xi_handle_focus_change: 0x559640421300 0x559640421300
> xi_handle_focus_change: 0x559640421300 0x559640421300

Was this printed immediately after you switched to frame 1 (on the Emacs
that has two frames)?  Or did you give the focus back to the other Emacs
(the one with a single frame) afterwards?

If the former is the case, could you please in addition to the earlier
instrumentation also instrument xi_focus_handle_for_device like such:

    case XI_FocusIn:
      device->focus_frame = mentioned_frame;
      device->focus_frame_time = event->time;

      fprintf (stderr, "XI_FocusIn\n"); <== add instrumentation here
      break;

    case XI_FocusOut:
      device->focus_frame = NULL;

      fprintf (stderr, "XI_FocusOut\n"); <== here
      break;

    case XI_Enter:
      if (!event->focus)
	break;

      if (device->use == XIMasterPointer)
	device = xi_device_from_id (dpyinfo, device->attachment);

      if (!device)
	break;

      device->focus_implicit_frame = mentioned_frame;
      device->focus_implicit_time = event->time;
      fprintf (stderr, "XI_Enter\n"); <=== here
      break;

    case XI_Leave:
      if (!event->focus)
	break;

      if (device->use == XIMasterPointer)
	device = xi_device_from_id (dpyinfo, device->attachment);

      if (!device)
	break;

      device->focus_implicit_frame = NULL;
      fprintf (stderr, "XI_Leave\n"); <=== and here
      break;

and show what is printed in the second Emacs (with a single frame) once
it starts to blink despite not being focused?

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57468; Package emacs. (Sat, 03 Sep 2022 13:45:02 GMT) Full text and rfc822 format available.

Message #61 received at 57468 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 57468 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Bob Rogers <rogers <at> rgrjr.com>
Subject: Re: bug#57468: 29.0.50; Text cursor continues to blink when frame
 loses focus
Date: Sat, 03 Sep 2022 21:44:01 +0800
I figured out how to reproduce the problem.  You have to keep the mouse
pointer inside the first frame while opening the second Emacs.  Then,
the focus sticks on the first frame because the X server totally messes
up reporting of XI_Leave events if the window manager does not set the
focus specifically on the client pointer (which the documentation is
adamant that you _can_ omit, so this is yet another X server bug.)

I installed a workaround on master.  It would be nice if all the people
who use Emacs without a window manager tried it out as well to see if it
leads to any unpleasant side effects, which it probably will, but I
don't know yet know what side effects there will be.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57468; Package emacs. (Sat, 03 Sep 2022 13:48:02 GMT) Full text and rfc822 format available.

Message #64 received at 57468 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Po Lu <luangruo <at> yahoo.com>
Cc: 57468 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Bob Rogers <rogers <at> rgrjr.com>
Subject: Re: bug#57468: 29.0.50; Text cursor continues to blink when frame
 loses focus
Date: Sat, 03 Sep 2022 15:47:03 +0200
Po Lu <luangruo <at> yahoo.com> writes:

> I installed a workaround on master.

Thanks; I can confirm that I can no longer reproduce the problem.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57468; Package emacs. (Sat, 03 Sep 2022 13:55:02 GMT) Full text and rfc822 format available.

Message #67 received at 57468 <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 57468 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Bob Rogers <rogers <at> rgrjr.com>
Subject: Re: bug#57468: 29.0.50; Text cursor continues to blink when frame
 loses focus
Date: Sat, 03 Sep 2022 21:54:11 +0800
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Po Lu <luangruo <at> yahoo.com> writes:
>
>> I installed a workaround on master.
>
> Thanks; I can confirm that I can no longer reproduce the problem.

Great!  If Bob says the same thing, I'll close this bug.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#57468; Package emacs. (Sat, 03 Sep 2022 17:54:01 GMT) Full text and rfc822 format available.

Message #70 received at 57468 <at> debbugs.gnu.org (full text, mbox):

From: Bob Rogers <rogers <at> rgrjr.com>
To: Po Lu <luangruo <at> yahoo.com>, Lars Ingebrigtsen <larsi <at> gnus.org>,
 57468 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#57468: 29.0.50; Text cursor continues to blink when frame
 loses focus
Date: Sat, 3 Sep 2022 10:53:25 -0700
   From: Po Lu <luangruo <at> yahoo.com>
   Date: Sat, 03 Sep 2022 21:54:11 +0800

   Lars Ingebrigtsen <larsi <at> gnus.org> writes:

   > Po Lu <luangruo <at> yahoo.com> writes:
   >
   >> I installed a workaround on master.
   >
   > Thanks; I can confirm that I can no longer reproduce the problem.

   Great!  If Bob says the same thing, I'll close this bug.

Seems to work here.  Thanks a bunch, guys; this was driving me nuts.

					-- Bob




Reply sent to Po Lu <luangruo <at> yahoo.com>:
You have taken responsibility. (Sun, 04 Sep 2022 00:37:02 GMT) Full text and rfc822 format available.

Notification sent to Bob Rogers <rogers <at> rgrjr.com>:
bug acknowledged by developer. (Sun, 04 Sep 2022 00:37:02 GMT) Full text and rfc822 format available.

Message #75 received at 57468-done <at> debbugs.gnu.org (full text, mbox):

From: Po Lu <luangruo <at> yahoo.com>
To: Bob Rogers <rogers <at> rgrjr.com>
Cc: Lars Ingebrigtsen <larsi <at> gnus.org>, 57468-done <at> debbugs.gnu.org,
 Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#57468: 29.0.50; Text cursor continues to blink when frame
 loses focus
Date: Sun, 04 Sep 2022 08:36:15 +0800
Bob Rogers <rogers <at> rgrjr.com> writes:

> Seems to work here.  Thanks a bunch, guys; this was driving me nuts.

Thanks, closing.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 02 Oct 2022 11:24:08 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 204 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.