Skip to content

Commit

Permalink
#1424: call "ensure_visible" when resizing the browser window, and tr…
Browse files Browse the repository at this point in the history
…y to keep the window in view if the browser window is now smaller (there is a bug in the event position calculations.. so this doesn't work quite right yet)

git-svn-id: https://xpra.org/svn/Xpra/trunk@15241 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Mar 9, 2017
1 parent 44b33d7 commit 0df0bdf
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/html5/js/Window.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,23 @@ XpraWindow.prototype.ensure_visible = function() {
var oldy = this.y;
// for now make sure we don't out of top left
// this will be much smarter!
if(oldx <= 0) {
this.x = 0 + this.leftoffset;
var min_visible = 10;
var desktop_size = this.client._get_desktop_size();
var ww = desktop_size[0];
var wh = desktop_size[1];
//this.log("x=", this.x, "y=", this.y, "w=", this.w, "h=", this.h, "leftoffset=", this.leftoffset, "topoffset=", this.topoffset, " - ww=", ww, "wh=", wh);
if(oldx + this.w <= min_visible) {
this.x = min_visible - this.w + this.leftoffset;
}
if(oldy <= 10) {
else if (oldx >= ww - min_visible) {
this.x = Math.min(oldx, ww - min_visible);
}
if(oldy <= min_visible) {
this.y = 0 + this.topoffset;
}
else if (oldy >= wh - min_visible) {
this.y = Math.min(oldy, wh - min_visible);
}
if((oldx != this.x) || (oldy != this.y)) {
this.updateCSSGeometry();
return false;
Expand Down Expand Up @@ -542,6 +553,7 @@ XpraWindow.prototype.handle_resized = function(e) {
XpraWindow.prototype.handle_moved = function(e) {
// add on padding to the event position so that
// it reflects the internal geometry of the canvas
//this.log("handle moved: position=", e.position.left, e.position.top);
this.x = Math.round(e.position.left) + this.leftoffset;
this.y = Math.round(e.position.top) + this.topoffset;
// make sure we are visible after move
Expand All @@ -559,6 +571,7 @@ XpraWindow.prototype.screen_resized = function() {
this.fill_screen();
this.handle_resized();
}
this.ensure_visible();
};

/**
Expand Down

0 comments on commit 0df0bdf

Please sign in to comment.