Add deferred work area option to position updates - #165
Merged
Conversation
Skip app bar reposition and broadcast handling while `DeferWorkArea` is enabled. This prevents `AppBarWindow` from reacting to position-change notifications or unexpected moves during deferred work area updates.
Expose the user32 constants and P/Invokes needed to work with window system menus, including cursor position, menu enabling, and popup tracking.
dremin
self-requested a review
August 10, 2026 06:20
Collaborator
Yes, if moving to NativeMethods.User32 then the old one should be removed :) |
dremin
reviewed
Aug 11, 2026
xoascf
commented
Aug 11, 2026
Remove the extra `deferWorkArea` parameters from window positioning methods and rely on the `DeferWorkArea` property instead. This keeps work area updates tied to the app bar's current state and simplifies the positioning flow.
When `Notification.Default` is set to `(None)` (such as in legacy or custom sound schemes), `PlaySound` with `SND_ALIAS` returned `true` without playing an audible sound, preventing the fallback to the XP notification sound. Using the registry-checking `PlaySystemSound` overload ensures empty sound assignments return `false` and trigger the fallback.
dremin
reviewed
Aug 13, 2026
Adds missing P/Invoke declarations for `CreateRectRgn` (Gdi32) and `SetWindowRgn` (User32). This enables creating and applying custom window regions from managed code, supporting non-rectangular window shaping/clipping.
Combine nested if conditions in AppBarWindow.UpdatePosition per review suggestion from @dremin.
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.
Introduces a
DeferWorkAreaproperty onAppBarWindowso callers can reposition app bars without immediately updating the shell work area (useful when dragging an app bar). WhenDeferWorkAreais enabled:UpdatePositionavoids callingABSetPosin normal non-shell mode and applies the desired rect directly, enabling staged/multi-step layout updates without premature work area changesSetWindowPositionskips updating the work area in shell modePosChanged) andWM_WINDOWPOSCHANGEDnotifications are ignored/deferred until positioning is completeMisc updates:
Fix
POINTstruct for x64: InManagedShell.Interop\NativeMethods.cs,POINTwas defined with 64-bitlongfields, causing memory corruption in Win32 functions likeGetCursorPos:intto restore the proper 8-byte size[StructLayout(LayoutKind.Sequential)]for precise memory alignmentlongconstructor for backward compatibilityWin32 Interop additions & consolidation:
TrackPopupMenuExand theTPMenum fromManagedShell.ShellFoldersintoManagedShell.Interop.NativeMethods.User32to avoid duplicate definitions.GetSystemMenu,EnableMenuItem,SC_*,MF_*) toNativeMethods.User32.cs.SetWindowRgn(user32.dll) andCreateRectRgn(gdi32.dll).Fix fallback to XP balloon sound for toast notifications: Corrected fallback logic so legacy Windows / XP sound schemes play properly when Windows 8+ toast sound schemes are unavailable.
User32 sources:
TPM.WORKAREA)Additional notes:
Moved in 12720b8TrackPopupMenuExis also defined inManagedShell\src\ManagedShell.ShellFolders\Interop.cs, we will probably need to update that one tooManagedShell\src\ManagedShell.ShellFolders\Structs\TPMPARAMS.csis there, or why it has no public fields. Since it is not touched in this PR, maybe it's not relevant?