-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Show local cursor while dragging the viewport #1992
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
base: master
Are you sure you want to change the base?
Changes from 5 commits
6eb28b8
355dd27
0f48f31
5782915
97c0ad4
abc7d63
254fff9
59e40b4
b1745d5
5a9a81c
4dd16ad
b5b7ebe
3b79d45
68a2db4
4fc3fc9
702302f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -290,12 +290,12 @@ export default class RFB extends EventTargetMixin { | |
|
|
||
| // ===== PROPERTIES ===== | ||
|
|
||
| this.dragViewport = false; | ||
| this.focusOnClick = true; | ||
|
|
||
| this._viewOnly = false; | ||
| this._clipViewport = false; | ||
| this._clippingViewport = false; | ||
| this._dragViewport = false; | ||
| this._scaleViewport = false; | ||
| this._resizeSession = false; | ||
|
|
||
|
|
@@ -342,6 +342,12 @@ export default class RFB extends EventTargetMixin { | |
| this._updateClip(); | ||
| } | ||
|
|
||
| get dragViewport() { return this._dragViewport; } | ||
| set dragViewport(dragViewport) { | ||
| this._dragViewport = dragViewport; | ||
| this._refreshCursor(); | ||
| } | ||
|
|
||
| get scaleViewport() { return this._scaleViewport; } | ||
| set scaleViewport(scale) { | ||
| this._scaleViewport = scale; | ||
|
|
@@ -1111,11 +1117,14 @@ export default class RFB extends EventTargetMixin { | |
|
|
||
| let bmask = RFB._convertButtonMask(ev.buttons); | ||
|
|
||
| let down = ev.type == 'mousedown'; | ||
| let down = false; | ||
|
Comment on lines
1114
to
+1155
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this improve?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a minor non-functional optimization. First, the event type is compared against the word As the commit message says: Do not compare to 'mousedown' on every 'mousemove'. I guess --- 0f48f31e08a70045e4fe5deebcac7d7b04fd816d/core/rfb.js
+++ 57829159839e7a2358f5c22a53414565f5704087/core/rfb.js
@@ -1117,11 +1117,9 @@ export default class RFB extends EventTargetMixin {
let bmask = RFB._convertButtonMask(ev.buttons);
+ let down = false;
- let down = ev.type == 'mousedown';
switch (ev.type) {
case 'mousedown':
+ down = true;
+ // eslint-disable-next-line no-fallthrough
case 'mouseup':
if (this._dragViewport) {
this._cursor.setLocalCursor(down ? 'grabbing' : 'grab');
@@ -1157 +1159 @@
break;
case 'mousemove': |
||
| switch (ev.type) { | ||
| case 'mousedown': | ||
| down = true; | ||
| // eslint-disable-next-line no-fallthrough | ||
| case 'mouseup': | ||
| if (this.dragViewport) { | ||
| if (this._dragViewport) { | ||
| this._cursor.setLocalCursor(down ? 'grabbing' : 'grab'); | ||
| if (down && !this._viewportDragging) { | ||
| this._viewportDragging = true; | ||
| this._viewportDragPos = {'x': pos.x, 'y': pos.y}; | ||
|
|
@@ -1334,7 +1343,7 @@ export default class RFB extends EventTargetMixin { | |
| this._handleTapEvent(ev, 0x2); | ||
| break; | ||
| case 'drag': | ||
| if (this.dragViewport) { | ||
| if (this._dragViewport) { | ||
| this._viewportHasMoved = false; | ||
| this._viewportDragging = true; | ||
| this._viewportDragPos = {'x': pos.x, 'y': pos.y}; | ||
|
|
@@ -1344,7 +1353,7 @@ export default class RFB extends EventTargetMixin { | |
| } | ||
| break; | ||
| case 'longpress': | ||
| if (this.dragViewport) { | ||
| if (this._dragViewport) { | ||
| // If dragViewport is true, we need to wait to see | ||
| // if we have dragged outside the threshold before | ||
| // sending any events to the server. | ||
|
|
@@ -1376,7 +1385,7 @@ export default class RFB extends EventTargetMixin { | |
| break; | ||
| case 'drag': | ||
| case 'longpress': | ||
| if (this.dragViewport) { | ||
| if (this._dragViewport) { | ||
| this._viewportDragging = true; | ||
| const deltaX = this._viewportDragPos.x - pos.x; | ||
| const deltaY = this._viewportDragPos.y - pos.y; | ||
|
|
@@ -1451,7 +1460,7 @@ export default class RFB extends EventTargetMixin { | |
| case 'twodrag': | ||
| break; | ||
| case 'drag': | ||
| if (this.dragViewport) { | ||
| if (this._dragViewport) { | ||
| this._viewportDragging = false; | ||
| } else { | ||
| this._fakeMouseMove(ev, pos.x, pos.y); | ||
|
|
@@ -1465,7 +1474,7 @@ export default class RFB extends EventTargetMixin { | |
| break; | ||
| } | ||
|
|
||
| if (this.dragViewport && !this._viewportHasMoved) { | ||
| if (this._dragViewport && !this._viewportHasMoved) { | ||
| this._fakeMouseMove(ev, pos.x, pos.y); | ||
| // If dragViewport is true, we need to wait to see | ||
| // if we have dragged outside the threshold before | ||
|
|
@@ -3032,7 +3041,7 @@ export default class RFB extends EventTargetMixin { | |
|
|
||
| _shouldShowDotCursor() { | ||
| // Called when this._cursorImage is updated | ||
| if (!this._showDotCursor) { | ||
| if (!this._showDotCursor || this._dragViewport) { | ||
| // User does not want to see the dot, so... | ||
| return false; | ||
| } | ||
|
|
@@ -3062,6 +3071,11 @@ export default class RFB extends EventTargetMixin { | |
| image.hotx, image.hoty, | ||
| image.w, image.h | ||
| ); | ||
| if (this._dragViewport) { | ||
| this._cursor.setLocalCursor(this._viewportDragging ? 'grabbing' : 'grab'); | ||
| } else { | ||
| this._cursor.setLocalCursor('none'); | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking that we only show the drag cursor whilst actively dragging. Otherwise, we want to keep showing the actual cursor to give proper feedback.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't make that many sense to only show a local cursor whilst dragging the viewport. There might be other reasons for a local cursor in different situations. See below. Reverted with 254fff9 |
||
| } | ||
|
|
||
| static genDES(password, challenge) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,7 +106,7 @@ export default class Cursor { | |
| } | ||
|
|
||
| clear() { | ||
| this._target.style.cursor = 'none'; | ||
| this.setLocalCursor('none'); | ||
| this._canvas.width = 0; | ||
| this._canvas.height = 0; | ||
| this._position.x = this._position.x + this._hotSpot.x; | ||
|
|
@@ -115,6 +115,10 @@ export default class Cursor { | |
| this._hotSpot.y = 0; | ||
| } | ||
|
|
||
| setLocalCursor(cursor) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this fits well with how this class normally operates. I think you'll need to extend the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| this._target.style.cursor = cursor; | ||
| } | ||
|
|
||
| // Mouse events might be emulated, this allows | ||
| // moving the cursor in such cases | ||
| move(clientX, clientY) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have the toolbar button for this. What's the purpose of this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a button, but no URL parameter to save this setting as bookmark or enable it automatically when embedding.
https://example.org/vnc.html?autoconnect=1&view_clip=1&view_drag=1Nevertheless, it wasn't working as intended. Fixed with abc7d63