diff -U 3 -dHBbprN kdebase-3.4.3/kwin/CursorDCOP.cpp kwin.new/CursorDCOP.cpp
--- kdebase-3.4.3/kwin/CursorDCOP.cpp	1970-01-01 01:00:00.000000000 +0100
+++ kwin.new/CursorDCOP.cpp	2005-12-01 23:02:47.000000000 +0100
@@ -0,0 +1,35 @@
+//
+// C++ Implementation: CursorDCOP
+//
+// Description: 
+//
+//
+// Author: Jérôme Pouiller (Jezz) <jerome.pouiller@no-log.org>, (C) 2005
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include <qcursor.h>
+#include <kdebug.h>
+
+#include "CursorDCOP.h"
+
+namespace KWinInternal {
+
+  CursorDCOP::CursorDCOP():
+    DCOPObject("Cursor") {
+  }
+
+  const QPoint CursorDCOP::getCursorPos() const {
+    return QCursor::pos();
+  }
+  
+  void CursorDCOP::moveCursorRel(const QPoint& value) const {
+    QCursor::setPos(QCursor::pos() + value);
+  }
+
+  void CursorDCOP::moveCursorAbs(const QPoint& value) const {
+    QCursor::setPos(value);
+  }
+
+}
diff -U 3 -dHBbprN kdebase-3.4.3/kwin/CursorDCOP.h kwin.new/CursorDCOP.h
--- kdebase-3.4.3/kwin/CursorDCOP.h	1970-01-01 01:00:00.000000000 +0100
+++ kwin.new/CursorDCOP.h	2005-12-01 23:02:21.000000000 +0100
@@ -0,0 +1,39 @@
+//
+// C++ Interface: CursorDCOP
+//
+// Description: 
+//
+//
+// Author: Jérôme Pouiller (Jezz) <jerome.pouiller@no-log.org>, (C) 2005
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#ifndef CURSOR_H
+#define CURSOR_H
+
+#include <qpixmap.h>
+#include <qpoint.h>
+#include <qrect.h>
+#include <qsize.h>
+
+#include <dcopobject.h>
+
+namespace KWinInternal {
+
+class CursorDCOP : virtual public DCOPObject {
+  K_DCOP
+
+  public:
+    CursorDCOP();
+
+  k_dcop:
+    const QPoint getCursorPos() const;
+    void         moveCursorRel(const QPoint& value) const;
+    void         moveCursorAbs(const QPoint& value) const;
+
+};
+
+}
+#endif
diff -U 3 -dHBbprN kdebase-3.4.3/kwin/DesktopsDCOP.cpp kwin.new/DesktopsDCOP.cpp
--- kdebase-3.4.3/kwin/DesktopsDCOP.cpp	1970-01-01 01:00:00.000000000 +0100
+++ kwin.new/DesktopsDCOP.cpp	2005-12-01 23:03:18.000000000 +0100
@@ -0,0 +1,110 @@
+//
+// C++ Implementation: DesktopsDCOP
+//
+// Description: 
+//
+//
+// Author: Jérôme Pouiller (Jezz) <jerome.pouiller@no-log.org>, (C) 2005
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include <qsize.h>
+#include <kdebug.h>
+
+#include "client.h"
+#include "DesktopsDCOP.h"
+
+namespace KWinInternal {
+  DesktopsDCOP   *DesktopsDCOP::instance = NULL;
+  static int     iError(-127);
+  
+  DesktopsDCOP::DesktopsDCOP(Workspace& wrkspc) : 
+      DCOPObject("Desktops"),
+      w(wrkspc) {
+    if (instance != NULL)
+      kdDebug() << "You shouldn't instanciate two times this classe" << endl;
+    instance = this;
+  }
+  
+  DesktopsDCOP& DesktopsDCOP::getInstance() {
+    if (instance == NULL)
+      kdDebug() << "Object not yet constructed! Will crash" << endl;
+    return *instance;
+  }
+  
+  const QString DesktopsDCOP::getDesktopName(int deskId) const {
+    return w.desktopName(getDeskId(deskId));
+  }
+  
+  int DesktopsDCOP::getCurDesktopId() const {
+    return getDeskId();
+  }
+  
+  int DesktopsDCOP::getDeskId(int deskId) const {
+    if (deskId == 0)
+      return w.currentDesktop();
+    return deskId;
+  }
+  
+  /*
+  int     DesktopsDCOP::getDesktopId(QString deskName) {
+    return iError;
+  }
+  */
+
+  void DesktopsDCOP::gotoDesktopRel(int value, int dir) {
+    int dest = getDesktopRel(value, dir, 0);
+    if (dest != getCurDesktopId())
+      w.setCurrentDesktop(dest);
+    //popupinfo->showInfo(getDesktopName(currentDesktop()));
+  }
+
+  int DesktopsDCOP::getDesktopRel(int value, int dir, int deskId) const {
+    deskId = getDeskId();
+    // deskId are 1 based
+    --deskId;
+    int x, y;
+    w.calcDesktopLayout(x, y);
+    QSize sz = QSize(x, y);
+    int nb = sz.width() * sz.height();
+    // Translate in positives values (equivalent of arithmetic module)
+    value = value % nb + nb; 
+    //kdDebug("kwinDcop") << "getDesktopRel, width:" << sz.width()  << " height:" <<
+    //  sz.height() << " nb:" << nb << endl;
+    switch (dir) {
+      case 0:
+        return (value - 1) % nb + 1;
+      case 1:
+        return (deskId + value) % nb + 1;
+      case 2:
+        return (deskId + value) % sz.width() + deskId - deskId % sz.width() + 1;
+      case 3:
+        return (deskId + value * sz.width()) % nb + 1;
+      default:
+        return iError;
+    }
+  }
+  
+  QPixmap DesktopsDCOP::getSnapshot() const {
+    return QPixmap::grabWindow(qt_xrootwin());
+  }
+
+  QValueList<unsigned int> DesktopsDCOP::getWindowsList(int deskId) {
+    deskId = getDeskId(deskId);
+    QValueList<unsigned int> ret = *(new QValueList<unsigned int>());
+    for (ClientList::ConstIterator it = w.stacking_order.begin(); 
+        it != w.stacking_order.end(); ++it)
+      if ((*it)->isOnDesktop(deskId))
+        ret += (*it)->window();
+    return ret;
+  }
+
+  QValueList<unsigned int> DesktopsDCOP::getAllWindowsList() {
+    QValueList<unsigned int> ret = *(new QValueList<unsigned int>());
+    for (ClientList::ConstIterator it = w.stacking_order.begin(); 
+        it != w.stacking_order.end(); ++it)
+      ret += (*it)->window();
+    return ret;
+  }
+}
diff -U 3 -dHBbprN kdebase-3.4.3/kwin/DesktopsDCOP.h kwin.new/DesktopsDCOP.h
--- kdebase-3.4.3/kwin/DesktopsDCOP.h	1970-01-01 01:00:00.000000000 +0100
+++ kwin.new/DesktopsDCOP.h	2005-12-01 23:03:39.000000000 +0100
@@ -0,0 +1,53 @@
+//
+// C++ Interface: DesktopsDCOP
+//
+// Description: 
+//
+//
+// Author: Jérôme Pouiller (Jezz) <jerome.pouiller@no-log.org>, (C) 2005
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#ifndef DESKTOPS_DCOP_H
+#define DESKTOPS_DCOP_H
+
+#include <qpixmap.h>
+#include <qpoint.h>
+#include <qrect.h>
+#include <qsize.h>
+
+#include <dcopobject.h>
+#include "workspace.h"
+
+namespace KWinInternal {
+
+class DesktopsDCOP : virtual public DCOPObject {
+  K_DCOP
+
+  public:
+    /* TODO use reference */
+    DesktopsDCOP(Workspace&);
+    static DesktopsDCOP& getInstance();
+    
+  k_dcop:
+    int           getCurDesktopId() const;
+    const QString getDesktopName(int deskId = 0) const;
+    void          gotoDesktopRel(int value, int dir);
+    int           getDesktopRel(int value, int direction = 0, int deskId = 0) const;
+    QPixmap       getSnapshot() const;
+    /* Memory Leak, use processDynamic  */
+    QValueList<unsigned int> getWindowsList(int deskId = 0);
+    /* Memory Leak, use processDynamic */
+    QValueList<unsigned int> getAllWindowsList();
+
+  private:
+    static DesktopsDCOP* instance;
+    int                  getDeskId(int deskId = 0) const;
+    Workspace&           w;
+  
+};
+
+}
+#endif /* DESKTOPS_DCOP_H */
diff -U 3 -dHBbprN kdebase-3.4.3/kwin/main.cpp kwin.new/main.cpp
--- kdebase-3.4.3/kwin/main.cpp	2005-10-05 15:38:59.000000000 +0200
+++ kwin.new/main.cpp	2005-12-01 18:46:49.000000000 +0100
@@ -26,6 +26,9 @@ License. See the file "COPYING" for the 
 #include "atoms.h"
 #include "options.h"
 #include "sm.h"
+#include "CursorDCOP.h"
+#include "WindowsDCOP.h"
+#include "DesktopsDCOP.h"
 
 #define INT8 _X11INT8
 #define INT32 _X11INT32
@@ -116,7 +119,10 @@ Application::Application( )
     atoms = new Atoms;
     
     // create workspace.
-    (void) new Workspace( isSessionRestored() );
+    Workspace *wrkSpc = new Workspace( isSessionRestored() );
+    (void *) new WindowsDCOP(*wrkSpc);
+    (void *) new DesktopsDCOP(*wrkSpc);
+    (void *) new CursorDCOP();
 
     syncX(); // trigger possible errors, there's still a chance to abort
 
diff -U 3 -dHBbprN kdebase-3.4.3/kwin/Makefile.am kwin.new/Makefile.am
--- kdebase-3.4.3/kwin/Makefile.am	2005-10-05 15:38:59.000000000 +0200
+++ kwin.new/Makefile.am	2005-12-01 18:46:49.000000000 +0100
@@ -10,17 +10,16 @@ bin_PROGRAMS = 
 lib_LTLIBRARIES =
 kdeinit_LTLIBRARIES = kwin.la
 
-kwin_la_SOURCES = workspace.cpp client.cpp placement.cpp atoms.cpp \
-	utils.cpp layers.cpp main.cpp popupinfo.cpp tabbox.cpp \
-	 options.cpp plugins.cpp events.cpp KWinInterface.skel \
-	killwindow.cpp geometrytip.cpp sm.cpp group.cpp bridge.cpp \
-	manage.cpp notifications.cpp activation.cpp useractions.cpp \
-	geometry.cpp rules.cpp
+kwin_la_SOURCES = workspace.cpp client.cpp placement.cpp atoms.cpp utils.cpp \
+	layers.cpp main.cpp popupinfo.cpp tabbox.cpp options.cpp plugins.cpp events.cpp \
+	KWinInterface.skel killwindow.cpp geometrytip.cpp sm.cpp group.cpp bridge.cpp manage.cpp \
+	notifications.cpp activation.cpp useractions.cpp geometry.cpp rules.cpp CursorDCOP.cpp \
+	DesktopsDCOP.cpp WindowsDCOP.cpp WindowsDCOP.skel DesktopsDCOP.skel CursorDCOP.skel
 
 kwin_la_LIBADD = $(LIB_KDEUI) lib/libkdecorations.la
-kwin_la_LDFLAGS = $(all_libraries) -module -avoid-version
+kwin_la_LDFLAGS = -avoid-version -module $(all_libraries)
 
-include_HEADERS = KWinInterface.h
+include_HEADERS = KWinInterface.h DesktopsDCOP.h WindowsDCOP.h CursorDCOP.h
 
 KDE_ICON = kwin
 
diff -U 3 -dHBbprN kdebase-3.4.3/kwin/WindowsDCOP.cpp kwin.new/WindowsDCOP.cpp
--- kdebase-3.4.3/kwin/WindowsDCOP.cpp	1970-01-01 01:00:00.000000000 +0100
+++ kwin.new/WindowsDCOP.cpp	2005-12-01 23:02:28.000000000 +0100
@@ -0,0 +1,505 @@
+//
+// C++ Implementation: WindowsDCOP
+//
+// Description: 
+//
+//
+// Author: Jérôme Pouiller (Jezz) <jerome.pouiller@no-log.org>, (C) 2005
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include <kdebug.h>
+#include "client.h"
+#include "options.h"
+#include "killwindow.h"
+#include "WindowsDCOP.h"
+#include "DesktopsDCOP.h"
+
+namespace KWinInternal {
+  WindowsDCOP   *WindowsDCOP::instance = NULL;
+  /*
+  ** Errors objects
+  **
+  ** These values are returned by get* and is* functions in errors cases
+  ** 
+  */
+  static QPoint  qptError(-1, -1);
+  static QSize   qszError(-1, -1);
+  static QRect   qrError(-1, -1, -1, -1);
+  //static QPixmap qpmError(0, 0);
+  static QString qstrError("Error");
+  static bool    bError(false);
+  static int     iError(-127);
+
+  /*
+  ** Interfaces to WindowsDCOP and Client.
+  **
+  ** These function are hidden for user. It is back office of this interface.
+  ** Notice massive use of reference (and not pointer). Using reference allows
+  ** to be sure that object exist (no null pointer case).
+  */
+  
+  
+  WindowsDCOP::WindowsDCOP(Workspace &wrkspc) : 
+      DCOPObject("Windows"),
+      w(wrkspc), 
+      clients(wrkspc.getClients()) { 
+    if (WindowsDCOP::instance != NULL)
+      kdDebug() << "You shouldn't instanciate two times this classe" << endl;
+    WindowsDCOP::instance = this;
+  }
+  
+  WindowsDCOP& WindowsDCOP::getInstance() {
+    if (WindowsDCOP::instance == NULL)
+      kdDebug() << "Object not yet constructed! Will crash" << endl;
+    return *WindowsDCOP::instance;
+  }
+  /*
+  ** Relative to Position
+  */
+  QPoint WindowsDCOP::getPosition(Client &c) const {
+    return getGeometry(c).topLeft();
+  }
+  
+  void WindowsDCOP::setPosAbs(const QPoint& pos, Client& c) const {
+    c.move(pos);
+  }
+  
+  void WindowsDCOP::setPosRel(const QPoint& pos, Client& c) const {
+    setPosAbs(getPosition(c) + pos, c);
+  }
+  
+  void WindowsDCOP::setPosInteractive(Client& c) {
+    w.performWindowOperation(&c, Options::UnrestrictedMoveOp);
+  }
+
+  /*
+  ** Relative to Size
+  */
+  QRect WindowsDCOP::getGeometry(Client& c) const {
+    return c.geometry();
+  }
+  
+  QSize WindowsDCOP::getSize(Client& c) const {
+    return getGeometry(c).size();
+  }
+  
+  void WindowsDCOP::setSizeAbs(const QSize& size, Client& c) const {
+    c.plainResize(size);
+  }
+  
+  void WindowsDCOP::setSizeRel(const QRect& size, Client& c) const {
+    setPosRel(size.topLeft(), c);
+    setSizeAbs(size.size(), c);
+  }
+  
+  void WindowsDCOP::setSizeInteractive(Client& c) {
+    w.performWindowOperation(&c, Options::UnrestrictedResizeOp);
+  }
+  
+  /*
+  ** Relative to Desktop
+  */
+  int WindowsDCOP::getDesktop(Client &c) const {
+    return c.desktop();
+  }
+  
+  /* NOTICE desktop base is window desktop (not current desktop) */
+  void WindowsDCOP::setDesktop(int value, int dir, Client &c) const {
+    c.setDesktop(DesktopsDCOP::getInstance().getDesktopRel(value, dir,getDesktop(c)));
+  }
+  
+  /*
+  ** Relative to window stack
+  ** TODO : better support of Raise/Lower (setStackRel) See Bug #99429
+  */ 
+  bool WindowsDCOP::isRaised(Client& c) const {
+    Client* topmost = NULL;
+    if (w.most_recently_raised 
+        && w.stacking_order.contains(w.most_recently_raised) 
+        &&  w.most_recently_raised->isShown(true) &&
+        c.isOnCurrentDesktop())
+      topmost = w.most_recently_raised;
+    else
+      topmost = w.topClientOnDesktop(c.isOnAllDesktops() ? w.currentDesktop() : c.desktop());
+    return (&c == topmost);
+  }
+  
+  void WindowsDCOP::raiseOrLower(bool value, Client& c) {
+    if (value)
+      w.raiseClient(&c);
+    else
+      w.lowerClient(&c);
+  }
+  
+  /*
+  ** -1 Bellow
+  **  0 Normal
+  **  1 Above
+  */
+  int WindowsDCOP::getKeepLayoutSetting(Client& c) const {
+    if (c.keepBelow())
+      return -1;
+    if (c.keepAbove())
+      return 1;
+    return 0;
+  }
+
+  void WindowsDCOP::setKeepAbove(bool value, Client& c) const {
+    c.setKeepAbove(value);
+  }
+  
+  void WindowsDCOP::setKeepBelow(bool value, Client& c) const {
+    c.setKeepBelow(value);
+  }
+
+  /*
+  ** Relative to State (Minimized, Maximized, Fullscreen, Shaded, Sticky, 
+  ** SkipTaskBar, SkipPager...)
+  */ 
+  bool WindowsDCOP::isMinimized(Client& c) const {
+    return c.isMinimized();
+  }
+  
+  void WindowsDCOP::setMinimized(bool value, Client& c) const {
+    if (value)
+      c.minimize();
+    else
+      c.unminimize();
+  }
+  
+  bool WindowsDCOP::isMaximized(Client& c) const {
+    return c.maximizeMode() & Client::MaximizeFull;
+  }
+  
+  void WindowsDCOP::setMaximized(bool value, Client& c) const {
+    c.setMaximize(value, value); 
+  }
+
+  bool WindowsDCOP::isFullscreen(Client& c) const {
+    return c.isFullScreen();
+  }
+  
+  void WindowsDCOP::setFullscreen(bool value, Client& c) const {
+    c.setFullScreen(value, true);
+  }
+  
+  bool WindowsDCOP::isShaded(Client& c) const {
+    return c.shadeMode() != ShadeNone;
+  }
+  
+  void WindowsDCOP::setShaded(bool value, Client& c) const {
+    c.setShade(value ? ShadeNormal : ShadeNone);
+  }
+  
+  bool WindowsDCOP::isBorderless(Client& c) const {
+    return c.noBorder();
+  }
+  
+  void WindowsDCOP::setBorderless(bool value, Client& c) const {
+    c.setUserNoBorder(value);
+  }
+
+  bool WindowsDCOP::isSticky(Client &c) const {
+    return c.isOnAllDesktops();
+  }
+  
+  void WindowsDCOP::setSticky(bool value, Client &c) const {
+    c.setOnAllDesktops(value);
+  }
+  
+  bool WindowsDCOP::isSkipTaskbar(Client& c) const {
+    /* FIXME, what is this argument ? What means from outside ? */
+    return c.skipTaskbar(true);
+  }
+  
+  void WindowsDCOP::setSkipTaskbar(bool value, Client& c) const {
+    /* FIXME, what is this argument ? What means from outside ? */
+    c.setSkipTaskbar(value, true);
+  }
+  
+  bool WindowsDCOP::isSkipPager(Client& c) const {
+    return c.skipPager();
+  }
+  
+  void WindowsDCOP::setSkipPager(bool value, Client& c) const {
+    c.setSkipPager(value);
+  }
+  
+  /*
+  ** 0x0000 NormalState/Nothing
+  ** 0x0001 SystrayState // Not Yet Implemented
+  ** 0x0002 MinimizedState aka IconicState
+  ** 0x0004 VMaximizedState, 
+  ** 0x0008 HMaximizedState, // Not Yet Implemented
+  ** 0x0010 FullScreenState
+  ** 0x0020 Shaded
+  ** 0x0040 Borderless
+  ** 0x0080 KeepAbove
+  ** 0x0100 KeepBelow
+  ** 0x0200 IgnorePager
+  ** 0x0400 IgnoreTaskbar
+  ** 0x0800 IsMovable  // Not Yet Implemented
+  ** 0x1000 IsResizable // Not Yet Implemented
+  ** 0x2000 IsClosable // Not Yet Implemented
+  */
+  unsigned WindowsDCOP::getState(Client& c) const {
+    unsigned ret = 0x00;
+//    if (isSystray(c))
+//      ret |= 0x001;
+    if (isMinimized(c))
+      ret |= 0x002;
+    if (isMaximized(c))
+      ret |= 0x004;
+    if (isFullscreen(c))
+      ret |= 0x010;
+    if (isShaded(c))
+      ret |= 0x020;
+    if (isBorderless(c))
+      ret |= 0x040;
+    int res = getKeepLayoutSetting(c);
+    if (res > 0)
+      ret |= 0x080;
+    if (res < 0)
+      ret |= 0x100;
+    if (isSkipPager(c))
+      ret |= 0x200;
+    if (isSkipTaskbar(c))
+      ret |= 0x400;
+    return ret;
+  }
+ 
+  void WindowsDCOP::setState(unsigned value, Client& c) const {
+//    setSystray(state & 0x001, c);
+    setMinimized(value & 0x002, c);
+    setMaximized(value & 0x004, c);
+    setFullscreen(value & 0x010, c);
+    setShaded(value & 0x020, c);
+    setBorderless(value & 0x040, c);
+    setKeepAbove(value & 0x080, c);
+    setKeepBelow(value & 0x100, c);
+    setSkipPager(value & 0x200, c);
+    setSkipTaskbar(value & 0x400 , c);
+  } 
+
+  /*
+  ** Relative to Focus
+  */
+  void WindowsDCOP::setFocus(Client &c) {
+    w.requestFocus(&c, false);
+  }
+
+  /*
+  ** Relative to other ressources of Client (Icons and Shortcuts)
+  */
+  QPixmap WindowsDCOP::getSnapshot(Client& c) const {
+    return QPixmap::grabWindow(c.frameId());
+  }
+  
+  QPixmap WindowsDCOP::getIcon(Client& c) const {
+    return c.icon();
+  }
+  
+//   QPixmap& WindowsDCOP::setIcon(const QPixmap& icon, Client& c) {
+//     return c.icon();
+//   }
+  
+  QPixmap WindowsDCOP::getMiniIcon(Client& c) const {
+    return c.miniIcon();
+  }
+  
+//   QPixmap& WindowsDCOP::setMiniIcon(const QPixmap& icon, Client& c, QPixmap icon) {
+//     return c.miniIcon();
+//   }
+  
+//    KShortcut& WindowsDCOP::getShortcut(Client& c) {
+//      return c.shortcut();
+//    }
+
+  void WindowsDCOP::setShortcut(const QString& sc, Client& c) const {
+    c.setShortcut(sc);
+  }
+  
+  void WindowsDCOP::setShortcutInteractive(Client& c) {
+    w.performWindowOperation(&c, Options::SetupWindowShortcutOp);
+  }
+
+  // pid_t == unsigned int
+  pid_t WindowsDCOP::getPid(Client& c) const {
+    return c.pid();
+  }
+  
+  /*
+  ** Relative to destroying client
+  */
+  void WindowsDCOP::close(Client& c) const {
+    c.closeWindow();
+  }
+  
+  void WindowsDCOP::kill(Client& c) const {
+    c.killWindow();
+  }
+  
+  void WindowsDCOP::killInteractive() const {
+    /* FIXME : Ctor argument seems useless */
+    KillWindow(NULL).start();
+  }
+
+  /*
+  **
+  ** Interface with user.
+  **
+  ** Theses function check arguments and convert them in better objects for
+  ** back-office functions. They can be considerated as front-office of this 
+  ** interface. There is no intelligence here and they are independant from
+  ** implementation.
+  **
+  */
+
+  /*
+  ** Helper macro
+  */
+/* 
+** In most cases, it's fast to call COND and slow to call FUN, 
+** so we don't call FUN if not needed
+*/
+#define SETCOND_HELPER(COND, FUN)                     \
+  void WindowsDCOP::FUN(int status, tWinId winId) {   \
+    Client *c = getClient(winId);                     \
+    if (c) {                                          \
+      bool cur = COND(*c);                            \
+      if (status >= 0 && !cur)                        \
+        FUN(true, *c);                                \
+      else if (status <= 0 && cur)                    \
+        FUN(false, *c);                               \
+    }                                                 \
+  }
+  
+#define SET0_HELPER(FUN)                              \
+  void WindowsDCOP::FUN(tWinId winId) {               \
+    Client *c = getClient(winId);                     \
+    if (c)                                            \
+      FUN(*c);                                        \
+  }
+  
+#define SET1_HELPER(FUN, ARG_TYPE)                    \
+  void WindowsDCOP::FUN(ARG_TYPE arg, tWinId winId) { \
+    Client *c = getClient(winId);                     \
+    if (c)                                            \
+      FUN(arg, *c);                                   \
+  }
+
+#define GET_HELPER(FUN, TYPE, ERROR)                  \
+  TYPE WindowsDCOP::FUN(tWinId winId) const {         \
+    Client *c = getClient(winId);                     \
+    if (c)                                            \
+      return FUN(*c);                                 \
+    return ERROR;                                     \
+  }
+  
+  /* 
+  ** Common functions
+  */
+  Client *WindowsDCOP::getClient(unsigned long winId) const {
+    if (winId == 0)
+      return w.active_popup_client ? w.active_popup_client : w.active_client;
+    for (ClientList::ConstIterator it = clients.begin();
+         it != clients.end(); ++it)
+      if (winId == (*it)->window())
+        return *it;
+    return NULL;
+  }
+
+  unsigned long WindowsDCOP::getCurWinId() const {
+    Client* c = w.active_popup_client ? w.active_popup_client : w.active_client;
+    if (c)
+      return c->window();
+    return 0L;
+  }
+  
+  SET0_HELPER(setFocus)
+  GET_HELPER(getDesktop, int, iError)
+  void WindowsDCOP::setDesktop(int value, int dir, unsigned long winId) {
+    Client *c = getClient(winId);
+    if (c)
+      setDesktop(value, dir, *c);
+  }
+  GET_HELPER(getPosition, const QPoint, qptError)     
+  SET1_HELPER(setPosAbs, const QPoint&)
+  SET1_HELPER(setPosRel, const QPoint&)
+  SET0_HELPER(setPosInteractive)
+  GET_HELPER(getGeometry, const QRect, qrError)  
+  GET_HELPER(getSize, const QSize, qszError)  
+  SET1_HELPER(setSizeAbs, const QSize&)
+  SET1_HELPER(setSizeRel, const QRect&)
+  SET0_HELPER(setSizeInteractive)
+  /* FIXME Memory leak (use processDynamic) */
+  GET_HELPER(getSnapshot, QPixmap, *(new QPixmap(0, 0)))
+  /* FIXME Memory leak (use processDynamic) */
+  GET_HELPER(getIcon, const QPixmap, *(new QPixmap(0, 0)))
+  //SET1_HELPER(setIcon, const QPixmap&)
+  /* FIXME Memory lack (use processDynamic) */
+  GET_HELPER(getMiniIcon, const QPixmap, *(new QPixmap(0, 0)))
+  //SET1_HELPER(setMiniIcon, const QPixmap&)
+  //GET_HELPER(getShortcut, KShortcut, kscError)
+  SET1_HELPER(setShortcut, const QString&)
+  SET0_HELPER(setShortcutInteractive)
+  GET_HELPER(getPid, uint, iError)
+  GET_HELPER(isRaised, bool, bError)
+  SETCOND_HELPER(isRaised, raiseOrLower) 
+  GET_HELPER(getKeepLayoutSetting, int, iError)
+  void WindowsDCOP::setKeepAbove(int status, unsigned long winId) {
+    Client *c = getClient(winId);
+    if (c) {
+      bool res;
+      if (status > 0)
+        res = true;
+      else if (status < 0)
+        res = false;
+      else
+        if (getKeepLayoutSetting(*c) > 0)
+          res = false;
+        else
+          res = true;
+      setKeepAbove(res, *c);
+    }
+  }
+  void WindowsDCOP::setKeepBelow(int status, unsigned long winId) {
+    Client *c = getClient(winId);
+    if (c) {
+      bool res;
+      if (status > 0)
+        res = true;
+      else if (status < 0)
+        res = false;
+      else
+        if (getKeepLayoutSetting(*c) < 0)
+          res = false;
+        else
+          res  = true;
+      setKeepBelow(res, *c);
+    }
+  }
+  GET_HELPER(isMinimized, bool, bError);
+  SETCOND_HELPER(isMinimized, setMinimized) 
+  GET_HELPER(isMaximized, bool, bError);
+  SETCOND_HELPER(isMaximized, setMaximized) 
+  GET_HELPER(isFullscreen, bool, bError);
+  SETCOND_HELPER(isFullscreen, setFullscreen) 
+  GET_HELPER(isShaded, bool, bError);
+  SETCOND_HELPER(isShaded, setShaded) 
+  GET_HELPER(isBorderless, bool, bError);
+  SETCOND_HELPER(isBorderless, setBorderless) 
+  GET_HELPER(isSticky, bool, bError);
+  SETCOND_HELPER(isSticky, setSticky) 
+  GET_HELPER(isSkipTaskbar, bool, bError);
+  SETCOND_HELPER(isSkipTaskbar, setSkipTaskbar) 
+  GET_HELPER(isSkipPager, bool, bError);
+  SETCOND_HELPER(isSkipPager, setSkipPager) 
+  GET_HELPER(getState, unsigned, iError);
+  SET1_HELPER(setState, unsigned)
+  SET0_HELPER(close)
+  SET0_HELPER(kill)
+  
+} // namespace
diff -U 3 -dHBbprN kdebase-3.4.3/kwin/WindowsDCOP.h kwin.new/WindowsDCOP.h
--- kdebase-3.4.3/kwin/WindowsDCOP.h	1970-01-01 01:00:00.000000000 +0100
+++ kwin.new/WindowsDCOP.h	2005-12-01 23:01:35.000000000 +0100
@@ -0,0 +1,146 @@
+//
+// C++ Interface: WindowsDCOP
+//
+// Description: 
+//
+//
+// Author: Jérôme Pouiller (Jezz) <jerome.pouiller@no-log.org>, (C) 2005
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#ifndef WINDOWS_DCOP_H
+#define WINDOWS_DCOP_H
+
+#include <qpixmap.h>
+#include <qpoint.h>
+#include <qrect.h>
+#include <qsize.h>
+
+#include <dcopobject.h>
+
+#include "workspace.h"
+#include "utils.h"
+
+namespace KWinInternal {
+
+typedef unsigned long tWinId;
+
+class WindowsDCOP : public DCOPObject {
+  K_DCOP
+  
+  public:
+    WindowsDCOP(Workspace&);
+    static WindowsDCOP& getInstance();
+    
+  k_dcop:
+    unsigned long getCurWinId() const;
+    void          setFocus(unsigned long winId = 0);
+    int           getDesktop(unsigned long winId = 0) const;
+    void          setDesktop(int value, int dir, unsigned long winId);
+    bool          isSticky(unsigned long winId = 0) const;
+    void          setSticky(int status, unsigned long winId = 0);
+    const QPoint  getPosition(unsigned long winId = 0) const;
+    void          setPosAbs(const QPoint& pos, unsigned long winId = 0);
+    void          setPosRel(const QPoint& pos, unsigned long winId = 0);
+    void          setPosInteractive(unsigned long winId = 0);
+    const QRect   getGeometry(unsigned long winId = 0) const;
+    const QSize   getSize(unsigned long winId = 0) const;
+    void          setSizeAbs(const QSize& size, unsigned long winId = 0);
+    void          setSizeRel(const QRect& size, unsigned long winId = 0);
+    void          setSizeInteractive(unsigned long winId = 0);
+          QPixmap getSnapshot(unsigned long winId = 0) const;
+    const QPixmap getIcon(unsigned long winId = 0) const;
+//     const QPixmap setIcon(QPixmap icon, unsigned long winId = 0);
+    const QPixmap getMiniIcon(unsigned long winId = 0) const;
+//     const QPixmap setMiniIcon(QPixmap icon, unsigned long winId = 0);
+//     KShortcut getShortcut(unsigned long winId = 0);
+    void      setShortcut(const QString& sc, unsigned long winId = 0);
+    void      setShortcutInteractive(unsigned long winId = 0);
+    uint      getPid(unsigned long winId = 0) const;
+    bool      isRaised(unsigned long winId = 0) const;
+    void      raiseOrLower(int status, unsigned long winId = 0);
+    int       getKeepLayoutSetting(unsigned long winId = 0) const;
+    void      setKeepAbove(int status, unsigned long winId = 0);
+    void      setKeepBelow(int status, unsigned long winId = 0);
+    bool      isSkipTaskbar(unsigned long winId = 0) const;
+    void      setSkipTaskbar(int status, unsigned long winId = 0);
+    bool      isSkipPager(unsigned long winId = 0) const;
+    void      setSkipPager(int status, unsigned long winId = 0);
+    unsigned  getState(unsigned long winId = 0) const;
+    void      setState(unsigned status, unsigned long winId = 0);
+    bool      isMinimized(unsigned long winId = 0) const;
+    void      setMinimized(int status, unsigned long winId = 0);
+    bool      isMaximized(unsigned long winId = 0) const;
+    void      setMaximized(int status, unsigned long winId = 0);
+    bool      isFullscreen(unsigned long winId = 0) const;
+    void      setFullscreen(int status, unsigned long winId = 0);
+    bool      isShaded(unsigned long winId = 0) const;
+    void      setShaded(int status, unsigned long winId = 0);
+    bool      isBorderless(unsigned long winId = 0) const;
+    void      setBorderless(int status, unsigned long winId = 0);
+    void      close(unsigned long winId = 0);
+    void      kill(unsigned long winId = 0);
+    void      killInteractive() const;
+    /* Because of its asyncronous aspect,     */
+    /* It must be treated with processDynamic */
+    //unsigned long getWindowInteractive();
+  
+  public:
+    Client* getClient(unsigned long winId) const;
+    void   setFocus(Client& c);
+    int    getDesktop(Client& c) const;
+    void   setDesktop(int value, int dir, Client& c) const;
+    bool   isSticky(Client& c) const;
+    void   setSticky(bool, Client& c) const;
+    QPoint getPosition(Client& c) const;
+    void   setPosAbs(const QPoint& pos, Client& c) const;
+    void   setPosRel(const QPoint& pos, Client& c) const;
+    void   setPosInteractive(Client& c);
+    QRect getGeometry(Client& c) const;
+    QSize getSize(Client& c) const;
+    void   setSizeAbs(const QSize& size, Client& c) const;
+    void   setSizeRel(const QRect& size, Client& c) const;
+    void   setSizeInteractive(Client& c);
+    QPixmap getSnapshot(Client& c) const;
+    QPixmap getIcon(Client& c) const;
+//     const QPixmap& setIcon(QPixmap icon, Client& c);
+    QPixmap getMiniIcon(Client& c) const;
+//     const QPixmap& setMiniIcon(QPixmap icon, Client& c);
+//     const KShortcut& getShortcut(Client& c);
+     void    setShortcut(const QString& sc, Client& c) const;
+     void    setShortcutInteractive(Client& c);
+     pid_t   getPid(Client& c) const;
+     bool    isRaised(Client& c) const;
+     void    raiseOrLower(bool, Client& c);
+     int     getKeepLayoutSetting(Client& c) const;
+     void    setKeepAbove(bool, Client& c) const;
+     void    setKeepBelow(bool, Client& c) const;
+     bool    isSkipTaskbar(Client& c) const;
+     void    setSkipTaskbar(bool, Client& c) const;
+     bool    isSkipPager(Client& c) const;
+     void    setSkipPager(bool, Client& c) const;
+     unsigned getState(Client& c) const;
+     void    setState(unsigned, Client& c) const;
+     bool    isMinimized(Client& c) const;
+     void    setMinimized(bool, Client& c) const;
+     bool    isMaximized(Client& c) const;
+     void    setMaximized(bool, Client& c) const;
+     bool    isFullscreen(Client& c) const;
+     void    setFullscreen(bool, Client& c) const;
+     bool    isShaded(Client& c) const;
+     void    setShaded(bool, Client& c) const;
+     bool    isBorderless(Client& c) const;
+     void    setBorderless(bool, Client& c) const;
+     void    close(Client& c) const;
+     void    kill(Client& c) const;
+
+  private:
+    static WindowsDCOP* instance;
+    Workspace&          w;
+    const ClientList&   clients;
+};
+
+}
+#endif /* WINDOWS_DCOP_H */
diff -U 3 -dHBbprN kdebase-3.4.3/kwin/workspace.cpp kwin.new/workspace.cpp
--- kdebase-3.4.3/kwin/workspace.cpp	2005-10-05 15:38:59.000000000 +0200
+++ kwin.new/workspace.cpp	2005-12-01 18:46:49.000000000 +0100
@@ -64,6 +64,9 @@ bool allowKompmgrRestart = TRUE;
 // comments. I dissagree that further splittings makes it easier. 2500
 // lines are not too much. It's the task that is complex, not the
 // code.
+
+// Jezz : I'm agree with Rikkus. Kwin is made in C++, not in C. We can have
+// classes, let's use it.
 Workspace::Workspace( bool restore )
   : DCOPObject        ("KWinInterface"),
     QObject           (0, "workspace"),
@@ -474,6 +477,10 @@ Client* Workspace::createClient( Window 
     return c;
     }
 
+const ClientList& Workspace::getClients() const {
+  return clients;
+}
+
 void Workspace::addClient( Client* c, allowed_t )
     {
     // waited with trans settings until window figured out if active or not ;)
diff -U 3 -dHBbprN kdebase-3.4.3/kwin/workspace.h kwin.new/workspace.h
--- kdebase-3.4.3/kwin/workspace.h	2005-10-05 15:38:59.000000000 +0200
+++ kwin.new/workspace.h	2005-12-01 21:42:52.000000000 +0100
@@ -102,6 +102,8 @@ class Workspace : public QObject, public
 
         bool initializing() const;
 
+        const ClientList &getClients() const;
+
         /**
          * Returns the active client, i.e. the client that has the focus (or None
          * if no client has the focus)
@@ -271,6 +273,8 @@ class Workspace : public QObject, public
         
         void toggleTopDockShadows(bool on);
 
+        void calcDesktopLayout(int &x, int &y) const;
+
     public slots:
         void refresh();
     // keybindings
@@ -451,8 +455,6 @@ class Workspace : public QObject, public
     
         void helperDialog( const QString& message, const Client* c );
 
-        void calcDesktopLayout(int &x, int &y) const;
-
         QPopupMenu* clientPopup();
         void closeActivePopup();
 
@@ -465,8 +467,10 @@ class Workspace : public QObject, public
         QMemArray<int> desktop_focus_chain;
 
         QWidget* active_popup;
+public:
         Client* active_popup_client;
 
+private:
         QWidget* desktop_widget;
 
         void loadSessionInfo();
@@ -481,12 +485,14 @@ class Workspace : public QObject, public
         static NET::WindowType txtToWindowType( const char* txt );
         static bool sessionInfoWindowTypeMatch( Client* c, SessionInfo* info );
 
+public:
         Client* active_client;
         Client* last_active_client;
         Client* most_recently_raised; // used _only_ by raiseOrLowerClient()
         Client* movingClient;
         Client* pending_take_activity;
 
+private:
     // delay(ed) window focus timer and client
         QTimer* delayFocusTimer;
         Client* delayfocus_client;
@@ -495,7 +501,9 @@ class Workspace : public QObject, public
         ClientList desktops;
 
         ClientList unconstrained_stacking_order;
+public:
         ClientList stacking_order;
+private:
         ClientList focus_chain;
         ClientList should_get_focus; // last is most recent
         ClientList attention_chain;

