Skip to content

Commit

Permalink
handle a lot more window states: above, below, modal, decorations, etc
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@15517 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Apr 4, 2017
1 parent 941c5c0 commit 78eccb7
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 56 deletions.
7 changes: 2 additions & 5 deletions src/html5/connect.html
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,6 @@ <h4 class="panel-title">Advanced options</h4>
<li class="list-group-item">
<input type="checkbox" id="video"> <span>Video (experimental) <input type="checkbox" id="mediasource_video"> Native decoding</span>
</li>
<li class="list-group-item">
<input type="checkbox" id="normal_fullscreen"> <span>Normal fullscreen windows</span>
</li>
<li class="list-group-item">
<input type="checkbox" id="debug"> <span>Debugging</span>
</li>
Expand Down Expand Up @@ -343,7 +340,7 @@ <h4 class="panel-title">Advanced options</h4>
"exit_with_children", "exit_with_client",
"sharing", "steal", "reconnect",
"video", "mediasource_video",
"normal_fullscreen", "debug", "insecure"];
"debug", "insecure"];
for (var i = 0; i < bool_props.length; i++) {
var prop = bool_props[i];
add_prop(prop, document.getElementById(prop).checked);
Expand Down Expand Up @@ -519,7 +516,7 @@ <h4 class="panel-title">Advanced options</h4>
"exit_with_children", "exit_with_client",
"sharing", "steal", "reconnect",
"video", "mediasource_video",
"normal_fullscreen", "debug", "insecure"];
"debug", "insecure"];
var default_on = ["steal", "clipboard", "printing", "file_transfer", "reconnect", "exit_with_children", "exit_with_client"];
for (var i = 0; i < bool_props.length; i++) {
var prop = bool_props[i];
Expand Down
11 changes: 10 additions & 1 deletion src/html5/css/client.css
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,18 @@ canvas {
padding-top: 7px;
background-color: #c0c0c0;
}
.windowinfocus {
.above {
z-index: 10000;
}
.below {
z-index: 0;
}
div.windowinfocus {
z-index: 5000;
}
.modal {
z-index: 20000;
}
.spinneroverlay {
width: 100%;
height: 100%;
Expand Down
7 changes: 0 additions & 7 deletions src/html5/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@
var sharing = getboolparam("sharing", false);
var video = getboolparam("video", false);
var mediasource_video = getboolparam("mediasource_video", false);
var normal_fullscreen = getboolparam("normal_fullscreen", false);
var remote_logging = getboolparam("remote_logging", true);
var debug = getboolparam("debug", false);
var insecure = getboolparam("insecure", false);
Expand Down Expand Up @@ -228,11 +227,6 @@
client.start_new_session = sns
}

// see if we should undecorate and maximise normal windows
if(normal_fullscreen) {
client.normal_fullscreen_mode = true;
}

// sound support
if(sound) {
client.audio_enabled = true;
Expand Down Expand Up @@ -307,7 +301,6 @@
"exit_with_client" : exit_with_client,
"sharing" : sharing,
"steal" : steal,
"normal_fullscreen" : normal_fullscreen,
"video" : video,
"mediasource_video" : mediasource_video,
"debug" : debug,
Expand Down
33 changes: 17 additions & 16 deletions src/html5/js/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ XpraClient.prototype.init_settings = function(container) {
this.steal = true;
this.remote_logging = true;
this.enabled_encodings = [];
this.normal_fullscreen_mode = false;
this.start_new_session = null;
this.clipboard_enabled = false;
this.file_transfer = false;
Expand Down Expand Up @@ -598,7 +597,6 @@ XpraClient.prototype._keyb_process = function(pressed, event) {
//send via a timer so we get a chance to capture the clipboard value,
//before we send control-V to the server:
var packet = ["key-action", this.topwindow, keyname, pressed, modifiers, keyval, str, keycode, group];
console.debug(packet);
var me = this;
setTimeout(function () {
//show("win="+win.toSource()+", keycode="+keycode+", modifiers=["+modifiers+"], str="+str);
Expand Down Expand Up @@ -896,6 +894,12 @@ XpraClient.prototype._make_hello = function() {
"notify-startup-complete" : true,
"generic-rgb-encodings" : true,
"window.raise" : true,
"metadata.supported" : [
"fullscreen", "maximized", "above", "below",
//"set-initial-position", "group-leader",
"title", "size-hints", "class-instance", "transient-for", "window-type",
"decorations", "override-redirect", "tray", "modal", "opacity",
],
"encodings" : this._get_encodings(),
"raw_window_icons" : true,
"encoding.icons.max_size" : [30, 30],
Expand Down Expand Up @@ -1006,12 +1010,6 @@ XpraClient.prototype._new_window = function(wid, x, y, w, h, metadata, override_
win.debug = this.debug;
this.id_to_window[wid] = win;
if (!override_redirect) {
if(this.normal_fullscreen_mode) {
if(win.windowtype == "NORMAL") {
win.undecorate();
win.set_maximized(true);
}
}
var geom = win.get_internal_geometry();
this.send(["map-window", wid, geom.x, geom.y, geom.w, geom.h, this._get_client_properties(win)]);
this._window_set_focus(win);
Expand Down Expand Up @@ -1069,23 +1067,26 @@ XpraClient.prototype._window_mouse_move = function(win, x, y, modifiers, buttons

XpraClient.prototype._window_mouse_click = function(win, button, pressed, x, y, modifiers, buttons) {
var wid = win.wid;
var client = win.client;
//console.debug("click focus=", client.focus, ", wid=", wid);
// dont call set focus unless the focus has actually changed
if(win.client.focus != wid) {
win.client._window_set_focus(win);
if(client.focus != wid) {
client._window_set_focus(win);
}
win.client.send(["button-action", wid, button, pressed, [x, y], modifiers, buttons]);
client.send(["button-action", wid, button, pressed, [x, y], modifiers, buttons]);
}

XpraClient.prototype._window_set_focus = function(win) {
// don't send focus packet for override_redirect windows!
if(!win.override_redirect) {
var client = win.client;
var wid = win.wid;
win.client.focus = wid;
win.client.topwindow = wid;
win.client.send(["focus", wid, []]);
client.focus = wid;
client.topwindow = wid;
client.send(["focus", wid, []]);
//set the focused flag on all windows:
for (var i in win.client.id_to_window) {
var iwin = win.client.id_to_window[i];
for (var i in client.id_to_window) {
var iwin = client.id_to_window[i];
iwin.focused = (i==wid);
iwin.updateFocus();
}
Expand Down
71 changes: 44 additions & 27 deletions src/html5/js/Window.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2016 Antoine Martin <[email protected]>
* Copyright (c) 2013-2017 Antoine Martin <[email protected]>
* Copyright (c) 2014 Joshua Higgins <[email protected]>
* Copyright (c) 2015-2016 Spikes, Inc.
* Licensed under MPL 2.0
Expand Down Expand Up @@ -61,6 +61,7 @@ function XpraWindow(client, canvas_state, wid, x, y, w, h, metadata, override_re
this.saved_geometry = null;
this.maximized = false;
this.focused = false;
this.decorations = true;

//these values represent the internal geometry
//i.e. geometry as windows appear to the compositor
Expand Down Expand Up @@ -136,13 +137,13 @@ function XpraWindow(client, canvas_state, wid, x, y, w, h, metadata, override_re
// adjust top offset
this.topoffset = this.topoffset + parseInt(jQuery(this.d_header).css('height'), 10);
// assign some interesting callbacks
jQuery('#head' + String(wid)).click(function() {
jQuery(this.d_header).click(function() {
set_focus_cb(me);
});
jQuery('#close' + String(wid)).click(function() {
jQuery(this.d_closebtn).click(function() {
window_closed_cb(me);
});
jQuery('#maximize' + String(wid)).click(function() {
jQuery(this.d_maximizebtn).click(function() {
me.toggle_maximized();
});
} else {
Expand Down Expand Up @@ -430,18 +431,48 @@ XpraWindow.prototype.set_metadata_safe = function(metadata) {
* Apply new metadata settings.
*/
XpraWindow.prototype.set_metadata = function(metadata) {
this.set_metadata_safe(metadata);
if ("fullscreen" in metadata) {
this.set_fullscreen(metadata["fullscreen"]==1);
}
if ("maximized" in metadata) {
this.set_maximized(metadata["maximized"]==1);
}
if ("title" in metadata) {
this.title = metadata["title"];
jQuery('#title' + this.wid).html(decodeURIComponent(escape(this.title)));
if ("decorations" in metadata) {
this.decorations = metadata["decorations"];
this.topoffset = parseInt(jQuery(this.div).css('border-top-width'), 10);
if (this.decorations) {
jQuery('#head' + this.wid).show();
jQuery(this.div).removeClass("undecorated");
jQuery(this.div).addClass("window");
this.topoffset = this.topoffset + parseInt(jQuery(this.d_header).css('height'), 10);
}
else {
jQuery('#head' + this.wid).hide();
jQuery(this.div).removeClass("window");
jQuery(this.div).addClass("undecorated");
}
// update geometry
this.updateCSSGeometry();
this.handle_resized();
}
if ("window-type" in metadata) {
this.windowtype = metadata["window-type"][0];
if ("opacity" in metadata) {
var opacity = metadata["opacity"];
jQuery(this.div).css('opacity', ''+(opacity/100.0));
}
//if the attribute is set, add the corresponding css class:
var attrs = ["modal", "above", "below"];
for (var i = 0; i < attrs.length; i++) {
var attr = attrs[i];
if (attr in metadata) {
var value = metadata[attr];
if (value) {
jQuery(this.div).addClass(attr);
}
else {
jQuery(this.div).removeClass(attr);
}
}
}
};

Expand Down Expand Up @@ -550,20 +581,6 @@ XpraWindow.prototype.fill_screen = function() {
this.h = (screen_size[1] - this.topoffset) - this.bottomoffset;
};

XpraWindow.prototype.undecorate = function() {
// hide the window decoration
jQuery(this.d_header).hide();
// replace window style
jQuery(this.div).removeClass("window");
jQuery(this.div).addClass("undecorated");
// reset the offsets
this.leftoffset = parseInt(jQuery(this.div).css('border-left-width'), 10);
this.rightoffset = parseInt(jQuery(this.div).css('border-right-width'), 10);
this.topoffset = parseInt(jQuery(this.div).css('border-top-width'), 10);
this.bottomoffset = parseInt(jQuery(this.div).css('border-bottom-width'), 10);
// update geometry
this.updateCSSGeometry();
}

/**
* We have resized the window, so we need to:
Expand Down Expand Up @@ -830,7 +847,7 @@ XpraWindow.prototype._init_video = function(width, height, coding, profile, leve
this.video.setAttribute('height', height);
this.video.style.pointerEvents = "all";
this.video.style.position = "absolute";
this.video.style.zIndex = "1";
this.video.style.zIndex = this.div.css("z-index")+1;
this.video.style.left = ""+this.leftoffset+"px";
this.video.style.top = ""+this.topoffset+"px";
if(this.debug) {
Expand Down Expand Up @@ -1042,9 +1059,9 @@ XpraWindow.prototype.do_paint = function paint(x, y, width, height, coding, img_
var level = options["level"] || "3.0";
this._init_video(width, height, coding, profile, level);
}
else if (this.video.style.zIndex != "1"){
//make sure video is on the top layer:
this.video.style.zIndex = "1";
else {
//keep it above the div:
this.video.style.zIndex = this.div.css("z-index")+1;
}
if(img_data.length>0) {
if(this.debug) {
Expand Down

0 comments on commit 78eccb7

Please sign in to comment.