Class Workspace
- Namespace
- Whim
- Assembly
- Whim.dll
Workspaces contain windows to be organized by layout engines.
public sealed record Workspace : IWorkspace, IDisposable, IEquatable<Workspace>
- Inheritance
-
Workspace
- Implements
- Inherited Members
- Extension Methods
Properties
ActiveLayoutEngine
The active layout engine.
public ILayoutEngine ActiveLayoutEngine { get; }
Property Value
ActiveLayoutEngineIndex
The index of the layout engine in LayoutEngines which is currently active.
public int ActiveLayoutEngineIndex { get; }
Property Value
BackingName
The name of the workspace.
public string BackingName { get; }
Property Value
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.
public Guid Id { get; }
Property Value
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().
public IWindow? LastFocusedWindow { get; }
Property Value
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.
public HWND LastFocusedWindowHandle { get; }
Property Value
LayoutEngines
All the layout engines currently in the workspace.
public ImmutableList<ILayoutEngine> LayoutEngines { get; }
Property Value
Name
The name of the workspace. When the
Name
is set, the
WorkspaceRenamed event is triggered.public string Name { get; set; }
Property Value
PreviousLayoutEngineIndex
The index of the layout engine in LayoutEngines which was previously active.
public int PreviousLayoutEngineIndex { get; }
Property Value
WindowPositions
Map of windows to their WindowPositions.
public ImmutableDictionary<HWND, WindowPosition> WindowPositions { get; }
Property Value
Windows
The windows in the workspace.
public IEnumerable<IWindow> Windows { get; }
Property Value
Methods
ActivatePreviouslyActiveLayoutEngine()
Activates previously active layout engine.
public void ActivatePreviouslyActiveLayoutEngine()
AddWindow(IWindow)
Adds the window to the workspace.
public 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
.public 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.
public 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.
public void Deactivate()
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
DoLayout()
Trigger a layout.
public void DoLayout()
FocusLastFocusedWindow()
If LastFocusedWindow is not null or not minimized, then we focus the
last window in the workspace.
public void FocusLastFocusedWindow()
FocusWindowInDirection(Direction, IWindow?, bool)
Focuses the
window
in the direction
.public 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.
public 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.
public 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
.public 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 theedges
. Thedeltas
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).public 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.
public 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.
public 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.
public 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
.public 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.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
- A string that represents the current object.
TryGetWindowState(IWindow)
Gets the current state (as of the last DoLayout()) of the window.
public 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.
public bool TrySetLayoutEngineFromIndex(int nextIdx)
Parameters
nextIdx
int- The index of the layout engine to make active.
Returns
TrySetLayoutEngineFromName(string)
Tries to set the layout engine to one with the
name
.public bool TrySetLayoutEngineFromName(string name)
Parameters
name
string- The name of the layout engine to make active.
Returns
WindowFocused(IWindow?)
Called when a window is focused, regardless of whether it's in this workspace.
public void WindowFocused(IWindow? window)
Parameters
window
IWindow