Git Product home page Git Product logo

Comments (6)

minad avatar minad commented on August 20, 2024 2

I currently use the workaround from ch11ng/exwm#933 and ch11ng/exwm#759.

    (advice-add #'exwm-layout--hide
                :after (lambda (id)
                         (with-current-buffer (exwm--id->buffer id)
                           (setq exwm--ewmh-state
                                 (delq xcb:Atom:_NET_WM_STATE_HIDDEN exwm--ewmh-state))
                           (exwm-layout--set-ewmh-state id)
                           (xcb:flush exwm--connection))))

This workaround completely defeats the _NET_WM_STATE_HIDDEN wm hint, which may have unwanted power consumption consequences.

from exwm.

minad avatar minad commented on August 20, 2024

Do you have such focus issues only with persp-mode and only with Discord, or also other programs? I don't use Discord but with Chromium I also regularly observe focus issues, when switching buffers with switch-to-buffer, consult-buffer or switching between tabs. I use tab-bar-mode instead of perspectives. After switching buffers, Chromium will not gain focus. I don't observe such a behavior with other programs, e.g., a simple Xterm or Thunderbird.

from exwm.

LemonBreezes avatar LemonBreezes commented on August 20, 2024

Do you have such focus issues only with persp-mode and only with Discord, or also other programs? I don't use Discord but with Chromium I also regularly observe focus issues, when switching buffers with switch-to-buffer, consult-buffer or switching between tabs. I use tab-bar-mode instead of perspectives. After switching buffers, Chromium will not gain focus. I don't observe such a behavior with other programs, e.g., a simple Xterm or Thunderbird.

Yeah, I think this can happen when switching buffer, switching window, etc, according to an old workaround I wrote years ago (but have disabled). Lately I don't use many programs outside of Emacs but definitely it seems to happen in Discord and not in Firefox.

I wrote a workaround that doesn't work as well as I would like it to because it interrupts repeat mode and creates a race condition where if I switch workspaces and start typing before the timers finish it will be interrupted, but if the delays are too low, it will also not work:

(defvar +exwm-refocus-application--message "")
(defvar +exwm-refocus-application--delays '(0.015 0.03))
(defvar +exwm-refocus-application--timer nil)
(defvar +exwm-refocus-application--last-time 0)
(defvar +exwm-refocus-application--last-state nil)

;;;###autoload
(defun +exwm-refocus-application (&rest _)
  "Refocus input for the currently selected EXWM buffer, if any."
  (when (and (derived-mode-p 'exwm-mode)
             (not (memq +exwm-refocus-application--timer
                        timer-list))
             (> (float-time) (+ +exwm-refocus-application--last-time
                                0.01
                                (cl-reduce #'+ +exwm-refocus-application--delays))))
    (run-at-time (nth 0 +exwm-refocus-application--delays)
                 nil #'+exwm-refocus-application--timer)))

(defun +exwm-refocus-application--timer ()
  (when (derived-mode-p 'exwm-mode)
    (setq +exwm-refocus-application--message (current-message))
    (let ((+exwm-refocus-application--last-state (bound-and-true-p evil-state)))
      (minibuffer-with-setup-hook
          #'+exwm-refocus-application-minibuffer-quit-timer
        (read-string "")))))

(defun +exwm-refocus-application-minibuffer-quit-timer ()
  (setq +exwm-refocus-application--timer
        (run-at-time (nth 1 +exwm-refocus-application--delays) nil
                     (lambda ()
                       (run-at-time
                        0.0 nil
                        (lambda ()
                          (when +exwm-refocus-application--message
                            (minibuffer-message +exwm-refocus-application--message))
                          (pcase +exwm-refocus-application--last-state
                            ;; My `exwm-evil' package.
                            ('insert (exwm-evil-core-insert))
                            ('normal (exwm-evil-core-normal))
                            (_ nil))))
                       (when (minibufferp)
                         (setq +exwm-refocus-application--last-time (float-time))
                         (throw 'exit nil))))))

Then add +exwm-refocus-application to as many focus-changing hooks as possible. This is probably the most major EXWM issue I've noticed throughout the years.

from exwm.

LemonBreezes avatar LemonBreezes commented on August 20, 2024

I currently use the workaround from ch11ng/exwm#933 and ch11ng/exwm#759.

    (advice-add #'exwm-layout--hide
                :after (lambda (id)
                         (with-current-buffer (exwm--id->buffer id)
                           (setq exwm--ewmh-state
                                 (delq xcb:Atom:_NET_WM_STATE_HIDDEN exwm--ewmh-state))
                           (exwm-layout--set-ewmh-state id)
                           (xcb:flush exwm--connection))))

This workaround completely defeats the _NET_WM_STATE_HIDDEN wm hint, which may have unwanted power consumption consequences.

Man. I've been using this for a few days and it's a game-changer. EXWM is not broken anymore. I think this fix alone will make a lot of people who try EXWM again stay in EXWM.

from exwm.

Stebalien avatar Stebalien commented on August 20, 2024

Have you tried setting exwm-layout-auto-iconify to nil? That may help.

This might be a race between updating input focus (which we defer and serialize with a lock) and processing other X events (which we serialize with a per-connection lock). Unfortunately, we're using two different locks here.

This is a shot in the dark, but could you test this patch?

diff --git a/exwm-input.el b/exwm-input.el
index f1f035c..fd8ed51 100644
--- a/exwm-input.el
+++ b/exwm-input.el
@@ -324,7 +324,7 @@ defun exwm-input--update-focus-commit
   "Attempt to update the window focus.
 If we're currently updating the window focus, re-schedule a focus update
 attempt later."
-  (if exwm-input--update-focus-lock
+  (if (or exwm-input--update-focus-lock (< 0 (slot-value exwm--connection 'event-lock)))
       (exwm-input--update-focus-defer)
     (let ((exwm-input--update-focus-lock t))
       (exwm-input--update-focus exwm-input--update-focus-window))))

from exwm.

LemonBreezes avatar LemonBreezes commented on August 20, 2024

Have you tried setting exwm-layout-auto-iconify to nil? That may help.

This might be a race between updating input focus (which we defer and serialize with a lock) and processing other X events (which we serialize with a per-connection lock). Unfortunately, we're using two different locks here.

This is a shot in the dark, but could you test this patch?

diff --git a/exwm-input.el b/exwm-input.el
index f1f035c..fd8ed51 100644
--- a/exwm-input.el
+++ b/exwm-input.el
@@ -324,7 +324,7 @@ defun exwm-input--update-focus-commit
   "Attempt to update the window focus.
 If we're currently updating the window focus, re-schedule a focus update
 attempt later."
-  (if exwm-input--update-focus-lock
+  (if (or exwm-input--update-focus-lock (< 0 (slot-value exwm--connection 'event-lock)))
       (exwm-input--update-focus-defer)
     (let ((exwm-input--update-focus-lock t))
       (exwm-input--update-focus exwm-input--update-focus-window))))

Hi. I haven't tried your patch but I've been using the exwm-layout--hide advice and the issue has not reoccured since.

from exwm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.