ch11ng / exwm

Emacs X Window Manager
2.85k stars 135 forks source link

A fix to call switch-to-buffer/find-file within an exwm-floating-frame #929

Closed zhenhua-wang closed 6 months ago

zhenhua-wang commented 11 months ago

When switching-to-buffer/find-file is invoked within an exwm-floating-frame, it currently results in the new buffer opening underneath the floating window. To address this issue, I have added the following advice to refocus on the main frame before calling switching-to-buffer/find-file. We might want to incorporate similar advice into the exwm package or redefine the behavior of switch-to-buffer for floating windows.

(defun zw/exwm-switch-to-buffer-advice (&rest args)
  (when exwm--floating-frame
    (select-frame-set-input-focus exwm-workspace--current)))
(advice-add 'find-file :before 'zw/exwm-switch-to-buffer-advice)
(advice-add 'switch-to-buffer :before 'zw/exwm-switch-to-buffer-advice)
(advice-add 'exwm-workspace-switch-to-buffer :before 'zw/exwm-switch-to-buffer-advice)