[Spice-devel] spice-html5 cursor positioning problem

Jeremy White jwhite at codeweavers.com
Fri Sep 12 12:36:54 PDT 2014


> I don't know about performance issues but I would suggest to calculate the pointer position relative to the canvas like this:
>
>    var rect = sc.display.surfaces[sc.display.primary_surface].canvas.getBoundingClientRect();
>    this.x = e.clientX - rect.left;
>    this.y = e.clientY - rect.top;

I don't think I had any special reason for the method I used; I am not 
especially a viewport/css/javascript expert, so what the code uses is 
mostly the result of my trial and error efforts.

So, it sounds worthwhile to me.  (My only requirement is that any change 
retain support for Firefox, Chrome,and IE).

> I'm not sure how SpiceMsgcMouseMotion would be changed since it takes the distance from the offsetParent into account but not any scrolling.
> In my tests I couldn't observe that function running (sc.mouse_mode == SPICE_MOUSE_MODE_CLIENT every time I checked). Can someone explain briefly or point me to an explanation about mouse modes and when they are used?

I also no longer recall the origins of that else code.  I do know that 
the spice-html5 client responds to any change in the mouse mode with a 
request to use mouse mode client, so the expectation is that the 
spice-html5 client will always operate in client mode.

I imagine it would be easy to test; in the v2 patch I've just pushed, 
main.js, the new function, handle_mouse_mode, just invert the 
client/server logic there.  That should force the client into 'server' 
mouse mode.

Cheers,

Jeremy


More information about the Spice-devel mailing list