Public Member Functions | List of all members
minx.layout.base.base Class Reference

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...
 

Detailed Description

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).

Constructor & Destructor Documentation

def minx.layout.base.base.__init__ (   self,
  m,
  p,
  r = None 
)

Layout base class constructor.

Parameters
mThe main window manager object.
pThe layout's parent minxlib.window.
rThe 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.

Note
As mentioned earlier, this class is not meant to be instantiated directly. Thus, this constructor must only be called by subclasses.

Member Function Documentation

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.

Parameters
wThe 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.

Parameters
nThe minxlib.window to be configured.
xx-coordinate of window's top-left corner.
yy-coordinate of window's top-left corner.
wWindow width.
hWindow height.
Returns
Tuple containing new geometry.

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.

Parameters
wThe 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.

Parameters
wThe 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.

Parameters
wThe 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.

Parameters
wThe 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.

Parameters
wThe 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.