Repository navigation
Conversation
Moving or sizing a window runs Windows' own modal loop inside DefWindowProc (WM_SYSCOMMAND SC_MOVE/SC_SIZE) until the drag ends. For that whole time the run loop doesn't run in any mode: NSTimers don't fire and nothing is redisplayed, so an indeterminate NSProgressIndicator or any timer-driven animation freezes while the user drags or resizes a window. A Win32 timer, set on WM_ENTERSIZEMOVE and killed on WM_EXITSIZEMOVE, now fires the run loop's due timers in its current mode (-limitDateForMode:, which polls no input sources, so Windows' loop keeps its own messages) and redisplays the windows that need it. It is guarded against reentry, and an exception from a timer is logged rather than unwinding through DefWindowProc. A timer may itself start a nested event loop (a modal panel, say). That loop would take the drag's input from under Windows' loop, so a later Escape or button-up never reached the drag. When a nested loop first asks for an event (-getEventMatchingMask:...) while the timer is pumping, the drag is cancelled with WM_CANCELMODE, as if Escape were pressed; Windows' loop ends once the timer returns. Testing: Tests/win32/sizemove.m (new; the directory's tests skip on every other backend). It posts its window WM_SYSCOMMAND SC_MOVE, a keyboard move that needs no mouse, from a second thread, which watches GetGUIThreadInfo's GUI_INMOVESIZE flag and ends the loop with Escape. It skips when Windows doesn't enter the loop (no interactive desktop). - "timers during a move loop": the window stays in the loop for a second, a 20 ms default-mode timer fires at least 25 times in it, and Escape still ends it. This guards against timers stopping during a drag, and against the timer taking the loop's own input. - "a modal panel started by a timer during a move loop": a timer opens a modal panel only while the window is in the loop. The panel must run and return, the drag must be over once it has, and no loop may be left running. This guards against a nested loop taking the drag's input. On master (2c7d5f1) 4 of the 7 checks fail: no ticks in the loop, so no panel during the drag; with this change all 7 pass. Both runs were on Windows 11 build 26300, MSYS2 CLANG64, clang 21.1.8, against libs-base master 220f7bdce and libs-gui master 662f89071. The test is written to fail rather than hang without the change. Measured with a separate test program over 3 s in each loop, at 96 DPI, on libs-gui 0.32.0 with the same change applied to the 0.32.0.5 backend we ship: a timer-driven progress indicator drew once without the change and 37 times with it, the same as outside the loop. In 20 runs where a timer opened a modal panel in the middle of a drag: no hangs, no lost Escape, and every drag ended before the Escape was sent. Not covered: an indicator using threaded animation still freezes. Its -setNeedsDisplay: reaches the main thread as a queued -performSelectorOnMainThread:, which only -acceptInputForMode: runs, and that would also poll Windows' input. A mouse-driven drag, which Windows ends on button-up, isn't tested, as the test can't press a button; the keyboard move runs the same loop. AI assistance: this change, its test and this description were written with Claude (Anthropic's Claude Code). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Upstream policy: checked gnustep/libs-back for contribution documents. It has no CONTRIBUTING, code of conduct, issue or PR template (GitHub community profile: https://github.com/gnustep/libs-back/community; README: https://github.com/gnustep/libs-back/blob/master/README). Two GNUstep-wide documents apply:
How this complies:
@autoreleasepool, and a GCC syntax check is clean.On Windows, moving or sizing a window runs Windows' own modal loop inside
DefWindowProc(WM_SYSCOMMANDSC_MOVE/SC_SIZE) until the drag ends. For that whole time the GNUstep run loop doesn't run in any mode:NSTimers don't fire and nothing is redisplayed. So an indeterminateNSProgressIndicator, or any timer-driven animation, freezes while the user drags or resizes a window.Change
WM_ENTERSIZEMOVE, start a 15 ms Win32 timer for the window; onWM_EXITSIZEMOVE, kill it.WM_TIMER:-limitDateForMode:, which polls no input sources, so Windows' loop keeps its own messages;-displayIfNeededthe visible windows that need it.DefWindowProc.-getEventMatchingMask:...) while the timer is pumping, the drag is cancelled withWM_CANCELMODE, as Escape would, and Windows' loop ends once the timer returns.Testing
New
Tests/win32/sizemove.m. The directory'sGNUmakefile.preambleand source guard skip it on every other backend. The test posts its windowWM_SYSCOMMANDSC_MOVE(a keyboard move, so no mouse is needed) from a second thread, watchesGetGUIThreadInfo'sGUI_INMOVESIZE, and ends the loop with Escape. It skips when Windows doesn't enter the loop (no interactive desktop).On master (2c7d5f1), 4 of the 7 checks fail; with this change, all 7 pass. Both runs were on Windows 11 build 26300, MSYS2 CLANG64, clang 21.1.8, against libs-base master 220f7bdce and libs-gui master 662f89071. The test fails rather than hangs without the change. Results of the whole libs-back suite (
make check) on that stack:The +7 are the new checks. The failures are the same in both:
pdfps.mtimes out, andsurfacedevice.m:64.A separate test program measured 3 s in each loop, at 96 DPI, on libs-gui 0.32.0 with the same change applied to a 0.32.0 backend. A timer-driven progress indicator drew once without the change and 37 times with it, the same as outside the loop. In 20 runs where a timer opened a modal panel in the middle of a drag, there were no hangs and no lost Escape, and every drag ended before the Escape was sent.
GCC (MinGW GCC 16.2, Objective-C front end, syntax only) reports nothing new in the changed files.
Not covered
-setNeedsDisplay:reaches the main thread as a queued-performSelectorOnMainThread:, which only-acceptInputForMode:runs, and that would also poll Windows' input. Covering it would need a way to run main-thread performers without polling input (libs-base), which is left for later.AI assistance: this change, its test and this description were written with Claude (Anthropic's Claude Code).