Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2976)

Unified Diff: examples/sample_app/sample_app.cc

Issue 685013002: Refactors event dispatching of NativeViewport into its own interface (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: cleanup Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | examples/surfaces_app/surfaces_app.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: examples/sample_app/sample_app.cc
diff --git a/examples/sample_app/sample_app.cc b/examples/sample_app/sample_app.cc
index 26eac514b0281d87b7aeb339951c3b32710ef2e9..afc80fab887fe4f9d45eb03cd849f4311bb0bbef 100644
--- a/examples/sample_app/sample_app.cc
+++ b/examples/sample_app/sample_app.cc
@@ -21,20 +21,24 @@
namespace examples {
-class SampleApp : public mojo::ApplicationDelegate,
- public mojo::NativeViewportClient {
+class SampleApp
+ : public mojo::ApplicationDelegate,
+ public mojo::NativeViewportClient,
+ public mojo::InterfaceImpl<mojo::NativeViewportEventDispatcher> {
public:
SampleApp() : weak_factory_(this) {}
- virtual ~SampleApp() {
+ ~SampleApp() override {
// TODO(darin): Fix shutdown so we don't need to leak this.
mojo_ignore_result(gles2_client_.release());
}
- virtual void Initialize(mojo::ApplicationImpl* app) override {
+ void Initialize(mojo::ApplicationImpl* app) override {
app->ConnectToService("mojo:native_viewport_service", &viewport_);
viewport_.set_client(this);
+ SetEventDispatcher();
+
// TODO(jamesr): Should be mojo:gpu_service
app->ConnectToService("mojo:native_viewport_service", &gpu_service_);
@@ -47,16 +51,16 @@ class SampleApp : public mojo::ApplicationDelegate,
viewport_->Show();
}
- virtual void OnDestroyed() override { mojo::RunLoop::current()->Quit(); }
+ void OnDestroyed() override { mojo::RunLoop::current()->Quit(); }
- virtual void OnSizeChanged(mojo::SizePtr size) override {
+ void OnSizeChanged(mojo::SizePtr size) override {
assert(size);
if (gles2_client_)
gles2_client_->SetSize(*size);
}
- virtual void OnEvent(mojo::EventPtr event,
- const mojo::Callback<void()>& callback) override {
+ void OnEvent(mojo::EventPtr event,
+ const mojo::Callback<void()>& callback) override {
assert(event);
if (event->location_data && event->location_data->in_view_location)
gles2_client_->HandleInputEvent(*event);
@@ -64,6 +68,12 @@ class SampleApp : public mojo::ApplicationDelegate,
}
private:
+ void SetEventDispatcher() {
+ mojo::NativeViewportEventDispatcherPtr proxy;
+ mojo::WeakBindToProxy(this, &proxy);
+ viewport_->SetEventDispatcher(proxy.Pass());
+ }
+
void OnCreatedNativeViewport(uint64_t native_viewport_id) {
mojo::SizePtr size = mojo::Size::New();
size->width = 800;
« no previous file with comments | « no previous file | examples/surfaces_app/surfaces_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698