Browse Source

Add win32 impl for client extending based on property value.

feature/managed-chrome-buttons-api
Dan Walmsley 6 years ago
parent
commit
d109da775b
  1. 54
      src/Windows/Avalonia.Win32/WindowImpl.WndProc.cs
  2. 59
      src/Windows/Avalonia.Win32/WindowImpl.cs

54
src/Windows/Avalonia.Win32/WindowImpl.WndProc.cs

@ -80,50 +80,20 @@ namespace Avalonia.Win32
{
IntPtr lRet = IntPtr.Zero;
callDwp = !DwmDefWindowProc(hWnd, msg, wParam, lParam, ref lRet);
MARGINS margins = new MARGINS { cxLeftWidth = 0, cxRightWidth = 0, cyBottomHeight = 0, cyTopHeight = 100 };
RECT border_thickness = new RECT();
callDwp = !DwmDefWindowProc(hWnd, msg, wParam, lParam, ref lRet);
switch ((WindowsMessage)msg)
{
case WindowsMessage.WM_ACTIVATE:
{
if (!_isClientAreaExtended)
{
if (GetStyle().HasFlag(WindowStyles.WS_THICKFRAME))
{
AdjustWindowRectEx(ref border_thickness, (uint)(GetStyle()), false, 0);
border_thickness.left *= -1;
border_thickness.top *= -1;
}
else if (GetStyle().HasFlag(WindowStyles.WS_BORDER))
{
border_thickness = new RECT { bottom = 1, left = 1, right = 1, top = 1 };
}
// Extend the frame into the client area.
margins.cxLeftWidth = border_thickness.left;
margins.cxRightWidth = border_thickness.right;
margins.cyBottomHeight = border_thickness.bottom;
margins.cyTopHeight = border_thickness.top;
var hr = DwmExtendFrameIntoClientArea(hWnd, ref margins);
//if (hr < 0)
{
// Handle the error.
}
_isClientAreaExtended = true;
_extendedMargins = new Thickness(margins.cxLeftWidth / Scaling, margins.cyTopHeight / Scaling, margins.cxRightWidth / Scaling, margins.cyBottomHeight / Scaling);
ExtendClientAreaToDecorationsChanged?.Invoke(true);
}
lRet = IntPtr.Zero;
callDwp = true;
break;
}
//case WindowsMessage.WM_ACTIVATE:
// {
// if (!_isClientAreaExtended)
// {
// ExtendClientArea();
// }
// lRet = IntPtr.Zero;
// callDwp = true;
// break;
// }
case WindowsMessage.WM_NCCALCSIZE:
{

59
src/Windows/Avalonia.Win32/WindowImpl.cs

@ -40,6 +40,7 @@ namespace Avalonia.Win32
private SavedWindowInfo _savedWindowInfo;
private bool _isFullScreenActive;
private bool _isClientAreaExtended;
#if USE_MANAGED_DRAG
private readonly ManagedWindowResizeDragHelper _managedDrag;
@ -67,6 +68,7 @@ namespace Avalonia.Win32
private Size _minSize;
private Size _maxSize;
private WindowImpl _parent;
private bool _extendClientAreaToDecorationsHint;
public WindowImpl()
{
@ -670,6 +672,43 @@ namespace Avalonia.Win32
TaskBarList.MarkFullscreen(_hwnd, fullscreen);
}
private void ExtendClientArea ()
{
if (!_isClientAreaExtended)
{
RECT border_thickness = new RECT();
MARGINS margins = new MARGINS();
if (GetStyle().HasFlag(WindowStyles.WS_THICKFRAME))
{
AdjustWindowRectEx(ref border_thickness, (uint)(GetStyle()), false, 0);
border_thickness.left *= -1;
border_thickness.top *= -1;
}
else if (GetStyle().HasFlag(WindowStyles.WS_BORDER))
{
border_thickness = new RECT { bottom = 1, left = 1, right = 1, top = 1 };
}
// Extend the frame into the client area.
margins.cxLeftWidth = border_thickness.left;
margins.cxRightWidth = border_thickness.right;
margins.cyBottomHeight = border_thickness.bottom;
margins.cyTopHeight = border_thickness.top;
var hr = DwmExtendFrameIntoClientArea(_hwnd, ref margins);
//if (hr < 0)
{
// Handle the error.
}
_isClientAreaExtended = true;
_extendedMargins = new Thickness(margins.cxLeftWidth / Scaling, margins.cyTopHeight / Scaling, margins.cxRightWidth / Scaling, margins.cyBottomHeight / Scaling);
ExtendClientAreaToDecorationsChanged?.Invoke(true);
}
}
private void ShowWindow(WindowState state)
{
ShowWindowCommand command;
@ -910,7 +949,25 @@ namespace Avalonia.Win32
}
}
IntPtr EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo.Handle => Handle.Handle;
IntPtr EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo.Handle => Handle.Handle;
public bool ExtendClientAreaToDecorationsHint
{
get => _extendClientAreaToDecorationsHint;
set
{
_extendClientAreaToDecorationsHint = true;
ExtendClientArea();
// TODO Trigger transition.
}
}
public Action<bool> ExtendClientAreaToDecorationsChanged { get; set; }
private Thickness _extendedMargins;
public Thickness ExtendedMargins => _extendedMargins;
private struct SavedWindowInfo
{

Loading…
Cancel
Save