forked from unoplatform/uno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add NativeOverlappedPresenter support for macOS/Skia host
- Loading branch information
Showing
9 changed files
with
305 additions
and
53 deletions.
There are no files selected for viewing
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
47 changes: 47 additions & 0 deletions
47
src/Uno.UI.Runtime.Skia.MacOS/MacOSNativeOverlappedPresenter.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,47 @@ | ||
using Microsoft.UI.Windowing; | ||
using Microsoft.UI.Windowing.Native; | ||
|
||
using Uno.Foundation.Logging; | ||
|
||
namespace Uno.UI.Runtime.Skia.MacOS; | ||
|
||
internal class MacOSNativeOverlappedPresenter : INativeOverlappedPresenter | ||
{ | ||
private nint _handle; | ||
|
||
public MacOSNativeOverlappedPresenter(MacOSWindowNative window) | ||
{ | ||
_handle = window.Handle; | ||
} | ||
|
||
public OverlappedPresenterState State => (OverlappedPresenterState)NativeUno.uno_window_get_overlapped_presenter_state(_handle); | ||
|
||
public void Maximize() => NativeUno.uno_window_maximize(_handle); | ||
|
||
public void Minimize(bool activateWindow) => NativeUno.uno_window_minimize(_handle, activateWindow); | ||
|
||
public void Restore(bool activateWindow) => NativeUno.uno_window_restore(_handle, activateWindow); | ||
|
||
public void SetBorderAndTitleBar(bool hasBorder, bool hasTitleBar) => NativeUno.uno_window_set_border_and_title_bar(_handle, hasBorder, hasTitleBar); | ||
|
||
public void SetIsAlwaysOnTop(bool isAlwaysOnTop) => NativeUno.uno_window_set_always_on_top(_handle, isAlwaysOnTop); | ||
|
||
public void SetIsMaximizable(bool isMaximizable) => NativeUno.uno_window_set_maximizable(_handle, isMaximizable); | ||
|
||
public void SetIsMinimizable(bool isMinimizable) => NativeUno.uno_window_set_minimizable(_handle, isMinimizable); | ||
|
||
public void SetIsModal(bool isModal) | ||
{ | ||
// we cannot set `modalPanel`, it's a readonly property, subclasses of NSPanel are modal, NSWindow are not | ||
// so we warn if we try to set a value that does not match the native window | ||
if (!NativeUno.uno_window_set_modal(_handle, isModal)) | ||
{ | ||
if (this.Log().IsEnabled(LogLevel.Warning)) | ||
{ | ||
this.Log().Warn($"Cannot change NSWindow {_handle} `modalPanel` after creation (readonly)."); | ||
} | ||
} | ||
} | ||
|
||
public void SetIsResizable(bool isResizable) => NativeUno.uno_window_set_resizable(_handle, isResizable); | ||
} |
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
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
Oops, something went wrong.