Idea to enhance window management in overlay mode



Hello folks,
I've a small idea which would enhance user experience in overlay mode. Currently, Window previews(in overlay mode) are being arranged in a way that every window is visible and easily accessible. In the process of bringing ease of access, we lost the facility to rearrange windows in overlay mode. I tried bringing both of these essential functionality together by a small tweak. When user drags any draggable object into a workspace, all the windows will be automatically arranged in their actual positions and sizes in that workspace. So that, user can decide where to place the dragged object. (windows will be restored back to their slots after a few secs). I'm attaching a working prototype patch to this mail. Try it and let me know your thoughts. Hope you like it.

Warning: The patch has some bugs and sometimes makes you annoyed ;) Also, I manually edited diff at some parts to eliminate my personal changes. Not sure, if I made any mistakes, please let me know.


--
Naagas.
0__
_> /__...
(_) \(_) Burn fat, not fuel
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -699,7 +699,7 @@ AppWell.prototype = {
     },
 
     // Draggable target interface
-    acceptDrop : function(source, actor, x, y, time) {
+    acceptDrop : function(source, actor, x, y, offsetx, offsety, time) {
         let app = null;
         if (source instanceof AppDisplayItem) {
             app = this._appSystem.get_app(source.getId());
diff --git a/js/ui/dnd.js b/js/ui/dnd.js
index 9188cad..9f85c47 100644
--- a/js/ui/dnd.js
+++ b/js/ui/dnd.js
@@ -255,6 +255,8 @@ _Draggable.prototype = {
                 if (target._delegate.acceptDrop(this.actor._delegate, this._dragActor,
                                                 (dropX - targX) / target.scale_x,
                                                 (dropY - targY) / target.scale_y,
+						this._dragOffsetX / target.scale_x,
+						this._dragOffsetY / target.scale_y,
                                                 event.get_time())) {
                     // If it accepted the drop without taking the actor,
                     // destroy it.
diff --git a/js/ui/overview.js b/js/ui/overview.js
index e217bfe..525cbd9 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -490,7 +490,7 @@ AddWorkspaceButton.prototype = {
     },
 
     // Draggable target interface
-    acceptDrop: function(source, actor, x, y, time) {
+    acceptDrop: function(source, actor, x, y, offsetx, offsety, time) {
         return this._acceptDropCallback(source, actor, x, y, time);
     }
 };
diff --git a/js/ui/workspaces.js b/js/ui/workspaces.js
index 565e557..7dfa8cf 100644
--- a/js/ui/workspaces.js
+++ b/js/ui/workspaces.js
@@ -247,11 +256,21 @@ WindowClone.prototype = {
     },
 
     _onButtonRelease : function (actor, event) {
-        this.emit('selected', event.get_time());
+	let button = event.get_button();
+	if (button == 1) {
+        	this.emit('selected', event.get_time());
+	} else if(button == 3) {
+	    if (!this._menu) {
+                this._menu = new AppWindowMenu(this);
+            }
+            this._menu.popup(event.get_coords());
+	}
     },
 
     _onDragBegin : function (draggable, time) {
         this._inDrag = true;
+	this.actor.scale_x = 1;
+	this.actor.scale_y = 1;
         this.emit('drag-begin');
     },
 
@@ -575,6 +594,7 @@ Workspace.prototype = {
         this._frame = null;
 
         this.leavingOverview = false;
+	this.DraggablePresent = null;
     },
 
     updateRemovable : function() {
@@ -1014,6 +1034,7 @@ Workspace.prototype = {
             let metaWindow = visibleWindows[i];
             let mainIndex = this._lookupIndex(metaWindow);
             let clone = metaWindow._delegate;
+	    if (clone.actor == this.DraggablePresent) continue;
             let overlay = this._windowOverlays[mainIndex];
 
             let [x, y, scale] = this._computeWindowRelativeLayout(metaWindow, slot);
@@ -1269,6 +1290,8 @@ Workspace.prototype = {
         Tweener.removeTweens(this.actor);
         this.actor.destroy();
         this.actor = null;
+        if (this.timer)
+            Mainloop.source_remove(this.timer);
 
         this._metaWorkspace.disconnect(this._windowAddedId);
         this._metaWorkspace.disconnect(this._windowRemovedId);
@@ -1291,6 +1314,50 @@ Workspace.prototype = {
         return tracker.is_window_interesting(win.get_meta_window());
     },
 
+    positionWindowsInActualPositions: function() {
+
+        let visibleWindows = this._getVisibleWindows();
+        for (let i = 0; i < visibleWindows.length; i++) {
+            let metaWindow = visibleWindows[i];
+            let mainIndex = this._lookupIndex(metaWindow);
+            let clone = metaWindow._delegate;
+	    if (clone.actor == this.DraggablePresent) continue;
+            let overlay = this._windowOverlays[mainIndex];
+            overlay.hide();
+            let rect = new Meta.Rectangle();
+            metaWindow.get_outer_rect(rect);
+            Tweener.addTween(clone.actor,
+                             { x: rect.x ,
+                               y: rect.y,
+			       scale_x: 1,
+			       scale_y: 1,
+                               workspace_relative: null,
+                               time: Overview.ANIMATION_TIME,
+                               transition: "easeOutQuad",
+                               onComplete: Lang.bind(this, function() {
+                                  overlay.fadeIn();
+                               })
+                             });
+        }
+        if (this.timer)
+            Mainloop.source_remove(this.timer);
+	this.timer = Mainloop.timeout_add(4000, Lang.bind(this, function() {
+				  this.positionWindows(false);
+				  this.DraggablePresent = null;
+			})); 
+    },
+
+
+    //Handles when a draggable object comes onto this workspace
+    handleDragOver: function(delegate, actor, x, y, time) {
+	if(this.DraggablePresent)
+		return;
+	this.DraggablePresent = actor;
+	this.positionWindowsInActualPositions();	
+	//log("Hey, you came into my teritory, get off!");
+    },
+
+
     // Create a clone of a (non-desktop) window and add it to the window list
     _addWindowClone : function(win) {
         let clone = new WindowClone(win);
@@ -1364,7 +1434,7 @@ Workspace.prototype = {
     },
 
     // Draggable target interface
-    acceptDrop : function(source, actor, x, y, time) {
+    acceptDrop : function(source, actor, x, y, offsetx, offsety, time) {
         if (source instanceof WindowClone) {
             let win = source.realWindow;
             if (this._isMyWindow(win))
@@ -1372,6 +1442,8 @@ Workspace.prototype = {
 
             // Set a hint on the Mutter.Window so its initial position
             // in the new workspace will be correct
+	    win.x = x + offsetx;
+	    win.y = y + offsety;
             win._overviewHint = {
                 x: actor.x,
                 y: actor.y,
@@ -1734,7 +1806,7 @@ Workspaces.prototype = {
     // Handles a drop onto the (+) button; assumes the new workspace
     // has already been added
     acceptNewWorkspaceDrop : function(source, dropActor, x, y, time) {
-        return this._workspaces[this._workspaces.length - 1].acceptDrop(source, dropActor, x, y, time);
+        return this._workspaces[this._workspaces.length - 1].acceptDrop(source, dropActor, x, y, 0, 0, time);
     }
 };


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]