Skip to content

Commit 0c8acf4

Browse files
authored
Emacs: Fix candidate overlay collapse when tab-line is enabled (#1507)
* candidate overlay works with the tab line * Adopting maintainer's advice * indent modified PiperOrigin-RevId: 914132399
1 parent 71fac5a commit 0c8acf4

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

src/unix/emacs/mozc.el

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ In a word, this function is a fixed version of `posn-at-point'."
643643
"Return the y coordinate in POSITION.
644644
645645
This function returns y offset from the top of the buffer area including
646-
the header line. This definition could be changed in future.
646+
the header line and tab line. This definition could be changed in future.
647647
648648
Note: On Emacs 22 and 23, y offset, returned by `posn-at-point' and taken
649649
by `posn-at-x-y', is relative to the top of the buffer area including
@@ -652,15 +652,21 @@ However, on Emacs 24, y offset returned by `posn-at-point' is relative to
652652
the text area excluding the header line, while y offset taken by
653653
`posn-at-x-y' is relative to the buffer area including the header line.
654654
This asymmetry is by design according to GNU Emacs team.
655+
On Emacs 27, the tab line was added. The tab line behaves like the header
656+
line on Emacs 24.
655657
656658
This function fixes the asymmetry between them on Emacs 24 and later versions.
657659
This hack could be moved to mozc-posn-at-x-y in a future version."
658660
(let ((y (cdr (posn-x-y position))))
659-
(if (or (null header-line-format) (<= emacs-major-version 23))
660-
y
661-
(+ y (or mozc-cached-header-line-height
662-
(setq mozc-cached-header-line-height (mozc-header-line-height))
663-
0)))))
661+
(cond ((fboundp #'window-tab-line-height)
662+
(+ y (window-tab-line-height) (window-header-line-height)))
663+
((or (null header-line-format) (<= emacs-major-version 23))
664+
y)
665+
(t
666+
(+ y (or mozc-cached-header-line-height
667+
(setq mozc-cached-header-line-height
668+
(mozc-header-line-height))
669+
0))))))
664670

665671
(defsubst mozc-window-width (&optional window)
666672
"Return the width of WINDOW in pixel.

0 commit comments

Comments
 (0)