Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ END TEMPLATE-->

### New features

*None yet*
* Added the ability to set Clyde windows to borderless mode.

### Bugfixes

Expand Down
33 changes: 24 additions & 9 deletions Robust.Client/Graphics/Clyde/Clyde.Windowing.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Robust.Client.Input;
using Robust.Client.UserInterface;
using Robust.Shared;
Expand All @@ -14,13 +7,19 @@
using Robust.Shared.Utility;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Threading;
using System.Threading.Tasks;
using TerraFX.Interop.Windows;
using FrameEventArgs = Robust.Shared.Timing.FrameEventArgs;
using GL = OpenToolkit.Graphics.OpenGL4.GL;

namespace Robust.Client.Graphics.Clyde
{
internal partial class Clyde
internal partial class Clyde
{
private readonly List<WindowReg> _windows = new();
private readonly List<WindowHandle> _windowHandles = new();
Expand Down Expand Up @@ -282,6 +281,13 @@ public void SetWindowTitle(string title)
_windowing!.WindowSetTitle(_mainWindow!, title);
}

private void SetWindowTitleBarVisible(WindowReg reg, bool visible)
{
DebugTools.AssertNotNull(_windowing);

_windowing!.WindowSetTitleBarVisible(reg, visible);
}

public void SetWindowMonitor(IClydeMonitor monitor)
{
DebugTools.AssertNotNull(_windowing);
Expand Down Expand Up @@ -342,6 +348,7 @@ public IClydeWindow CreateWindow(WindowCreateParameters parameters)
_mainWindow = reg;

reg.IsVisible = parameters.Visible;
reg.IsTitleBarVisible = parameters.TitleBarVisible;

_windows.Add(reg);
_windowHandles.Add(reg.Handle);
Expand Down Expand Up @@ -415,7 +422,7 @@ public bool VsyncEnabled

private void WindowModeChanged(int mode)
{
_windowMode = (WindowMode) mode;
_windowMode = (WindowMode)mode;
_windowing?.UpdateMainWindowMode();
}

Expand Down Expand Up @@ -495,6 +502,7 @@ private abstract class WindowReg
public bool IsMinimized;
public string Title = "";
public bool IsVisible;
public bool IsTitleBarVisible;
public IClydeWindow? Owner;

public bool DisposeOnClose;
Expand Down Expand Up @@ -554,6 +562,12 @@ public bool IsVisible
set => _clyde.SetWindowVisible(Reg, value);
}

public bool IsTitleBarVisible
{
get => Reg.IsTitleBarVisible;
set => _clyde.SetWindowTitleBarVisible(Reg, value);
}

public Vector2 ContentScale => Reg.WindowScale;

public bool DisposeOnClose
Expand Down Expand Up @@ -607,6 +621,7 @@ public void SetWindowProgress(WindowProgressState state, float value)
}

public nint? WindowsHWnd => _clyde._windowing!.WindowGetWin32Window(Reg);

}

private sealed class MonitorHandle : IClydeMonitor
Expand Down
20 changes: 12 additions & 8 deletions Robust.Client/Graphics/Clyde/ClydeHeadless.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Numerics;
using System.Threading.Tasks;
using JetBrains.Annotations;
using Robust.Client.Audio;
using Robust.Client.Input;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;
Expand All @@ -16,6 +10,11 @@
using Robust.Shared.Timing;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using System;
using System.Collections.Generic;
using System.IO;
using System.Numerics;
using System.Threading.Tasks;
using Color = Robust.Shared.Maths.Color;

namespace Robust.Client.Graphics.Clyde
Expand Down Expand Up @@ -47,7 +46,7 @@ public ClydeHeadless()
SixLabors.ImageSharp.Configuration.Default.PreferContiguousImageBuffers = true;

var mainRt = new DummyRenderWindow(this);
var window = new DummyWindow(mainRt) {Id = new WindowId(1)};
var window = new DummyWindow(mainRt) { Id = new WindowId(1) };

_windows.Add(window);
MainWindow = window;
Expand Down Expand Up @@ -111,6 +110,10 @@ public void SetWindowTitle(string title)
// Nada.
}

public void SetWindowTitleBarVisible(bool visible)
{
}

public void SetWindowMonitor(IClydeMonitor monitor)
{
// Nada.
Expand Down Expand Up @@ -283,7 +286,7 @@ public void TextInputStop()
// Nada.
}

public ClydeHandle LoadShader(ParsedShader shader, string? name = null, Dictionary<string,string>? defines = null)
public ClydeHandle LoadShader(ParsedShader shader, string? name = null, Dictionary<string, string>? defines = null)
{
return default;
}
Expand Down Expand Up @@ -579,6 +582,7 @@ public DummyWindow(IRenderTarget renderTarget)
public bool IsFocused => false;
public bool IsMinimized => false;
public bool IsVisible { get; set; } = true;
public bool IsTitleBarVisible { get; set; } = true;
public Vector2 ContentScale => Vector2.One;
public bool DisposeOnClose { get; set; }
public event Action<WindowRequestClosedEventArgs>? RequestClosed { add { } remove { } }
Expand Down
5 changes: 3 additions & 2 deletions Robust.Client/Graphics/Clyde/Windowing/IWindowingImpl.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System.Threading.Tasks;
using Robust.Client.Input;
using Robust.Shared.Maths;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using System;
using System.Threading.Tasks;

namespace Robust.Client.Graphics.Clyde
{
Expand Down Expand Up @@ -38,6 +38,7 @@ private interface IWindowingImpl

void WindowDestroy(WindowReg reg);
void WindowSetTitle(WindowReg window, string title);
void WindowSetTitleBarVisible(WindowReg window, bool visible);
void WindowSetMonitor(WindowReg window, IClydeMonitor monitor);
void WindowSetSize(WindowReg window, Vector2i size);
void WindowSetVisible(WindowReg window, bool visible);
Expand Down
36 changes: 26 additions & 10 deletions Robust.Client/Graphics/Clyde/Windowing/Sdl3.Window.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
Expand Down Expand Up @@ -265,14 +265,14 @@ private void WinThreadWinDestroy(CmdWinDestroy cmd)
switch (_videoDriver)
{
case SdlVideoDriver.Windows:
{
var hWnd = SDL.SDL_GetPointerProperty(
props,
SDL.SDL_PROP_WINDOW_WIN32_HWND_POINTER,
0);
WsiShared.SetWindowStyleNoTitleOptionsWindows((HWND)hWnd);
break;
}
{
var hWnd = SDL.SDL_GetPointerProperty(
props,
SDL.SDL_PROP_WINDOW_WIN32_HWND_POINTER,
0);
WsiShared.SetWindowStyleNoTitleOptionsWindows((HWND)hWnd);
break;
}
case SdlVideoDriver.X11:
unsafe
{
Expand Down Expand Up @@ -415,9 +415,25 @@ public void WindowSetTitle(WindowReg window, string title)
});
}


private static void WinThreadWinSetTitle(CmdWinSetTitle cmd)
{
SDL.SDL_SetWindowTitle(cmd.Window, cmd.Title);
SDL.SDL_SetWindowTitle(cmd.Window, cmd.Title);
}

public void WindowSetTitleBarVisible(WindowReg window, bool visible)
{
window.IsTitleBarVisible = visible;
SendCmd(new CmdWinSetTitleBarVisible
{
Window = WinPtr(window),
Visible = visible,
});
}

private static void WinThreadWinSetTitleBarVisible(CmdWinSetTitleBarVisible cmd)
{
SDL.SDL_SetWindowBordered(cmd.Window, cmd.Visible);
}

public void WindowSetMonitor(WindowReg window, IClydeMonitor monitor)
Expand Down
18 changes: 14 additions & 4 deletions Robust.Client/Graphics/Clyde/Windowing/Sdl3.WindowThread.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using System.Runtime.CompilerServices;
using System.Threading.Channels;
using System.Threading.Tasks;
using Robust.Shared;
using Robust.Shared.Maths;
using SDL3;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using System;
using System.Runtime.CompilerServices;
using System.Threading.Channels;
using System.Threading.Tasks;

namespace Robust.Client.Graphics.Clyde;

Expand Down Expand Up @@ -81,6 +81,10 @@ private void ProcessSdl3Cmd(CmdBase cmdb)
WinThreadWinSetTitle(cmd);
break;

case CmdWinSetTitleBarVisible cmd:
WinThreadWinSetTitleBarVisible(cmd);
break;

case CmdSetClipboard cmd:
WinThreadSetClipboard(cmd);
break;
Expand Down Expand Up @@ -291,6 +295,12 @@ private sealed class CmdWinSetTitle : CmdBase
public required string Title;
}

private sealed class CmdWinSetTitleBarVisible : CmdBase
{
public nint Window;
public required bool Visible;
}

private sealed class CmdCursorCreate : CmdBase
{
public required Image<Rgba32> Bytes;
Expand Down
5 changes: 3 additions & 2 deletions Robust.Client/Graphics/IClydeWindow.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using System.Numerics;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using SDL3;
using System;
using System.Numerics;

namespace Robust.Client.Graphics
{
Expand All @@ -20,6 +20,7 @@ public interface IClydeWindow : IDisposable
bool IsFocused { get; }
bool IsMinimized { get; }
bool IsVisible { get; set; }
bool IsTitleBarVisible { get; set; }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably shouldn't be named this given it changes more than the title bar?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review, I'll update the names of everything to be centered around the 'border' rather than the 'title bar' since thats how SDL names it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated it to be IsBordered rather than IsTitleBarVisible, as that's the naming convention that SDL uses

Vector2 ContentScale { get; }

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions Robust.Client/Graphics/WindowCreateParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public sealed class WindowCreateParameters
public string Title = "";
public bool Maximized;
public bool Visible = true;
public bool TitleBarVisible = true;
public IClydeMonitor? Monitor;
public bool Fullscreen;

Expand Down
Loading