From addc87dcf1e16953e73c62312b0e443dbdc876f5 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Fri, 18 Mar 2016 12:43:51 -0700 Subject: [PATCH] Look for the keyboard in the view services The engine now provides the keyboard and raw keyboard services via the view services. This patch updates the framework to look there for the keyboard. Also, this patch migrates callers to the new MojoServices name for these entry points. --- bin/cache/engine.version | 2 +- packages/flutter/lib/shell.dart | 32 +++++++++++++++---- .../flutter/lib/src/rendering/child_view.dart | 2 +- .../lib/src/services/asset_bundle.dart | 2 +- .../flutter/lib/src/services/keyboard.dart | 2 +- .../src/widgets/raw_keyboard_listener.dart | 2 +- 6 files changed, 30 insertions(+), 12 deletions(-) diff --git a/bin/cache/engine.version b/bin/cache/engine.version index f764260e98..954262aa4d 100644 --- a/bin/cache/engine.version +++ b/bin/cache/engine.version @@ -1 +1 @@ -138fae117a19b6c7a9ae1a098daf35275a3002e7 +5114eade633fa9d08355d3e7a67b4c9f983d4357 diff --git a/packages/flutter/lib/shell.dart b/packages/flutter/lib/shell.dart index 92ce9e2509..35e27127c1 100644 --- a/packages/flutter/lib/shell.dart +++ b/packages/flutter/lib/shell.dart @@ -30,7 +30,7 @@ class MojoShell { static MojoShell _instance; static mojom.ShellProxy _initShellProxy() { - core.MojoHandle shellHandle = new core.MojoHandle(ui.takeShellProxyHandle()); + core.MojoHandle shellHandle = new core.MojoHandle(ui.MojoServices.takeShell()); if (!shellHandle.isValid) return null; return new mojom.ShellProxy.fromHandle(shellHandle); @@ -38,13 +38,13 @@ class MojoShell { final mojom.Shell _shell = _initShellProxy()?.ptr; static ApplicationConnection _initEmbedderConnection() { - core.MojoHandle servicesHandle = new core.MojoHandle(ui.takeServicesProvidedByEmbedder()); - core.MojoHandle exposedServicesHandle = new core.MojoHandle(ui.takeServicesProvidedToEmbedder()); - if (!servicesHandle.isValid || !exposedServicesHandle.isValid) + core.MojoHandle incomingServicesHandle = new core.MojoHandle(ui.MojoServices.takeIncomingServices()); + core.MojoHandle outgoingServicesHandle = new core.MojoHandle(ui.MojoServices.takeOutgoingServices()); + if (!incomingServicesHandle.isValid || !outgoingServicesHandle.isValid) return null; - mojom.ServiceProviderProxy services = new mojom.ServiceProviderProxy.fromHandle(servicesHandle); - mojom.ServiceProviderStub exposedServices = new mojom.ServiceProviderStub.fromHandle(exposedServicesHandle); - return new ApplicationConnection(exposedServices, services); + mojom.ServiceProviderProxy incomingServices = new mojom.ServiceProviderProxy.fromHandle(incomingServicesHandle); + mojom.ServiceProviderStub outgoingServices = new mojom.ServiceProviderStub.fromHandle(outgoingServicesHandle); + return new ApplicationConnection(outgoingServices, incomingServices); } final ApplicationConnection _embedderConnection = _initEmbedderConnection(); @@ -92,6 +92,24 @@ class MojoShell { services.close(); } + static mojom.ServiceProviderProxy _takeViewServices() { + core.MojoHandle services = new core.MojoHandle(ui.MojoServices.takeViewServices()); + if (!services.isValid) + return null; + return new mojom.ServiceProviderProxy.fromHandle(services); + } + final mojom.ServiceProviderProxy _viewServices = _takeViewServices(); + + void connectToViewAssociatedService(bindings.ProxyBase proxy) { + if (overrideConnectToService != null && overrideConnectToService(null, proxy)) + return; + if (_viewServices == null) + return; + core.MojoMessagePipe pipe = new core.MojoMessagePipe(); + proxy.impl.bind(pipe.endpoints[0]); + _viewServices.ptr.connectToService(proxy.serviceName, pipe.endpoints[1]); + } + /// Registers a service to expose to the embedder. void provideService(String interfaceName, ServiceFactory factory) { _embedderConnection?.provideService(interfaceName, factory); diff --git a/packages/flutter/lib/src/rendering/child_view.dart b/packages/flutter/lib/src/rendering/child_view.dart index adfc4f59e0..500dd723dd 100644 --- a/packages/flutter/lib/src/rendering/child_view.dart +++ b/packages/flutter/lib/src/rendering/child_view.dart @@ -18,7 +18,7 @@ import 'box.dart'; import 'object.dart'; mojom.ViewProxy _initViewProxy() { - int viewHandle = ui.takeViewHandle(); + int viewHandle = ui.MojoServices.takeView(); if (viewHandle == core.MojoHandle.INVALID) return null; return new mojom.ViewProxy.fromHandle(new core.MojoHandle(viewHandle)); diff --git a/packages/flutter/lib/src/services/asset_bundle.dart b/packages/flutter/lib/src/services/asset_bundle.dart index d6977cfb5a..bcc6e3b039 100644 --- a/packages/flutter/lib/src/services/asset_bundle.dart +++ b/packages/flutter/lib/src/services/asset_bundle.dart @@ -105,7 +105,7 @@ class MojoAssetBundle extends CachingAssetBundle { } AssetBundle _initRootBundle() { - int h = ui.takeRootBundleHandle(); + int h = ui.MojoServices.takeRootBundle(); if (h == core.MojoHandle.INVALID) return null; core.MojoHandle handle = new core.MojoHandle(h); diff --git a/packages/flutter/lib/src/services/keyboard.dart b/packages/flutter/lib/src/services/keyboard.dart index 98cb634b9b..201c66b5da 100644 --- a/packages/flutter/lib/src/services/keyboard.dart +++ b/packages/flutter/lib/src/services/keyboard.dart @@ -84,7 +84,7 @@ class KeyboardHandle { mojom.KeyboardProxy _initKeyboardProxy() { mojom.KeyboardProxy proxy = new mojom.KeyboardProxy.unbound(); - shell.connectToService(null, proxy); + shell.connectToViewAssociatedService(proxy); return proxy; } diff --git a/packages/flutter/lib/src/widgets/raw_keyboard_listener.dart b/packages/flutter/lib/src/widgets/raw_keyboard_listener.dart index 399813afcf..89956a4b81 100644 --- a/packages/flutter/lib/src/widgets/raw_keyboard_listener.dart +++ b/packages/flutter/lib/src/widgets/raw_keyboard_listener.dart @@ -59,7 +59,7 @@ class _RawKeyboardListenerState extends State implements mo return; _stub = new mojom.RawKeyboardListenerStub.unbound()..impl = this; mojom.RawKeyboardServiceProxy keyboard = new mojom.RawKeyboardServiceProxy.unbound(); - shell.connectToService(null, keyboard); + shell.connectToViewAssociatedService(keyboard); keyboard.ptr.addListener(_stub); keyboard.close(); }