# HG changeset patch # User Paul Boddie # Date 1228004229 -3600 # Node ID 885719b03d9173c9922c0a8ef5961bc5cce77d0e # Parent ebdd77ea86b82d041f34e689e6111d48fb70f988 Added a function to obtain the root window. diff -r ebdd77ea86b8 -r 885719b03d91 desktop/windows.py --- a/desktop/windows.py Sat Nov 01 00:04:01 2008 +0100 +++ b/desktop/windows.py Sun Nov 30 01:17:09 2008 +0100 @@ -3,7 +3,7 @@ """ Simple desktop window enumeration for Python. -Copyright (C) 2007 Paul Boddie +Copyright (C) 2007, 2008 Paul Boddie This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -28,6 +28,11 @@ windows = desktop.windows.list() +To obtain the root window, typically the desktop background, use the +desktop.windows.root function as follows: + +root = desktop.windows.root() + Each window object can be inspected through a number of methods. For example: name = window.name() @@ -156,4 +161,20 @@ return [Window(handle) for handle in handles] +def root(desktop=None): + + """ + Return the root window for the current desktop. If the optional 'desktop' + parameter is specified then attempt to use that particular desktop + environment's mechanisms to look for windows. + """ + + # NOTE: The desktop parameter is currently ignored and X11 is tested for + # NOTE: directly. + + if _is_x11(): + return Window(None) + else: + raise OSError, "Desktop '%s' not supported" % use_desktop(desktop) + # vim: tabstop=4 expandtab shiftwidth=4