emacs-application-framework
emacs-application-framework copied to clipboard
EAF frame not in center in Mac OS
Describe the bug EAF window is never in the center, it's always to the bottom right.
To Reproduce I just installed eaf through spacemacs and this was my issue.
Expected behavior EAF buffer should appear in the center of the screen.
Versions (please complete the following info):
- Distro and DE/WM: macOS Monterey version 12.4
- Versions of Dependencies:
- M-x emacs-version: GNU Emacs 29.0.50 (build 2, x86_64-apple-darwin21.5.0, NS appkit-2113.50 Version 12.4 (Build 21F79)) of 2022-05-18
Error logs
qt.webenginecontext:
GL Type: core_profile
Surface Type: OpenGL
Surface Profile: CoreProfile
Surface Version: 4.1
QSG RHI Backend: OpenGL
Using Supported QSG Backend: yes
Using Software Dynamic GL: no
Using Multithreaded OpenGL: yes
Init Parameters:
* application-name Python
* browser-subprocess-path /Users/Joshua.T.Wood/Library/Python/3.8/lib/python/site-packages/PyQt6/Qt6/lib/QtWebEngineCore.framework/Helpers/QtWebEngineProcess.app/Contents/MacOS/QtWebEngineProcess
* disable-features ConsolidatedMovementXY,InstalledApp,BackgroundFetch,WebOTP,WebPayments,WebUSB,PictureInPicture
* disable-speech-api
* disable-web-security
* enable-features NetworkServiceInProcess,TracingServiceInProcess
* enable-gpu-rasterization
* enable-native-gpu-memory-buffers
* enable-threaded-compositing
* ignore-gpu-blocklist
* in-process-gpu
* use-gl core_profile
[EAF] Browser https://www.google.com/ loading time: 0.9189050197601318s
[EAF] Browser https://www.google.com/ loading time: 0.4785439968109131s
Screenshots

Additional context Add any other context about the problem here.
Same problem here.
修改下列函数eaf-monitor-configuration-change
(defun eaf-monitor-configuration-change (&rest _)
"EAF function to respond when detecting a window configuration change."
(when (and eaf--monitor-configuration-p
(eaf-epc-live-p eaf-epc-process))
(ignore-errors
(let (view-infos)
(dolist (frame (frame-list))
(dolist (window (window-list frame))
(with-current-buffer (window-buffer window)
(when (derived-mode-p 'eaf-mode)
;; When `eaf-fullscreen-p' is non-nil, and only the EAF window is present, use frame size
(if (and eaf-fullscreen-p (equal (length (cl-remove-if #'window-dedicated-p (window-list frame))) 1))
(push (format "%s:%s:%s:%s:%s:%s"
eaf--buffer-id
(eaf-get-emacs-xid frame)
0 0 (frame-pixel-width frame) (frame-pixel-height frame))
view-infos)
(let* ((window-allocation (eaf-get-window-allocation window))
(window-divider-right-padding (if window-divider-mode window-divider-default-right-width 0))
(window-divider-bottom-padding (if window-divider-mode window-divider-default-bottom-width 0))
(titlebar-height (eaf--get-titlebar-height))
(frame-coordinate (eaf--get-frame-coordinate))
(frame-x (car frame-coordinate))
(frame-y (cadr frame-coordinate))
(x (nth 0 window-allocation))
(y (nth 1 window-allocation))
(w (nth 2 window-allocation))
(h (nth 3 window-allocation)))
(push (format "%s:%s:%s:%s:%s:%s"
eaf--buffer-id
(eaf-get-emacs-xid frame)
(+ x frame-x)
(+ y titlebar-height frame-y)
(- w window-divider-right-padding)
(- h window-divider-bottom-padding))
view-infos)))))))
(eaf-call-async "update_views" (mapconcat #'identity view-infos ","))))))

上面的函数去掉了对于x,y位置的调整,(eaf--buffer-x-position-adjust frame)
和(eaf--buffer-y-postion-adjust frame)
。
@manateelazycat 大佬看看怎么修改下代码,我非专业不知道其他地方、其他系统及环境有没有影响,就不提PR了。我测试了28.2和29.0.60两个版本的Emacs在Mac 13上都不需要进行x,y的调整。
eaf--buffer-x-position-adjust frame
@lhpfvs 大佬, 我没有 macOS, 你怎么看上一条建议? 还需要 eaf--buffer-x-position-adjust 和 eaf--buffer-y-position-adjust 吗?
这两个不能去掉的吧,上面没问题只是因为刚好是最大化显示,如果没有最大化肯定是有问题的
修改下列函数
eaf-monitor-configuration-change
(defun eaf-monitor-configuration-change (&rest _) "EAF function to respond when detecting a window configuration change." (when (and eaf--monitor-configuration-p (eaf-epc-live-p eaf-epc-process)) (ignore-errors (let (view-infos) (dolist (frame (frame-list)) (dolist (window (window-list frame)) (with-current-buffer (window-buffer window) (when (derived-mode-p 'eaf-mode) ;; When `eaf-fullscreen-p' is non-nil, and only the EAF window is present, use frame size (if (and eaf-fullscreen-p (equal (length (cl-remove-if #'window-dedicated-p (window-list frame))) 1)) (push (format "%s:%s:%s:%s:%s:%s" eaf--buffer-id (eaf-get-emacs-xid frame) 0 0 (frame-pixel-width frame) (frame-pixel-height frame)) view-infos) (let* ((window-allocation (eaf-get-window-allocation window)) (window-divider-right-padding (if window-divider-mode window-divider-default-right-width 0)) (window-divider-bottom-padding (if window-divider-mode window-divider-default-bottom-width 0)) (titlebar-height (eaf--get-titlebar-height)) (frame-coordinate (eaf--get-frame-coordinate)) (frame-x (car frame-coordinate)) (frame-y (cadr frame-coordinate)) (x (nth 0 window-allocation)) (y (nth 1 window-allocation)) (w (nth 2 window-allocation)) (h (nth 3 window-allocation))) (push (format "%s:%s:%s:%s:%s:%s" eaf--buffer-id (eaf-get-emacs-xid frame) (+ x frame-x) (+ y titlebar-height frame-y) (- w window-divider-right-padding) (- h window-divider-bottom-padding)) view-infos))))))) (eaf-call-async "update_views" (mapconcat #'identity view-infos ","))))))
![]()
我的系统环境是MacOS M1 13,Emacs version 29. 上面的函数去掉了对于x,y位置的调整,
(eaf--buffer-x-position-adjust frame)
和(eaf--buffer-y-postion-adjust frame)
。@manateelazycat 大佬看看怎么修改下代码,我非专业不知道其他地方、其他系统及环境有没有影响,就不提PR了。我测试了28.2和29.0.60两个版本的Emacs在Mac 13上都不需要进行x,y的调整。
28.2不做任何修改也有同样问题吗?
这两个不能去掉的吧,上面没问题只是因为刚好是最大化显示,如果没有最大化肯定是有问题的
你说的是对的,我一直使用最大化显示,所以没发现这个问题。
不做修改28.2是正常的,是在29上面不正常。
针对Emacs 29打个补丁?
nsport的29有问题,调整窗口大小后frame-parameter没有更新,导致坐标不对,只有移动窗口才会更新。macport版本如果29发布了,应该是正常的。
今天又更新了下 emacs-plus 29.0.60 打开 eaf-pdf-viewer之后会新开一个 Emacs 窗口,在这个新开的窗口中 pdf的位置是正常的,eaf-git 的 buffer 也是正常的。

看左下角有两个 Emacs和 python 小火箭,不知道 Emacs改了啥。退出第一个Emacs窗口,Emacs也会自动重启,只能强制关闭。
这个问题目前看来只能保持这种状态,等Emacs29啥时候稳定了再说吧。
今天又更新了下 emacs-plus 29.0.60 打开 eaf-pdf-viewer之后会新开一个 Emacs 窗口,在这个新开的窗口中 pdf的位置是正常的,eaf-git 的 buffer 也是正常的。
![]()
看左下角有两个 Emacs和 python 小火箭,不知道 Emacs改了啥。退出第一个Emacs窗口,Emacs也会自动重启,只能强制关闭。
这个问题目前看来只能保持这种状态,等Emacs29啥时候稳定了再说吧。
你的右下角进度信息为啥那么大?
你的右下角进度信息为啥那么大?
这个不知道啊,没改过这个设置。全屏看上去正常一些。
上面的那个两个Emacs的问题重新安装一遍之后消失了。
全屏下对不齐的问题还是存在。
(frame-parameter (car (frame-list)) 'left)
这个返回的值在最大化窗口下就不对,非最大化窗口是正常的。
你的右下角进度信息为啥那么大?
这个不知道啊,没改过这个设置。全屏看上去正常一些。
上面的那个两个Emacs的问题重新安装一遍之后消失了。
全屏下对不齐的问题还是存在。
(frame-parameter (car (frame-list)) 'left)
这个返回的值在最大化窗口下就不对,非最大化窗口是正常的。
@lhpfvs 已经支出了是 mac 构建不同包的问题, 而不是 emacs 的问题?
你的右下角进度信息为啥那么大?
这个不知道啊,没改过这个设置。全屏看上去正常一些。
上面的那个两个Emacs的问题重新安装一遍之后消失了。 全屏下对不齐的问题还是存在。
(frame-parameter (car (frame-list)) 'left)
这个返回的值在最大化窗口下就不对,非最大化窗口是正常的。@lhpfvs 已经支出了是 mac 构建不同包的问题, 而不是 emacs 的问题?
官方Emacs本身就是有问题的,只要是改变窗口大小都会马上出错,但是移动一下窗口就能恢复正常。最大化窗口下只要试一试移动应该就可以了。