Browse Source
* compute win32 window styles from properties, instead of toggling relevant styles * save client rect early, before swithing to full screen * add callbacks for window style and wndproc * move new options class to Avalonia.Controls * use toplevel instance to set the callbacks instead * remove redundant casting * call wndproc callback before the default handler * remove unused using * ensure window state when decorations changed * move win32 specific delegates * make Win32SpecificOptions static * fix build * replace Set callbacks with Add/Remove callbacks * fix docs * only recreate styles when the change isn't caused by a fullscreen updatepull/13069/head
committed by
GitHub
5 changed files with 214 additions and 68 deletions
@ -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; } |
|||
} |
|||
} |
|||
@ -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; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue