-
Notifications
You must be signed in to change notification settings - Fork 471
Expand file tree
/
Copy pathLinuxGameHost.cs
More file actions
61 lines (49 loc) · 2.03 KB
/
LinuxGameHost.cs
File metadata and controls
61 lines (49 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// 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.
#nullable disable
using System;
using System.Collections.Generic;
using System.IO;
using SDL2;
using osu.Framework.Input;
using osu.Framework.Platform.Linux.SDL2;
namespace osu.Framework.Platform.Linux
{
public class LinuxGameHost : DesktopGameHost
{
/// <summary>
/// If SDL disables the compositor.
/// </summary>
/// <remarks>
/// On Linux, SDL will disable the compositor by default.
/// Since not all applications want to do that, we can specify it manually.
/// </remarks>
public readonly bool BypassCompositor;
internal LinuxGameHost(string gameName, HostOptions options)
: base(gameName, options)
{
BypassCompositor = Options.BypassCompositor;
}
protected override void SetupForRun()
{
SDL.SDL_SetHint(SDL.SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, BypassCompositor ? "1" : "0");
SDL.SDL_SetHint("SDL_VIDEODRIVER", "wayland,x11");
base.SetupForRun();
}
protected override IWindow CreateWindow(GraphicsSurfaceType preferredSurface) => new SDL2DesktopWindow(preferredSurface);
public override IEnumerable<string> UserStoragePaths
{
get
{
string xdg = Environment.GetEnvironmentVariable("XDG_DATA_HOME");
if (!string.IsNullOrEmpty(xdg))
yield return xdg;
yield return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), ".local", "share");
foreach (string path in base.UserStoragePaths)
yield return path;
}
}
public override Clipboard GetClipboard() => new SDL2Clipboard();
protected override ReadableKeyCombinationProvider CreateReadableKeyCombinationProvider() => new LinuxReadableKeyCombinationProvider();
}
}