Subject: bug#58438: 29.0.50; EXWM focus lost

From: Po Lu <[email-masked]>
Date: Wed, 12 Oct 2022 08:52:00 +0800

forcemerge 58438 58245
thanks

Manuel Giraud <[email-masked]> writes:

> Hi,
>
> I'm using EXWM.  Since this patch 3924fbd025, whenever I'm starting an
> external graphical program (eg. Firefox), the cursor will stay hollow in
> other Emacs buffers even when I switch to them.
>
> Do you think that EXWM is at fault here regarding EWMH?

Yes; it must either set `x-no-window-manager' to a non-nil value, stop
announcing support for _NET_ACTIVE_WINDOW, or implement said property
correctly.  At present, it assumes Emacs itself will never rely on said
property to activate its frames, which is no longer true in Emacs 29.

Please point the EXWM developers to this document:

  https://specifications.freedesktop.org/wm-spec/wm-spec-latest.html#idm46409506372544

And say that this part of exwm.el:

     ;; _NET_ACTIVE_WINDOW.
     ((= type xcb:Atom:_NET_ACTIVE_WINDOW) <==== add code after here
      (let ((buffer (exwm--id->buffer id))
            iconic window)
        (when (buffer-live-p buffer)
          (with-current-buffer buffer
            (when (eq exwm--frame exwm-workspace--current)
              (if exwm--floating-frame
                  (select-frame exwm--floating-frame)
                (setq iconic (exwm-layout--iconic-state-p))
                (when iconic
                  ;; State change: iconic => normal.
                  (set-window-buffer (frame-selected-window exwm--frame)
                                     (current-buffer)))
                ;; Focus transfer.
                (setq window (get-buffer-window nil t))
                (when (or iconic
                          (not (eq window (selected-window))))
                  (select-window window))))))))

must loop through each frame on the display EXWM manages, and should the
frame's `outer-window-id' match what is specified in the client message,
call `x-focus-frame' on the frame with noactivate set to a non-nil
value.