A base class for Minx layouts. More...
Public Member Functions | |
def | __init__ |
Layout base class constructor. More... | |
def | __str__ |
Return layout's name. More... | |
def | will_manage |
Check if this layout is willing to manage specified window. More... | |
def | add |
Add a window to be managed by this layout. More... | |
def | reparented |
Reparent notification. More... | |
def | configure_request |
Decide window geometry on configure requests for top-level windows. More... | |
def | map_request |
Resize top-level window before it gets mapped to screen. More... | |
def | focused |
Focus-in notification. More... | |
def | unfocused |
Focus-out notification. More... | |
A base class for Minx layouts.
This class implements a base class from which all Minx layout classes must be derived. This class is not meant to be instantiated; instead, you should instantiate one of the layout subclasses provided by Minx (or one of the custom layouts you implement yourself).
def minx.layout.base.base.__init__ | ( | self, | |
m, | |||
p, | |||
r = None |
|||
) |
Layout base class constructor.
m | The main window manager object. |
p | The layout's parent minxlib.window. |
r | The rectangle within parent window assigned to this layout. |
Each layout class's constructor must call this base class constructor, passing it at least the parameters m and p, which we need because a layout is basically an X window encapsulated by a Python object with some additional methods tacked on. Thus, in order to be able to create the layout window, we need the display connection (which is in the wm class) and the parent window of the layout window.
The parameter r is optional. It specifies the rectangle within the parent window that the layout will occupy. It should be a tuple of four integers. The first two integers in this tuple specify the x and y coordinates respectively of the layout window's top-left corner; the third and fourth integers are the layout window's width and height respectively.
If r is not supplied by the subclass constructor, the layout will occupy the entire area of the parent window.
After creating the layout's window, this method sets some properties on the newly created window and then maps it on screen.
def minx.layout.base.base.__str__ | ( | self) |
Return layout's name.
This method will convert the layout object to a human-readable string representation (which is useful for debugging as well as identifying layouts).
def minx.layout.base.base.add | ( | self, | |
w | |||
) |
Add a window to be managed by this layout.
w | The minxlib.window to be managed. |
This method tells the layout that it should manage the given window, which involves, among other things, reparenting the client window so that this layout becomes its parent.
def minx.layout.base.base.configure_request | ( | self, | |
n, | |||
x, | |||
y, | |||
w, | |||
h | |||
) |
Decide window geometry on configure requests for top-level windows.
n | The minxlib.window to be configured. |
x | x-coordinate of window's top-left corner. |
y | y-coordinate of window's top-left corner. |
w | Window width. |
h | Window height. |
When the main window manager object receives a configure_request
message in its event loop, it will eventually end up calling this method on the layout object that has reparented the window n. This method is meant to be overridden by layout subclasses; the base class implementation does nothing.
Subclasses should return a 4-tuple of integers containing the new window geometry to apply in accordance with their particular layout policies. The first two numbers in this tuple specify the x and y coordinates of the window's top-left corner; the third and fourth numbers are the window's width and height respectively.
The wm object's configure_request
event handler will use the returned tuple to honour the window's configure request. To clarify, layouts should not directly add a hook for x_configure_request
; instead, they should let the main window manager object do that and override this method to let the main wm
object know how to configure the windows they are managing.
def minx.layout.base.base.focused | ( | self, | |
w | |||
) |
Focus-in notification.
w | The focused minxlib.window. |
When the main window manager object receives a focus_in
message in its event loop, it will eventually end up calling this method on the layout object that has reparented the window w. This method is meant to be overridden by layout subclasses; the base class implementation does nothing.
The intent of this method is to inform layouts about changes in the input focus. When a window receives the input focus, the window manager may change its border color and size. And when that happens, the layout managing the newly focused window may well have to adjust the geometries of one/more/all of the windows it is managing to take into account the new border size.
def minx.layout.base.base.map_request | ( | self, | |
w | |||
) |
Resize top-level window before it gets mapped to screen.
w | The minxlib.window to be mapped. |
When the main window manager object receives a map_request
message in its event loop, it will eventually end up calling this method on the layout object that has reparented the window w. This method is meant to be overridden by layout subclasses; the base class implementation does nothing.
The intent of this method is to give layouts an opportunity to move and resize the windows they are managing just before a window gets mapped. Layouts should not themselves map the window (though no harm should come from that). Rather, they should let the main window manager object map windows and, in this method, if necessary, restrict themselves to reconfiguring their windows to match their layout policy.
def minx.layout.base.base.reparented | ( | self, | |
w | |||
) |
Reparent notification.
w | The minxlib.window that was reparented. |
When the main window manager object receives a reparent_notify
message in its event loop, it will eventually end up calling this method on the layout object that has reparented the window w.
This method is meant to be overridden by layout subclasses. The base class implementation does nothing.
def minx.layout.base.base.unfocused | ( | self, | |
w | |||
) |
Focus-out notification.
w | The minxlib.window that lost focus. |
When the main window manager object receives a focus_out
message in its event loop, it will eventually end up calling this method on the layout object that has reparented the window w. This method is meant to be overridden by layout subclasses; the base class implementation does nothing.
The intent of this method is to inform layouts about changes in the input focus. When a window loses the input focus, the window manager may change its border color and size. Of course, when that happens, the layout managing the newly unfocused window may well have to adjust the geometries of one/more/all of the windows it is managing to take into account the new border size.
def minx.layout.base.base.will_manage | ( | self, | |
w | |||
) |
Check if this layout is willing to manage specified window.
w | The minxlib.window to be managed. |
This method returns True if the layout is willing to manage the window w, False otherwise.
The intent of this function is to allow layouts to decide whether or not they want to accept a window. For example, if a layout is written to expressly work with a particular application, it can return True for that application's windows and False for all the others.
This method may be overridden by layout subclasses. The base class implementation returns True. Thus, unless a subclass overrides this function, it will be taken as willing to manage all windows.