-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve updates of Win32 window's WindowStyles #12752
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
251726c
compute win32 window styles from properties, instead of toggling rele…
emmauss 42f87b9
save client rect early, before swithing to full screen
emmauss 5eecd53
add callbacks for window style and wndproc
emmauss f0e16c1
move new options class to Avalonia.Controls
emmauss dbc7680
use toplevel instance to set the callbacks instead
emmauss c231615
remove redundant casting
emmauss 977a484
call wndproc callback before the default handler
emmauss f4c9d66
remove unused using
emmauss 881f52c
ensure window state when decorations changed
emmauss 2d1150a
move win32 specific delegates
emmauss 500edf5
make Win32SpecificOptions static
emmauss dd1db17
fix build
emmauss 86d33a3
replace Set callbacks with Add/Remove callbacks
emmauss 7cfdb00
fix docs
emmauss 0705446
only recreate styles when the change isn't caused by a fullscreen update
emmauss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/Avalonia.Controls/Platform/IWin32OptionsTopLevelImpl.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Avalonia.Metadata; | ||
using Avalonia.Platform; | ||
using static Avalonia.Controls.Platform.Win32SpecificOptions; | ||
|
||
namespace Avalonia.Controls.Platform | ||
{ | ||
[PrivateApi] | ||
public interface IWin32OptionsTopLevelImpl : ITopLevelImpl | ||
{ | ||
/// <summary> | ||
/// Gets or sets a callback to set the window styles. | ||
/// </summary> | ||
public CustomWindowStylesCallback? WindowStylesCallback { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets a custom callback for the window's WndProc | ||
/// </summary> | ||
public CustomWndProcHookCallback? WndProcHookCallback { get; set; } | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Avalonia.Controls; | ||
using Avalonia.Metadata; | ||
using Avalonia.Platform; | ||
using static Avalonia.Controls.Platform.IWin32OptionsTopLevelImpl; | ||
|
||
namespace Avalonia.Controls.Platform | ||
{ | ||
public static class Win32SpecificOptions | ||
{ | ||
public delegate (uint style, uint exStyle) CustomWindowStylesCallback(uint style, uint exStyle); | ||
public delegate IntPtr CustomWndProcHookCallback(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam, ref bool handled); | ||
|
||
/// <summary> | ||
/// Adds a callback to set the window's style. | ||
/// </summary> | ||
/// <param name="topLevel">The window implementation</param> | ||
/// <param name="callback">The callback</param> | ||
public static void AddWindowStylesCallback(TopLevel topLevel, CustomWindowStylesCallback? callback) | ||
{ | ||
if (topLevel.PlatformImpl is IWin32OptionsTopLevelImpl toplevelImpl) | ||
{ | ||
toplevelImpl.WindowStylesCallback += callback; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Removes a callback to set the window's style. | ||
/// </summary> | ||
/// <param name="topLevel">The window implementation</param> | ||
/// <param name="callback">The callback</param> | ||
public static void RemoveWindowStylesCallback(TopLevel topLevel, CustomWindowStylesCallback? callback) | ||
{ | ||
if (topLevel.PlatformImpl is IWin32OptionsTopLevelImpl toplevelImpl) | ||
{ | ||
toplevelImpl.WindowStylesCallback -= callback; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Adds a custom callback for the window's WndProc | ||
/// </summary> | ||
/// <param name="topLevel">The window</param> | ||
/// <param name="callback">The callback</param> | ||
public static void AddWndProcHookCallback(TopLevel topLevel, CustomWndProcHookCallback? callback) | ||
{ | ||
if (topLevel.PlatformImpl is IWin32OptionsTopLevelImpl toplevelImpl) | ||
{ | ||
toplevelImpl.WndProcHookCallback += callback; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Removes a custom callback for the window's WndProc | ||
/// </summary> | ||
/// <param name="topLevel">The window</param> | ||
/// <param name="callback">The callback</param> | ||
public static void RemoveWndProcHookCallback(TopLevel topLevel, CustomWndProcHookCallback? callback) | ||
{ | ||
if (topLevel.PlatformImpl is IWin32OptionsTopLevelImpl toplevelImpl) | ||
{ | ||
toplevelImpl.WndProcHookCallback -= callback; | ||
} | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could return IDisposable instead of void, to facilitate clean-up.