Subject: 30.0.50; Inaccurate window-absolute-pixel-position Values on macOS After Sleep and During Fullscreen Mode

From: Jones Stephen <[email-masked]>
Date: Wed, 3 Jul 2024 10:38:16 +0800

Dear Emacs Developers,

I am encountering an issue with window-absolute-pixel-position on macOS
that leads to incorrect Y-coordinate values under specific conditions. This
bug appears to manifest in two scenarios: after the system resumes from
sleep, and when Emacs is in fullscreen mode.

Environment:

Emacs Version: (30.0.50)
Operating System: macOS (After 14.00)
Issue Description:

After Sleep: When macOS resumes from sleep, the Y-coordinate value returned
by window-absolute-pixel-position is off by approximately one-fourth of the
screen height.
During Fullscreen Mode: In fullscreen mode, the Y-coordinate is incorrectly
offset by the height of the navbar.
Steps to Reproduce:

Open Emacs and position a window at a known pixel position.
Either put the system to sleep and wake it, or switch Emacs to fullscreen
mode.
Evaluate (window-absolute-pixel-position) and note the Y-coordinate.
Expected Behavior:
The function should return accurate window positions regardless of sleep
mode or fullscreen state, without any unexpected offsets.

Actual Behavior:
The Y-coordinate is inaccurately calculated, showing a significant offset
that seems to be influenced by system sleep and fullscreen transitions.

This issue can be particularly disruptive in workflows that rely on precise
window positioning, such as automated GUI testing or window management
scripts. Any insights or fixes would be greatly appreciated!

Thank you for your attention to this matter.

Best regards,
happyo

In GNU Emacs 30.0.50 (build 2, aarch64-apple-darwin23.3.0, NS
appkit-2487.40 Version 14.3 (Build 23D56)) of 2024-05-14 built on
happyo.local
Windowing system distributor 'Apple', version 10.3.2554
System Description:  macOS 15.0

Configured using:
'configure --disable-dependency-tracking --disable-silent-rules
--enable-locallisppath=/opt/homebrew/share/emacs/site-lisp
--infodir=/opt/homebrew/Cellar/emacs-plus@30/30.0.50/share/info/emacs
--prefix=/opt/homebrew/Cellar/emacs-plus@30/30.0.50 --with-xml2
--with-gnutls --without-compress-install --without-dbus
--without-imagemagick --with-modules --with-rsvg --with-webp --with-ns
--disable-ns-self-contained 'CFLAGS=-Os -w -pipe
-mmacosx-version-min=14
-isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk
-DFD_SETSIZE=10000 -DDARWIN_UNLIMITED_SELECT'
'CPPFLAGS=-I/opt/homebrew/opt/icu4c/include
-I/opt/homebrew/opt/sqlite/include -I/opt/homebrew/opt/readline/include
-isystem/opt/homebrew/include -F/opt/homebrew/Frameworks
-isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk'
'LDFLAGS=-L/opt/homebrew/opt/icu4c/lib -L/opt/homebrew/opt/sqlite/lib
-L/opt/homebrew/opt/readline/lib -L/opt/homebrew/lib
-F/opt/homebrew/Frameworks -Wl,-headerpad_max_install_names
-isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk''

Configured features:
ACL GIF GLIB GMP GNUTLS JPEG LCMS2 LIBXML2 MODULES NOTIFY KQUEUE NS
PDUMPER PNG RSVG SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER
WEBP XIM ZLIB

Important settings:
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix

Major mode: ELisp/l

Minor modes in effect:
rainbow-delimiters-mode: t
smartparens-mode: t
olivetti-mode: t
electric-pair-mode: t
projectile-mode: t
hexl-follow-ascii: t
copilot-mode: t
lsp-bridge-mode: t
auto-insert-mode: t
yas-global-mode: t
yas-minor-mode: t
recentf-mode: t
savehist-mode: t
consult-notes-denote-mode: t
denote-menu-bar-mode: t
ns-auto-titlebar-mode: t
treemacs-filewatch-mode: t
treemacs-follow-mode: t
treemacs-git-mode: t
treemacs-fringe-indicator-mode: t
global-git-commit-mode: t
magit-auto-revert-mode: t
server-mode: t
my-custom-minor-mode: t
windmove-mode: t
global-auto-revert-mode: t
vertico-posframe-mode: t
vertico-mode: t
meow-global-mode: t
meow-mode: t
meow-normal-mode: t
delete-selection-mode: t
meow-esc-mode: t
cnfonts-mode: t
override-global-mode: t
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
minibuffer-regexp-mode: t
line-number-mode: t
visual-line-mode: t
transient-mark-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t

Load-path shadows:
~/.emacs.d/site-lisp/ob-swift-enhanced/spinner hides
/Users/belyenochi/.emacs.d/elpa/spinner-1.7.4/spinner
~/.emacs.d/site-lisp/vertico/vertico hides
/Users/belyenochi/.emacs.d/elpa/vertico-20240511.2047/vertico
/Users/belyenochi/.emacs.d/elpa/transient-20240609.2020/transient hides
/opt/homebrew/Cellar/emacs-plus@30
/30.0.50/share/emacs/30.0.50/lisp/transient

Features:
(shadow sort mail-extr emacsbug goto-addr etags fileloop generator
tramp-cmds treemacs-mouse-interface display-line-numbers
treemacs-file-management hydra lv vc-hg vc-bzr vc-src vc-sccs vc-svn
vc-cvs vc-rcs log-view vc bug-reference magit-extras vc-git
vc-dispatcher rainbow-mode network-stream nsm rainbow-delimiters
smartparens loadhist olivetti elec-pair time init-macos mac-plugin
init-pomodoro init-swift ob-swift-enhanced xcode-build swift-refactor
swift-additions xcode-additions xcodebuildserver projectile ibuf-ext
ibuffer ibuffer-loaddefs ios-simulator ios-device periphery
periphery-helper mode-line-hud spinner ob-swift ob ob-tangle ol org-src
ob-ref ob-lob ob-table ob-exp ob-comint ob-core org-cycle org-fold
org-fold-core ob-eval org-keys oc org-compat org-macs async init-debug
dape eglot external-completion flymake ert ewoc hexl gdb-mi bindat gud
repeat swift-mode init-treesit swift-ts-mode c-ts-common treesit
init-copilot copilot copilot-balancer editorconfig editorconfig-core
editorconfig-core-handle editorconfig-fnmatch f jsonrpc init-lsp
apheleia apheleia-rcs apheleia-dp apheleia-formatters apheleia-utils
apheleia-log apheleia-formatter-context lsp-bridge
lsp-bridge-semantic-tokens lsp-bridge-dart lsp-bridge-inlay-hint
lsp-bridge-org-babel lsp-bridge-lsp-installer lsp-bridge-diagnostic
lsp-bridge-code-action acm acm-quick-access acm-backend-jupyter
acm-backend-org-roam acm-backend-copilot acm-backend-codeium
acm-backend-ctags acm-backend-citre acm-backend-tabnine
acm-backend-telega acm-backend-tempel acm-backend-search-sdcv-words
acm-backend-search-file-words acm-backend-path acm-backend-lsp
acm-backend-elisp acm-backend-yas acm-icon svg xml
lsp-bridge-call-hierarchy lsp-bridge-peek lsp-bridge-jdtls
lsp-bridge-ref grep lsp-bridge-epc acm-frame markdown-mode noutline
outline init-exec-path exec-path-from-shell init-yasnippet autoinsert
yasnippet lisp-mnt init-sessions dashboard dashboard-widgets recentf
tree-widget ffap thingatpt savehist init-denote consult-notes-denote
consult-notes denote-silo-extras denote init-org init-translate
go-translate go-translate-v2 gts-engine-youdao gts-engine-stardict
gts-engine-deepl gts-engine-google-rpc gts-engine-google gts-engine-bing
gts-implements gts-faces gts-core gt-text-utility gt-engine-echo
gt-engine-chatgpt gt-engine-youdao gt-engine-stardict gt-engine-deepl
gt-engine-google-rpc gt-engine-google gt-engine-bing gt-extension plz
warnings gt-faces gt-core let-alist dom init-mode-line init-gui-frames
ns-auto-titlebar init-themes cus-edit cus-load wid-edit
treemacs-nerd-icons treemacs treemacs-header-line treemacs-compatibility
treemacs-mode treemacs-bookmarks treemacs-tags xref project
treemacs-interface treemacs-persistence treemacs-filewatch-mode
treemacs-follow-mode treemacs-rendering treemacs-annotations
treemacs-async treemacs-workspaces treemacs-dom treemacs-visuals
treemacs-fringe-indicator pulse treemacs-faces treemacs-icons
treemacs-scope treemacs-themes treemacs-core-utils pfuture inline
hl-line ht treemacs-logging treemacs-customization treemacs-macros s
nerd-icons nerd-icons-faces nerd-icons-data nerd-icons-data-mdicon
nerd-icons-data-flicon nerd-icons-data-codicon nerd-icons-data-devicon
nerd-icons-data-sucicon nerd-icons-data-wicon nerd-icons-data-faicon
nerd-icons-data-powerline nerd-icons-data-octicon
nerd-icons-data-pomicon nerd-icons-data-ipsicon ef-summer-theme
chinese-color ef-themes init-magit magit-bookmark magit-submodule
magit-blame magit-stash magit-reflog magit-bisect magit-push magit-pull
magit-fetch magit-clone magit-remote magit-commit magit-sequence
magit-notes magit-worktree magit-tag magit-merge magit-branch
magit-reset magit-files magit-refs magit-status magit magit-repos
magit-apply magit-wip magit-log which-func imenu magit-diff smerge-mode
diff diff-mode track-changes git-commit log-edit message sendmail
yank-media puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg
rfc6068 epg-config gnus-util mm-decode mm-bodies mm-encode mail-parse
rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev
mail-utils gmm-utils mailheader pcvs-util add-log magit-core
magit-autorevert magit-margin magit-transient magit-process with-editor
server magit-mode transient magit-git magit-base magit-section
cursor-sensor crm dash init-keybinding init-lisp init-treemacs
init-windows windmove init-editing-utils autorevert filenotify
init-search consult vertico-posframe vertico-multiform posframe vertico
compat fussy flx init-xterm vterm bookmark face-remap compile
text-property-search term disp-table ehelp vterm-module term/xterm xterm
vterm-toggle tramp-sh tramp trampver tramp-integration files-x
tramp-message tramp-compat xdg shell pcomplete comint ansi-osc ring
parse-time iso8601 time-date format-spec ansi-color tramp-loaddefs
init-projectile init-meow cl-extra meow meow-tutor meow-cheatsheet
meow-cheatsheet-layout meow-core meow-shims delsel meow-esc meow-command
array meow-beacon meow-thing meow-visual meow-keypad meow-helpers
meow-util color meow-keymap meow-face meow-var init-proxy init-osx-keys
edmacro kmacro init-chinese cnfonts touch-screen init-func init-elpa
use-package use-package-ensure use-package-delight use-package-diminish
use-package-bind-key bind-key use-package-core finder-inf
apheleia-autoloads easy-mmode async-autoloads
auto-package-update-autoloads cnfonts-autoloads dashboard-autoloads
default-text-scale-autoloads disable-mouse-autoloads
editorconfig-autoloads exec-path-from-shell-autoloads f-autoloads
format-all-autoloads fussy-autoloads flx-autoloads
ibuffer-projectile-autoloads imenu-list-autoloads indent-guide-autoloads
inheritenv-autoloads language-id-autoloads markdown-mode-autoloads
move-dup-autoloads ns-auto-titlebar-autoloads objc-font-lock-autoloads
olivetti-autoloads orderless-autoloads paradox-autoloads plz-autoloads
prettier-js-autoloads rainbow-delimiters-autoloads
rainbow-mode-autoloads slime-autoloads macrostep-autoloads
smartparens-autoloads smooth-scrolling-autoloads speed-type-autoloads
spinner-autoloads transwin-autoloads treemacs-icons-dired-autoloads
treemacs-magit-autoloads magit-autoloads pcase magit-section-autoloads
git-commit-autoloads transient-autoloads treemacs-nerd-icons-autoloads
nerd-icons-autoloads treemacs-projectile-autoloads projectile-autoloads
treemacs-tab-bar-autoloads treemacs-autoloads cfrs-autoloads
ht-autoloads hydra-autoloads lv-autoloads pfuture-autoloads
ace-window-autoloads avy-autoloads s-autoloads unicode-escape-autoloads
pp rx names edebug debug backtrace help-mode find-func dash-autoloads
names-autoloads advice vertico-posframe-autoloads vertico-autoloads
posframe-autoloads vterm-toggle-autoloads vterm-autoloads
vundo-autoloads wgrep-autoloads info with-editor-autoloads package
browse-url url url-proxy url-privacy url-expand url-methods url-history
url-cookie generate-lisp-file url-domsuf url-util mailcap url-handlers
url-parse auth-source cl-seq eieio eieio-core cl-macs icons
password-cache json subr-x map byte-opt gv bytecomp byte-compile
url-vars cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc paren
electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/ns-win ns-win ucs-normalize mule-util term/common-win tool-bar dnd
fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads kqueue cocoa ns lcms2
multi-tty make-network-process emacs)

Memory information:
((conses 16 1184799 9644722) (symbols 48 64280 2983)
(strings 32 386699 132024) (string-bytes 1 17501886)
(vectors 16 97354) (vector-slots 8 1735672 1510714)
(floats 8 1268 28445) (intervals 56 51964 36252) (buffers 992 85))