=== 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-10 17:38:10 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2015-09-11 19:12:54 +0000 @@ -919,6 +919,7 @@ Window.prototype.moveToTop = function() { moveZOrderEntryToTop(this.id); + taskBar.setTaskIconActive(this.id, 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 12:06:53 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.virtual_desktop.js 2015-09-11 19:09:26 +0000 @@ -233,6 +233,9 @@ /** The task bar dragged panel */ var dragged; + /** active task icon index */ + var activeTaskIconIndex; + var canvas = document.createElement('canvas'); canvas.className="canvas"; canvas.style["height"] = "100%"; @@ -580,8 +583,6 @@ taskIcon = new TaskIcon(windowId, TASK_ICON_WIDTH, TASK_ICON_HEIGHT, foreground, "", null, 0, 0); taskIcons.push(taskIcon); - // By default the task is active. Only one task can be active. - deactivateHead(); } return taskIcon; }; @@ -655,22 +656,26 @@ widgetsToRemove.splice(index, 1); widgetsToAdd.push(taskIcon); //if the task icon becomes visible it should be active - taskIcon.setActive(visible); - } + 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; }; - /** - * Deactivate the head tasks. - */ - function deactivateHead() - { - for (var i = 0; i < taskIcons.length - 1; i++) - { - taskIcons[i].setActive(false); - } - } - this.setIconForTask = setIconForTask; /** @@ -724,6 +729,63 @@ return taskIcon; }; + this.setTaskIconActive = setTaskIconActive; + + /** + * Sets the active state for the task that represents the target window. + * + * @param {Number} windowId + * The target window id. + * @param {Boolean} active + * The window state. + * + * @return {TaskIcon} + * The task that represents the target window. + */ + function setTaskIconActive(windowId, active) + { + var taskIcon = findTaskIcon(windowId); + if (taskIcon) + { + updateTaskBar(taskIcon, active); + } + return taskIcon; + }; + + /** + * Updates the given task icon and the active task icon index, then draws the task bar. + * + * @param {TaskIcon} taskIcon + * The task icon that is going to change its state + * @param {Boolean} active + * The new active state + */ + function updateTaskBar(taskIcon, active) + { + taskIcon.setActive(active); + if (activeTaskIconIndex === taskIcon.index) + { + if (!active) + { + activeTaskIconIndex = undefined; + } + } + else + { + //new active window + if (active) + { + if (activeTaskIconIndex !== undefined) + { + var oldActiveTaskIcon = taskIcons[activeTaskIconIndex]; + oldActiveTaskIcon.setActive(false); + } + activeTaskIconIndex = taskIcon.index; + } + } + draw(); + } + this.setFont = setFont; /** @@ -816,7 +878,7 @@ { return; } - taskIcon.setActive(false); + updateTaskBar(taskIcon, false); taskIcon.draw(); }; @@ -833,7 +895,7 @@ { return; } - taskIcon.setActive(true); + updateTaskBar(taskIcon, true); taskIcon.draw(); }; @@ -949,7 +1011,7 @@ var taskIcon = taskIcons[i]; if (taskIcon.testMousePointerInside(event) && !taskIcon.isActive()) { - taskIcon.setActive(true); + updateTaskBar(taskIcon, true); if (taskIconOnClickCallback) { taskIconOnClickCallback(taskIcon.id); @@ -1069,7 +1131,7 @@ this.height = h; this.color = c; var that = this; - var active = true; + var active = false; this.x = 0; this.y = 0; /**The internal index, if the task icon is on the task bar, it is set