Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle LOK_CALLBACK_TOOLTIP in wsd #7897

Merged
merged 2 commits into from Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions browser/src/core/Socket.js
Expand Up @@ -1166,6 +1166,10 @@ app.definitions.Socket = L.Class.extend({
// Switching modes.
window.location.reload(false);
}
else if (textMsg.startsWith('tooltip: ')) {
var tooltipInfo = JSON.parse(textMsg.substring(textMsg.indexOf('{')));
this._map.showDocumentTooltip(tooltipInfo, $('.leaflet-layer'));
}
else if (!textMsg.startsWith('tile:') && !textMsg.startsWith('delta:') &&
!textMsg.startsWith('renderfont:') && !textMsg.startsWith('windowpaint:')) {

Expand Down
18 changes: 18 additions & 0 deletions browser/src/map/Map.js
Expand Up @@ -424,6 +424,24 @@ L.Map = L.Evented.extend({
}
},

showDocumentTooltip: function(tooltipInfo, elem) {
var split = tooltipInfo.rectangle.split(',');
var latlng = this._docLayer._twipsToLatLng(new L.Point(+split[0], +split[1]));
var pt = this.latLngToContainerPoint(latlng);

elem.tooltip();
elem.tooltip('enable');
elem.tooltip('option', 'content', tooltipInfo.text);
elem.tooltip('option', 'items', elem[0]);
elem.tooltip('option', 'position', { my: 'left bottom', at: 'left+' + pt.x + ' top+' + pt.y, collision: 'fit fit' });
elem.tooltip('open');
document.addEventListener('mousemove', function closeTooltip() {
elem.tooltip('close');
elem.tooltip('disable');
document.removeEventListener('mousemove', closeTooltip);
});
},

updateModificationIndicator: function(newModificationTime) {
var timeout;

Expand Down
5 changes: 5 additions & 0 deletions kit/ChildSession.cpp
Expand Up @@ -3209,6 +3209,11 @@ void ChildSession::loKitCallback(const int type, const std::string& payload)
sendTextFrame("corelog: " + payload);
break;
}
case LOK_CALLBACK_TOOLTIP:
{
sendTextFrame("tooltip: " + payload);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might need to add "tooltip:" in HTTPWSTest::testInactiveClient(), in case it is generated by a test document.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!
Let me merge this, and then I will try to create a follow-up implementing your suggestion.

break;
}
default:
LOG_ERR("Unknown callback event (" << lokCallbackTypeToString(type) << "): " << payload);
}
Expand Down