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

multi_window example too simple #459

Closed
PerBothner opened this issue Dec 28, 2021 · 3 comments
Closed

multi_window example too simple #459

PerBothner opened this issue Dec 28, 2021 · 3 comments
Labels
good first issue Good for newcomers help wanted Help is requested to fix this issue type: enhancement

Comments

@PerBothner
Copy link
Contributor

This isn't really a feature request but rather a request to enhance the example applications.
Warning: I am quite new to Rust, and it is quite likely an experienced Rust programmer would not have these problems.

I'm trying to create multiple non-trivial windows in the same application. The examples/multi_window.rs is a bit too simple, in that window2 is relatively simple and very different from window1. I'd like openWindow to create the same kind of window, which means using the same new_window function/closure to create both. But then I get into nasty move/ownership issues, which I haven't been able to solve, so far.

Attached is what I have so far. It builds and runs - but as soon as I uncomment the second new_window call I get lots of errors. What is the clean/recommended way to get that functionality? (Feel free to use anything in my code that you find useful if you enhance the examples.) The use of "http://example.com" is just a place-holder. Most likely would be to enhance the UserEvent::NewWindow to pass suitable options from JavaScript to the rpc-handler to the event_loop handler.

main-rs.txt

Note I also used the seemingly-newer EventLoop::with_use_event idiom from custom_titlebar.rs, instead of the mpsc::channel logic from multi_window.rs.

@wusyong wusyong added good first issue Good for newcomers help wanted Help is requested to fix this issue type: enhancement labels Dec 30, 2021
@PerBothner
Copy link
Contributor Author

If someone with more Rush experience has a suggestion for a general approach, I can probably work out the details.

I tried converting variables to static items. However, some of them are mutable, and mutable statics aren't thread-safe. Using a bunch of unsafe code didn't seem like a promising approach.

@lucasfernog
Copy link
Member

Maybe paste your initial code here or Discord so we can help you.

amrbashir added a commit that referenced this issue Feb 5, 2022
@wusyong wusyong closed this as completed in 756bf8b Feb 5, 2022
wusyong pushed a commit that referenced this issue Feb 5, 2022
* refactor: remove unnecessary private mod shared (#400)

* refactor: remove unnecessary private mod shared

* chore: make fmt happy

* refactor: use eventloop proxy in `custom_titlebar` example (#401)

* Switch to tauri-webview2 (#411)

* Switch to tauri-webview2

This is a temporary fix of null pointer crash on `get_content` of web resource request. We will switch it back once upstream is updated.

* Add change file

* fix: remove clipboard property for consistency across platforms (#412)

* Remove clipboard property for consistancy across platforms

* Remove clipboard property for consistency

* feat: add inner_size for webview struct (#394)

* Add inner_size method

* Add inner_size for webview

* Fix feature flag placement

* Add feature flag on inner_size

* Cargo fmt

* feat(linux): allow resizing undecorated window using touch, closes #399 (#402)

* feat(linux): allow resizing undecorated window using touch
closes #399

* fix windows

* update custom_titlebar example

* revert windows changes

* Implement WebContextImpl on mac (#372)

* Implement WebContextImpl on mac

* Update type visibility

* Update cfg declaration

* Move WebContextImpl to wkwebview

* Fix protocol signature

* Add missing feature flag

* Cargo fmt

* Add change file

* Replace winapi with windows crate and use webview2-com instead of webview2 (#414)

* Add Windows and webview2-com  crates

* Replace winapi and webview2-sys with webview2-com

* Get all the examples working with webview2-com

* Point to the published version of webview2-com

* Add a summary in .changes

* Remove extra projects not in config.json

* Run cargo fmt --all

* Fix clippy warnings

* Update to 32-bit compatible webview2-com

* Sync with refactor in next branch of tao

* Use path prefix to prevent variable shadowing

* Fix Linux nightly/stable clippy warnings

* Update to latest review feedback in TAO

* Replace tao dependency with git+branch

* Switch to next branch of upstream tao repo

* doc: add warning doc on webcontext and ptr detections (#419)

* Add warning doc on webcontext and ptr detections

* cargo fmt

* Move Unix's webcontext implementation to webkitgtk (#421)

* chore: add `on_issue_closed.yml` (#424)

* Update webkit2gtk to 0.15 (#429)

* Update webkit2gtk

* Update webkit2gtk to 0.15

* Add changes file

* fix: add feature flags to toggle private APIs (#431)

* Add transparent feature flag

* Add flag for video fullscreen on macOS

* Add change file

* Make clippy happy

* Add clipboard field in WebViewAttributes (#432)

* fix(webview/linux): Use a workaround to fix CORS ... (#435)

... when making XHR requests inside a custom URI scheme context.

Reference: https://github.com/WebKit/WebKit/blob/9b6eae32a61d94be9963ef60d73a6d378099a97d/Source/WebKit/UIProcess/API/glib/WebKitProtocolHandler.cpp#L82-L91

* Delete on_issue_closed.yml (#436)

* Enable secure context back (#438)

* Disable all option on custom url scheme for now

* Enable secure context back

* fix link to tao repo (#439)

* fix(deps): update rust crate http to 0.2.5 (#416)

Co-authored-by: Renovate Bot <[email protected]>

* fix link to tao

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Ngo Iok Ui (Wu Yu Wei) <[email protected]>

* chore: remove unused files (#440)

* Update webview2-com and windows crates (#446)

* Replace webivew2-com-sys with prebuilt windows

* Bump to latest versions

* Set file drop handler after window creation

* Point tao back to the upstream next branch

* Rerun cargo fmt and fix Windows clippy warnings

* Add changelog file

* Use aliases for webview2_com instead of windows

* Use time instead of chrono (#447)

* Use time instead of chrono

* Make clippy happy

* fix(macos): unsupported key feedback sound (#448)

* fix(macos): unsupported key feedback sound, closes #

* Fix scope of YES

Co-authored-by: Yu-Wei Wu <[email protected]>

* Revert "fix(macos): unsupported key feedback sound (#448)"

This reverts commit b8fdfd6.

* Use tao commit with windows 0.25

* Switch back to tao's next branch

* feat: enable cookie persistence on Linux (#453)

* feat: enable cookie persistence on Linux

* fmt

* Bump webkit2gtk version (#457)

* Update windows crate to 0.29.0 and webview2-com to 0.9.0 (#455)

* Update to windows 0.29.0

* Add change description

* Update tao dependency (#461)

* fix: ignore transparency on Windows 7 (#460)

* fix: ignore transparency on Windows 7

* Update Cargo.toml

Co-authored-by: Ngo Iok Ui (Wu Yu Wei) <[email protected]>

* Remove clippy check (#462)

* chore: update PR template

* Fix: #276 - Add ability to set custom User Agent (#464)

* feat: Custom user agent attribute

Included example

* Fix setting type on Windows

Co-authored-by: Adit Sachde <[email protected]>
Co-authored-by: Wu Yu Wei <[email protected]>

* Add support of `HTTPBodyStream` (#465)

* Update to 2021 edition (#466)

* Update windows crate to 0.30.0

* change tao dep

* remove "tray" from default features and allow using "ayatana" instead (#469)

The "tray" feature enables dependency on libappindicator3.

On Debian 11 (and some other systems), libappindicator3 was
removed and replaced with libayatana-appindicator3:
  https://www.debian.org/releases/bullseye/amd64/release-notes/ch-information.en.html#noteworthy-obsolete-packages

This new library can be used by enabling the "ayatana" feature.

Depending on the system, only one of those library will usually
be available, and thus, only one of the "tray" and "ayatana"
feature would compile fine.

Having "tray" in default features did prevent building on systems
with no libappindicator3 available.

* Update tray examples (#470)

* chore: update pull request commit exmple

* feat: enable objc's exception feature [TRI-039]

* refactor: IPC handler [TRI-019]

* Feat/isolation (#5)

Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Ngo Iok Ui (Wu Yu Wei) <[email protected]>
Co-authored-by: Yu-Wei Wu <[email protected]>
Co-authored-by: Adit Sachde <[email protected]>
Co-authored-by: Wu Yu Wei <[email protected]>
Co-authored-by: Amr Bashir <[email protected]>
Co-authored-by: Bogdan Bivolaru <[email protected]>
Co-authored-by: Bill Avery <[email protected]>
Co-authored-by: Lucas Fernandes Nogueira <[email protected]>
Co-authored-by: Lucas Fernandes Nogueira <[email protected]>
Co-authored-by: amrbashir <[email protected]>
Co-authored-by: Chip Reed <[email protected]>
Co-authored-by: Jhonatan A <[email protected]>

* chore: fix Linux clippy warnings

* chore(audit): add report

* fix: windows build

* Update gtk to 0.15 (#472)

* chore: new `multi_window` example, closes #459 (#476)

* chore: new `multi_window` example, closes #459

* revert license change

Co-authored-by: Jason <[email protected]>
Co-authored-by: Amr Bashir <[email protected]>
Co-authored-by: Bill Avery <[email protected]>
Co-authored-by: liushuyu <[email protected]>
Co-authored-by: Bogdan Bivolaru <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Renovate Bot <[email protected]>
Co-authored-by: Lucas Fernandes Nogueira <[email protected]>
Co-authored-by: Lucas Fernandes Nogueira <[email protected]>
Co-authored-by: amrbashir <[email protected]>
Co-authored-by: Jhonatan A <[email protected]>
Co-authored-by: Adit Sachde <[email protected]>
Co-authored-by: Michael Alyn Miller <[email protected]>
Co-authored-by: Bill Avery <[email protected]>
Co-authored-by: Aurélien Jacobs <[email protected]>
Co-authored-by: Chip Reed <[email protected]>
@PerBothner
Copy link
Contributor Author

Thank you! I managed to modify my dt-wry front-end based on your example. Running the command domterm -Bwry multiple times creates multiple windows using a single dt-wry executable. I also added support for a --geometry option.

The source code is here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Help is requested to fix this issue type: enhancement
Projects
None yet
Development

No branches or pull requests

3 participants