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

Help using DragToggle in vnc_auto #480

Closed
onny opened this issue Apr 26, 2015 · 4 comments
Closed

Help using DragToggle in vnc_auto #480

onny opened this issue Apr 26, 2015 · 4 comments
Labels

Comments

@onny
Copy link

onny commented Apr 26, 2015

Hey,
it's very complicated to strip vnc.html down to a minimum, especially when you have to use and debug it on a mobile device aditionally.
I then tried to add set_viewportDrag in vnc_auto.html after rfb.connect function

rfb.connect("example.com", "1234", "", "websockify");
rfb.set_viewportDrag(true);

This sueccessfully disables the click event inside the vnc session but does not enable draging on my mobile Android phone.
I guess this might have something to do with CSS and stylesheets of the canvas element?

Thank you for any hint,
Jonas

@samhed
Copy link
Member

samhed commented May 20, 2015

As you can see in our example application (vnc.html which uses ui.js), on touch devices the actual page content is never bigger than the browser window but the VNC content can be. We call this behavior "clipping" or simply viewport. This is a setting which always is forced on touch enabled devices.

Our dragging relies on moving the display viewport on the VNC content. Since the viewport/content can be bigger than the browser window when NOT clipping we must couple dragging with clipping.

Use:

display.set_viewport(true);

@samhed samhed closed this as completed May 20, 2015
@onny
Copy link
Author

onny commented Aug 4, 2017

Thank you @samhed for this clarification. I'm still trying to figure out how I could adopt noVNC to my needs.
I was trying to use vnc.html as base for my VNC viewer but it was too complicated (too many UI elements which I don't need). vnc_auto.html is a good and basic example and all what I need there is local resizing and for mobile screen the dragging and viewport functionality.

I was trying to enable clipping/dragging but it seems that it is not easy like that:

            rfb.connect(host, port, password, path);
            var display = rfb.get_display();
            display.set_viewport(true);

:(
In case of local downscaling, should I reimplement this myself or is there any way I could use an already implemented function?
Since this didn't work in vnc_auto.html:

                rfb = new RFB({'target':       $D('noVNC_canvas'),
[...]
                               'resize': 'scale',
                               'shared':       WebUtil.getConfigVar('shared', true),
                               'view_only':    false,
[...]

Best regards,
Jonas

@DirectXMan12
Copy link
Member

I was trying to enable clipping/dragging but it seems that it is not easy like that:

So, you have the first part right -- display.set_viewport(true) enables clipping. Then, you have to actually change the size of the viewport (display.viewportChangeSize(width, height)).

Dragging requires enabling dragging on the RFB object (rfb.set_viewportDrag(true)) while dragging.

Look for updateViewClip and updateViewDrag in app/ui.js.

In case of local downscaling, should I reimplement this myself or is there any way I could use an already implemented function?

noVNC does support local scaling. You can see how it works at https://github.com/novnc/noVNC/blob/master/app/ui.js#L1247 (applyResizeMode in app/ui.js). You'd have to replicate that yourself (basically, pass the desired screen size to rfb.get_display().autoscale(width, height, downscaleOnly)).

@onny
Copy link
Author

onny commented Aug 4, 2017

I'll give that a try, thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants