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

EAF frame not in center in Mac OS #990

Open
JoshTRN opened this issue Jul 7, 2022 · 13 comments
Open

EAF frame not in center in Mac OS #990

JoshTRN opened this issue Jul 7, 2022 · 13 comments
Labels
help wanted Extra attention is needed

Comments

@JoshTRN
Copy link

JoshTRN commented Jul 7, 2022

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
image

image

Additional context
Add any other context about the problem here.

@Jousimies
Copy link

Same problem here.

@Jousimies
Copy link

修改下列函数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 ","))))))

image

我的系统环境是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的调整。

@manateelazycat
Copy link
Member

eaf--buffer-x-position-adjust frame

@lhpfvs 大佬, 我没有 macOS, 你怎么看上一条建议? 还需要 eaf--buffer-x-position-adjust 和 eaf--buffer-y-position-adjust 吗?

@lhpfvs
Copy link
Contributor

lhpfvs commented Dec 13, 2022

这两个不能去掉的吧,上面没问题只是因为刚好是最大化显示,如果没有最大化肯定是有问题的

@lhpfvs
Copy link
Contributor

lhpfvs commented Dec 13, 2022

修改下列函数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 ","))))))
image

我的系统环境是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不做任何修改也有同样问题吗?

@Jousimies
Copy link

这两个不能去掉的吧,上面没问题只是因为刚好是最大化显示,如果没有最大化肯定是有问题的

你说的是对的,我一直使用最大化显示,所以没发现这个问题。

不做修改28.2是正常的,是在29上面不正常。

@manateelazycat
Copy link
Member

针对Emacs 29打个补丁?

@lhpfvs
Copy link
Contributor

lhpfvs commented Dec 13, 2022

nsport的29有问题,调整窗口大小后frame-parameter没有更新,导致坐标不对,只有移动窗口才会更新。macport版本如果29发布了,应该是正常的。

@Jousimies
Copy link

Jousimies commented Dec 13, 2022

今天又更新了下 emacs-plus 29.0.60 打开 eaf-pdf-viewer之后会新开一个 Emacs 窗口,在这个新开的窗口中 pdf的位置是正常的,eaf-git 的 buffer 也是正常的。

image

看左下角有两个 Emacs和 python 小火箭,不知道 Emacs改了啥。退出第一个Emacs窗口,Emacs也会自动重启,只能强制关闭。

这个问题目前看来只能保持这种状态,等Emacs29啥时候稳定了再说吧。

@manateelazycat
Copy link
Member

今天又更新了下 emacs-plus 29.0.60 打开 eaf-pdf-viewer之后会新开一个 Emacs 窗口,在这个新开的窗口中 pdf的位置是正常的,eaf-git 的 buffer 也是正常的。

image

看左下角有两个 Emacs和 python 小火箭,不知道 Emacs改了啥。退出第一个Emacs窗口,Emacs也会自动重启,只能强制关闭。

这个问题目前看来只能保持这种状态,等Emacs29啥时候稳定了再说吧。

你的右下角进度信息为啥那么大?

@Jousimies
Copy link

你的右下角进度信息为啥那么大?

这个不知道啊,没改过这个设置。全屏看上去正常一些。
image

上面的那个两个Emacs的问题重新安装一遍之后消失了。

全屏下对不齐的问题还是存在。

(frame-parameter (car (frame-list)) 'left)这个返回的值在最大化窗口下就不对,非最大化窗口是正常的。

@manateelazycat
Copy link
Member

你的右下角进度信息为啥那么大?

这个不知道啊,没改过这个设置。全屏看上去正常一些。 image

上面的那个两个Emacs的问题重新安装一遍之后消失了。

全屏下对不齐的问题还是存在。

(frame-parameter (car (frame-list)) 'left)这个返回的值在最大化窗口下就不对,非最大化窗口是正常的。

@lhpfvs 已经支出了是 mac 构建不同包的问题, 而不是 emacs 的问题?

@lhpfvs
Copy link
Contributor

lhpfvs commented Dec 14, 2022

你的右下角进度信息为啥那么大?

这个不知道啊,没改过这个设置。全屏看上去正常一些。 image
上面的那个两个Emacs的问题重新安装一遍之后消失了。
全屏下对不齐的问题还是存在。
(frame-parameter (car (frame-list)) 'left)这个返回的值在最大化窗口下就不对,非最大化窗口是正常的。

@lhpfvs 已经支出了是 mac 构建不同包的问题, 而不是 emacs 的问题?

官方Emacs本身就是有问题的,只要是改变窗口大小都会马上出错,但是移动一下窗口就能恢复正常。最大化窗口下只要试一试移动应该就可以了。

@manateelazycat manateelazycat added the help wanted Extra attention is needed label Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants