Skip to content

Commit

Permalink
keep current stacking order when focusing a window
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@15634 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Apr 16, 2017
1 parent 0fc962b commit 74ce3bd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
23 changes: 21 additions & 2 deletions src/html5/js/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1097,16 +1097,35 @@ XpraClient.prototype._window_set_focus = function(win) {
if (client.focus == wid) {
return;
}
var top_stacking_layer = Object.keys(client.id_to_window).length;
var old_stacking_layer = win.stacking_layer;
client.focus = wid;
client.topwindow = wid;
client.send(["focus", wid, []]);
//set the focused flag on all windows:
//set the focused flag on all windows,
//adjust stacking order:
var iwin = null;
for (var i in client.id_to_window) {
var iwin = client.id_to_window[i];
iwin = client.id_to_window[i];
iwin.focused = (i==wid);
if (iwin.focused) {
iwin.stacking_layer = top_stacking_layer;
}
else {
//move it down to fill the gap:
if (iwin.stacking_layer>old_stacking_layer) {
iwin.stacking_layer--;
}
}
iwin.updateFocus();
iwin.update_zindex();
}
//set stacking order:
iwin = client.id_to_window[last_focused];
if (iwin) {
iwin.stacking_layer = stacking_layer--;
}

client._set_favicon(wid);
}

Expand Down
6 changes: 3 additions & 3 deletions src/html5/js/Window.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function XpraWindow(client, canvas_state, wid, x, y, w, h, metadata, override_re
this.focused = false;
this.decorations = true;
this.resizable = false;
this.stacking_layer = 0;

//these values represent the internal geometry
//i.e. geometry as windows appear to the compositor
Expand Down Expand Up @@ -407,7 +408,7 @@ XpraWindow.prototype.toString = function() {


XpraWindow.prototype.update_zindex = function() {
var z = 5000;
var z = 5000 + this.stacking_layer;
if (this.override_redirect) {
z = 15000;
}
Expand All @@ -430,7 +431,7 @@ XpraWindow.prototype.update_zindex = function() {
}
}
if (this.focused) {
z += 1000;
z += 2500;
}
jQuery(this.div).css('z-index', z);
}
Expand Down Expand Up @@ -537,7 +538,6 @@ XpraWindow.prototype.apply_size_constraints = function() {
if (this.decorations) {
//adjust for header
hdec = jQuery('#head' + this.wid).outerHeight(true);
console.log("hdec=", hdec);
}
var min_size = null, max_size = null;
if (size_constraints) {
Expand Down

0 comments on commit 74ce3bd

Please sign in to comment.