-
Notifications
You must be signed in to change notification settings - Fork 15
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
Fullscreen toggle for all Emacs buffers #89
Comments
More sophisticated version: (defvar +exwm-fullscreen--restore nil)
(defun +exwm-fullscreen--change (&rest _)
(when +exwm-fullscreen--restore
(+exwm-fullscreen)))
(defun +exwm-fullscreen--enter ()
;; Create frame and resize
(let ((frame (make-frame '((minibuffer . nil)
(fullscreen . fullboth)))))
(push (lambda () (delete-frame frame)) +exwm-fullscreen--restore)
(let ((geo (frame-monitor-geometry)))
(set-frame-size frame (nth 2 geo) (nth 3 geo) t)))
;; Disable tab-bar-mode
(when tab-bar-mode
(push #'tab-bar-mode +exwm-fullscreen--restore)
(tab-bar-mode -1))
;; Adjust buffer-local variables
(dolist (var '(mode-line-format tab-line-format))
(let ((buf (current-buffer))
(orig (symbol-value var))
(local (local-variable-p var)))
(set (make-local-variable var) nil)
(push (lambda ()
(when (buffer-live-p buf)
(with-current-buffer buf
(if local
(kill-local-variable var)
(set var orig)))))
+exwm-fullscreen--restore)))
;; Special mode tricks
(when (and (eq major-mode 'pdf-view-mode) (fboundp 'pdf-view-fit-page-to-window))
(pdf-view-fit-page-to-window))
;; Ensure that buffer change leaves fullscreen
(run-at-time
0.1 nil
(lambda (buf)
(when +exwm-fullscreen--restore
(add-hook 'window-selection-change-functions #'+exwm-fullscreen--change nil 'local)
(add-hook 'window-buffer-change-functions #'+exwm-fullscreen--change nil 'local)
(push (lambda ()
(when (buffer-live-p buf)
(with-current-buffer buf
(remove-hook 'window-selection-change-functions #'+exwm-fullscreen--change 'local)
(remove-hook 'window-buffer-change-functions #'+exwm-fullscreen--change 'local))))
+exwm-fullscreen--restore)))
(current-buffer)))
(defun +exwm-fullscreen ()
(interactive)
(cond
;; Leave fullscreen for Emacs buffer
(+exwm-fullscreen--restore
(mapc #'funcall +exwm-fullscreen--restore)
(setq +exwm-fullscreen--restore nil))
;; EXWM buffer fullscreen toggle
((eq major-mode 'exwm-mode)
(exwm-layout-toggle-fullscreen))
;; Enter fullscreen for Emacs buffer
(t (+exwm-fullscreen--enter)))) |
A proper full-screen would be great! (defvar fullscreen-buffer--state nil)
(defun fullscreen-buffer--toggle ()
"Maximize buffer"
(interactive)
(if fullscreen-buffer--state
(let ((val (get-register (tab-bar--current-tab-index))))
(register-val-jump-to val nil)
(tab-bar-mode t)
(setq mode-line-format (default-value 'mode-line-format))
(setq fullscreen-buffer--state nil))
(progn
(window-configuration-to-register (tab-bar--current-tab-index))
(delete-other-windows)
(tab-bar-mode -1)
(setq mode-line-format nil)
(setq fullscreen-buffer--state t)))) Testing your config, looks like it correctly enables full-screen for both EXWM and normal buffers, but there seem to be some issues:
|
I also had a similar function in my config: (defun my-toggle-fullscreen ()
"Toggle fullscreen for the current buffer.
Automatically exits fullscreen if any window-changing command is executed."
(interactive)
(if (= 1 (length (window-list)))
(when my-fullscreen-window-configuration
(set-window-configuration my-fullscreen-window-configuration)
(setq my-fullscreen-window-configuration nil)
(advice-remove 'split-window #'my-exit-fullscreen-advice))
(setq my-fullscreen-window-configuration (current-window-configuration))
(delete-other-windows)
(advice-add 'split-window :before #'my-exit-fullscreen-advice))) I think a builtin function would be great. |
In my config I've bound s-f to +exwm-fullscreen. s-f works fpr toggling both normal and EXWM buffers. |
@minad just tried again after putting in a dedicated file with lexical-binding, works fine. Was tricked again by dynamic scoping by default. More comments:
Another concern is how this would play with the idea discussed earlier here about using tabs for workspaces and frames per monitors. I have a function that automatically gets a list of connected outputs from xrandr and ensures that each connected screen has a frame on |
I think it should work well with the tab-bar idea for workspaces. As you said, we will anyway have to continue to support multiple Emacs frames anyway because of multiple monitors. The question is if it leads to complications if we continue to allow multiple frames on a single monitor. |
This is exactly what I was thinking of. The model "one monitor - one frame" could potentially simplify the logic around automatically enabling external monitors, which is great for laptops, especially when a user is connecting it to different external gear with unpredictable output names (home/office/clients etc.) This is what I have currently: ;; Attempt to ensure correct external monitor handling
(defun +exwm-ensure-workspaces (num-workspaces)
"Ensure there are exactly NUM-WORKSPACES created in EXWM"
(let ((current-num-workspaces (length exwm-workspace--list)))
(when (< current-num-workspaces num-workspaces)
(dotimes (_ (- num-workspaces current-num-workspaces))
(exwm-workspace-add))
(message "Created %d new workspaces" (- num-workspaces current-num-workspaces)))
(when (> current-num-workspaces num-workspaces)
(dotimes (i (- current-num-workspaces num-workspaces))
(exwm-workspace-delete))
(message "Deleted %d workspaces" (- current-num-workspaces num-workspaces)))))
(defun +exwm-xrandr-list ()
"xrandr query to get a list of monitors"
(split-string (shell-command-to-string "xrandr --listmonitors | awk '{print $4}'") "\n" t))
(defun +exwm-update-workspaces ()
"Ensure every connected monitor has a dedicated EXWM workspace"
(let* ((monitors (+exwm-xrandr-list))
(num-monitors (length monitors)))
;; Ensure enough workspaces exist
(+exwm-ensure-workspaces num-monitors)
;; Clear current RANDR configuration
(setq exwm-randr-workspace-monitor-plist nil)
(dotimes (i num-monitors)
;; Assign a workspace to each monitor
(setq exwm-randr-workspace-monitor-plist
(append exwm-randr-workspace-monitor-plist
(list i (nth i monitors)))))
(+exwm-ensure-workspaces num-monitors)
(message "Updated workspaces for monitors: %s" monitors)))
(add-hook 'exwm-randr-refresh-hook #'+exwm-update-workspaces)
(add-hook 'exwm-randr-screen-change-hook #'exwm-randr-refresh) |
A general fullscreen toggle would be nice to have. I have this in my config right now, but this likely misses many edge cases and might not be the best solution.
The text was updated successfully, but these errors were encountered: