Skip to content

Commit

Permalink
Merge pull request dotnet#1952 from Arugin/feature/set-focus
Browse files Browse the repository at this point in the history
Added SetFocus method to the Window
  • Loading branch information
ThomasMiz committed Apr 26, 2024
2 parents 2f07bf5 + bf55028 commit c6c0e34
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Windowing/Silk.NET.Windowing.Common/Interfaces/IView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ public interface IView : IViewProperties, IGLContextSource, IVkSurfaceSource, ID
/// </summary>
void Reset();

/// <summary>
/// Sets focus to current window.
/// </summary>
void Focus();

/// <summary>
/// Close this window.
/// </summary>
Expand Down Expand Up @@ -146,4 +151,4 @@ public interface IView : IViewProperties, IGLContextSource, IVkSurfaceSource, ID
/// <param name="onFrame">The callback to run each frame.</param>
void Run(Action onFrame);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ protected ViewImplementationBase(ViewOptions opts)
public abstract void ContinueEvents();
public abstract Vector2D<int> PointToClient(Vector2D<int> point);
public abstract Vector2D<int> PointToScreen(Vector2D<int> point);
public abstract void Focus();
public abstract void Close();
protected abstract void RegisterCallbacks();
protected abstract void UnregisterCallbacks();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Silk.NET.Windowing.IView.Render -> System.Action<double>?
Silk.NET.Windowing.IView.Reset() -> void
Silk.NET.Windowing.IView.Resize -> System.Action<Silk.NET.Maths.Vector2D<int>>?
Silk.NET.Windowing.IView.Run(System.Action! onFrame) -> void
Silk.NET.Windowing.IView.Focus() -> void
Silk.NET.Windowing.IView.Time.get -> double
Silk.NET.Windowing.IView.Update -> System.Action<double>?
Silk.NET.Windowing.IViewProperties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Silk.NET.Windowing.IView.Render -> System.Action<double>?
Silk.NET.Windowing.IView.Reset() -> void
Silk.NET.Windowing.IView.Resize -> System.Action<Silk.NET.Maths.Vector2D<int>>?
Silk.NET.Windowing.IView.Run(System.Action! onFrame) -> void
Silk.NET.Windowing.IView.Focus() -> void
Silk.NET.Windowing.IView.Time.get -> double
Silk.NET.Windowing.IView.Update -> System.Action<double>?
Silk.NET.Windowing.IViewProperties
Expand Down
5 changes: 5 additions & 0 deletions src/Windowing/Silk.NET.Windowing.Glfw/GlfwWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,11 @@ public bool TryGetProcAddress(string proc, out nint addr, int? slot = default)
return ret;
}

public override void Focus()
{
_glfw.FocusWindow(_glfwWindow);
}

public override void Close()
{
Closing?.Invoke();
Expand Down
5 changes: 5 additions & 0 deletions src/Windowing/Silk.NET.Windowing.Sdl/SdlView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,11 @@ internal void RemoveEvent(int index)
Reset();
}

public override void Focus()
{
Sdl.RaiseWindow(SdlWindow);
}

public override void Close()
{
Closing?.Invoke();
Expand Down

0 comments on commit c6c0e34

Please sign in to comment.