summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Frank Erikson <kristian@kristian-desktop.(none)>2009-01-11 12:32:20 +1300
committerKristian Frank Erikson <kristian@kristian-desktop.(none)>2009-01-11 12:32:20 +1300
commit577b4158140595eb7d89ff606f558ad3b8f99cf2 (patch)
tree9506facdcf553a4bdf17ed73a0b35655ab57235d
parenta8a697fe25aa508e3dc06e9bbca62f4a3d93294b (diff)
downloadpython-compiz-manager-577b4158140595eb7d89ff606f558ad3b8f99cf2.tar.gz
python-compiz-manager-577b4158140595eb7d89ff606f558ad3b8f99cf2.tar.bz2
Modified CompizManager to now use the new C extension and added licencing terms to the extension.
-rwxr-xr-xCompizManager.py89
-rw-r--r--CompizPyWindowList-setup.py21
-rw-r--r--CompizPyWindowList.c24
-rw-r--r--CompizTests.py1
4 files changed, 65 insertions, 70 deletions
diff --git a/CompizManager.py b/CompizManager.py
index 13ddf20..6e89221 100755
--- a/CompizManager.py
+++ b/CompizManager.py
@@ -164,69 +164,16 @@ class CompizManager(object):
plugin.doAction(action, parameters)
else: raise CompizNotActiveError
- def listAllWindows(self):
- import os
- import string
- """ Return a dictionary with attributes for each window, including info "xwininfo" returns as well as
- Compiz Fusion specific details like which viewport or face of the cube, etc. -- Not implemented """
- # Go get the list of windows
+ def listWindows(self):
+ import CompizPyWindowList
+ """
+ For now this simply returns a list containing tuples of windows titles and window id's.
- # Implementation using wmctrl for getting list of windows
- """
- wmctrl = os.popen("wmctrl -l")
- wmctrl = wmctrl.read()
- outputWindowList = string.splitfields(wmctrl, '\n')
- print outputWindowList
- for window in outputWindowList: # Parse each string's window info
- windowinfo = string.splitfields(window, ' ')
- print windowinfo[0]
- print windowinfo[1]
- print windowinfo[2]
- print windowinfo[3]
- """
-
- # Implementation using xwininfo for getting list of windows
- xwininfo = os.popen("xwininfo -root -children")
- xwininfo = xwininfo.read()
- childrenIndex = string.rindex(xwininfo, 'children') # Discard unnecessary output
- windowsString = xwininfo[(childrenIndex+10):]
- windowsString = windowsString.rstrip()
- outputWindowList = string.splitfields(windowsString, '\n')
- count = 0
- windowList = WindowList()
- for window in outputWindowList: # Parse each string's window info
- count = count + 1
- window = window.lstrip() # Strip left spaces
- firstSpace = window.find(' ') # Find the first space
- windowId = int(window[:firstSpace], 16) # Extract window id
- # Go find out if mapped from xwininfo
- xwininfo = os.popen("xwininfo -id " + str(windowId) + " -stats")
- xwininfo = xwininfo.read()
- viewableCheck = xwininfo.find('IsViewable') # Check if we can see it.. Not much point otherwise
- colormapCheck = xwininfo.find('Colormap: 0x0 (not installed)')
- stateCheck = xwininfo.find('State: yes')
- if viewableCheck != (-1) and colormapCheck == (-1) and stateCheck == (-1):
- secondSpace = window.find(' ', firstSpace+1) # Find the next space
- if window[firstSpace+1] == '"':
- secondQuote = window.find('"', firstSpace+3)
- windowName = window[firstSpace+2:secondQuote] # Get the window name
- windowList.addWindow(windowName, windowId)
- print windowList.windowInfo(windowName)
-
-class WindowList(object):
- """ Attributes for each window, including info "xwininfo" returns as well as
- Compiz Fusion specific details like which viewport or face of the cube, etc. """
-
- # Next thing to do - start adding all the missing attributes
- def __init__(self):
- self.windows = {}
+ Hopefully in the future it will have more specific details like which viewport or face of the cube, etc. -- Not yet implemented """
- def addWindow(self, title, windowId): # add other attributes in a dict.. All keyed by the title
- self.windows[title] = windowId
-
- def windowInfo(self, title): # Temp func for printing windows - dev
- return 'Window title: ' + title + ' id: ' + str(self.windows[title])
-
+ # Go get the list of windows from the now C extension written specifically
+ # Implementation using wmctrl source code
+ return CompizPyWindowList.listWindows()
def AllToScreen():
@@ -254,16 +201,18 @@ if __name__ == '__main__':
# Set a global manager for the tests:
manager = CompizManager()
- # from CompizTests import *
- # Pre test setup
- # preTestSetup()
- # Run the tests
- # suite = unittest.TestLoader().loadTestsFromTestCase(TestCompizManagerClasses)
- # unittest.TextTestRunner(verbosity=2).run(suite)
- # Run the test cleanup
- # postTestCleanup()
+ from CompizTests import *
+ # Pre test setup
+ preTestSetup()
+ # Run the tests
+ suite = unittest.TestLoader().loadTestsFromTestCase(TestCompizManagerClasses)
+ unittest.TextTestRunner(verbosity=2).run(suite)
+ # Run the post test cleanup
+ postTestCleanup()
# Print a file with actions and options listed in it
AllToFile('Plugins with options and actions.txt')
- manager.listAllWindows()
+
+ print "\nWindows currently active:"
+ print manager.listWindows()
diff --git a/CompizPyWindowList-setup.py b/CompizPyWindowList-setup.py
index 32ad552..9af5d2f 100644
--- a/CompizPyWindowList-setup.py
+++ b/CompizPyWindowList-setup.py
@@ -1,3 +1,24 @@
+#
+# Copyright Eyemagnet Limited
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+#
+# Author: Kristian F. Erikson <kristian@erikson.dk>
+#
+
# To rebuild this module the command is: ~$ python CompizPyWindowList-setup.py build_ext -i
from distutils.core import setup, Extension
diff --git a/CompizPyWindowList.c b/CompizPyWindowList.c
index 41fc21b..6381fb4 100644
--- a/CompizPyWindowList.c
+++ b/CompizPyWindowList.c
@@ -1,3 +1,27 @@
+/*
+ * Copyright © Eyemagnet Limited
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * This plugin is based on Wmctrl-1.07 by Tomas Styblo and the 1.07-6
+ * Debian patch by Decklin Foster.
+ *
+ * Author: Kristian F. Erikson <kristian@erikson.dk>
+ */
+
#include <Python.h>
#include <stdlib.h>
#include <unistd.h>
diff --git a/CompizTests.py b/CompizTests.py
index 0ffc86b..7ce1e28 100644
--- a/CompizTests.py
+++ b/CompizTests.py
@@ -23,6 +23,7 @@ import unittest
from CompizManager import CompizManager
from CompizError import *
from CompizTools import *
+import time
def preTestSetup():