Functions for managing any window.
To get windows, see mjolnir.window.focusedwindow
and mjolnir.window.visiblewindows
.
To get window geometrical attributes, see mjolnir.window.{frame,size,topleft}
.
To move and resize windows, see mjolnir.window.set{frame,size,topleft}
.
It may be handy to get a window's app or screen via mjolnir.window.application
and mjolnir.window.screen
.
See the screen
module for detailed explanation of how Mjolnir uses window/screen coordinates.
mjolnir.window.allwindows() -> win[]
Returns all windows
mjolnir.window.focusedwindow() -> window
Returns the focused window, or nil.
mjolnir.window.orderedwindows() -> win[]
Returns all visible windows, ordered from front to back.
mjolnir.window.visiblewindows() -> win[]
Get all windows on all screens that match window.isvisible.
mjolnir.window.windowforid() -> win or nil
Returns the window for the given id, or nil if it's an invalid id.
mjolnir.window:application() -> app
Returns the app that the window belongs to; may be nil.
mjolnir.window:becomemain() -> bool
Make this window the main window of the given application; deos not implicitly focus the app.
mjolnir.window:close() -> bool
Closes the window; returns whether it succeeded.
mjolnir.window:focus() -> bool
Try to make this window focused.
mjolnir.window:focuswindow_east()
Focus the first focus-able window to the east of this one.
mjolnir.window:focuswindow_north()
Focus the first focus-able window to the north of this one.
mjolnir.window:focuswindow_south()
Focus the first focus-able window to the south of this one.
mjolnir.window:focuswindow_west()
Focus the first focus-able window to the west of this one.
mjolnir.window:frame() -> rect
Get the frame of the window in absolute coordinates.
mjolnir.window:id() -> number, sometimes nil
Returns a unique number identifying this window.
mjolnir.window:isfullscreen() -> bool or nil
Returns whether the window is full screen, or nil if asking that question fails.
mjolnir.window:isminimized() -> bool
True if the window is currently minimized in the dock.
mjolnir.window:isstandard() -> bool
True if the window's subrole indicates it's 'a standard window'.
mjolnir.window:isvisible() -> bool
True if the app is not hidden and the window is not minimized.
NOTE: some apps (e.g. in Adobe Creative Cloud) have literally-invisible windows and also like to put them very far offscreen; this method may return true for such windows.
mjolnir.window:maximize()
Make this window fill the whole screen its on, without covering the dock or menu.
mjolnir.window:minimize()
Minimizes the window.
mjolnir.window:movetounit(rect)
Moves and resizes the window to fit on the given portion of the screen.
The argument is a rect with each key being between 0.0 and 1.0.
Example: win:movetounit(x=0, y=0, w=0.5, h=0.5) -- window now fills top-left quarter of screen
mjolnir.window:otherwindows_allscreens() -> win[]
Get every window except this one.
mjolnir.window:otherwindows_samescreen() -> win[]
Get other windows on the same screen as self.
mjolnir.window:role() -> string
Returns the role of the window, whatever that means.
mjolnir.window:screen()
Get the screen which most contains this window (by area).
mjolnir.window:setframe(rect)
Set the frame of the window in absolute coordinates.
mjolnir.window:setfullscreen(bool) -> bool
Sets whether the window is full screen; returns whether it succeeded.
mjolnir.window:setsize(size)
Resizes the window.
mjolnir.window:settopleft(point)
Moves the window to the given point in absolute coordinate.
mjolnir.window:size() -> size
The size of the window.
mjolnir.window:subrole() -> string
Returns the subrole of the window, whatever that means.
mjolnir.window:title() -> string
Returns the title of the window (as UTF8).
mjolnir.window:topleft() -> point
The top-left corner of the window in absolute coordinates.
mjolnir.window:unminimize()
Un-minimizes the window.
mjolnir.window:windows_to_east()
Get all windows east of this one, ordered by closeness.
mjolnir.window:windows_to_north()
Get all windows north of this one, ordered by closeness.
mjolnir.window:windows_to_south()
Get all windows south of this one, ordered by closeness.
mjolnir.window:windows_to_west()
Get all windows west of this one, ordered by closeness.