Skip to content

Commit

Permalink
#1797 precise wheel support
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@18920 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Mar 31, 2018
1 parent f9eed64 commit afc70ab
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/html5/js/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1233,13 +1233,32 @@ XpraClient.prototype.do_window_mouse_scroll = function(e, window) {
y = Math.round(mouse.y);
var modifiers = [];
var buttons = [];
var wid = 0;
if (window) {
wid = window.wid;
}
var wheel = Utilities.normalizeWheel(e);
this.debug("mouse", "normalized wheel event:", wheel);
//clamp to prevent event floods:
var px = Math.min(1200, wheel.pixelX);
var py = Math.min(1200, wheel.pixelY);
var apx = Math.abs(px);
var apy = Math.abs(py);
if (this.server_precise_wheel) {
if (apx>0) {
var btn_x = (px>=0) ? 6 : 7;
var xdist = Math.round(px*1000/120);
this.send(["wheel-motion", wid, btn_x, -xdist,
(x, y), modifiers, buttons]);
}
if (apy>0) {
var btn_y = (py>=0) ? 5 : 4;
var ydist = Math.round(py*1000/120);
this.send(["wheel-motion", wid, btn_y, -ydist,
(x, y), modifiers, buttons]);
}
return;
}
//generate a single event if we can, or add to accumulators:
if (apx>=40 && apx<=160) {
this.wheel_delta_x = (px>0) ? 120 : -120;
Expand All @@ -1258,10 +1277,6 @@ XpraClient.prototype.do_window_mouse_scroll = function(e, window) {
var wy = Math.abs(this.wheel_delta_y);
var btn_x = (this.wheel_delta_x>=0) ? 6 : 7;
var btn_y = (this.wheel_delta_y>=0) ? 5 : 4;
var wid = 0;
if (window) {
wid = window.wid;
}
while (wx>=120) {
wx -= 120;
this.send(["button-action", wid, btn_x, true, [x, y], modifiers, buttons]);
Expand Down Expand Up @@ -1564,6 +1579,8 @@ XpraClient.prototype._process_hello = function(packet, ctx) {
ctx.server_screen_sizes = hello["screen-sizes"] || [];
console.log("server screen sizes:", ctx.server_screen_sizes)

ctx.server_precise_wheel = hello["wheel.precise"] || false;

ctx.remote_open_files = Boolean(hello["open-files"]);
ctx.remote_file_transfer = Boolean(hello["file-transfer"]);
ctx.remote_printing = Boolean(hello["printing"]);
Expand Down

0 comments on commit afc70ab

Please sign in to comment.