Commits

mathematicalcoffee committed ce3072d

fixed bugs so this enables/disables smoothly

  • Participants
  • Parent commits b080fb6

Comments (0)

Files changed (1)

File xpenguins@mathematical.coffee.gmail.com/xpenguins.js

         this._playing = 0;
         this._numbers = {};
         this._relaunch = false;
+        this._toons = [];
     },
 
     /***************************************
 
     /* Have to override get_workspace to incorporate a movable window :/ */
     get_workspace: function () {
-        XPUtil.DEBUG('[XP] get_workspace: %d', this._XPenguinsWindow.get_workspace().index());
-        return this._XPenguinsWindow.get_workspace();
+        if (!this._XPenguinsWindow) {
+            return global.screen.get_active_workspace();
+        } else {
+            XPUtil.DEBUG('[XP] get_workspace: %d', this._XPenguinsWindow.get_workspace().index());
+            return this._XPenguinsWindow.get_workspace();
+        }
     },
 
     /* Initialise all variables & load themes & initialise toons.
         this._exiting = false;
 
         this._dirty = true;
-        
+
         /* Laziness */
         let opt = this.options;
         /* If they set onAllWorkspaces but are running in a window,
         if (this._sleepID) {
             Mainloop.source_remove(this._sleepID);
         }
-        if (this._XPenguinsWindowDestroyedID && this._XPenguinsWindow.actor) {
+        if (this._XPenguinsWindowDestroyedID && this._XPenguinsWindow && this._XPenguinsWindow.actor) {
             this._XPenguinsWindow.actor.disconnect(this._XPenguinsWindowDestroyedID);
             this._XPenguinsWindowDestroyedID = null;
         }
                     for (let type in gdata) {
                         if (gdata.hasOwnProperty(type) &&
                                 !this._theme.toonData[i][type].master) {
-                            Main.uiGroup.remove_actor(gdata[type].texture);
+                            gdata[type].texture.unparent();
                         }
                     }
                 }
 
         /* Note: we *don't* destroy the window clone so that it may be
          * re-used for the next run without having to re-assign the window
-         * we want to run in. 
+         * we want to run in.
          */
         //this._XPenguinsWindow.destroy();
 
         WindowListener.WindowListener.prototype.destroy.call(this);
         this.exit();
     },
-    
+
     /* connects up events required to maintain toonWindows as an accurate
      * snapshot of what the windows on the workspace look like
      * We override it to add windows for the xpenguins window.
         if (this.options.stackingOrder) {
             winList = global.display.sort_windows_by_stacking(winList);
             /* sort by monitor ... ? */
-            winList.sort(function (a, b) { 
+            winList.sort(function (a, b) {
                 return a.get_monitor() - b.get_monitor();
             });
         }
             if (!this._onDesktop && win === this._XPenguinsWindow.meta_window) {
                 break;
             }
-            if (this._onDesktop && this.options.ignoreMaximised && 
+            if (this._onDesktop && this.options.ignoreMaximised &&
                     win.get_maximized() ===
                     (Meta.MaximizeFlags.HORIZONTAL | Meta.MaximizeFlags.VERTICAL)) {
                 /* look for the next monitor */
         this._dirty = false;
     },
 
-
     /****************
      * Initialising *
      ****************/
         };
     },
 
-
     /* returns array of themes with non-zero toons */
     getThemes: function () {
         return this.themeList.filter(Lang.bind(this, function (name) {
             Lang.bind(this, this._onXPenguinsWindowDestroyed)
         );
 
-
         /* Note: we can't just call stop then start instantaneously, because
          * the current instance of _frame will return true (since _playing
          * is now the new instance) and the new instance of _frame will also
         }
     },
 
-
     /*******************
      * PRIVATE METHODS *
      *******************/
         }
     },
 
-
     /* _frame is called every frame of the iteration.
      * It consists of two parts:
      *
         // it's this._toons.length - this._deadToons.length
         /************* END xpenguins_frame() ************/
 
-
         /************* START main loop ************/
         /* If there are no toons left & 'exiting' has been signalled,
          * then we've just finished killing all the penguins.