Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using polybar with EXWM causes Corfu to popup incorrectly. #31

Open
LemonBreezes opened this issue Apr 1, 2024 · 7 comments
Open

Using polybar with EXWM causes Corfu to popup incorrectly. #31

LemonBreezes opened this issue Apr 1, 2024 · 7 comments

Comments

@LemonBreezes
Copy link

LemonBreezes commented Apr 1, 2024

Today I have been testing various status bar solutions for EXWM and have noticed that while using polybar, the Corfu popup covers the text I am typing:

image

@LemonBreezes
Copy link
Author

LemonBreezes commented Apr 1, 2024

It seems like adding the height of the polybar to corfu--make-frame (see the (+ 17 y)) fixes the positioning:

image

@minad
Copy link
Member

minad commented Apr 1, 2024

Today I have been testing various status bar solutions for EXWM and have noticed that while using polybar, the Corfu popup covers the text I am typing:

Off topic, but my recommendation for a status bar is to use the Emacs tab-bar. This is the best solution since you can also tweak it in Elisp. ;)

@minad
Copy link
Member

minad commented Apr 1, 2024

Regarding Corfu, I suspect that the problem is similar to the problem of multi monitor setups, where we should take the position of the parent frame on the correct monitor into account. Without EXWM this is not a problem, since we do not unparent the Corfu child frame and as such stay always relative to the Emacs parent frame. See minad/corfu#408.

@LemonBreezes
Copy link
Author

Regarding Corfu, I suspect that the problem is similar to the problem of multi monitor setups, where we should take the position of the parent frame on the correct monitor into account. Without EXWM this is not a problem, since we do not unparent the Corfu child frame and as such stay always relative to the Emacs parent frame. See minad/corfu#408.

Yes actually! So what I had to do was add the x and y of (frame-position) to the x and y used in corfu--make-frame in an advice manner. I combined it with the advice from there:

(defun get-focused-monitor-geometry ()
  "Get the geometry of the monitor displaying the selected frame in EXWM."
  (let* ((monitor-attrs (frame-monitor-attributes))
         (workarea (assoc 'workarea monitor-attrs))
         (geometry (cdr workarea)))
    (list (nth 0 geometry) ; X
          (nth 1 geometry) ; Y
          (nth 2 geometry) ; Width
          (nth 3 geometry) ; Height
          )))

(defun advise-corfu-make-frame-with-monitor-awareness (orig-fun frame x y width height buffer)
  "Advise `corfu--make-frame` to be monitor-aware, adjusting X and Y according to the focused monitor."

  ;; Get the geometry of the currently focused monitor
  (let* ((monitor-geometry (get-focused-monitor-geometry))
         (monitor-x (nth 0 monitor-geometry))
         (monitor-y (nth 1 monitor-geometry))
         (selected-frame-position (frame-position))
         (selected-frame-x (car selected-frame-position))
         (selected-frame-y (cdr selected-frame-position))
         (new-x (+ monitor-x selected-frame-x x))
         (new-y (+ monitor-y selected-frame-y y)))

    ;; Call the original function with potentially adjusted coordinates
    (funcall orig-fun frame new-x new-y width height buffer)))

(advice-add 'corfu--make-frame :around #'advise-corfu-make-frame-with-monitor-awareness)

Also, regarding the tab-bar, I PR'd some documentation for using i3bar.el with EXWM, Stebalien/i3bar.el#10, but in my opinion it's possible to do better with a standalone polybar-like package for using the tab-bar as a status bar. Polybar seems good enough for me right now though, and already has a segment for controlling MPD.

@minad
Copy link
Member

minad commented Apr 1, 2024

Oh, interesting! I wasn't aware of @Stebalien's i3bar. What I am doing is different. I have all the status elements implemented in Elisp (or most of the ones also supported by i3bar). That's maybe not as efficient but nicely extensible. Also my music player is in Elisp, so I don't miss music player integration. But even with mpd, it is easy enough to access directly from Emacs. There exist at least ten Emacs mpd clients. ;)

@LemonBreezes
Copy link
Author

LemonBreezes commented Apr 1, 2024

Oh, interesting! I wasn't aware of @Stebalien's i3bar. What I am doing is different. I have all the status elements implemented in Elisp (or most of the ones also supported by i3bar). That's maybe not as efficient but nicely extensible. Also my music player is in Elisp, so I don't miss music player integration. But even with mpd, it is easy enough to access directly from Emacs. There exist at least ten Emacs mpd clients. ;)

What do you use for music? I mostly use a combination of EMMS and MPD. I have a transient for jumping to some of my music directories (https://github.com/lemonbreezes/cae-emacs/blob/master/modules/cae/misc-applications/autoload/emms.el#L21) and I wrote a trivial command to jump to a random line in the current buffer (https://github.com/lemonbreezes/cae-emacs/blob/master/autoload/cae-editor.el#L432). So I jump to a music directory, jump to a random line, and play what I land on mostly.

I also set up a few Dired keybindings for my music directory in a .dir-locals.el, https://github.com/lemonbreezes/cae-emacs/blob/master/dir-local-files/music-dir.el.

@minad
Copy link
Member

minad commented Apr 1, 2024

What do you use for music?

Just a small custom thingy based on mpv. It can play directly in Dired or other buffers (whatever format) via an Embark-style target finder. It basically turns arbitrary buffers into playlists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants