manateelazycat / lsp-bridge

A blazingly fast LSP client for Emacs
GNU General Public License v3.0
1.36k stars 197 forks source link

acm popup menu not align well with cursor on KDE plasma 6 wayland #915

Closed eval-exec closed 2 months ago

eval-exec commented 2 months ago

I am running KDE Plasma 6 on a HiDPI screen with a resolution of 3840x2160. I am using Xwayland to run Emacs, and the completion menu in the lsp-bridge does not align properly with the current cursor position.

lsp-bridge version: * ac40260 - (HEAD -> master, origin/master, origin/HEAD) Add new option acm-backend-lsp-block-kind-list (18 hours ago) <Andy Stewart> system: "x86_64-linux" host os: Linux 6.8.6, NixOS, 24.05 (Uakari), 24.05.20240416.5672bc9 DE: KDE Plasma 6.0.3 WM: KWin (Wayland)

What environment variables or configurations can affect the position of acm-popup-menu? What information should I provide to help analyze this issue?

Thank you. :blue_heart:

image

Screencast_20240420_103416.webm

manateelazycat commented 2 months ago

You can take a look at https://github.com/manateelazycat/lsp-bridge/blob/ac402603a5f3f64e61fae8194fd3be8f3f3dea06/acm/acm.el#L677 here

Did you use a centering plugin like olivetti?

eval-exec commented 2 months ago

I didn't use `centering plugin like olivetti or writeroom-mode.


If I hack acm-frame-get-popup-position to this, only change

(cons (+ x window-left)
          (+ y window-top offset-y))

to

(cons (+ x window-left 88)
          (+ y window-top offset-y))

then the popup menu looks align well...

(defun acm-frame-get-popup-position (frame-popup-point &optional line-bias)
  (let* ((edges (window-pixel-edges))
         (window-left (+ (nth 0 edges)
                         ;; We need adjust left margin for buffer centering module.
                         (/ (- (window-pixel-width)
                               (window-body-width nil t))
                            2)))
         (window-top (nth 1 edges))
         (pos (posn-x-y (posn-at-point frame-popup-point)))
         (x (car pos))
         (y (+ (cdr pos) (* (or line-bias 0) (line-pixel-height))))
         (offset-y
          ;; We need move down to skip tab-line and header-line.
          (if (version< emacs-version "27.0")
              (window-header-line-height)
            (+ (window-tab-line-height)
               (window-header-line-height)))))
    (cons (+ x window-left 88)
          (+ y window-top offset-y))))
eval-exec commented 2 months ago

@manateelazycat What do you think using (window-absolute-pixel-position) to get the acm-frame-get-popup-position? Ref: https://emacs.stackexchange.com/questions/19555/obtain-absolute-pixel-position-of-point

manateelazycat commented 2 months ago

截图 2024-04-21 07-10-50

上面是我的截图, 你的Emacs不支持svg图标渲染, 还是你禁用了图标?

manateelazycat commented 2 months ago

@eval-exec I have push new patch https://github.com/manateelazycat/lsp-bridge/commit/12302c741eafdab370fb619460979de930458a53

This patch will adjust acm menu position follow option acm-enable-icon and acm-enable-quick-access. 截图 2024-04-21 07-39-19 截图 2024-04-21 07-39-02 截图 2024-04-21 07-38-53

Thanks for feedback