Skip to content

Commit

Permalink
cool#4250 - dpiscale: propagate from the client to the view via new l…
Browse files Browse the repository at this point in the history
…ok API.

In order to get the zoom level correct during save, it is
necessary to get the dpiscale from the browser to the client.
Use a new LOK setViewOption API to do this.

Tolerate old style clientzoom to avoid changes to unit tests.

Signed-off-by: Michael Meeks <[email protected]>
Change-Id: Ib32d4765fffefaf9b6b52f6a789834914ae58b6f
  • Loading branch information
mmeeks committed Nov 27, 2024
1 parent dccca45 commit ea6250e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
8 changes: 5 additions & 3 deletions browser/src/layer/tile/CanvasTileLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1030,9 +1030,11 @@ L.CanvasTileLayer = L.Layer.extend({
return;

var newClientZoom = 'tilepixelwidth=' + this._tileWidthPx + ' ' +
'tilepixelheight=' + this._tileHeightPx + ' ' +
'tiletwipwidth=' + this._tileWidthTwips + ' ' +
'tiletwipheight=' + this._tileHeightTwips;
'tilepixelheight=' + this._tileHeightPx + ' ' +
'tiletwipwidth=' + this._tileWidthTwips + ' ' +
'tiletwipheight=' + this._tileHeightTwips + ' ' +
'dpiscale=' + window.devicePixelRatio + ' ' +
'zoom=' + this._map.getZoom()

if (this._clientZoom !== newClientZoom || forceUpdate) {
// the zoom level has changed
Expand Down
12 changes: 11 additions & 1 deletion kit/ChildSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1189,8 +1189,9 @@ bool ChildSession::getCommandValues(const StringVector& tokens)
bool ChildSession::clientZoom(const StringVector& tokens)
{
int tilePixelWidth, tilePixelHeight, tileTwipWidth, tileTwipHeight;
std::string dpiScale, zoom;

if (tokens.size() != 5 ||
if (tokens.size() < 5 ||
!getTokenInteger(tokens[1], "tilepixelwidth", tilePixelWidth) ||
!getTokenInteger(tokens[2], "tilepixelheight", tilePixelHeight) ||
!getTokenInteger(tokens[3], "tiletwipwidth", tileTwipWidth) ||
Expand All @@ -1203,6 +1204,15 @@ bool ChildSession::clientZoom(const StringVector& tokens)
getLOKitDocument()->setView(_viewId);

getLOKitDocument()->setClientZoom(tilePixelWidth, tilePixelHeight, tileTwipWidth, tileTwipHeight);

if (tokens.size() == 7 &&
getTokenString(tokens[5], "dpiscale", dpiScale) &&
getTokenString(tokens[6], "zoom", zoom))
{
getLOKitDocument()->setViewOption("dpiscale", dpiScale.c_str());
getLOKitDocument()->setViewOption("zoom", zoom.c_str());
}

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion wsd/ClientSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ bool ClientSession::_handleInput(const char *buffer, int length)
else if (tokens.equals(0, "clientzoom"))
{
int tilePixelWidth, tilePixelHeight, tileTwipWidth, tileTwipHeight;
if (tokens.size() != 5 ||
if (tokens.size() < 5 ||
!getTokenInteger(tokens[1], "tilepixelwidth", tilePixelWidth) ||
!getTokenInteger(tokens[2], "tilepixelheight", tilePixelHeight) ||
!getTokenInteger(tokens[3], "tiletwipwidth", tileTwipWidth) ||
Expand Down

0 comments on commit ea6250e

Please sign in to comment.