[Libreoffice-commits] online.git: kit/ChildSession.cpp loleaflet/src
Pranav Kant
pranavk at collabora.co.uk
Wed Nov 29 08:05:48 UTC 2017
kit/ChildSession.cpp | 21 ----------
loleaflet/src/control/Control.LokDialog.js | 59 ++++++++++++++++++-----------
loleaflet/src/layer/tile/TileLayer.js | 4 -
3 files changed, 42 insertions(+), 42 deletions(-)
New commits:
commit a91f022e426ff34fba032142659fb43fbde65ee9
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Wed Nov 29 00:59:33 2017 +0530
lokdialog: Remove getDialogInfo call; ncorrect dialog size handling
Change-Id: Ieff59baa984982bd8126102dafc5a97f673a4150
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 3c1083c7..b540febe 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -947,7 +947,6 @@ bool ChildSession::renderDialog(const char* /*buffer*/, int /*length*/, const st
size_t pixmapDataSize = 4 * bufferWidth * bufferHeight;
std::vector<unsigned char> pixmap(pixmapDataSize);
int width = bufferWidth, height = bufferHeight;
- char* pDialogTitle = nullptr;
std::string response;
if (isChild)
{
@@ -966,30 +965,14 @@ bool ChildSession::renderDialog(const char* /*buffer*/, int /*length*/, const st
Timestamp timestamp;
getLOKitDocument()->paintDialog(dialogId, pixmap.data(), startX, startY, width, height);
- int dialogWidth = 0;
- int dialogHeight = 0;
- getLOKitDocument()->getDialogInfo(dialogId, &pDialogTitle, dialogWidth, dialogHeight);
-
- std::string encodedDialogTitle;
- if (pDialogTitle)
- {
- std::string aDialogTitle(pDialogTitle);
- URI::encode(aDialogTitle, "", encodedDialogTitle);
- free(pDialogTitle);
- }
-
- // rendered width, height cannot be less than the dialog width, height
- width = std::min(width, dialogWidth);
- height = std::min(height, dialogHeight);
const double area = width * height;
-
LOG_TRC("paintDialog for " << dialogId << " returned " << width << "X" << height
<< "@(" << startX << "," << startY << ")"
<< "and rendered in " << (timestamp.elapsed()/1000.)
<< "ms (" << area / (timestamp.elapsed()) << " MP/s).");
- response = "dialogpaint: id=" + tokens[1] + " title=" + encodedDialogTitle +
- " dialogwidth=" + std::to_string(dialogWidth) + " dialogheight=" + std::to_string(dialogHeight);
+ response = "dialogpaint: id=" + tokens[1] +
+ " width=" + std::to_string(width) + " height=" + std::to_string(height);
if (!paintRectangle.empty())
response += " rectangle=" + paintRectangle;
diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js
index 853972a8..c6a67444 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -63,17 +63,25 @@ L.Control.LokDialog = L.Control.extend({
this._map._socket.sendMessage(dialogCmd + ' ' + dialogId + (rectangle ? ' rectangle=' + rectangle : ''));
},
+ _isRectangleValid: function(rect) {
+ rect = rect.split(',');
+ if (parseInt(rect[0]) < 0 || parseInt(rect[1]) < 0 || parseInt(rect[2]) < 0 || parseInt(rect[3]) < 0)
+ return false;
+ return true;
+ },
+
_onDialogMsg: function(e) {
e.dialogId = this.dialogIdPrefix + e.dialogId;
if (e.action === 'created') {
this._width = parseInt(e.size.split(',')[0]);
this._height = parseInt(e.size.split(',')[1]);
-
this._launchDialog(e.dialogId);
this._sendDialogCommand(e.dialogId, this._createRectStr());
} else if (e.action === 'invalidate') {
- // ignore any invalidate callbacks when we have closed the dialog
if (this._isOpen(e.dialogId)) {
+ if (!this._isRectangleValid(e.rectangle))
+ return;
+
if (!e.rectangle)
e.rectangle = '0,0,' + this._width + ',' + this._height;
this._sendDialogCommand(e.dialogId, e.rectangle);
@@ -82,6 +90,11 @@ L.Control.LokDialog = L.Control.extend({
this._width = parseInt(e.size.split(',')[0]);
this._height = parseInt(e.size.split(',')[1]);
+ // FIXME: we don't really have to destroy and launch the dialog again but do it for
+ // now because the size sent to us previously in 'created' cb is not correct
+ $('#' + e.dialogId).remove();
+ this._launchDialog(e.dialogId);
+ $('#' + e.dialogId).dialog('option', 'title', this._title);
this._sendDialogCommand(e.dialogId, this._createRectStr());
} else if (e.action === 'cursor_invalidate') {
if (this._isOpen(e.dialogId) && !!e.rectangle) {
@@ -94,6 +107,9 @@ L.Control.LokDialog = L.Control.extend({
// set the position of the lokdialog-cursor
$(this._dialogs[e.dialogId].cursor).css({left: x, top: y});
}
+ } else if (e.action === 'title_changed') {
+ this._title = e.title;
+ $('#' + e.dialogId).dialog('option', 'title', e.title);
} else if (e.action === 'cursor_visible') {
var visible = e.visible === 'true';
if (visible)
@@ -228,7 +244,6 @@ L.Control.LokDialog = L.Control.extend({
if (!this._isOpen(dialogId))
return;
- $('#' + dialogId).dialog('option', 'title', decodeURIComponent(title));
var img = new Image();
var canvas = document.getElementById(dialogId + '-canvas');
var ctx = canvas.getContext('2d');
@@ -246,31 +261,33 @@ L.Control.LokDialog = L.Control.extend({
img.src = imgData;
},
- _isSameSize: function(dialogId, newWidth, newHeight) {
- var ret = false;
- if (this._isOpen(dialogId))
- {
- var oldWidth = $('#' + dialogId + '-canvas').width();
- var oldHeight = $('#' + dialogId + '-canvas').height();
- if (oldWidth == newWidth && oldHeight == newHeight)
- ret = true;
- }
-
- return ret;
- },
-
// Binary dialog msg recvd from core
_onDialogPaint: function (e) {
var dialogId = this.dialogIdPrefix + e.id;
if (!this._isOpen(dialogId))
return;
- if (!this._isSameSize(dialogId, e.dialogWidth, e.dialogHeight)) {
- var canvas = document.getElementById(dialogId + '-canvas');
- canvas.width = e.dialogWidth;
- canvas.height = e.dialogHeight;
+ // FIXME: as a precaution, if we get larger width or height here than what we got in 'created'
+ // callback, then adjust the dialog canvas size
+ var changed = false;
+ var canvas = document.getElementById(dialogId + '-canvas');
+ if (e.width > this._width) {
+ changed = true;
+ this._width = e.width;
+ canvas.width = e.width;
+ $('#' + dialogId).dialog('option', 'width', e.width);
+ }
+
+ if (e.height > this._height) {
+ changed = true;
+ this._height = e.height;
+ canvas.height = e.height;
+ $('#' + dialogId).dialog('option', 'height', e.height);
+ }
- $('#' + dialogId).dialog('option', 'width', e.dialogWidth);
+ if (changed) {
+ this._sendDialogCommand(dialogId, this._createRectStr());
+ return;
}
this._paintDialog(dialogId, e.title, e.rectangle, e.dialog);
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 5f0ba440..d704368e 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1212,8 +1212,8 @@ L.TileLayer = L.GridLayer.extend({
dialog: img,
title: command.title,
// TODO: add id too
- dialogWidth: command.dialogwidth,
- dialogHeight: command.dialogheight,
+ width: command.width,
+ height: command.height,
rectangle: command.rectangle
});
},
More information about the Libreoffice-commits
mailing list