Table of Contents

Interface IWorkspace

Namespace
Whim
Assembly
Whim.dll
Workspaces contain windows to be organized by layout engines.
public interface IWorkspace : IDisposable
Inherited Members

Properties

ActiveLayoutEngine

The active layout engine.
ILayoutEngine ActiveLayoutEngine { get; }

Property Value

ILayoutEngine

ActiveLayoutEngineIndex

The index of the layout engine in LayoutEngines which is currently active.
int ActiveLayoutEngineIndex { get; }

Property Value

int

BackingName

The name of the workspace.
string BackingName { get; }

Property Value

string

Remarks

Until the legacy Workspace implementation is removed, this is called BackingName to avoid confusion with Name. Once the legacy Workspace implementation is removed, this will be called Name.

Id

The unique id of the workspace.
Guid Id { get; }

Property Value

Guid

LastFocusedWindow

The last focused window. This is still set when the window has lost focus (provided another window in the workspace does not have focus). This is useful in cases like when the command palette is opened and wants to perform an action on the last focused window. To focus the last focused window, use FocusLastFocusedWindow().
IWindow? LastFocusedWindow { get; }

Property Value

IWindow

LastFocusedWindowHandle

The index of the last focused window in the workspace. WARNING: When the value is 0, it means that no window is focused. Check this with IsNull.
HWND LastFocusedWindowHandle { get; }

Property Value

HWND

LayoutEngines

All the layout engines currently in the workspace.
ImmutableList<ILayoutEngine> LayoutEngines { get; }

Property Value

ImmutableList<ILayoutEngine>

Name

The name of the workspace. When the Name is set, the WorkspaceRenamed event is triggered.
string Name { get; set; }

Property Value

string

PreviousLayoutEngineIndex

The index of the layout engine in LayoutEngines which was previously active.
int PreviousLayoutEngineIndex { get; }

Property Value

int

WindowPositions

Map of windows to their WindowPositions.
ImmutableDictionary<HWND, WindowPosition> WindowPositions { get; }

Property Value

ImmutableDictionary<HWND, WindowPosition>

Windows

The windows in the workspace.
IEnumerable<IWindow> Windows { get; }

Property Value

IEnumerable<IWindow>

Methods

ActivatePreviouslyActiveLayoutEngine()

Activates previously active layout engine.
void ActivatePreviouslyActiveLayoutEngine()

AddWindow(IWindow)

Adds the window to the workspace.
bool AddWindow(IWindow window)

Parameters

window IWindow

Returns

bool
Whether the window was added.

Remarks

Be careful of calling this outside of Whim's core code. It may cause the workspace to become out of sync with the IButlerPantry. DoLayout() is not called in this method.

ContainsWindow(IWindow)

Returns true when the workspace contains the provided window.
bool ContainsWindow(IWindow window)

Parameters

window IWindow
The window to check for.

Returns

bool
True when the workspace contains the provided window.

CycleLayoutEngine(bool)

Cycle to the next or previous layout engine.
void CycleLayoutEngine(bool reverse = false)

Parameters

reverse bool
When true, activate the previous layout, otherwise activate the next layout. Defaults to false.

Deactivate()

Deactivates the workspace.
void Deactivate()

DoLayout()

Trigger a layout.
void DoLayout()

FocusLastFocusedWindow()

If LastFocusedWindow is not null or not minimized, then we focus the last window in the workspace.
void FocusLastFocusedWindow()

FocusWindowInDirection(Direction, IWindow?, bool)

Focuses the window in the direction.
bool FocusWindowInDirection(Direction direction, IWindow? window = null, bool deferLayout = false)

Parameters

direction Direction
The direction to focus in.
window IWindow
The origin window
deferLayout bool
Whether to defer the layout until the next DoLayout(). Defaults to false.

Returns

bool
Whether the ActiveLayoutEngine changed.

MinimizeWindowEnd(IWindow)

Called when a window is being unminimized - i.e., the window size will no longer be Minimized. Will unminimize a window in the ActiveLayoutEngine.
void MinimizeWindowEnd(IWindow window)

Parameters

window IWindow

Remarks

Be careful of calling this outside of Whim's core code. It may cause the workspace to become out of sync with the IButlerPantry. DoLayout() is not called in this method.

MinimizeWindowStart(IWindow)

Called when a window is being minimized - i.e., the window size will become Minimized. Will minimize a window in the ActiveLayoutEngine.
void MinimizeWindowStart(IWindow window)

Parameters

window IWindow

Remarks

Be careful of calling this outside of Whim's core code. It may cause the workspace to become out of sync with the IButlerPantry. DoLayout() is not called in this method.

MoveWindowEdgesInDirection(Direction, IPoint<double>, IWindow?, bool)

Change the window's edges direction by the specified deltas.
bool MoveWindowEdgesInDirection(Direction edges, IPoint<double> deltas, IWindow? window = null, bool deferLayout = false)

Parameters

edges Direction
The edges to change.
deltas IPoint<double>
The deltas to change the given edges by. When a value is positive, then the edge will move in the direction of the edges. The deltas have a coordinate space of [0, 1] for both x and y (the unit square).
window IWindow
The window to change the edge of. If null, the currently focused window is used.
deferLayout bool
Whether to defer the layout until the next DoLayout(). Defaults to false.

Returns

bool
Whether the ActiveLayoutEngine changed.

MoveWindowToPoint(IWindow, IPoint<double>, bool)

Moves or adds the given window to the given point. The point has a coordinate space of [0, 1] for both x and y (the unit square).
bool MoveWindowToPoint(IWindow window, IPoint<double> point, bool deferLayout = false)

Parameters

window IWindow
The window to move.
point IPoint<double>
The point to move the window to.
deferLayout bool
Whether to defer the layout until the next DoLayout(). Defaults to false.

Returns

bool
Whether the ActiveLayoutEngine changed.

PerformCustomLayoutEngineAction(LayoutEngineCustomAction)

Performs a custom action in a layout engine.
bool PerformCustomLayoutEngineAction(LayoutEngineCustomAction action)

Parameters

action LayoutEngineCustomAction
Metadata about the action to perform, and the payload to perform it with.

Returns

bool
Whether the ActiveLayoutEngine changed.

Remarks

Layout engines need to handle the custom action in PerformCustomAction<T>(LayoutEngineCustomAction<T>). For more, see PerformCustomAction<T>(LayoutEngineCustomAction<T>).

PerformCustomLayoutEngineAction<T>(LayoutEngineCustomAction<T>)

Performs a custom action in a layout engine.
bool PerformCustomLayoutEngineAction<T>(LayoutEngineCustomAction<T> action)

Parameters

action LayoutEngineCustomAction<T>
Metadata about the action to perform, and the payload to perform it with.

Returns

bool
Whether the ActiveLayoutEngine changed.

Type Parameters

T
The type of action's payload.

Remarks

Layout engines need to handle the custom action in PerformCustomAction<T>(LayoutEngineCustomAction<T>). For more, see PerformCustomAction<T>(LayoutEngineCustomAction<T>).

RemoveWindow(IWindow)

Removes the window from the workspace.
bool RemoveWindow(IWindow window)

Parameters

window IWindow

Returns

bool
True when the window was removed.

Remarks

Be careful of calling this outside of Whim's core code. It may cause the workspace to become out of sync with the IButlerPantry. DoLayout() is not called in this method.

SwapWindowInDirection(Direction, IWindow?, bool)

Swaps the window in the direction.
bool SwapWindowInDirection(Direction direction, IWindow? window = null, bool deferLayout = false)

Parameters

direction Direction
The direction to swap the window in.
window IWindow
The window to swap. If null, the currently focused window is swapped.
deferLayout bool
Whether to defer the layout until the next DoLayout(). Defaults to false.

Returns

bool
Whether the ActiveLayoutEngine changed.

TryGetWindowState(IWindow)

Gets the current state (as of the last DoLayout()) of the window.
IWindowState? TryGetWindowState(IWindow window)

Parameters

window IWindow

Returns

IWindowState
If the window is not in the workspace, or the workspace is not active, null is returned.

TrySetLayoutEngineFromIndex(int)

Rotate to the next layout engine.
bool TrySetLayoutEngineFromIndex(int nextIdx)

Parameters

nextIdx int
The index of the layout engine to make active.

Returns

bool
true if the layout engine is the one specified by nextIdx.

TrySetLayoutEngineFromName(string)

Tries to set the layout engine to one with the name.
bool TrySetLayoutEngineFromName(string name)

Parameters

name string
The name of the layout engine to make active.

Returns

bool