diff -ur src/bar.cpp ../../superkaramba/src/bar.cpp
--- src/bar.cpp	2003-07-06 19:11:45.000000000 -0400
+++ ../../superkaramba/src/bar.cpp	2003-08-24 11:31:24.000000000 -0400
@@ -104,7 +104,7 @@
 }
 
 
-void Bar::mUpdate( QPainter *p )
+void Bar::mUpdate( MeterPainter *p )
 {
     int x, y, width, height;
     x = getX();
Only in ../../superkaramba/src: bar.cpp~
diff -ur src/bar.h ../../superkaramba/src/bar.h
--- src/bar.h	2003-07-06 18:54:40.000000000 -0400
+++ ../../superkaramba/src/bar.h	2003-08-24 11:36:08.000000000 -0400
@@ -20,7 +20,7 @@
     Bar( int ix,int iy,int iw,int ih );
     ~Bar();
 
-    void mUpdate( QPainter * );
+    void mUpdate( MeterPainter * );
 
 
 public slots:
Only in ../../superkaramba/src: bar.h~
diff -ur src/clickarea.cpp ../../superkaramba/src/clickarea.cpp
--- src/clickarea.cpp	2003-06-14 15:21:08.000000000 -0400
+++ ../../superkaramba/src/clickarea.cpp	2003-08-24 11:31:29.000000000 -0400
@@ -59,7 +59,7 @@
     return rect;
 }
 
-void ClickArea::mUpdate( QPainter *p )
+void ClickArea::mUpdate( MeterPainter *p )
 {
 
     p->drawRect(boundingBox);
Only in ../../superkaramba/src: clickarea.cpp~
diff -ur src/clickarea.h ../../superkaramba/src/clickarea.h
--- src/clickarea.h	2003-06-14 15:21:08.000000000 -0400
+++ ../../superkaramba/src/clickarea.h	2003-08-24 11:36:11.000000000 -0400
@@ -32,7 +32,7 @@
 
     QRect getRectangle();
 
-    void mUpdate( QPainter* );
+    void mUpdate( MeterPainter* );
     void setValue( int );
     void setValue( QString );
 
Only in ../../superkaramba/src: clickarea.h~
diff -ur src/clickmap.cpp ../../superkaramba/src/clickmap.cpp
--- src/clickmap.cpp	2003-06-14 15:21:08.000000000 -0400
+++ ../../superkaramba/src/clickmap.cpp	2003-08-24 11:31:35.000000000 -0400
@@ -53,7 +53,7 @@
   return false;
 }
 
-void ClickMap::mUpdate( QPainter *p )
+void ClickMap::mUpdate( MeterPainter *p )
 {
     int i = 0; //text.getLineHeight();
     int row = 1;
Only in ../../superkaramba/src: clickmap.cpp~
diff -ur src/clickmap.h ../../superkaramba/src/clickmap.h
--- src/clickmap.h	2003-06-14 15:21:08.000000000 -0400
+++ ../../superkaramba/src/clickmap.h	2003-08-24 11:36:14.000000000 -0400
@@ -28,7 +28,7 @@
     ~ClickMap();
 
     virtual bool click( QMouseEvent* );
-    void mUpdate( QPainter* );
+    void mUpdate( MeterPainter* );
     void setValue( QString );
     void setValue( int );
     void setTextProps( TextField * );
Only in ../../superkaramba/src: clickmap.h~
diff -ur src/graph.cpp ../../superkaramba/src/graph.cpp
--- src/graph.cpp	2003-06-14 15:21:08.000000000 -0400
+++ ../../superkaramba/src/graph.cpp	2003-08-24 11:31:38.000000000 -0400
@@ -66,7 +66,7 @@
 }
 
 
-void Graph::mUpdate(QPainter *p)
+void Graph::mUpdate(MeterPainter *p)
 {
     double step = (getWidth() / (nbrPoints-1.001));
     double xPos = 0;
Only in ../../superkaramba/src: graph.cpp~
diff -ur src/graph.h ../../superkaramba/src/graph.h
--- src/graph.h	2003-04-21 09:17:03.000000000 -0400
+++ ../../superkaramba/src/graph.h	2003-08-24 11:36:17.000000000 -0400
@@ -28,7 +28,7 @@
   void setMax( int );
 
   void setColor(int, int, int);
-  void mUpdate( QPainter * );
+  void mUpdate( MeterPainter * );
 
 private:
 int* values;
Only in ../../superkaramba/src: graph.h~
Only in ../../superkaramba/src: htmllabel.h~
diff -ur src/imagelabel.cpp ../../superkaramba/src/imagelabel.cpp
--- src/imagelabel.cpp	2003-06-17 16:04:28.000000000 -0400
+++ ../../superkaramba/src/imagelabel.cpp	2003-08-26 18:56:26.000000000 -0400
@@ -274,7 +274,7 @@
   rect_off = QRect(getX(),getY(),pixmapWidth,pixmapHeight);
 }
 
-void ImageLabel::mUpdate(QPainter* p, int backgroundUpdate)
+void ImageLabel::mUpdate(MeterPainter* p, int backgroundUpdate)
 {
   if (backgroundUpdate == 1){
   //only draw image if not hidden
@@ -303,7 +303,7 @@
 }
 }
 
-void ImageLabel::mUpdate(QPainter* p)
+void ImageLabel::mUpdate(MeterPainter* p)
 {
   //only draw image if not hidden
   if (hidden == 0 && background == 0) {
Only in ../../superkaramba/src: imagelabel.cpp~
diff -ur src/imagelabel.h ../../superkaramba/src/imagelabel.h
--- src/imagelabel.h	2003-06-14 16:43:23.000000000 -0400
+++ ../../superkaramba/src/imagelabel.h	2003-08-24 11:36:25.000000000 -0400
@@ -99,8 +99,8 @@
   
   void rotate(int);
   void removeImageTransformations();
-  void mUpdate( QPainter * );
-  void mUpdate( QPainter *, int );
+  void mUpdate( MeterPainter * );
+  void mUpdate( MeterPainter *, int );
 
   void rolloverImage(QMouseEvent *e);
   void parseImages( QString fn, QString fn_roll, int, int, int, int );
Only in ../../superkaramba/src: imagelabel.h~
diff -ur src/karamba.cpp ../../superkaramba/src/karamba.cpp
--- src/karamba.cpp	2003-08-18 22:29:37.000000000 -0400
+++ ../../superkaramba/src/karamba.cpp	2003-08-26 19:09:04.000000000 -0400
@@ -997,8 +997,10 @@
 
   currTheme->widgetMask = new QBitmap(path);
 
+#ifdef CHANDAN_CLEANUP 
   currTheme->kroot->stop();
   delete currTheme->kroot;
+#endif /* CHANDAN_CLEANUP  */
 
   //  currTheme->setMask(*(currTheme->widgetMask));
 
@@ -1006,8 +1008,10 @@
   currTheme->setMask(blah);
 
 
+#ifdef CHANDAN_CLEANUP 
   currTheme->kroot = new KarambaRootPixmap((QWidget*)currTheme);
   currTheme->kroot->start();
+#endif /* CHANDAN_CLEANUP  */
 
   return (int)currTheme->widgetMask;
 }
@@ -1716,7 +1720,9 @@
 /* now a method we need to expose to Python */
 long redrawWidgetBackground(long widget) {
   karamba* currTheme = (karamba*)widget;
+#ifdef CHANDAN_CLEANUP 
   currTheme->kroot->repaint(true);
+#endif /* CHANDAN_CLEANUP  */
   return 1;
 }
 
@@ -1964,13 +1970,37 @@
     widgetMask = 0;
     info = new NETWinInfo( qt_xdisplay(), winId(), qt_xrootwin(), NET::WMState );
 
-
     kWinModule = new KWinModule();
-    connect( kWinModule,SIGNAL(currentDesktopChanged(int)), this,SLOT(currentDesktopChanged(int)) );
+    desktop = 0; //kWinModule->currentDesktop();
+    printf ("Started on desktop %d\n", desktop);
+//--    connect( kWinModule,SIGNAL(currentDesktopChanged(int)), this,SLOT(currentDesktopChanged(int)) );
 
     themeConfMenu = new KPopupMenu( this);
     themeConfMenu -> setCheckable(true);
 
+    /* XXX - need to be able to delete all these DesktopChangeSlot objects */
+    DesktopChangeSlot *dslot;
+    int mid;
+
+    toDesktopMenu = new KPopupMenu (this);
+    toDesktopMenu -> setCheckable(true);
+    mid = toDesktopMenu -> insertItem ("&All Desktops", 
+                                 dslot = new DesktopChangeSlot(this,0), 
+                                 SLOT(receive()));
+    dslot->setMenuId(mid);
+
+    toDesktopMenu -> insertSeparator();
+    for (int ndesktop=1; ndesktop <= kWinModule->numberOfDesktops(); ndesktop++)
+    {
+        QString name = "Desktop &";
+        name += ('0' + ndesktop);
+
+        mid = toDesktopMenu -> insertItem (name,
+                                     dslot = new DesktopChangeSlot(this, ndesktop),
+                                           SLOT(receive()));
+        dslot->setMenuId(mid);
+    }        
+                           
     kpop = new KPopupMenu( this );
     kpop -> setCheckable(true);
 
@@ -1991,9 +2021,14 @@
                    CTRL+Key_L, this, SLOT( slotToggleLocked() ), accColl  , "Locked position" );
     accColl->insert(toggleLocked);
     toggleLocked -> setChecked(true);
-
     toggleLocked->plug(kpop);
 
+    toggleOnTop = new KToggleAction (  tr("Toggle &On Top"), SmallIconSet("up"),
+                   CTRL+Key_T, this, SLOT( slotToggleOnTop() ), accColl  , "On top" );
+    accColl->insert(toggleOnTop);
+    toggleOnTop -> setChecked(false);
+    toggleOnTop -> plug(kpop);
+
     toggleFastTransforms = new KToggleAction(tr("Use &fast image scaling"),
        CTRL+Key_F, this, SLOT( slotToggleFastTransforms() ), accColl, "Fast transformations");
 
@@ -2009,6 +2044,8 @@
     kpop->insertItem(tr("&Edit"), keditpop);
     kpop->insertItem(tr("Configure &theme"), themeConfMenu);
     kpop->setItemEnabled(THEMECONF, false);
+    kpop->insertItem(tr("To Des&ktop"), toDesktopMenu);
+    
     kpop->insertItem( SmallIconSet("reload3"),tr("&Reload theme"),this,SLOT(reloadConfig()), CTRL+Key_R );
     kpop->insertItem( SmallIconSet("fileclose"),tr("&Close this theme"), this, SLOT(killWidget()), CTRL+Key_C );
 
@@ -2060,8 +2097,10 @@
     }
     else
     {
+#ifdef CHANDAN_CLEANUP 
         kroot = new KarambaRootPixmap((QWidget*)this);
         kroot->start();
+#endif /* CHANDAN_CLEANUP  */
 
 
     }
@@ -2073,12 +2112,31 @@
         slotToggleLocked();
     }
 
+    if (config -> readBoolEntry("onTop", true))
+    {
+        toggleLocked -> setChecked(true);
+        slotToggleLocked();
+    }
+
     if (!config -> readBoolEntry("fastTransforms", true))
     {
         toggleFastTransforms -> setChecked(false);
         slotToggleFastTransforms();
     }
 
+    desktop = config -> readNumEntry("desktop", desktop);
+    if (desktop > kWinModule->numberOfDesktops())
+    {
+        desktop = 0;
+    }
+
+    if (desktop)
+    {
+        info->setDesktop( desktop );
+    }
+    else
+        info->setDesktop( NETWinInfo::OnAllDesktops);
+
     // Read Themespecific Config Entries
     config -> setGroup("theme");
     if (config -> hasKey("widgetPosX") && config -> hasKey("widgetPosY"))
@@ -2092,7 +2150,7 @@
     
     haveUpdated = 0;
     this->setMouseTracking(true);
-
+    this->setAutoMask(true);
 
 //     KParts::ReadOnlyPart* m_part;
 
@@ -2149,6 +2207,8 @@
 
     if( toggleLocked != 0)
         delete toggleLocked;
+    if( toggleOnTop != 0)
+        delete toggleOnTop;
     if( accColl != 0)
         delete accColl;
     if ( menuAccColl != 0)
@@ -2233,6 +2293,9 @@
                 toggleLocked->setChecked( getBoolean( "LOCKED", line ) );
                 slotToggleLocked();
 
+                toggleOnTop->setChecked( getBoolean( "ONTOP", line ) );
+                slotToggleOnTop();
+
 
                 getInt( "X",line );
                 getInt( "Y",line );
@@ -2272,28 +2335,43 @@
                     }
 
                 pm = QPixmap(size());
-
+                mask = QBitmap(size());
+                mask.fill(Qt::color0);
+                printf ("Created initial mask @ %p\n", &mask);
                 if( getBoolean("ONTOP", line ) )
                 {
-                    onTop = true;
-                    KWin::setState( winId(), NET::StaysOnTop );
+                    toggleOnTop -> setChecked(true);
+                    slotToggleOnTop();
                 }
 
                 if( getBoolean("MANAGED", line ) ) {
-		  managed = true;
-		  reparent(0, Qt::WType_Dialog | WStyle_Customize | WStyle_NormalBorder|  WRepaintNoErase | WDestructiveClose, pos());
-		  //		    reparent(0,WDestructiveClose, pos());
-		    
-		    
-		} else {
-		  info->setDesktop( NETWinInfo::OnAllDesktops );
-		  info->setState( NETWinInfo::SkipTaskbar | NETWinInfo::SkipPager,NETWinInfo::SkipTaskbar | NETWinInfo::SkipPager );
-		  if (onTop) {
-                    KWin::setState( winId(), NET::StaysOnTop );
+                    managed = true;
+                    reparent(0, Qt::WType_Dialog | WStyle_Customize | WStyle_NormalBorder|  WRepaintNoErase | WDestructiveClose, pos());
+                    //		    reparent(0,WDestructiveClose, pos());
+                    
+                    
+                } else {
+                    info->setState( NETWinInfo::SkipTaskbar | NETWinInfo::SkipPager,NETWinInfo::SkipTaskbar | NETWinInfo::SkipPager );
+                    if (onTop) {
+                        KWin::setState( winId(), NET::StaysOnTop );
+                        
+                    }
+                }
+
+                if (getBoolean("ONALLDESKTOPS", line))
+                {
+                    desktop = 200; // ugly
+                }
+
+#if 0
+                bool dfound=false;
+                int desktop = getInt("DESKTOP", line, dfound);
+                if (dfound)
+                {
+                    info->setDesktop( dfound );
+                }
+#endif
 
-		  }
-		}
-		
                 if( getBoolean("TOPBAR", line ) )
                 {
                     move(x,0);
@@ -3216,6 +3294,7 @@
         PyThreadState_Swap(myThreadState);
 
         pFunc = PyDict_GetItemString(pDict, "meterClicked");
+        printf ("meterClicked callback @ %p\n", pFunc);
 
         if (pFunc && PyCallable_Check(pFunc))
         {
@@ -3233,10 +3312,12 @@
             // if meter is of type RichTextLabel
             if (RichTextLabel* richText = dynamic_cast<RichTextLabel*>(meter))
             {
+                printf ("debug1\n");
                 pValue = PyString_FromString(richText -> anchorAt(e -> x(), e -> y()).ascii());
             }
             else
             {
+                printf ("debug2\n");
                 pValue = PyInt_FromLong((int)meter);
             }
             PyTuple_SetItem(pArgs, 1, pValue);
@@ -3284,6 +3365,7 @@
 
 void karamba::passClick( QMouseEvent *e )
 {
+    printf ("passClick called\n");
 	QObjectListIt it2( *timeList ); // iterate over meters
     while ( it2 != 0 )
     {
@@ -3627,7 +3709,17 @@
             lowerTimer.restart();
         }
     QRect rect = e->rect();
+
+//    printf ("paintEvent : mask @ %p\n", &mask);
+
     bitBlt(this,rect.topLeft(),&pm,rect,Qt::CopyROP);
+//    bitBlt(this,rect.topLeft(),&mask,rect,Qt::CopyROP);
+}
+
+void karamba::updateMask()  // paint clock mask
+{
+//    printf ("updateMask : mask @ %p\n", &mask);
+    setMask( mask );
 }
 
 void karamba::updateSensors()
@@ -3641,6 +3733,7 @@
     QTimer::singleShot( 500, this, SLOT(step()) );
 }
 
+#ifdef CHANDAN_CLEANUP
 void karamba::updateBackground(KSharedPixmap* kpm)
 {
     background = QPixmap(*kpm);
@@ -3675,19 +3768,24 @@
 {
     kroot->repaint( true );
 }
-
+#endif /* CHANDAN CLEANUP */
 
 void karamba::externalStep()
 {
-  QPixmap buffer = QPixmap(size());
-
-  pm = QPixmap(size());
-  buffer.fill(Qt::black);
-
+    QPixmap buffer = QPixmap(size());
+    
+    cout << "externalStep called\n";
+    
+    pm = QPixmap(size());
+    buffer.fill(Qt::black);
+//    buffer.fill(qRgba(0,0,0,0));
+//    mask = convertToMask(buffer);
+    
     QObjectListIt it( *meterList ); // iterate over meters
     p.begin(&buffer);
-    bitBlt(&buffer,0,0,&background,0,Qt::CopyROP);
-
+    
+//    bitBlt(&buffer,0,0,&background,0,Qt::CopyROP);
+    
     while ( it != 0 )
     {
         ((Meter*) *it)->mUpdate(&p);
@@ -3695,7 +3793,39 @@
     }
     p.end();
 
+#if 1
+    // CHANDAN: do the mask
+//    QPixmap pmask = QPixmap(size());
+    mask = QBitmap(size());
+    
+//    printf ("step: got new mask @ %p\n", &mask);
+    mask.fill(Qt::color0);
+    MeterPainter paint;
+    
+    paint.begin( &mask, this );
+    paint.setMaskLock(false);
+    paint.setBrush( color1 );           // use non-transparent color
+    paint.setPen( color1 );
+    paint.setMaskLock(true);
+    
+    QObjectListIt maskit( *meterList ); // iterate over meters
+    while ( maskit != 0 )
+    {
+        TextLabel *meter = (TextLabel *) *maskit;
+        QColor col, bgcol;
+        
+        meter->mUpdate(&paint);
+        
+        ++maskit;
+    }
+    paint.end();
+#endif
+
     bitBlt(&pm,0,0,&buffer,0,Qt::CopyROP);
+
+    if (autoMask())
+        updateMask();    
+
     repaint();
     //    update();
     //    kroot->repaint(true);
@@ -3708,12 +3838,15 @@
     QPixmap buffer = QPixmap(size());
     buffer.fill(Qt::black);
 
+    
     QObjectListIt it( *meterList ); // iterate over meters
     p.begin(&buffer);
-
-    bitBlt(&buffer,0,0,&background,0,Qt::CopyROP);
-
-
+    
+    cout << "step called\n";
+// This one has problems. The background pixmap is just 2 pixels wide
+//    bitBlt(&buffer,0,0,&background,0,Qt::CopyROP);
+    
+    
     while ( it != 0 )
     {
         ((Meter*) *it)->mUpdate(&p);
@@ -3721,64 +3854,104 @@
     }
     p.end();
 
-    bitBlt(&pm,0,0,&buffer,0,Qt::CopyROP);
-    update();
-
-
-    if (pythonThemeExtensionLoaded) {
-
-      // get the global lock
-      PyEval_AcquireLock();
-      // get a reference to the PyInterpreterState
-
-      //Python thread references
-      extern PyThreadState * mainThreadState;
-
-      PyInterpreterState * mainInterpreterState = mainThreadState->interp;
-      // create a thread state object for this thread
-      PyThreadState * myThreadState = PyThreadState_New(mainInterpreterState);
-      PyThreadState_Swap(myThreadState);
-
-      if (haveUpdated == 0) {
-	pFunc = PyDict_GetItemString(pDict, "initWidget");
-	haveUpdated = 1;
-      }
-      else
-	pFunc = PyDict_GetItemString(pDict, "widgetUpdated");
-
-
-      if (pFunc && PyCallable_Check(pFunc)) {
-	pArgs = PyTuple_New(1);
+#if 1
+    // CHANDAN: do the mask
+//    QPixmap pmask = QPixmap(size());
+    mask = QBitmap(size());
+    
+//    printf ("step: got new mask @ %p\n", &mask);
+    mask.fill(Qt::color0);
+    MeterPainter paint;
+    
+    paint.begin( &mask, this );
+    paint.setMaskLock(false);
+    paint.setBrush( color1 );           // use non-transparent color
+    paint.setPen( color1 );
+    paint.setMaskLock(true);
+    
+    QObjectListIt maskit( *meterList ); // iterate over meters
+    while ( maskit != 0 )
+    {
+        TextLabel *meter = (TextLabel *) *maskit;
+        QColor col, bgcol;
+        
+//        col = meter->getColor();
+//        bgcol = meter->getBGColor();
+        
+//        meter->setColor(Qt::color1);
+//        meter->setBGColor(Qt::color1);
+        meter->mUpdate(&paint);
+        
+//        meter->setColor(col);
+//        meter->setBGColor(bgcol);
+        
+        ++maskit;
+    }
+    paint.end();
+#endif
 
-	  pValue = PyInt_FromLong((int)this);
-	  PyTuple_SetItem(pArgs, 0, pValue);
-	
-	pValue = PyObject_CallObject(pFunc, pArgs);
-	if (pValue != NULL) {
-	  Py_DECREF(pValue);
-	}
-	else {
-	  PyErr_Print();
-	  fprintf(stderr,"Call to widgetUpdated failed\n");
-	}
-	Py_DECREF(pArgs);
-      
-      }
-	else {
-	  PyErr_Print();
-	  fprintf(stderr, "Cannot find python widgetUpdated callback function\n");
-	}
+    bitBlt(&pm,0,0,&buffer,0,Qt::CopyROP);
 
-      // swap my thread state out of the interpreter
-      PyThreadState_Swap(NULL);
-      // clear out any cruft from thread state object
-      PyThreadState_Clear(myThreadState);
-      // delete my thread state object
-      PyThreadState_Delete(myThreadState);
-      // release the lock
-      PyEval_ReleaseLock();
+    if (autoMask())
+        updateMask();
 
+    update();
     
+    
+    if (pythonThemeExtensionLoaded) {
+        
+        // get the global lock
+        PyEval_AcquireLock();
+        // get a reference to the PyInterpreterState
+        
+        //Python thread references
+        extern PyThreadState * mainThreadState;
+        
+        PyInterpreterState * mainInterpreterState = mainThreadState->interp;
+        // create a thread state object for this thread
+        PyThreadState * myThreadState = PyThreadState_New(mainInterpreterState);
+        PyThreadState_Swap(myThreadState);
+        
+        if (haveUpdated == 0) {
+            pFunc = PyDict_GetItemString(pDict, "initWidget");
+            haveUpdated = 1;
+        }
+        else
+            pFunc = PyDict_GetItemString(pDict, "widgetUpdated");
+        
+        
+        if (pFunc && PyCallable_Check(pFunc)) {
+            pArgs = PyTuple_New(1);
+            
+            pValue = PyInt_FromLong((int)this);
+            PyTuple_SetItem(pArgs, 0, pValue);
+            
+            pValue = PyObject_CallObject(pFunc, pArgs);
+            if (pValue != NULL) {
+                Py_DECREF(pValue);
+            }
+            else {
+                PyErr_Print();
+                fprintf(stderr,"Call to widgetUpdated failed\n");
+            }
+            Py_DECREF(pArgs);
+            
+        }
+        else {
+            PyErr_Print();
+            fprintf(stderr, "Cannot find python widgetUpdated callback function\n");
+        }
+        
+        // swap my thread state out of the interpreter
+        PyThreadState_Swap(NULL);
+        // clear out any cruft from thread state object
+        PyThreadState_Clear(myThreadState);
+        // delete my thread state object
+        PyThreadState_Delete(myThreadState);
+        // release the lock
+        PyEval_ReleaseLock();
+        
+        
     }
 }
 
@@ -3797,6 +3970,24 @@
 
 }
 
+void karamba::slotToggleOnTop()
+{
+  //    qDebug("toggleLocked");
+    onTop  = toggleOnTop->isChecked();
+    if( toggleOnTop -> isChecked() )
+    {
+        toggleOnTop->setIconSet(SmallIconSet("down"));
+        KWin::setState( winId(), NET::StaysOnTop );
+    }
+    else
+    {
+        toggleOnTop->setIconSet(SmallIconSet("up"));
+        KWin::clearState( winId(), NET::StaysOnTop );
+        lower();
+    }
+
+}
+
 void karamba::slotToggleFastTransforms()
 {
 //	bool fastTransforms = toggleFastTransforms -> isChecked();
@@ -3823,7 +4014,10 @@
 {
     config -> setGroup("internal");
     config -> writeEntry("lockedPosition", toggleLocked -> isChecked() );
+    config -> writeEntry("onTop", toggleOnTop -> isChecked() );
+    config -> writeEntry("", toggleLocked -> isChecked() );
     config -> writeEntry("fastTransforms", toggleFastTransforms -> isChecked() );
+    config -> writeEntry("desktop", desktop );
 
     config -> setGroup("theme");
     // Widget Position
@@ -4131,6 +4325,26 @@
   KRun::runURL( KURL( "http://netdragon.sourceforge.net/index.php?page=Themes" ), "text/html" );
 }
 
+void karamba::toDesktop(int id, int menuid)
+{
+    int i;
+
+    desktop = id;
+    for (i=0; ; i++)
+    {
+        int mid = toDesktopMenu->idAt(i);
+        if (mid == -1)
+            break;
+
+        toDesktopMenu->setItemChecked(mid, false);
+    }
+    toDesktopMenu->setItemChecked(menuid, true);
+
+    if (desktop)
+        info->setDesktop( desktop);
+    else
+        info->setDesktop( NETWinInfo::OnAllDesktops );
+}
 
 SignalBridge::SignalBridge(QObject* parent, QString name, KActionCollection* ac) : QObject(parent, name),
    collection(ac)
@@ -4143,4 +4357,29 @@
   emit enabled(name(), ((KToggleAction*)collection -> action(name())) -> isChecked());
 }
 
+DesktopChangeSlot::DesktopChangeSlot(QObject *parent, int id)
+    : QObject(parent, "")
+{
+    desktopid = id;
+}
+
+void DesktopChangeSlot::receive()
+{
+    karamba *k = (karamba *)parent();
+
+    /* XXX - check type cast */
+
+    k->toDesktop(desktopid, menuid);
+}
+
+void DesktopChangeSlot::setMenuId(int id)
+{
+    menuid = id;
+}
+
+int DesktopChangeSlot::menuId()
+{
+    return menuid;
+}
+
 #include "karamba.moc"
Only in ../../superkaramba/src: karamba.cpp~
diff -ur src/karamba.h ../../superkaramba/src/karamba.h
--- src/karamba.h	2003-08-18 21:53:59.000000000 -0400
+++ ../../superkaramba/src/karamba.h	2003-08-26 18:55:33.000000000 -0400
@@ -103,7 +103,9 @@
     KPopupMenu* keditpop;
     KPopupMenu *kpop;
     QBitmap* widgetMask;
+#ifdef CHANDAN_CLEANUP 
     KarambaRootPixmap *kroot;
+#endif /* CHANDAN_CLEANUP  */
     //KRootPixmap *kroot;
     TaskManager taskManager;
     TaskList taskList;
@@ -125,6 +127,8 @@
     void mouseDoubleClickEvent( QMouseEvent *);
     void mouseMoveEvent( QMouseEvent *);
     void closeEvent ( QCloseEvent *);
+    // CHANDAN
+    void updateMask();
     void paintEvent ( QPaintEvent *);
     void saveProperties(KConfig *);
     void readProperties(KConfig *);
@@ -166,18 +170,22 @@
     bool foundKaramba;
 
     KPopupMenu* themeConfMenu;
+    KPopupMenu* toDesktopMenu;
+
 
     DCOPClient *client;
     QCString appId;
 
     QPixmap pm;
+    QBitmap mask;
     QPixmap background;
-    QPainter p;
+    MeterPainter p;
 
     QPoint clickPos;
     KActionCollection* accColl;
     KActionCollection* menuAccColl;
     KToggleAction *toggleLocked;
+    KToggleAction *toggleOnTop;
     // use highquality scale and rotate algorithms
     KToggleAction *toggleFastTransforms;
 
@@ -186,20 +194,24 @@
     PyObject *pArgs, *pValue;
 
     bool pythonThemeExtensionLoaded;
+    int  desktop; 
 
 public slots:
     void step();
     void externalStep();
     void updateSensors();
-    void currentDesktopChanged(int);
+#ifdef CHANDAN_CLEANUP 
+//    void currentDesktopChanged(int);
+#endif /* CHANDAN_CLEANUP  */
     void slotToggleConfigOption(QString key, bool);
-    void updateBackground(KSharedPixmap*);
+//    void updateBackground(KSharedPixmap*);
     void passMenuOptionChanged(QString key, bool);
     void passMenuItemClicked(int);
     void quitKaramba();
     void processExited (KProcess *proc);
     void receivedStdout (KProcess *proc, char *buffer, int buflen); 
     void downloadThemes();
+    void toDesktop(int desktopid, int menuid);
 
 private slots:
     void startNewKaramba();
@@ -208,6 +220,7 @@
     void editConfig();
     void editScript();
     void slotToggleLocked();
+    void slotToggleOnTop();
     void slotToggleFastTransforms();
     void popupNotify(int);
 
@@ -230,4 +243,27 @@
     KActionCollection* collection;
 };
 
+/*
+ * Slot to receive the event of moving the karamba object
+ * to a new desktop. Generated by karamba::toDesktopMenu items
+ */
+class DesktopChangeSlot : public QObject
+{
+  Q_OBJECT
+
+  public:
+  DesktopChangeSlot(QObject *parent, int desktop_id);
+  /* Parent should be the karamba object
+   * desktop id of 0 indicates all desktops */
+  void setMenuId(int id);
+  int menuId();
+
+  public slots:
+      void receive();
+  
+ protected:
+  int desktopid;
+  int menuid;
+};
+  
 #endif // _KARAMBA_H_
Only in ../../superkaramba/src: karamba.h~
diff -ur src/karambarootpixmap.cpp ../../superkaramba/src/karambarootpixmap.cpp
--- src/karambarootpixmap.cpp	2003-05-12 23:52:52.000000000 -0400
+++ ../../superkaramba/src/karambarootpixmap.cpp	2003-08-26 12:28:19.000000000 -0400
@@ -7,6 +7,7 @@
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  ***************************************************************************/
+#ifdef CHANDAN_CLEANUP 
 #include "karambarootpixmap.h"
 
 #include "karamba.h"
@@ -30,6 +31,7 @@
 
 
 void  KarambaRootPixmap::updateBackground ( KSharedPixmap *kpm ){
-  ((karamba*)widget)->updateBackground(kpm); 
+//  ((karamba*)widget)->updateBackground(kpm); 
 }
 
+#endif /* CHANDAN_CLEANUP  */
Only in ../../superkaramba/src: karambarootpixmap.cpp~
diff -ur src/karambarootpixmap.h ../../superkaramba/src/karambarootpixmap.h
--- src/karambarootpixmap.h	2003-04-21 09:17:03.000000000 -0400
+++ ../../superkaramba/src/karambarootpixmap.h	2003-08-26 12:28:08.000000000 -0400
@@ -7,6 +7,8 @@
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  ***************************************************************************/
+#ifdef CHANDAN_CLEANUP 
+
 #ifndef KARAMBAROOTPIXMAP_H
 #define KARAMBAROOTPIXMAP_H
 
@@ -37,3 +39,5 @@
 };
 
 #endif
+
+#endif /* CHANDAN_CLEANUP  */
Only in ../../superkaramba/src: karambarootpixmap.h~
Only in ../../superkaramba/src: khtml.h~
diff -ur src/meter.cpp ../../superkaramba/src/meter.cpp
--- src/meter.cpp	2003-07-06 19:14:19.000000000 -0400
+++ ../../superkaramba/src/meter.cpp	2003-08-25 13:56:27.000000000 -0400
@@ -7,6 +7,7 @@
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  ***************************************************************************/
+#include <qbitmap.h>
 #include "meter.h"
 
 Meter::Meter( int  ix  , int iy, int iw, int ih)
@@ -99,3 +100,124 @@
 {
   return boundingBox.contains(x, y) && clickable;
 }
+
+MeterPainter::MeterPainter()
+    : QPainter()
+{
+    masklock = false;
+}
+void MeterPainter::setPen(const QPen &pen)
+{
+    QColor pcol = pen.color();
+/*
+    printf ("called setpen: %d,%d,%d lock %d\n",
+            pcol.red(),
+            pcol.green(),
+            pcol.blue(),
+            (masklock==true)?1:0);
+*/
+    if (!maskLock())
+        QPainter::setPen(pen);
+}
+
+bool MeterPainter::maskLock()
+{
+    return masklock;
+}
+
+void MeterPainter::setMaskLock( bool lock)
+{
+    masklock = lock;
+}
+
+int pixel_alpha(const QImage &image, int x, int y)
+{
+    QRgb pixel = image.pixel(x,y);
+    return qAlpha(pixel);
+}
+
+QBitmap convertToMask(const QPixmap &pixmap)
+{
+    QImage image = pixmap.convertToImage();
+    QImage newim = QImage(image.size(), 8, 2);
+
+    newim.setColor(0, qRgb(0,0,0));
+    newim.setColor(1, qRgb(255,255,255));
+
+//    printf ("Size: %d,%d\n", newim.width(), newim.height());
+    
+    for (int i=0; i<image.width(); i++)
+    {
+        for (int j=0; j<image.height(); j++)
+        {
+            // DEBUG
+//            printf ("%d, %d: %d\n", i, j, pixel_alpha(image, i, j));
+            if (pixel_alpha(image, i, j) == 0)
+                *(newim.scanLine(j) + i) = 1;
+            else
+                *(newim.scanLine(j) + i) = 0;
+        }
+    }
+
+    QBitmap bmap;
+    bmap = newim;
+    return bmap;
+}
+
+void MeterPainter::drawPixmap ( int x,
+                                int y,
+                                const QPixmap & pixmap,
+                                int sx,
+                                int sy,
+                                     int sw,
+                                     int sh )
+{
+    if (masklock)
+    {
+        QBitmap bmap;
+        bmap = convertToMask(pixmap);
+
+        QPainter::drawPixmap(x,y,bmap,sx,sy,sw,sh);
+    }
+    else
+        QPainter::drawPixmap(x,y,pixmap,sx,sy,sw,sh);
+}
+
+void MeterPainter::drawTiledPixmap ( int x,
+                                     int y,
+                                     int w,
+                                     int h,
+                                     const QPixmap & pixmap,
+                                     int sx,
+                                     int sy ) 
+{
+    if (masklock)
+    {
+        QBitmap bmap;
+        bmap = convertToMask(pixmap);
+
+        QPainter::drawTiledPixmap(x,y,w,h,bmap,sx,sy);
+    }
+    else
+        QPainter::drawTiledPixmap(x,y,w,h,pixmap,sx,sy);
+
+}
+
+void MeterPainter::drawImage ( int x,
+                 int y,
+                 const QImage & image,
+                 int sx,
+                 int sy,
+                 int sw,
+                 int sh,
+                 int conversionFlags )
+{
+    int rw=sw, rh=sh;
+
+    if (rw == -1)
+        rw = image.width();
+    if (rh == -1)
+        rh = image.height();
+
+//    fillRect(x,y,rw,rh,Qt::color1);
+}
Only in ../../superkaramba/src: meter.cpp~
diff -ur src/meter.h ../../superkaramba/src/meter.h
--- src/meter.h	2003-07-06 19:13:07.000000000 -0400
+++ ../../superkaramba/src/meter.h	2003-08-25 12:29:07.000000000 -0400
@@ -11,12 +11,51 @@
 #define METER_H
 
 #include <qpixmap.h>
+#include <qimage.h>
 #include <qpainter.h>
 #include <qstring.h>
 #include <qstringlist.h>
 #include <qobject.h>
 
 #include <qfileinfo.h>
+
+QBitmap convertToMask(const QPixmap &pixmap);
+class MeterPainter : public QPainter
+{
+ protected:
+    bool masklock;
+
+public:
+    MeterPainter();
+    void setMaskLock(bool lock);
+    bool maskLock();
+    void setPen( const QPen& pen);
+
+    void drawImage( int x,
+                    int y,
+                    const QImage & image,
+                    int sx = 0,
+                    int sy = 0,
+                    int sw = -1,
+                    int sh = -1,
+                    int conversionFlags = 0 );
+    
+    void drawPixmap( int x,
+                     int y,
+                     const QPixmap & pixmap,
+                     int sx=0,
+                     int sy=0,
+                     int sw=-1,
+                     int sh=-1 );
+    void drawTiledPixmap ( int x,
+                           int y,
+                           int w,
+                           int h,
+                           const QPixmap & pixmap,
+                           int sx = 0,
+                           int sy = 0 ) ;
+};
+
 class Meter : public QObject
 {
 Q_OBJECT
@@ -41,7 +80,7 @@
 
   void setThemePath( QString );
 
-  virtual void mUpdate(QPainter *)=0 ;
+  virtual void mUpdate(MeterPainter *)=0 ;
 
   virtual void setValue(int){}
   virtual void setValue(QString){}
@@ -80,4 +119,6 @@
   int hidden;
    
 };
+
+
 #endif // METER_H
Only in ../../superkaramba/src: meter.h~
diff -ur src/richtextlabel.cpp ../../superkaramba/src/richtextlabel.cpp
--- src/richtextlabel.cpp	2003-06-14 15:21:22.000000000 -0400
+++ ../../superkaramba/src/richtextlabel.cpp	2003-08-25 20:35:09.000000000 -0400
@@ -52,9 +52,11 @@
                                -1 /*no pageBreak*/, Qt::blue /* (has no effect) link Color*/, underlineLinks);
 
     // set the text to a reasonable size
-    text -> adjustSize();
-    setWidth(text -> width());
-    setHeight(text -> height());
+//    text -> adjustSize();
+//    setWidth(text -> width());
+//    setHeight(text -> height());
+    text->setWidth(getWidth());
+//    text->setHeight(getHeight());
 }
 
 void RichTextLabel::setFont(QString f)
@@ -100,7 +102,7 @@
     hidden = true;
 }
 
-void RichTextLabel::mUpdate(QPainter *p)
+void RichTextLabel::mUpdate(MeterPainter *p)
 {
     if (hidden || text == 0)
     {
@@ -126,8 +128,10 @@
     {
         return false;
     }
-    QPoint point(e -> x() - getX(), e -> y() - getX());
+    QPoint point(e -> x() - getX(), e -> y() - getY());
     QString anchor = text -> anchorAt(point);
+    printf ("richtext click called: anchor %s\n", (const char *)anchor);
+
     if (anchor[0] != '#')
     {
         if (e -> button() == Qt::LeftButton)
Only in ../../superkaramba/src: richtextlabel.cpp~
diff -ur src/richtextlabel.h ../../superkaramba/src/richtextlabel.h
--- src/richtextlabel.h	2003-06-14 15:21:22.000000000 -0400
+++ ../../superkaramba/src/richtextlabel.h	2003-08-24 11:36:43.000000000 -0400
@@ -42,7 +42,7 @@
     virtual bool insideActiveArea(int, int);
 
     virtual bool click(QMouseEvent*);
-    virtual void mUpdate(QPainter*);
+    virtual void mUpdate(MeterPainter*);
 
     QString anchorAt(int, int);
 
Only in ../../superkaramba/src: richtextlabel.h~
diff -ur src/textlabel.cpp ../../superkaramba/src/textlabel.cpp
--- src/textlabel.cpp	2003-06-14 15:21:22.000000000 -0400
+++ ../../superkaramba/src/textlabel.cpp	2003-08-24 11:31:12.000000000 -0400
@@ -80,6 +80,11 @@
     color.setRgb(r,g,b);
 }
 
+void TextLabel::setColor(const QColor &col)
+{
+    color = col;
+}
+
 QColor TextLabel::getColor() const
 {
     return color;
@@ -90,6 +95,11 @@
     bgColor.setRgb( r, g, b );
 }
 
+void TextLabel::setBGColor(const  QColor &color)
+{
+    bgColor = color;
+}
+
 QColor TextLabel::getBGColor() const
 {
     return bgColor;
@@ -161,7 +171,7 @@
     return shadow;
 }
 
-void TextLabel::mUpdate(QPainter *p)
+void TextLabel::mUpdate(MeterPainter *p)
 {
     int i = 0; //lineHeight;
     int row = 1;
Only in ../../superkaramba/src: textlabel.cpp~
diff -ur src/textlabel.h ../../superkaramba/src/textlabel.h
--- src/textlabel.h	2003-06-14 15:21:22.000000000 -0400
+++ ../../superkaramba/src/textlabel.h	2003-08-24 11:36:46.000000000 -0400
@@ -37,8 +37,12 @@
     void setAlignment( QString );
     void setFixedPitch( bool );
     void setShadow( int );
-    void mUpdate( QPainter * );
+    void mUpdate( MeterPainter * );
 
+    //CHANDAN
+    void setColor(const QColor &color);
+    void setBGColor(const QColor &color);
+ 
     void showText();
     void hideText();
     int getFontSize() const;
Only in ../../superkaramba/src: textlabel.h~