Skip to content

[WIP] Unfork glutin.#17311

Closed
glennw wants to merge 1 commit intoservo:masterfrom
glennw:glutin-unfork
Closed

[WIP] Unfork glutin.#17311
glennw wants to merge 1 commit intoservo:masterfrom
glennw:glutin-unfork

Conversation

@glennw
Copy link
Copy Markdown
Member

@glennw glennw commented Jun 14, 2017

This builds and runs correctly on Linux with upstream glutin.

Moving to upstream glutin would have a few advantages:

  • Get future updates easily.
  • Allow us to upstream some planned optimization work on glutin (primarily swap buffers and dirty rect support).
  • Easily work with D3D / Wayland / Vulkan backends.

There's a number of items that would need to be checked / fixed before we could land this:

  • Get compiling and test on Mac.
  • Get compiling and test on Windows.
  • Get compiling and test on Android.
  • Confirm that window resizing and painting is working correctly on Mac.
  • Get the icon loading patches either upstreamed or rebased on a new glutin fork.
  • Get the platform_window() code working [or drop CEF for now?].

This change is Reviewable

@highfive
Copy link
Copy Markdown

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jun 14, 2017
@glennw
Copy link
Copy Markdown
Member Author

glennw commented Jun 14, 2017

Anyone want to try this / make fixes for Mac / Windows / Android? I think they should be relatively minor.

@MortimerGoro
Copy link
Copy Markdown
Contributor

MortimerGoro commented Jun 14, 2017

@glennw I'll compile & test on Android. We'll need to wait for this PR to be merged: rust-windowing/glutin#868. The glutin API have changed, so I need to resubmit the PR, and we´ll need to update the glutin version here when published

@jdm
Copy link
Copy Markdown
Member

jdm commented Jun 14, 2017

For mac:

diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs
index e4247c6523..b26a4b769b 100644
--- a/ports/glutin/window.rs
+++ b/ports/glutin/window.rs
@@ -86,7 +86,7 @@ fn builder_with_platform_options(mut builder: glutin::WindowBuilder) -> glutin::
         // output file.
         builder = builder.with_activation_policy(ActivationPolicy::Prohibited)
     }
-    builder.with_app_name(String::from("Servo"))
+    builder.with_title(String::from("Servo"))
 }

 #[cfg(not(target_os = "macos"))]

When resizing, the window only displays white until I let go of the mouse button.

@bors-servo
Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #17184) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Jun 14, 2017
@pyfisch
Copy link
Copy Markdown
Contributor

pyfisch commented Jun 22, 2017

Platform specific handle_keyboard_input should not be needed anymore with rust-windowing/winit#173.

@ahicks92
Copy link
Copy Markdown
Contributor

I want to try helping with this on Windows and am going to see if I can get it to compile here shortly.

Can we get a rebase? One of the other things that just got fixed for Windows is the ability to run the WPT suite. It would be useful if this was applied on top of that, I think, in the sense that I'm going to have to somehow have those commits involved

@ahicks92
Copy link
Copy Markdown
Contributor

A simple ./mach build -d does compile on Windows. Haven't dug into the diff yet.

This builds and runs correctly on Linux with upstream glutin.

Moving to upstream glutin would have a few advantages:
 * Get future updates easily.
 * Allow us to upstream some planned optimization work on glutin (primarily swap buffers and dirty rect support).
 * Easily work with D3D / Wayland / Vulkan backends.

There's a number of items that would need to be checked / fixed before we could land this:

- [ ] Get compiling and test on Mac.
- [ ] Get compiling and test on Windows.
- [ ] Get compiling and test on Android.
- [ ] Confirm that window resizing and painting is working correctly on Mac.
- [ ] Get the icon loading patches either upstreamed or rebased on a new glutin fork.
- [ ] Get the platform_window() code working [or drop CEF for now?].
@jdm
Copy link
Copy Markdown
Member

jdm commented Jun 25, 2017

I have pushed my rebased and amended version of this branch to https://github.com/jdm/servo/tree/unfork-glutin .

@jdm
Copy link
Copy Markdown
Member

jdm commented Jun 25, 2017

It currently fails ./mach test-tidy because of many duplicate crate versions, and etc/ci/check_no_panic.sh yields ports/glutin/window.rs:331: panic!("TODO: Support platform_window again!");.

@ahicks92
Copy link
Copy Markdown
Contributor

@jdm
If providing the URL is for me, rebasing isn't the issue. I'm trying to figure out how to coordinate with @glennw without making everyone's lives difficult.

Is rebasing mine and opening a PR against them, whereupon they rebase theirs (presumably to a later point off master than mine) and then I rebase mine on theirs again going to work? This sort of workflow doesn't seem to be documented by anyone. I thought I was fairly good with git until today.

@jdm
Copy link
Copy Markdown
Member

jdm commented Jun 26, 2017

I know; but providing a branch makes it extremely easy for @glennw to reset this PR's branch to an already working rebased copy.

@jdm jdm removed the S-needs-rebase There are merge conflict errors. label Jun 30, 2017
@jdm
Copy link
Copy Markdown
Member

jdm commented Jun 30, 2017

Rebased commit has been pushed.

@bors-servo
Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #17561) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Jun 30, 2017
@ahicks92
Copy link
Copy Markdown
Contributor

ahicks92 commented Jul 1, 2017

I will take another more serious look at this hopefully this weekend.

}
Event::KeyboardInput(element_state, _scan_code, Some(virtual_key_code)) => {
self.handle_keyboard_input(element_state, _scan_code, virtual_key_code);
Event::WindowEvent { event: glutin::WindowEvent::KeyboardInput(state, scan_code, Some(virtual_key_code), _), .. } => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we use the new mods parameter and not rely on key_modifiers?

}
}
let mouse_pos = self.mouse_pos.get();
self.handle_mouse(mouse_button, element_state, mouse_pos.x, mouse_pos.y);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need pos. mouse_pos is updated on mouse move. But it's possible that the click happened without a prior mouse move event. For example, if the mouse changes position when servo was not focused.

self.mouse_pos.set(Point2D::new(x, y));
self.event_queue.borrow_mut().push(
WindowEvent::MouseWindowMoveEventClass(TypedPoint2D::new(x as f32, y as f32)));
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as for click. pos is necessary.

@MortimerGoro
Copy link
Copy Markdown
Contributor

MortimerGoro commented Aug 1, 2017

Glutin has changed the API again. There is not a clear way to rebase the Android PR: rust-windowing/glutin#868

Asked tomaka about the issue. Will change the code & rebase again when we I get his feedback.

@emilio
Copy link
Copy Markdown
Member

emilio commented Aug 28, 2017

Any update here? It'd be quite nice to get this landed eventually.

@nox
Copy link
Copy Markdown
Contributor

nox commented Oct 9, 2017

Ping on this.

@paulrouget
Copy link
Copy Markdown
Contributor

FYI, I built a Servo port (with tab support) that uses the upstream glutin: https://github.com/paulrouget/servoshell - (see the src/platform/glutin).

@glennw
Copy link
Copy Markdown
Member Author

glennw commented Oct 17, 2017

I'm not going to have time to work on this in the near future - closing for now.

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

Labels

S-awaiting-review There is new code that needs to be reviewed. S-needs-rebase There are merge conflict errors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.