Public Member Functions | Static Public Member Functions | List of all members
minxlib::root_window Class Reference

Encapsulate the details of an X root window. More...

#include <root_window.hh>

Public Member Functions

 root_window (Display *d, int s)
 Create a wrapper object for a root window. More...
 
 root_window (Display *d, int s, const XineramaScreenInfo &i)
 Create a wrapper object for a root window with Xinerama active. More...
 
void set_properties (const std::map< std::string, std::string > &prop)
 Set window properties. More...
 
void reparent (const window &p)
 Reparent this window to another. More...
 
window parent ()
 Get this root window's parent window. More...
 
int screen ()
 Get screen number of this root window. More...
 
void show ()
 Show the window, i.e., map it. More...
 
void hide ()
 Hide this window, i.e., unmap it. More...
 
bool is_mapped ()
 Check if root window is currently mapped or not. More...
 
void move_resize (int x, int y, int w, int h)
 Move and resize the window. More...
 
void configure (int x, int y, int w, int h, int b, const window *s, int t, unsigned int v)
 Configure the window. More...
 
void set_border_attr (unsigned long c, unsigned int s)
 Set window's border color and size. More...
 
std::vector< int > geometry ()
 Retrieve window's size, position, and border width. More...
 
void focus ()
 Set input focus on this root window and raise it. More...
 
void kill ()
 Kill this window. More...
 
void nuke ()
 Kill this window using brute force. More...
 
- Public Member Functions inherited from minxlib::window
 window (Display *d, Window w)
 Create a wrapper object for an existing Xlib window. More...
 
bool operator== (const window &w) const
 Window equality operator. More...
 
bool operator!= (const window &w) const
 Window inequality operator. More...
 
bool operator== (Window w) const
 Window equality operator. More...
 
bool operator!= (Window w) const
 Window inequality operator. More...
 
 operator Window () const
 Convert to an Xlib Window. More...
 
std::map< std::string,
std::string > 
properties ()
 Retrieve window properties from X server. More...
 
std::vector< windowchildren ()
 Get this window's children. More...
 
void select_events (long mask)
 Set the X event mask for this window. More...
 
void grab_key (const std::string &s)
 Setup a passive keyboard grab. More...
 
virtual ~window ()
 Destructor. More...
 

Static Public Member Functions

static void pythonize ()
 Export the window class to minxlib Python module. More...
 
- Static Public Member Functions inherited from minxlib::window
static void pythonize ()
 Export the window class to minxlib Python module. More...
 

Additional Inherited Members

- Public Types inherited from minxlib::window
enum  event_mask
 An enumeration for the different event masks. More...
 
enum  configure_mask
 An enumeration for the different configure values. More...
 

Detailed Description

Encapsulate the details of an X root window.

This class provides an API for the Python parts of Minx to be able to deal with X root windows. It wraps around the relevant parts of Xlib and exposes its functionality to Python via Boost.Python.

Although we could just represent a root window as just another minxlib::window, we have a dedicated subclass for root windows to be able to deal with Xinerama. When Xinerama is active, a multi-head setup will have just one root window. However, to make Minx's layout functionality work properly across multiple physical monitors, minxlib always presents as many root windows as there are physical monitors. With Xinerama, these root windows will have the same window ID, but will have different geometries.

Constructor & Destructor Documentation

minxlib::root_window::root_window ( Display *  d,
int  s 
)

Create a wrapper object for a root window.

Parameters
dThe display object to which the window is "linked."
sThe zero-based screen index whose root window we want.
Returns
A valid wrapper object for the specified screen's root window.

This constructor is meant to be used when Xinerama is not active. In multi-head setups without Xinerama, the X server will be configured with independent displays.

minxlib::root_window::root_window ( Display *  d,
int  s,
const XineramaScreenInfo &  i 
)

Create a wrapper object for a root window with Xinerama active.

Parameters
dThe display object to which the window is "linked."
sThe zero-based screen index whose root window we want.
iThe Xinerama screen info structure for the specified screen.
Returns
A valid wrapper object for the specified screen's root window.

This constructor is meant to be used when Xinerama is active. It is the caller's responsibility to obtain the XineramaScreenInfo structures by calling XineramaQueryScreens() and then freeing them once all the necessary root window objects have been created.

Member Function Documentation

void minxlib::root_window::configure ( int  x,
int  y,
int  w,
int  h,
int  b,
const window s,
int  t,
unsigned int  v 
)
virtual

Configure the window.

Parameters
xWindow's x coordinate relative to parent's origin.
yWindow's y coordinate relative to parent's origin.
wWindow's width (not counting its border).
hWindow's height (not counting its border).
bWindow's border width.
sWindow's sibling for stacking operations.
tWindow's stacking mode.
vValue mask to determine what to configure.
Returns
Nothing.

This is an override of minxlib::window::configure(). minxlib does not allow root windows to be configured. Thus, this implementation simply logs a warning to the Minx log and does nothing else.

Reimplemented from minxlib::window.

void minxlib::root_window::focus ( )
virtual

Set input focus on this root window and raise it.

Returns
Nothing.

This is an override of minxlib::window::focus(). minxlib does not allow root windows to be focused. Thus, this implementation simply logs a warning to the Minx log and does nothing else.

Reimplemented from minxlib::window.

std::vector<int> minxlib::root_window::geometry ( )
virtual

Retrieve window's size, position, and border width.

Returns
STL vector of ints containing window geometry.

Root windows have a fixed geometry. When a root window object is constructed, we determine its geometry and store that in a data member. This function simply returns the above-mentioned data member, which is an STL vector of integers containing the following five values:

  • Element 0: x-coordinate of root window's top-left corner
  • Element 1: y-coordinate of root window's top-left corner
  • Element 2: root window width
  • Element 3: root window height
  • Element 4: root window's border width (always zero)
Note
For non-Xinerama setups, this function simply calls minxlib::window::geometry(), which, in turn, calls XGetGeometry(). If the call to XGetGeometry() fails, this function will return an empty vector (and, eventually, the X server will raise a protocol error).
On the Python side, the STL vector returned by this function will be converted into a Python list.

Reimplemented from minxlib::window.

void minxlib::root_window::hide ( )
virtual

Hide this window, i.e., unmap it.

Returns
Nothing.

This is an override of minxlib::window::hide(). Since root windows are always visible and cannot be unmapped, this function simply logs a warning to the Minx log.

Reimplemented from minxlib::window.

bool minxlib::root_window::is_mapped ( )
virtual

Check if root window is currently mapped or not.

Returns
True (root windows are always mapped).

Reimplemented from minxlib::window.

void minxlib::root_window::kill ( )
virtual

Kill this window.

Returns
Nothing.

This is an override of minxlib::window::kill(). minxlib does not allow root windows to be killed. Thus, this implementation simply logs a warning to the Minx log and does nothing else.

Reimplemented from minxlib::window.

void minxlib::root_window::move_resize ( int  x,
int  y,
int  w,
int  h 
)
virtual

Move and resize the window.

Parameters
xWindow's x coordinate relative to parent's origin.
yWindow's y coordinate relative to parent's origin.
wWindow's width (not counting its border).
hWindow's height (not counting its border).
Returns
Nothing.

This is an override of minxlib::window::move_resize(). minxlib does not allow root windows to be moved and/or resized. Thus, this implementation simply logs a warning to the Minx log and does nothing else.

Reimplemented from minxlib::window.

void minxlib::root_window::nuke ( )
virtual

Kill this window using brute force.

Returns
Nothing.

This is an override of minxlib::window::nuke(). minxlib does not allow root windows to be killed. Thus, this implementation simply logs a warning to the Minx log and does nothing else.

Reimplemented from minxlib::window.

window minxlib::root_window::parent ( )
virtual

Get this root window's parent window.

Returns
Window with ID zero.

This is an override of minxlib::window::parent(). minxlib does not allow querying root windows for their parents. Thus, this implementation simply logs a warning to the Minx log and returns a window object with ID zero.

Reimplemented from minxlib::window.

static void minxlib::root_window::pythonize ( )
static

Export the window class to minxlib Python module.

Returns
Nothing.

This function exposes the root window class's interface so that it can be used by the Python parts of Minx. It is meant to be called by the Boost.Python initialization code in python.cc.

void minxlib::root_window::reparent ( const window p)
virtual

Reparent this window to another.

Parameters
pNew parent window.
Returns
Nothing.

This is an override of minxlib::window::reparent(). minxlib does not allow root windows to be reparented. Thus, this implementation simply logs a warning to the Minx log and does nothing else.

Reimplemented from minxlib::window.

int minxlib::root_window::screen ( )
virtual

Get screen number of this root window.

Returns
Root window's screen number.

This function simply returns the screen index used when this root window object was created.

Reimplemented from minxlib::window.

void minxlib::root_window::set_border_attr ( unsigned long  c,
unsigned int  s 
)
virtual

Set window's border color and size.

Parameters
cThree-byte RGB spec.
sBorder size (in pixels).
Returns
Nothing.

This is an override of minxlib::window::set_border_attr(). minxlib does not allow root window borders to be changed. Thus, this implementation simply logs a warning to the Minx log and does nothing else.

Reimplemented from minxlib::window.

void minxlib::root_window::set_properties ( const std::map< std::string, std::string > &  prop)
virtual

Set window properties.

Parameters
propAn STL map of strings to strings.
Returns
Nothing.

This is an override of minxlib::window::set_properties(). minxlib does not allow root window properties to be set. Thus, this implementation simply logs a warning to the Minx log and does nothing else.

Reimplemented from minxlib::window.

void minxlib::root_window::show ( )
virtual

Show the window, i.e., map it.

Returns
Nothing.

This is an override of minxlib::window::show(). Since root windows are always visible, this function simply logs a warning to the Minx log.

Reimplemented from minxlib::window.