Allow moving a webcontents to a different webview #7157

Merged
merged 1 commit into from Sep 20, 2016

Projects

None yet

4 participants

@Mossop
Contributor
Mossop commented Sep 9, 2016

This adds a guestinstance attribute to webviews. When the webview first loads it updates its guestinstance with the instance ID for the webcontents. Setting the attribute to an existing guestinstance moves the webcontents to the new webview and sends a destroy event on the original webview. This fixes #1871.

This also adds the did-attach event since it is useful for detecting when the move is complete and I think that that fixes #6972 as did-attach is sent for the first navigation too.

@Mossop Mossop Add a guestinstance attribute to webviews reflecting their current guest
instance ID and allowing moving a guest instance to a new webview.
313b2fa
@Mossop Mossop referenced this pull request in mozilla/tofino Sep 19, 2016
Open

Drag / drop tabs to move between windows #1168

@zcbenz
Contributor
zcbenz commented Sep 20, 2016

This is awesome. 👍

@zcbenz zcbenz merged commit e3e4506 into electron:master Sep 20, 2016

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build failed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
@aluxian-huginn aluxian-huginn referenced this pull request in Aluxian/Messenger-for-Desktop Sep 22, 2016
Closed

Update dependency: electron v1.4.1 #648

@TimNZ
TimNZ commented Sep 23, 2016 edited

@Mossop I can't figure out whether this is of interest to me - what real world coolness does this enable? Dragging content between BrowserWindow?

Update:

Ok I have now read #1871 but would like to see a code or pseudo-code example of a recommended approach.

@Mossop
Contributor
Mossop commented Sep 23, 2016

@TimNZ The tests show some examples but basically if you take the value of the guestinstance attribute from an active webview and set it on a different webview, even in a different BrowserWindow, then the content will move to the new webview and the old will receive a destroy event.

@TimNZ
TimNZ commented Sep 23, 2016

Thanks, was just reading through the tests now. I guess there is still limitations around implementing a similar tab drag into new window like a browser as we don't have the native GUI mechanism in Electron to do it?

@Mossop
Contributor
Mossop commented Sep 23, 2016

@TimNZ It's doable with html5 drag and drop APIs but you would of course have to write the app code yourself.

@TimNZ
TimNZ commented Sep 23, 2016

@Mossop Cool thanks. I'm building a business app MVP and not strong on HTML5, will have an expert doing that stuff. Great work!

@davej
Contributor
davej commented Sep 24, 2016

Could it be possible to duplicate/clone the webcontents? i.e., not 'destroy' the existing window?

This could allow multi-window apps that don't incur the penalty of the large init time associated with initialising javascript frameworks etc..

I created an issue for this a few months ago at #6063. Is something like this definitely not feasible? It could be a game-changer for multi-window electron apps if something like this was possible.

@Mossop
Contributor
Mossop commented Sep 24, 2016

@davej I can't say for certain that it's impossible but at the very least I think it would be extremely difficult to achieve that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment