=== modified file 'src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js' --- src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js 2015-09-07 17:08:14 +0000 +++ src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js 2015-09-13 22:30:59 +0000 @@ -668,7 +668,7 @@ offset = offset + 1; var theWindow = p2j.screen.getWindow(windowID); - p2j.logger.log("recieved 0x99: iconified = " + iconified); + //p2j.logger.log("recieved 0x99: iconified = " + iconified + " windowId=" + windowID); if (iconified) { theWindow.iconify(); === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js' --- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2015-09-11 19:19:05 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2015-09-13 22:30:08 +0000 @@ -465,9 +465,19 @@ // this code depends on each canvas being style.position = 'absolute' so that it is // outside of the browser's layout processing this.canvas.style.visibility = visible ? "visible" : "hidden"; - - // bring to the top of the z-order - moveZOrderEntryToTop(this.id); + if (visible) + { + // bring to the top of the z-order + moveZOrderEntryToTop(this.id); + } + }; + + /** + * Is visible. + */ + Window.prototype.isVisible = function() + { + return this.canvas.style.visibility === "visible"; }; /** @@ -936,11 +946,11 @@ */ Window.prototype.iconify = function() { - p2j.logger.log("Window.prototype.iconify(" + this.id + ")"); + //p2j.logger.log("Window.prototype.iconify(" + this.id + ")"); this.setVisible(false); - taskBar.iconify(this.id); + activateTopVisibleWindow(this.id); }; /** @@ -948,7 +958,7 @@ */ Window.prototype.deiconify = function() { - p2j.logger.log("Window.prototype.deiconify(" + this.id + ")"); + //p2j.logger.log("Window.prototype.deiconify(" + this.id + ")"); this.setVisible(true); @@ -1005,6 +1015,45 @@ }; /** + * Move the first upper visible window to the top of other visible windows + * after the selected window is minimized. + * + * @param {Number} id + * The id of the window that has been minimized. + */ + function activateTopVisibleWindow(id) + { + var topWindow = findTopVisibleWindow(id); + if (topWindow) + { + topWindow.moveToTop(); + } + } + + /** + * Find a visible window having the maximal z-index from all windows that are different + * from the selected window. + * + * @param {Number} id + * The id of the selected window. + * + * @return {Window} + * The first different visible window having the maximal z-index. + */ + function findTopVisibleWindow(id) + { + for(var j = zlist.length - 1; j >=0; j--) + { + var win = zlist[j].win; + if ((win.id !== id) && win.isVisible()) + { + return win; + } + } + return null; + } + + /** * Find the index of the given window in the z-order list. * * @param {Number} wid @@ -1440,6 +1489,7 @@ */ me.setWindowVisible = function(wid, visible) { + //p2j.logger.log("setWindowVisible: wid = " + wid + " visible = " + visible); if (!isValidWindowId(wid)) { me.error("Cannot change visibility for window for id that is invalid."); @@ -1478,6 +1528,7 @@ */ me.restackZOrderEntries = function(wids) { + //p2j.logger.log("restackZOrderEntries: top window = " + wids[wids.length - 1]); if (zlist.length != wids.length) { me.error("Restacking list must have the same number of elements as the z-order list!"); @@ -1508,6 +1559,7 @@ addZOrderEntry(wids[i], win); } + taskBar.setTaskIconActive(wids[wids.length - 1], true); }; /** === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.virtual_desktop.js' --- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.virtual_desktop.js 2015-09-11 19:19:05 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.virtual_desktop.js 2015-09-13 22:28:43 +0000 @@ -567,7 +567,7 @@ this.addTaskIcon = addTaskIcon; /** - * Adds new task to the task bar. + * Adds new task to the task bar. Check if there exists. New created task is hidden. * * @param {Number} windowId * The id of the window that needs to be represented by this task. @@ -577,12 +577,16 @@ */ function addTaskIcon(windowId) { - var taskIcon = findTaskIcon(windowId); + var taskIcon = findWidget(windowId, taskIcons); if (taskIcon === null) { - taskIcon = new TaskIcon(windowId, TASK_ICON_WIDTH, TASK_ICON_HEIGHT, foreground, - "", null, 0, 0); - taskIcons.push(taskIcon); + taskIcon = findWidget(windowId, hiddenTaskIcons); + if (taskIcon === null) + { + taskIcon = new TaskIcon(windowId, TASK_ICON_WIDTH, TASK_ICON_HEIGHT, foreground, + "", null, 0, 0); + hiddenTaskIcons.push(taskIcon); + } } return taskIcon; }; @@ -655,22 +659,13 @@ //shrunk the task icons by removing it widgetsToRemove.splice(index, 1); widgetsToAdd.push(taskIcon); + if (visible) + { + // sets the current position in visible task icon list + taskIcon.index = widgetsToAdd.length - 1; + } //if the task icon becomes visible it should be active updateTaskBar(taskIcon, visible) - return taskIcon; - } - // task icon is already visible - taskIcon = findWidget(windowId, taskIcons); - if (taskIcon) - { - updateTaskBar(taskIcon, visible); - return taskIcon; - } - // task icon is already hidden - taskIcon = findWidget(windowId, hiddenTaskIcons); - if (taskIcon) - { - updateTaskBar(taskIcon, visible); } return taskIcon; @@ -1011,12 +1006,10 @@ var taskIcon = taskIcons[i]; if (taskIcon.testMousePointerInside(event) && !taskIcon.isActive()) { - updateTaskBar(taskIcon, true); if (taskIconOnClickCallback) { taskIconOnClickCallback(taskIcon.id); } - taskIcon.draw(); break; }