Interface IWindowComponent
Interface for abstraction layer drivers which implement the window component.
Inherited Members
Namespace: OpenTK.Platform
Assembly: OpenTK.Platform.dll
Syntax
public interface IWindowComponent : IPalComponent
Properties
CanCaptureCursor
true when the driver supports capturing the cursor in a window using SetCursorCaptureMode(WindowHandle, CursorCaptureMode).
Declaration
bool CanCaptureCursor { get; }
Property Value
Type | Description |
---|---|
bool |
See Also
CanGetDisplay
true when the driver can provide the display the window is in using GetDisplay(WindowHandle).
Declaration
bool CanGetDisplay { get; }
Property Value
Type | Description |
---|---|
bool |
See Also
CanSetCursor
true when the driver supports setting the cursor of the window using SetCursor(WindowHandle, CursorHandle?).
Declaration
bool CanSetCursor { get; }
Property Value
Type | Description |
---|---|
bool |
See Also
CanSetIcon
true when the driver supports setting and getting the window icon using SetIcon(WindowHandle, IconHandle) and GetIcon(WindowHandle).
Declaration
bool CanSetIcon { get; }
Property Value
Type | Description |
---|---|
bool |
See Also
SupportedEvents
Read-only list of event types the driver supports.
Declaration
IReadOnlyList<PlatformEventType> SupportedEvents { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<PlatformEventType> |
SupportedModes
Read-only list of window modes the driver supports.
Declaration
IReadOnlyList<WindowMode> SupportedModes { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<WindowMode> |
SupportedStyles
Read-only list of window styles the driver supports.
Declaration
IReadOnlyList<WindowBorderStyle> SupportedStyles { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<WindowBorderStyle> |
Methods
ClientToFramebuffer(WindowHandle, Vector2, out Vector2)
Converts window relative coordinates to framebuffer coordinates.
Declaration
void ClientToFramebuffer(WindowHandle handle, Vector2 client, out Vector2 framebuffer)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle of the window whose coordinate system to use. |
Vector2 | client | The client coordinate. |
Vector2 | framebuffer | The framebuffer coordinate. |
Remarks
On platforms that support non-integer screen and client space coordinates (macOS) this function will return full precision results, on integer based platforms (win32 and X11) the input coordinates will (if necessary) be truncated to ints before conversion.
See Also
ClientToScreen(WindowHandle, Vector2, out Vector2)
Converts window relative coordinates to screen coordinates.
Declaration
void ClientToScreen(WindowHandle handle, Vector2 client, out Vector2 screen)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | The window handle. |
Vector2 | client | The client coordinate. |
Vector2 | screen | The screen coordinate. |
Remarks
On platforms that support non-integer screen and client space coordinates (macOS) this function will return full precision results, on integer based platforms (win32 and X11) the input coordinates will (if necessary) be truncated to ints before conversion.
See Also
Create(GraphicsApiHints)
Create a window object.
Declaration
WindowHandle Create(GraphicsApiHints hints)
Parameters
Type | Name | Description |
---|---|---|
GraphicsApiHints | hints | Graphics API hints to be passed to the operating system. |
Returns
Type | Description |
---|---|
WindowHandle | Handle to the new window object. |
See Also
Destroy(WindowHandle)
Destroy a window object. After a window has been destroyed the handle should no longer be used in any function other than IsWindowDestroyed(WindowHandle).
Declaration
void Destroy(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window object. |
See Also
FocusWindow(WindowHandle)
Gives the window input focus.
Declaration
void FocusWindow(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to the window to focus. |
See Also
FramebufferToClient(WindowHandle, Vector2, out Vector2)
Converts framebuffer coordinates to framebuffer coordinates.
Declaration
void FramebufferToClient(WindowHandle handle, Vector2 framebuffer, out Vector2 client)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle of the window whose coordinate system to use. |
Vector2 | framebuffer | The framebuffer coordinate. |
Vector2 | client | The client coordinate. |
Remarks
On platforms that support non-integer screen and client space coordinates (macOS) this function will return full precision results, on integer based platforms (win32 and X11) the input coordinates will (if necessary) be truncated to ints before conversion.
See Also
GetBorderStyle(WindowHandle)
Get the border style of a window.
Declaration
WindowBorderStyle GetBorderStyle(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to window. |
Returns
Type | Description |
---|---|
WindowBorderStyle | The border style of the window. |
See Also
GetBounds(WindowHandle, out int, out int, out int, out int)
Get the bounds of the window.
Declaration
void GetBounds(WindowHandle handle, out int x, out int y, out int width, out int height)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int | x | X coordinate of the window. |
int | y | Y coordinate of the window. |
int | width | Width of the window in screen coordinates. |
int | height | Height of the window in screen coordinates. |
GetClientBounds(WindowHandle, out int, out int, out int, out int)
Get the client area bounds (drawing area) of a window.
Declaration
void GetClientBounds(WindowHandle handle, out int x, out int y, out int width, out int height)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int | x | X coordinate of the client area. |
int | y | Y coordinate of the client area. |
int | width | Width of the client area in pixels. |
int | height | Height of the client area in pixels. |
GetClientPosition(WindowHandle, out Vector2i)
Get the position of the client area (drawing area) of a window.
Declaration
void GetClientPosition(WindowHandle handle, out Vector2i clientPosition)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
Vector2i | clientPosition | The coordinate of the client area in screen coordinates. |
GetClientSize(WindowHandle, out Vector2i)
Get the size of the client area (drawing area) of a window.
Declaration
void GetClientSize(WindowHandle handle, out Vector2i clientSize)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
Vector2i | clientSize | Size of the client area in screen coordinates. |
GetCursorCaptureMode(WindowHandle)
Gets the current cursor capture mode. See SetCursorCaptureMode(WindowHandle, CursorCaptureMode) for more details.
Declaration
CursorCaptureMode GetCursorCaptureMode(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
Returns
Type | Description |
---|---|
CursorCaptureMode | The current cursor capture mode. |
See Also
GetDisplay(WindowHandle)
Get the display handle a window is in.
Declaration
DisplayHandle GetDisplay(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
Returns
Type | Description |
---|---|
DisplayHandle | The display handle the window is in. |
Exceptions
Type | Condition |
---|---|
PalNotImplementedException | Backend does not support finding the window display. CanGetDisplay. |
See Also
GetFramebufferSize(WindowHandle, out Vector2i)
Get the size of the window framebuffer in pixels. Use this value when calls to graphics APIs that want pixels, e.g. GL.Viewport().
Declaration
void GetFramebufferSize(WindowHandle handle, out Vector2i framebufferSize)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
Vector2i | framebufferSize | Size in pixels of the window framebuffer. |
GetFullscreenDisplay(WindowHandle, out DisplayHandle?)
Gets the display that the specified window is fullscreen on, if the window is fullscreen.
Declaration
bool GetFullscreenDisplay(WindowHandle handle, out DisplayHandle? display)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | The window handle. |
DisplayHandle | display | The display where the window is fullscreen or null if the window is not fullscreen. |
Returns
Type | Description |
---|---|
bool |
See Also
GetIcon(WindowHandle)
Get a handle to the window icon object.
Declaration
IconHandle? GetIcon(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
Returns
Type | Description |
---|---|
IconHandle | Handle to the windows icon object, or null if none is set. |
Exceptions
Type | Condition |
---|---|
PlatformNotSupportedException | Backend does not support getting the window icon. See CanSetIcon. |
See Also
GetMaxClientSize(WindowHandle, out int?, out int?)
Gets the maximum size of the client area.
Declaration
void GetMaxClientSize(WindowHandle handle, out int? width, out int? height)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int? | width | The maximum width of the client area of the window, or null if no limit is set. |
int? | height | The maximum height of the client area of the window, or null if no limit is set. |
GetMinClientSize(WindowHandle, out int?, out int?)
Gets the minimum size of the client area.
Declaration
void GetMinClientSize(WindowHandle handle, out int? width, out int? height)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int? | width | The minimum width of the client area of the window, or null if no limit is set. |
int? | height | The minimum height of the client area of the window, or null if no limit is set. |
GetMode(WindowHandle)
Get the mode of a window.
Declaration
WindowMode GetMode(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
Returns
Type | Description |
---|---|
WindowMode | The mode of the window. |
GetPosition(WindowHandle, out Vector2i)
Get the window position in display coordinates (top left origin).
Declaration
void GetPosition(WindowHandle handle, out Vector2i position)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
Vector2i | position | Coordinate of the window in screen coordinates. |
See Also
GetScaleFactor(WindowHandle, out float, out float)
Returns the current scale factor of this window.
Declaration
void GetScaleFactor(WindowHandle handle, out float scaleX, out float scaleY)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | The window handle. |
float | scaleX | The x scale factor of the window. |
float | scaleY | The y scale factor of the window. |
See Also
GetSize(WindowHandle, out Vector2i)
Get the size of the window.
Declaration
void GetSize(WindowHandle handle, out Vector2i size)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
Vector2i | size | Size of the window in screen coordinates. |
GetTitle(WindowHandle)
Get the title of a window.
Declaration
string GetTitle(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
Returns
Type | Description |
---|---|
string | The title of the window. |
See Also
GetTransparencyMode(WindowHandle, out float)
Gets the transparency mode of the specified window.
Declaration
WindowTransparencyMode GetTransparencyMode(WindowHandle handle, out float opacity)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | The window to query the transparency mode of. |
float | opacity | The window opacity if the transparency mode was TransparentWindow, 0 otherwise. |
Returns
Type | Description |
---|---|
WindowTransparencyMode | The transparency mode of the specified window. |
See Also
IsAlwaysOnTop(WindowHandle)
Gets if the current window is always on top or not.
Declaration
bool IsAlwaysOnTop(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | A handle to the window to get whether or not is always on top. |
Returns
Type | Description |
---|---|
bool | Whether the window is always on top or not. |
See Also
IsFocused(WindowHandle)
Returns true if the given window has input focus.
Declaration
bool IsFocused(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
Returns
Type | Description |
---|---|
bool | If the window has input focus. |
See Also
IsWindowDestroyed(WindowHandle)
Checks if Destroy(WindowHandle) has been called on this handle.
Declaration
bool IsWindowDestroyed(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | The window handle to check if it's destroyed or not. |
Returns
Type | Description |
---|---|
bool | If Destroy(WindowHandle) was called with the window handle. |
See Also
ProcessEvents(bool)
Processes platform events and sends them to the EventQueue.
Declaration
void ProcessEvents(bool waitForEvents)
Parameters
Type | Name | Description |
---|---|---|
bool | waitForEvents | Specifies if this function should wait for events or return immediately if there are no events. |
RequestAttention(WindowHandle)
Requests that the user pay attention to the window. Usually by flashing the window icon.
Declaration
void RequestAttention(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | A handle to the window that requests attention. |
See Also
ScreenToClient(WindowHandle, Vector2, out Vector2)
Converts screen coordinates to window relative coordinates.
Declaration
void ScreenToClient(WindowHandle handle, Vector2 screen, out Vector2 client)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | The window handle. |
Vector2 | screen | The screen coordinate. |
Vector2 | client | The client coordinate. |
Remarks
On platforms that support non-integer screen and client space coordinates (macOS) this function will return full precision results, on integer based platforms (win32 and X11) the input coordinates will (if necessary) be truncated to ints before conversion.
See Also
SetAlwaysOnTop(WindowHandle, bool)
Set if the window is an always on top window or not.
Declaration
void SetAlwaysOnTop(WindowHandle handle, bool floating)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | A handle to the window to make always on top. |
bool | floating | Whether the window should be always on top or not. |
See Also
SetBorderStyle(WindowHandle, WindowBorderStyle)
Set the border style of a window.
Declaration
void SetBorderStyle(WindowHandle handle, WindowBorderStyle style)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
WindowBorderStyle | style | The new border style of the window. |
Exceptions
Type | Condition |
---|---|
InvalidEnumArgumentException |
|
PlatformNotSupportedException | Backend does not support the value set by |
SetBounds(WindowHandle, int, int, int, int)
Set the bounds of the window.
Declaration
void SetBounds(WindowHandle handle, int x, int y, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int | x | New X coordinate of the window. |
int | y | New Y coordinate of the window. |
int | width | New width of the window in screen coordinates. |
int | height | New height of the window in screen coordinates. |
SetClientBounds(WindowHandle, int, int, int, int)
Set the client area bounds (drawing area) of a window.
Declaration
void SetClientBounds(WindowHandle handle, int x, int y, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int | x | New X coordinate of the client area. |
int | y | New Y coordinate of the client area. |
int | width | New width of the client area in pixels. |
int | height | New height of the client area in pixels. |
SetClientPosition(WindowHandle, Vector2i)
Set the position of the client area (drawing area) of a window.
Declaration
void SetClientPosition(WindowHandle handle, Vector2i newClientPosition)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
Vector2i | newClientPosition | New coordinate of the client area in screen coordinates. |
SetClientSize(WindowHandle, Vector2i)
Set the size of the client area (drawing area) of a window.
Declaration
void SetClientSize(WindowHandle handle, Vector2i newClientSize)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
Vector2i | newClientSize | New size of the client area in screen coordinates. |
SetCursor(WindowHandle, CursorHandle?)
Set the cursor object for a window.
Declaration
void SetCursor(WindowHandle handle, CursorHandle? cursor)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
CursorHandle | cursor | Handle to a cursor object, or null for hidden cursor. |
Exceptions
Type | Condition |
---|---|
PlatformNotSupportedException | Backend does not support setting the window mouse cursor. See CanSetCursor. |
See Also
SetCursorCaptureMode(WindowHandle, CursorCaptureMode)
Sets the cursor capture mode of the window. A cursor can be confined to the bounds of the window, or locked to the center of the window.
Declaration
void SetCursorCaptureMode(WindowHandle handle, CursorCaptureMode mode)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
CursorCaptureMode | mode | The cursor capture mode. |
See Also
SetFullscreenDisplay(WindowHandle, DisplayHandle?)
Put a window into 'windowed fullscreen' on a specified display or the display the window is displayed on.
If display
is null
then the window will be made fullscreen on the 'nearest' display.
Declaration
void SetFullscreenDisplay(WindowHandle handle, DisplayHandle? display)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | The window to make fullscreen. |
DisplayHandle | display | The display to make the window fullscreen on. |
Remarks
To make an 'exclusive fullscreen' window see SetFullscreenDisplay(WindowHandle, DisplayHandle, VideoMode).
See Also
SetFullscreenDisplay(WindowHandle, DisplayHandle, VideoMode)
Put a window into 'exclusive fullscreen' on a specified display and change the video mode to the specified video mode. Only video modes accuired using GetSupportedVideoModes(DisplayHandle) are expected to work.
Declaration
void SetFullscreenDisplay(WindowHandle handle, DisplayHandle display, VideoMode videoMode)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | The window to make fullscreen. |
DisplayHandle | display | The display to make the window fullscreen on. |
VideoMode | videoMode | The video mode to use when making the window fullscreen. |
Remarks
To make a 'windowed fullscreen' window see SetFullscreenDisplay(WindowHandle, DisplayHandle?).
See Also
SetHitTestCallback(WindowHandle, HitTest?)
Sets a delegate that is used for hit testing. Hit testing allows the user to specify if a click should start a drag or resize operation on the window.
Hit testing is not always done in respone to the user clicking the mouse. The operating system can do hit testing for any reason and doesn't need to be in respose to some user action. It is recommended to keep this code efficient as it will be called often.
Declaration
void SetHitTestCallback(WindowHandle handle, HitTest? test)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | The window for which this hit test delegate should be used for. |
HitTest | test | The hit test delegate. |
See Also
SetIcon(WindowHandle, IconHandle)
Set window icon object handle.
Declaration
void SetIcon(WindowHandle handle, IconHandle icon)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
IconHandle | icon | Handle to an icon object. |
Exceptions
Type | Condition |
---|---|
PlatformNotSupportedException | Backend does not support setting the window icon. See CanSetIcon. |
See Also
SetMaxClientSize(WindowHandle, int?, int?)
Sets the maximum size of the client area.
Declaration
void SetMaxClientSize(WindowHandle handle, int? width, int? height)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int? | width | New maximum width of the client area of the window, or null to remove limit. |
int? | height | New maximum height of the client area of the window, or null to remove limit. |
SetMinClientSize(WindowHandle, int?, int?)
Sets the minimum size of the client area.
Declaration
void SetMinClientSize(WindowHandle handle, int? width, int? height)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
int? | width | New minimum width of the client area of the window, or null to remove limit. |
int? | height | New minimum height of the client area of the window, or null to remove limit. |
SetMode(WindowHandle, WindowMode)
Set the mode of a window.
Declaration
void SetMode(WindowHandle handle, WindowMode mode)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
WindowMode | mode | The new mode of the window. |
Remarks
Setting WindowedFullscreen or ExclusiveFullscreen will make the window fullscreen in the nearest monitor to the window location. Use SetFullscreenDisplay(WindowHandle, DisplayHandle?) or SetFullscreenDisplay(WindowHandle, DisplayHandle, VideoMode) to explicitly set the monitor.
Exceptions
Type | Condition |
---|---|
InvalidEnumArgumentException |
|
PlatformNotSupportedException | Backend does not support the value set by |
See Also
SetPosition(WindowHandle, Vector2i)
Set the window position in display coordinates (top left origin).
Declaration
void SetPosition(WindowHandle handle, Vector2i newPosition)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
Vector2i | newPosition | New position of the window in screen coordinates. |
SetSize(WindowHandle, Vector2i)
Set the size of the window.
Declaration
void SetSize(WindowHandle handle, Vector2i newSize)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
Vector2i | newSize | New size of the window in screen coordinates. |
SetTitle(WindowHandle, string)
Set the title of a window.
Declaration
void SetTitle(WindowHandle handle, string title)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | Handle to a window. |
string | title | New window title string. |
See Also
SetTransparencyMode(WindowHandle, WindowTransparencyMode, float)
Sets the transparency mode of the specified window.
Declaration
void SetTransparencyMode(WindowHandle handle, WindowTransparencyMode transparencyMode, float opacity = 0.5)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | The window to set the transparency mode of. |
WindowTransparencyMode | transparencyMode | The transparency mode to apply to the window. |
float | opacity | The whole window opacity. Ignored if |
See Also
SupportsFramebufferTransparency(WindowHandle)
Returns true if TransparentFramebuffer is supported for this window.
Win32 | Always returns true. |
macOS | Always returns true. |
Linux/X11 | Returns true if the selected ContextValues had SupportsFramebufferTransparencytrue. |
Declaration
bool SupportsFramebufferTransparency(WindowHandle handle)
Parameters
Type | Name | Description |
---|---|---|
WindowHandle | handle | The window to query framebuffer transparency support for. |
Returns
Type | Description |
---|---|
bool | If SetTransparencyMode(WindowHandle, WindowTransparencyMode, float) with TransparentFramebuffer would work. |