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

Add web support via stdweb and web-sys #1221

Merged
merged 79 commits into from
Oct 16, 2019
Merged
Changes from 1 commit
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
fd4db40
Create the type layout
ryanisaacg Feb 13, 2019
f44e98d
Implemented a few easy methods
ryanisaacg Feb 20, 2019
c088f8b
Create the outline of event input and handler calls
ryanisaacg Feb 26, 2019
f698d45
Add key and mouse event support that typechecks
ryanisaacg Mar 2, 2019
37d354c
Get to a state where a canvas is spawned
ryanisaacg Mar 10, 2019
283a8de
Refactor out the stdweb functionality into different modules
ryanisaacg Mar 10, 2019
3dd0e31
Merge eventloop-2.0 into stdweb-eventloop-2
ryanisaacg Mar 11, 2019
aaee724
Rearchitect to allow API compliance
ryanisaacg Mar 12, 2019
d1deba8
Rename modules
ryanisaacg Mar 12, 2019
a5166ba
Implement request_redraw
ryanisaacg Mar 16, 2019
96786bb
Implement focus event
ryanisaacg Mar 16, 2019
85446d8
Fix warnings
ryanisaacg Mar 16, 2019
b09629f
Handle ControlFlow::Exit
ryanisaacg Mar 19, 2019
7c6bdcc
Handle ControlFlow::Exit and dealing with events-in-events
ryanisaacg Mar 23, 2019
9e25561
Fix compile failures and add canvas positioning
ryanisaacg Apr 3, 2019
fe5e300
Clean up and document the core of stdweb event handling
ryanisaacg Apr 25, 2019
9f801cf
Only send the request-redraw on the next animation frame
ryanisaacg Apr 29, 2019
70c7382
Fix the request_animation_frame lifetimes
ryanisaacg May 2, 2019
37dadab
Add access to the canvas in the Window
ryanisaacg Jun 1, 2019
1409f83
Add support for mouse wheel
ryanisaacg Jun 1, 2019
f2b6ef2
Merge master into stdweb-eventloop-2
ryanisaacg Jun 1, 2019
b59e3c6
WIP
ryanisaacg Jun 15, 2019
2690306
Implement Poll and WaitUntil in the stdweb backend
ryanisaacg Jun 17, 2019
182beb4
Indicate that I will be maintaing the stdweb backend
ryanisaacg Jun 17, 2019
e4d8e22
Start implementing web-sys backend
blm768 Jun 4, 2019
54b4074
Port remaining modules to web_sys
blm768 Jun 5, 2019
7dabad4
Fix throwToEscapeEventLoop function
blm768 Jun 6, 2019
77cd3ad
TEMPORARY: add testing example
blm768 Jun 6, 2019
94f6294
Prevent callbacks from being destroyed too early
blm768 Jun 7, 2019
91a511b
Replace JS snippet with throw_str
blm768 Jun 8, 2019
7de1261
Fix some warnings
blm768 Jun 8, 2019
5d31f73
Clean up Cargo.toml after incorrect rebase
blm768 Jun 18, 2019
b571362
Fix a panic due to double-borrow
ryanisaacg Jun 21, 2019
cf28751
Remove unnecessary set-to-wait in example
ryanisaacg Jun 23, 2019
a0f280e
Update how timeouts are cleared to avoid possible double-clearing
ryanisaacg Jun 23, 2019
eea9530
Merge remote-tracking branch 'blm/web-sys' into stdweb-eventloop-2
hecrj Jun 24, 2019
c5703eb
Draft `web` platform structure
hecrj Jun 25, 2019
b79089e
Implement `web_sys::Canvas` event listeners
hecrj Jun 25, 2019
9c5657b
Remove `Canvas` when dropped
hecrj Jun 25, 2019
d5368d7
Implement `Canvas::request_redraw`
hecrj Jun 25, 2019
8ad078b
Implement keyboard and blur/focus events
hecrj Jun 25, 2019
8f66d96
Support `ReceivedCharacter` event
hecrj Jun 25, 2019
1596cc5
Avoid leaking implementation details in `Canvas` API
hecrj Jun 25, 2019
bb28598
Implement `stdweb` backend for `web` platform
hecrj Jun 26, 2019
2a35646
Use latest `stdweb` revision
hecrj Jun 26, 2019
ea73dac
Fix feature names
hecrj Jun 26, 2019
7f2ba0e
Fix `set_cursor_icon`
hecrj Jun 29, 2019
de12028
Fix mouse release/press events
hecrj Jun 29, 2019
e89674d
Add `dyn` keyword where necessary
hecrj Jul 1, 2019
5cc84f3
Improve feature names to enable web backends
hecrj Jul 1, 2019
76645f3
Bump version
hecrj Jul 7, 2019
613fafd
Merge branch 'web' into webmerge2
goddessfreya Jul 10, 2019
53e646d
Merge pull request #1038 from ZeGentzy/web
Osspial Jul 10, 2019
7b23d19
Fix `web` errors (#1040)
hecrj Jul 10, 2019
fe12996
Update the web backend todo list
ryanisaacg Jul 17, 2019
e897d70
Bump the stdweb version to 0.4.18 (#1049)
ryanisaacg Jul 17, 2019
dbdde3d
Stop appending canvas to document in web platform (#1089)
hecrj Aug 8, 2019
7ee9d56
Disable web module on other targets than wasm32 (#1102)
Aug 14, 2019
e87bc3d
Send a LoopDestroyed event when the browser is closed (#1155)
ryanisaacg Sep 11, 2019
2c47c43
Implement WindowID on the web platform (#1177)
ryanisaacg Sep 19, 2019
28a5081
Fix web redraw requested (#1181)
ryanisaacg Sep 23, 2019
3e8669e
Merge branch 'master' into merge-master-to-web
ryanisaacg Sep 24, 2019
8cea3e2
Update the documentation to reflect web support (#1183)
ryanisaacg Sep 24, 2019
6732fa7
Fix compilation errors
ryanisaacg Sep 24, 2019
86bafdc
Merge branch 'web' into merge-master-to-web
ryanisaacg Sep 24, 2019
dcd9ddd
Fix the examples
ryanisaacg Sep 24, 2019
ea93a01
Switch to the released version
ryanisaacg Sep 27, 2019
a336e9e
Fix the formatting in the changelog
ryanisaacg Sep 27, 2019
cf3b0f3
Attach the raw handle data attribute
ryanisaacg Sep 27, 2019
e21df58
Merge branch 'master' into merge-master-to-web
ryanisaacg Sep 30, 2019
ab4d971
Fix imports in the multithreaded example
ryanisaacg Sep 30, 2019
02f2815
Update cargo fmt
ryanisaacg Sep 30, 2019
157ca9c
Update the feature matrix for wasm (#1218)
ryanisaacg Oct 9, 2019
bedb889
Fix the event key code variable name (#1219)
ryanisaacg Oct 11, 2019
3ff4834
Add web fullscreen support (#1142)
ryanisaacg Oct 11, 2019
a557b3c
Add web targets to travis (#1220)
ryanisaacg Oct 13, 2019
f62bb33
Merge branch 'master' into web
ryanisaacg Oct 13, 2019
676268d
Merge remote-tracking branch 'upstream/master' into web
ryanisaacg Oct 13, 2019
35bc65f
Remove usage of derivative
ryanisaacg Oct 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Handle ControlFlow::Exit and dealing with events-in-events
  • Loading branch information
ryanisaacg committed Mar 23, 2019
commit 7c6bdcc459bf33592f7c996c4d2506ea89ad0f6b
26 changes: 26 additions & 0 deletions src/platform_impl/stdweb/event_loop.rs
Original file line number Diff line number Diff line change
@@ -231,6 +231,11 @@ fn add_event<T: 'static, E, F>(elrs: &EventLoopRunnerShared<T>, target: &impl IE
let elrs = elrs.clone();

target.add_event_listener(move |event: E| {
// Don't capture the event if the events loop has been destroyed
if elrs.runner.borrow().control == ControlFlow::Exit {
return;
}

event.prevent_default();
event.stop_propagation();
event.cancel_bubble();
@@ -251,6 +256,22 @@ impl<T> ELRShared<T> {
// TODO: handle event loop closures
// TODO: handle event buffer
pub fn send_event(&self, event: Event<T>) {
let start_cause = StartCause::Poll; // TODO: this is obviously not right
self.handle_start(StartCause::Poll);
self.handle_event(event);
self.handle_event(Event::EventsCleared);
}

fn handle_start(&self, start: StartCause) {
let is_handling = if Some(ref runner) = *self.runner.borrow() {
runner.handling
} else {
false
};
self.handle_event(Event::StartCause(is_handling));
}

fn handle_event(&self, event: Event<T>) {
match *self.runner.borrow_mut() {
Some(ref mut runner) if !runner.handling => {
runner.handling = true;
@@ -264,6 +285,11 @@ impl<T> ELRShared<T> {
}
_ => self.events.borrow_mut().push_back(event)
}
if self.runner.borrow().is_some() {
if let Some(event) = self.events.borrow_mut().pop_front() {
self.handle_event(event);
}
}
}

}