[scenic][view_ref] Change the ViewRef's underlying kernel object type.

The ViewRef should be a handle<eventpair>, instead of a handle<event>.

SCN-1410 #comment

TEST: fx run-test a11y_tests; fx run-test shortcut_test
Change-Id: Ic920075bac7508bc43204d41ad61817ddbd01c20
diff --git a/sdk/fidl/fuchsia.ui.views/fuchsia.ui.views.api b/sdk/fidl/fuchsia.ui.views/fuchsia.ui.views.api
index c0083de..0895061 100644
--- a/sdk/fidl/fuchsia.ui.views/fuchsia.ui.views.api
+++ b/sdk/fidl/fuchsia.ui.views/fuchsia.ui.views.api
@@ -1,6 +1,6 @@
 {
   "fidl/fuchsia.ui.views/commands.fidl": "3b8cf058c392d88a98a1b56b7f1ea809",
-  "fidl/fuchsia.ui.views/view.fidl": "9c4aa0db2f3a312519daf681c6fc6a53",
+  "fidl/fuchsia.ui.views/view.fidl": "da92cf923f6a35ad64f260200f7d2ea2",
   "fidl/fuchsia.ui.views/view_config.fidl": "125d69ad66f6d2fef3b9498b5d8c08c3",
   "fidl/fuchsia.ui.views/view_token.fidl": "3020ee0c3f85ac734587f6b1a54b0584"
 }
\ No newline at end of file
diff --git a/sdk/fidl/fuchsia.ui.views/view.fidl b/sdk/fidl/fuchsia.ui.views/view.fidl
index 48f284b..49d9443 100644
--- a/sdk/fidl/fuchsia.ui.views/view.fidl
+++ b/sdk/fidl/fuchsia.ui.views/view.fidl
@@ -104,26 +104,45 @@
     SetConfig(ViewConfig config);
 };
 
-/// A ViewRef is a kernel object that identifies a unique View
-/// across the system. When two ViewRefs refer to the same View,
-/// they have identical KOIDs.
+/// A ViewRef is a handle to a kernel object which identifies a unique View
+/// across the system. Two ViewRefs to the same View have the same KOID.
 ///
-/// We use a ViewRef to identify a View, to validate a View, and to
-/// signal invalidation.
+/// Clients use a ViewRef to identify a View, to validate a View, and to
+/// receive a View invalidation signal.
 ///
-/// For example, accessibility accepts a ViewRef to validate that
-/// a client has a valid View, and subsequently uses that ViewRef
-/// to group the semantic nodes associated with that View.
+/// As part of View creation, the client creates a linked
+/// ViewRef/ViewRefControl pair and hands the pair to Scenic (ViewRefControl is
+/// described below).  The client must remove the ViewRef's signal
+/// capabilities; otherwise the View is not created.
 ///
-/// Another example: We use ViewRefs to create a FocusChain
-/// (TBD), which identifies Views considered as "in-focus" down
-/// the View hierarchy. When a View is destroyed, Scenic signals
-/// to all ViewRef holders that the ViewRef is now invalid.
+/// The client may freely clone its ViewRef and share it, even before sending
+/// it to Scenic.
 ///
-/// Scenic creates and associates a ViewRef for each View. Scenic
-/// creates a copy of a ViewRef upon request by that View. The
-/// clone is transferrable, cloneable, and waitable, but not
-/// signalable (latter is reserved for Scenic).
+/// Example 1. Accessibility accepts a ViewRef from a client to group the
+/// semantic nodes, and semantic operations, associated with a client's View.
+/// It must validate a client's ViewRef with Scenic.
+///
+/// Example 2. We use ViewRefs to create a FocusChain, which identifies Views
+/// considered as "in-focus" down the View hierarchy. When a View is destroyed,
+/// Scenic signals to all FocusChain holders that the ViewRef is now invalid.
 struct ViewRef {
-    handle<event> reference;
+    handle<eventpair> reference;
+};
+
+/// A ViewRefControl is the peer to a ViewRef. Their |reference|s are linked.
+///
+/// Like ViewRef, a ViewRefControl is a typed handle to an eventpair.  Unlike
+/// ViewRef, a ViewRefControl's handle is unique. Scenic uses this property
+/// when it ties a ViewRefControl to a View, arranged to share fate.  When a
+/// View is destroyed, the associated destruction of its ViewRefControl
+/// triggers an automatic ZX_ERR_PEER_CLOSED signal sent to all ViewRef
+/// holders; hence ViewRef holders may track View lifetime.
+///
+/// As part of View creation, the client creates a linked
+/// ViewRef/ViewRefControl pair and hands the pair to Scenic (ViewRef is
+/// described above).  The client must not clone the ViewRefControl. It must
+/// not remove or modify the ViewRefControl's capabilities; otherwise the View
+/// is not created.
+struct ViewRefControl {
+    handle<eventpair> reference;
 };
diff --git a/src/ui/bin/shortcut/src/main.rs b/src/ui/bin/shortcut/src/main.rs
index 9024297..bcccf7e 100644
--- a/src/ui/bin/shortcut/src/main.rs
+++ b/src/ui/bin/shortcut/src/main.rs
@@ -142,8 +142,8 @@
             fidl::endpoints::create_request_stream::<ui_shortcut::ListenerMarker>()?;
 
         // Set listener and view ref.
-        let view_ref =
-            &mut ui_views::ViewRef { reference: zx::Event::create().expect("reference created") };
+        let (raw_event_pair, _) = zx::EventPair::create()?;
+        let view_ref = &mut ui_views::ViewRef { reference: raw_event_pair };
         registry.set_view(view_ref, listener_client_end).expect("set_view");
 
         // Set the shortcut.