Layout manager. More...
Public Member Functions | |
def | __init__ |
Construct layout manager. More... | |
def | add |
Add given layout object to the layout manager. More... | |
def | find |
Return layout object given either its X window or the window's name. More... | |
def | focused_layout |
Return current layout. More... | |
def | receptive_layout |
Find a layout to manage a new window. More... | |
Layout manager.
This class keeps track of the different layout objects created by end-users and also provides a convenient API for dealing with these layouts.
def minx.core.layman.layman.__init__ | ( | self, | |
wm | |||
) |
Construct layout manager.
wm | The main window manager object. |
The layout manager is meant to be used by the main window manager object. When the layout manager is created, we squirrel away a reference to the main wm object so we can later get access to the "global" config object and any other things we might need from the wm object.
def minx.core.layman.layman.add | ( | self, | |
layout | |||
) |
Add given layout object to the layout manager.
layout | The layout object to be added. |
This method adds the specified layout object to the layout manager's internal list and performs other necessary bookkeeping.
def minx.core.layman.layman.find | ( | self, | |
w | |||
) |
Return layout object given either its X window or the window's name.
w | A string or the minxlib.window to find. |
This method searches all the layouts currently being managed by the layout manager to see if any of them corresponds to the window w. If w is a string, then this method will look for a layout whose X window has the string w in its name.
If there is no matching layout, this function will raise an unknown_layout exception.
def minx.core.layman.layman.focused_layout | ( | self) |
Return current layout.
This method returns the layout that has the top-level window that currently has the input focus. If no window has the input focus or if there is no layout corresponding to the focused window, this method will return None.
def minx.core.layman.layman.receptive_layout | ( | self, | |
w | |||
) |
Find a layout to manage a new window.
w | The minxlib.window to be managed. |
When a new window is created, Minx has to find a layout that will manage it. For lack of a better term, we refer to this layout as the receptive layout (because it will "receive" the new window). To find a layout willing and able to manage the new window, this function follows the procedure outlined below:
receptive_layout_hook
. The receptive_layout_hook
gives end-user code an opportunity to fine-tune the layout to be used for each window. If you have multiple functions for this hook, only the return value of the first one will be considered. That is, use only one hook for this; in fact, you shouldn't need an entire chain of hooks for the receptive_layout_hook
.
Minx will only accept the return value of the receptive_layout_hook
if all of the following conditions are true:
If the above-mentioned hook is not defined or if it returns something not fulfilling the above conditions, we check if the layout with the window that is currently focused is on the same screen as the new window and is willing to manage it. If so, this function will return the currently focused layout as the receptive layout, i.e., the layout that will manage the new window.
If no window has the input focus, or if the focused layout is not on the same screen as the new window, or if it is unwilling to manage the new window, then we search the layout manager's remaining layouts for a layout that is on the same screen as the new window and is willing to manage it.
If no such layout exists, Minx will fall back to creating a new layout object on the same screen as the new window and use that as the receptive layout. The layout class used for this fallback policy is referred to as the default layout. Currently, Minx uses the full layout as the default layout class.
receptive_layout_hook
.