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 popper independently per frame #71

Open
ashlineldridge opened this issue Jul 2, 2024 · 4 comments
Open

Using popper independently per frame #71

ashlineldridge opened this issue Jul 2, 2024 · 4 comments

Comments

@ashlineldridge
Copy link

Hi, I'm seeing some odd behavior that is preventing me from being able to reliably toggle popper across frames using popper-toggle (without the workaround below).

If I hop between frames and run M-x popper-toggle then popper will, as expected, toggle the popup window for the current frame. However, if I bind popper-toggle to a keybinding then I don't get the same results. I suspect that by switching frame and invoking a keybinding (rather than M-x popper-toggle) that popper--update-popups is not called and so popper-open-popup-alist is not updated.

As a workaround, I've added the following to my config to ensure the popper-open-popup-alist is up to date prior to toggling:

(advice-add #'popper-toggle :before (lambda (&rest _) (popper--update-popups)))

This line stood out to me as a potential cause for this behavior as select-frame-hook does not exist for me (currently on Emacs 30):

(add-hook 'select-frame-hook #'popper--update-popups)
@karthink
Copy link
Owner

karthink commented Jul 2, 2024

This line stood out to me as a potential cause for this behavior as select-frame-hook does not exist for me (currently on Emacs 30):

Huh, it looks like select-frame-hook is gone from Emacs 29.3 as well. There's no direct replacement, it looks like after-focus-change-function is the closest but this is pretty complex, it's not a hook.

@ashlineldridge
Copy link
Author

When I did a quick search, it seemed that select-frame-hook was an XEmacs thing. I couldn't see any evidence of it existing in Emacs. This comment seems to back that up.

@jaihindhreddy
Copy link

I'm quite new to Emacs Lisp, but I seem to have hit the same problem. I'm trying to customize popper-display-function to make the pop-ups show up in a floating posframe. I found the "POP" in the mode-line in the posframe upon running popper-toggle, but running it again spawns a nested posframe instead of closing the already open pop-up. This seems to be because popper-open-popup-alist is not updated.

FWIW here's the display function I'm using (It's most probably very broken):

(defun my-popper-display-buffer-in-posframe (buf &optional alist)
  "Display BUFFER in a posframe. ALIST is ignored."
  (posframe-show buf
                 :poshandler #'posframe-poshandler-frame-center
                 :width (floor (* (frame-width) 0.8))
                 :height (floor (* (frame-height) 0.8))
                 :internal-border-width 1
                 :internal-border-color "gray50"
                 :accept-focus t
                 :cursor 'bar
                 :respect-mode-line t)
  (with-current-buffer buf
    (setq-local popper-popup-status 'popup)
    ;; Return window for popper's reference
    (let* ((win (frame-selected-window (buffer-local-value 'posframe--frame buf))))
      (select-window win)
      win)))

@karthink
Copy link
Owner

karthink commented Jan 14, 2025 via email

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

3 participants