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

From: Gerd Möllmann <[email-masked]>
Date: Fri, 26 Jul 2024 22:32:20 +0200

Gerd Möllmann <[email-masked]> writes:

> Alan Third <[email-masked]> writes:
>
>> On Thu, Jul 25, 2024 at 09:39:16AM +0200, Gerd Möllmann wrote:
>>> Gerd Möllmann <[email-masked]> writes:
>>> 
>>> The following patch for master addresses this at least partially. Part
>>> of the problem is, it appears to me, is that windowDidMove is not called
>>> when entering/exiting fullscreen mode, so that a frame's left_pos and
>>> top_pos are not adjusted. The patch tries to fix that. I haven't found
>>> out what to do with the frame parameters top and left.
>>
>> If you look at toggleFullScreen it creates a new NSWindow for
>> switching to fullscreen, or re-uses the old non-fullscreen NSWindow
>> when switching out of fullscreen, so the windows don't move.
>>
>> You can actually just call windowDidMove directly. I'd suggest doing
>> it at the end of toggleFullScreen.
>
> Thanks, I'll give that a try tomorrow.

Tried it today :-).

And it looks like toggleFullScreen is somehow not being used. When I
press the green button to go into fullscreen, I land in
windowDidEnterFullscreen, but it's called directly from AppKit. Similar
for exiting fullscreen.

* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 8.1
    frame #0: 0x0000000100365e54 emacs`-[EmacsView windowDidEnterFullScreen](self=0x000000014860f930, _cmd="windowDidEnterFullScreen") at nsterm.m:8350:4
    frame #1: 0x0000000100365e30 emacs`-[EmacsView windowDidEnterFullScreen:](self=0x000000014860f930, _cmd="windowDidEnterFullScreen:", notification=@"NSWindowDidEnterFullScreenNotification") at nsterm.m:8344:3
  frame #2: 0x0000000191b4f144 CoreFoundation`__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 148
  frame #3: 0x0000000191be33d8 CoreFoundation`___CFXRegistrationPost_block_invoke + 88
  frame #4: 0x0000000191be3320 CoreFoundation`_CFXRegistrationPost + 440
  frame #5: 0x0000000191b1d678 CoreFoundation`_CFXNotificationPost + 768
  frame #6: 0x0000000192c3a4e4 Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 88
  frame #7: 0x00000001961742b8 AppKit`-[NSWindow(NSFullScreen) _didEnterFullScreen] + 92
  frame #8: 0x0000000195f568d8 AppKit`-[_NSEnterFullScreenTransitionController doAfterEnterFullScreen] + 208
  frame #9: 0x0000000195f57710 AppKit`-[_NSEnterFullScreenTransitionController _performFinalTransitionCleanup] + 56
  frame #10: 0x0000000195f5767c AppKit`__68-[_NSEnterFullScreenTransitionController _startFullScreenTransition]_block_invoke + 236
  frame #11: 0x00000001918c8750 libdispatch.dylib`_dispatch_call_block_and_release + 32
  frame #12: 0x00000001918ca3e8 libdispatch.dylib`_dispatch_client_callout + 20
  frame #13: 0x00000001918d8bb8 libdispatch.dylib`_dispatch_main_queue_drain + 988
  frame #14: 0x00000001918d87cc libdispatch.dylib`_dispatch_main_queue_callback_4CF + 44
  frame #15: 0x0000000191b9bad4 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
  frame #16: 0x0000000191b59258 CoreFoundation`__CFRunLoopRun + 1996
  frame #17: 0x0000000191b58434 CoreFoundation`CFRunLoopRunSpecific + 608
  frame #18: 0x000000019c2fc19c HIToolbox`RunCurrentEventLoopInMode + 292
  frame #19: 0x000000019c2fbfd8 HIToolbox`ReceiveNextEventCommon + 648
  frame #20: 0x000000019c2fbd30 HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 76
  frame #21: 0x00000001953b7d68 AppKit`_DPSNextEvent + 660
  frame #22: 0x0000000195bad808 AppKit`-[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 700
  frame #23: 0x00000001953ab09c AppKit`-[NSApplication run] + 476
    frame #24: 0x000000010035b4bc emacs`-[EmacsApp run](self=0x0000000149005bf0, _cmd="run") at nsterm.m:5952:7
    frame #25: 0x0000000100359b38 emacs`ns_select_1(nfds=0, readfds=0x000000016fdfd24c, writefds=0x000000016fdfd1cc, exceptfds=0x0000000000000000, timeout=0x000000016fdfd1a0, sigmask=0x0000000000000000, run_loop_only=NO) at nsterm.m:4964:3
    frame #26: 0x00000001003596f8 emacs`ns_select(nfds=0, readfds=0x000000016fdfd24c, writefds=0x000000016fdfd1cc, exceptfds=0x0000000000000000, timeout=0x000000016fdfd1a0, sigmask=0x0000000000000000) at nsterm.m:5016:10
    frame #27: 0x00000001002cc594 emacs`wait_reading_process_output(time_limit=0, nsecs=0, read_kbd=-1, do_display=true, wait_for_cell=(struct Lisp_Symbol *) $0 = 0x0000000100a840d0, wait_proc=0x0000000000000000, just_wait_proc=0) at process.c:5748:18