|
@@ -27,11 +27,7 @@ using static Avalonia.X11.XLib;
|
|
// ReSharper disable StringLiteralTypo
|
|
// ReSharper disable StringLiteralTypo
|
|
namespace Avalonia.X11
|
|
namespace Avalonia.X11
|
|
{
|
|
{
|
|
- unsafe partial class X11Window : IWindowImpl, IPopupImpl, IXI2Client,
|
|
|
|
- ITopLevelImplWithNativeMenuExporter,
|
|
|
|
- ITopLevelImplWithNativeControlHost,
|
|
|
|
- ITopLevelImplWithTextInputMethod,
|
|
|
|
- ITopLevelImplWithStorageProvider
|
|
|
|
|
|
+ unsafe partial class X11Window : IWindowImpl, IPopupImpl, IXI2Client
|
|
{
|
|
{
|
|
private readonly AvaloniaX11Platform _platform;
|
|
private readonly AvaloniaX11Platform _platform;
|
|
private readonly bool _popup;
|
|
private readonly bool _popup;
|
|
@@ -43,6 +39,9 @@ namespace Avalonia.X11
|
|
private readonly MouseDevice _mouse;
|
|
private readonly MouseDevice _mouse;
|
|
private readonly TouchDevice _touch;
|
|
private readonly TouchDevice _touch;
|
|
private readonly IKeyboardDevice _keyboard;
|
|
private readonly IKeyboardDevice _keyboard;
|
|
|
|
+ private readonly ITopLevelNativeMenuExporter _nativeMenuExporter;
|
|
|
|
+ private readonly IStorageProvider _storageProvider;
|
|
|
|
+ private readonly X11NativeControlHost _nativeControlHost;
|
|
private PixelPoint? _position;
|
|
private PixelPoint? _position;
|
|
private PixelSize _realSize;
|
|
private PixelSize _realSize;
|
|
private IntPtr _handle;
|
|
private IntPtr _handle;
|
|
@@ -199,8 +198,8 @@ namespace Avalonia.X11
|
|
if(_popup)
|
|
if(_popup)
|
|
PopupPositioner = new ManagedPopupPositioner(new ManagedPopupPositionerPopupImplHelper(popupParent, MoveResize));
|
|
PopupPositioner = new ManagedPopupPositioner(new ManagedPopupPositionerPopupImplHelper(popupParent, MoveResize));
|
|
if (platform.Options.UseDBusMenu)
|
|
if (platform.Options.UseDBusMenu)
|
|
- NativeMenuExporter = DBusMenuExporter.TryCreateTopLevelNativeMenu(_handle);
|
|
|
|
- NativeControlHost = new X11NativeControlHost(_platform, this);
|
|
|
|
|
|
+ _nativeMenuExporter = DBusMenuExporter.TryCreateTopLevelNativeMenu(_handle);
|
|
|
|
+ _nativeControlHost = new X11NativeControlHost(_platform, this);
|
|
InitializeIme();
|
|
InitializeIme();
|
|
|
|
|
|
XChangeProperty(_x11.Display, _handle, _x11.Atoms.WM_PROTOCOLS, _x11.Atoms.XA_ATOM, 32,
|
|
XChangeProperty(_x11.Display, _handle, _x11.Atoms.WM_PROTOCOLS, _x11.Atoms.XA_ATOM, 32,
|
|
@@ -213,7 +212,7 @@ namespace Avalonia.X11
|
|
_x11.Atoms.XA_CARDINAL, 32, PropertyMode.Replace, ref _xSyncCounter, 1);
|
|
_x11.Atoms.XA_CARDINAL, 32, PropertyMode.Replace, ref _xSyncCounter, 1);
|
|
}
|
|
}
|
|
|
|
|
|
- StorageProvider = new CompositeStorageProvider(new Func<Task<IStorageProvider>>[]
|
|
|
|
|
|
+ _storageProvider = new CompositeStorageProvider(new Func<Task<IStorageProvider>>[]
|
|
{
|
|
{
|
|
() => _platform.Options.UseDBusFilePicker ? DBusSystemDialog.TryCreate(Handle) : Task.FromResult<IStorageProvider>(null),
|
|
() => _platform.Options.UseDBusFilePicker ? DBusSystemDialog.TryCreate(Handle) : Task.FromResult<IStorageProvider>(null),
|
|
() => GtkSystemDialog.TryCreate(this),
|
|
() => GtkSystemDialog.TryCreate(this),
|
|
@@ -796,6 +795,31 @@ namespace Avalonia.X11
|
|
Cleanup();
|
|
Cleanup();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public virtual object TryGetFeature(Type featureType)
|
|
|
|
+ {
|
|
|
|
+ if (featureType == typeof(ITopLevelNativeMenuExporter))
|
|
|
|
+ {
|
|
|
|
+ return _nativeMenuExporter;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (featureType == typeof(IStorageProvider))
|
|
|
|
+ {
|
|
|
|
+ return _storageProvider;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (featureType == typeof(ITextInputMethodImpl))
|
|
|
|
+ {
|
|
|
|
+ return _ime;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (featureType == typeof(INativeControlHostImpl))
|
|
|
|
+ {
|
|
|
|
+ return _nativeControlHost;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
void Cleanup()
|
|
void Cleanup()
|
|
{
|
|
{
|
|
if (_rawEventGrouper != null)
|
|
if (_rawEventGrouper != null)
|
|
@@ -1195,9 +1219,6 @@ namespace Avalonia.X11
|
|
}
|
|
}
|
|
|
|
|
|
public IPopupPositioner PopupPositioner { get; }
|
|
public IPopupPositioner PopupPositioner { get; }
|
|
- public ITopLevelNativeMenuExporter NativeMenuExporter { get; }
|
|
|
|
- public INativeControlHostImpl NativeControlHost { get; }
|
|
|
|
- public ITextInputMethodImpl TextInputMethod => _ime;
|
|
|
|
|
|
|
|
public void SetTransparencyLevelHint(WindowTransparencyLevel transparencyLevel) =>
|
|
public void SetTransparencyLevelHint(WindowTransparencyLevel transparencyLevel) =>
|
|
_transparencyHelper?.SetTransparencyRequest(transparencyLevel);
|
|
_transparencyHelper?.SetTransparencyRequest(transparencyLevel);
|
|
@@ -1215,8 +1236,6 @@ namespace Avalonia.X11
|
|
|
|
|
|
public bool NeedsManagedDecorations => false;
|
|
public bool NeedsManagedDecorations => false;
|
|
|
|
|
|
- public IStorageProvider StorageProvider { get; }
|
|
|
|
-
|
|
|
|
public class SurfacePlatformHandle : IPlatformNativeSurfaceHandle
|
|
public class SurfacePlatformHandle : IPlatformNativeSurfaceHandle
|
|
{
|
|
{
|
|
private readonly X11Window _owner;
|
|
private readonly X11Window _owner;
|