mirror of
https://github.com/SK-la/osu-framework.git
synced 2026-03-15 03:20:30 +00:00
Merge pull request #6268 from Susko3/dont-overload-DisplayHandle
Refactor `DisplayHandle` into seperate android and linux properties
This commit is contained in:
@@ -9,7 +9,7 @@ namespace osu.Framework.Android
|
||||
{
|
||||
internal class AndroidGameWindow : SDL3MobileWindow
|
||||
{
|
||||
public override IntPtr DisplayHandle => AndroidGameActivity.Surface.NativeSurface?.Handle ?? IntPtr.Zero;
|
||||
public override IntPtr SurfaceHandle => AndroidGameActivity.Surface.NativeSurface?.Handle ?? IntPtr.Zero;
|
||||
|
||||
public AndroidGameWindow(GraphicsSurfaceType surfaceType, string appName)
|
||||
: base(surfaceType, appName)
|
||||
|
||||
@@ -162,15 +162,15 @@ namespace osu.Framework.Graphics.Veldrid
|
||||
{
|
||||
var linuxGraphics = (ILinuxGraphicsSurface)this.graphicsSurface;
|
||||
swapchain.Source = linuxGraphics.IsWayland
|
||||
? SwapchainSource.CreateWayland(this.graphicsSurface.DisplayHandle, this.graphicsSurface.WindowHandle)
|
||||
: SwapchainSource.CreateXlib(this.graphicsSurface.DisplayHandle, this.graphicsSurface.WindowHandle);
|
||||
? SwapchainSource.CreateWayland(linuxGraphics.DisplayHandle, this.graphicsSurface.WindowHandle)
|
||||
: SwapchainSource.CreateXlib(linuxGraphics.DisplayHandle, this.graphicsSurface.WindowHandle);
|
||||
break;
|
||||
}
|
||||
|
||||
case RuntimeInfo.Platform.Android:
|
||||
{
|
||||
var androidGraphics = (IAndroidGraphicsSurface)this.graphicsSurface;
|
||||
swapchain.Source = SwapchainSource.CreateAndroidSurface(this.graphicsSurface.DisplayHandle, androidGraphics.JniEnvHandle);
|
||||
swapchain.Source = SwapchainSource.CreateAndroidSurface(androidGraphics.SurfaceHandle, androidGraphics.JniEnvHandle);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,5 +11,11 @@ namespace osu.Framework.Platform
|
||||
/// Returns JNI environment handle.
|
||||
/// </summary>
|
||||
IntPtr JniEnvHandle { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Android Surface handle.
|
||||
/// </summary>
|
||||
/// <remarks>https://developer.android.com/reference/android/view/Surface.html</remarks>
|
||||
IntPtr SurfaceHandle { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,6 @@ namespace osu.Framework.Platform
|
||||
/// </summary>
|
||||
IntPtr WindowHandle { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A pointer representing a handle to the display containing this window, provided by the operating system.
|
||||
/// This is specific to X11/Wayland subsystems.
|
||||
/// </summary>
|
||||
IntPtr DisplayHandle { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of surface.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
|
||||
namespace osu.Framework.Platform
|
||||
{
|
||||
public interface ILinuxGraphicsSurface
|
||||
@@ -9,5 +11,11 @@ namespace osu.Framework.Platform
|
||||
/// Whether the current display server is Wayland.
|
||||
/// </summary>
|
||||
bool IsWayland { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A pointer representing a handle to the display containing this window, provided by the operating system.
|
||||
/// This is specific to X11/Wayland subsystems.
|
||||
/// </summary>
|
||||
IntPtr DisplayHandle { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ namespace osu.Framework.Platform.SDL
|
||||
private IntPtr context;
|
||||
|
||||
public IntPtr WindowHandle => window.WindowHandle;
|
||||
public IntPtr DisplayHandle => window.DisplayHandle;
|
||||
|
||||
public GraphicsSurfaceType Type { get; }
|
||||
|
||||
@@ -216,6 +215,9 @@ namespace osu.Framework.Platform.SDL
|
||||
|
||||
bool ILinuxGraphicsSurface.IsWayland => window.IsWayland;
|
||||
|
||||
[SupportedOSPlatform("linux")]
|
||||
IntPtr ILinuxGraphicsSurface.DisplayHandle => window.DisplayHandle;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Android-specific implementation
|
||||
@@ -223,6 +225,9 @@ namespace osu.Framework.Platform.SDL
|
||||
[SupportedOSPlatform("android")]
|
||||
IntPtr IAndroidGraphicsSurface.JniEnvHandle => SDL3.SDL_AndroidGetJNIEnv();
|
||||
|
||||
[SupportedOSPlatform("android")]
|
||||
IntPtr IAndroidGraphicsSurface.SurfaceHandle => window.SurfaceHandle;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using System;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Configuration;
|
||||
@@ -119,7 +120,8 @@ namespace osu.Framework.Platform
|
||||
}
|
||||
}
|
||||
|
||||
public virtual IntPtr DisplayHandle
|
||||
[SupportedOSPlatform("linux")]
|
||||
public IntPtr DisplayHandle
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -138,6 +140,9 @@ namespace osu.Framework.Platform
|
||||
}
|
||||
}
|
||||
|
||||
[SupportedOSPlatform("android")]
|
||||
public virtual IntPtr SurfaceHandle => throw new PlatformNotSupportedException();
|
||||
|
||||
public bool CapsLockPressed => SDL3.SDL_GetModState().HasFlagFast(SDL_Keymod.SDL_KMOD_CAPS);
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user