aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Rouget <me@paulrouget.com>2019-08-20 10:10:07 +0200
committerPaul Rouget <me@paulrouget.com>2019-08-21 11:12:20 +0200
commitaaefaee5dc93bd0aa0c21e3d717e178b0145142b (patch)
treebd70a23e8fa64a7d4b6c3991b2eb2b11dee039f2
parent5c1d130217db8ece7313d69a7e76130085d67e94 (diff)
downloadservo-aaefaee5dc93bd0aa0c21e3d717e178b0145142b.tar.gz
servo-aaefaee5dc93bd0aa0c21e3d717e178b0145142b.zip
Disable URL bar hit testing while scrolling in Servo
-rw-r--r--support/hololens/ServoApp/BrowserPage.cpp6
-rw-r--r--support/hololens/ServoApp/BrowserPage.xaml2
-rw-r--r--support/hololens/ServoApp/ServoControl/ServoControl.cpp17
-rw-r--r--support/hololens/ServoApp/ServoControl/ServoControl.h54
-rw-r--r--support/hololens/ServoApp/ServoControl/ServoControl.idl8
5 files changed, 68 insertions, 19 deletions
diff --git a/support/hololens/ServoApp/BrowserPage.cpp b/support/hololens/ServoApp/BrowserPage.cpp
index 0db7a055cec..617ef66e27d 100644
--- a/support/hololens/ServoApp/BrowserPage.cpp
+++ b/support/hololens/ServoApp/BrowserPage.cpp
@@ -35,6 +35,12 @@ void BrowserPage::BindServoEvents() {
reloadButton().IsEnabled(true);
stopButton().IsEnabled(false);
});
+ servoControl().OnCaptureGesturesStarted([=] {
+ servoControl().Focus(FocusState::Programmatic);
+ navigationBar().IsHitTestVisible(false);
+ });
+ servoControl().OnCaptureGesturesEnded(
+ [=] { navigationBar().IsHitTestVisible(true); });
}
void BrowserPage::LoadServoURI(Uri uri) {
diff --git a/support/hololens/ServoApp/BrowserPage.xaml b/support/hololens/ServoApp/BrowserPage.xaml
index 5a99683e95d..50f5c7972ab 100644
--- a/support/hololens/ServoApp/BrowserPage.xaml
+++ b/support/hololens/ServoApp/BrowserPage.xaml
@@ -13,7 +13,7 @@
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
- <Grid Grid.Row="0">
+ <Grid Grid.Row="0" x:Name="navigationBar">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
diff --git a/support/hololens/ServoApp/ServoControl/ServoControl.cpp b/support/hololens/ServoApp/ServoControl/ServoControl.cpp
index 9de129c1e4e..bba1bce0aa5 100644
--- a/support/hololens/ServoApp/ServoControl/ServoControl.cpp
+++ b/support/hololens/ServoApp/ServoControl/ServoControl.cpp
@@ -32,9 +32,22 @@ void ServoControl::Shutdown() {
}
void ServoControl::OnLoaded(IInspectable const &, RoutedEventArgs const &) {
- Panel().PointerReleased(
+ auto panel = Panel();
+ panel.PointerReleased(
std::bind(&ServoControl::OnSurfaceClicked, this, _1, _2));
- Panel().ManipulationDelta(
+ panel.ManipulationStarted(
+ [=](IInspectable const &,
+ Input::ManipulationStartedRoutedEventArgs const &e) {
+ mOnCaptureGesturesStartedEvent();
+ e.Handled(true);
+ });
+ panel.ManipulationCompleted(
+ [=](IInspectable const &,
+ Input::ManipulationCompletedRoutedEventArgs const &e) {
+ mOnCaptureGesturesEndedEvent();
+ e.Handled(true);
+ });
+ panel.ManipulationDelta(
std::bind(&ServoControl::OnSurfaceManipulationDelta, this, _1, _2));
InitializeConditionVariable(&mGLCondVar);
InitializeCriticalSection(&mGLLock);
diff --git a/support/hololens/ServoApp/ServoControl/ServoControl.h b/support/hololens/ServoApp/ServoControl/ServoControl.h
index bd1d8a74d63..cb733ddfa37 100644
--- a/support/hololens/ServoApp/ServoControl/ServoControl.h
+++ b/support/hololens/ServoApp/ServoControl/ServoControl.h
@@ -15,34 +15,59 @@ struct ServoControl : ServoControlT<ServoControl>, public servo::ServoDelegate {
void Shutdown();
Windows::Foundation::Uri LoadURIOrSearch(hstring);
- void OnLoaded(IInspectable const &, Windows::UI::Xaml::RoutedEventArgs const &);
+ void OnLoaded(IInspectable const &,
+ Windows::UI::Xaml::RoutedEventArgs const &);
winrt::event_token
- OnURLChanged(Windows::Foundation::EventHandler<hstring> const &handler){
+ OnURLChanged(Windows::Foundation::EventHandler<hstring> const &handler) {
return mOnURLChangedEvent.add(handler);
};
- void OnURLChanged(winrt::event_token const& token) noexcept { mOnURLChangedEvent.remove(token); }
+ void OnURLChanged(winrt::event_token const &token) noexcept {
+ mOnURLChangedEvent.remove(token);
+ }
winrt::event_token
- OnTitleChanged(Windows::Foundation::EventHandler<hstring> const &handler){
+ OnTitleChanged(Windows::Foundation::EventHandler<hstring> const &handler) {
return mOnTitleChangedEvent.add(handler);
};
- void OnTitleChanged(winrt::event_token const& token) noexcept { mOnTitleChangedEvent.remove(token); }
+ void OnTitleChanged(winrt::event_token const &token) noexcept {
+ mOnTitleChangedEvent.remove(token);
+ }
- winrt::event_token OnHistoryChanged(HistoryChangedDelegate const &handler){
+ winrt::event_token OnHistoryChanged(HistoryChangedDelegate const &handler) {
return mOnHistoryChangedEvent.add(handler);
};
- void OnHistoryChanged(winrt::event_token const& token) noexcept { mOnHistoryChangedEvent.remove(token); }
+ void OnHistoryChanged(winrt::event_token const &token) noexcept {
+ mOnHistoryChangedEvent.remove(token);
+ }
- winrt::event_token OnLoadStarted(LoadStatusChangedDelegate const &handler){
+ winrt::event_token OnLoadStarted(EventDelegate const &handler) {
return mOnLoadStartedEvent.add(handler);
};
- void OnLoadStarted(winrt::event_token const& token) noexcept { mOnLoadStartedEvent.remove(token); }
+ void OnLoadStarted(winrt::event_token const &token) noexcept {
+ mOnLoadStartedEvent.remove(token);
+ }
- winrt::event_token OnLoadEnded(LoadStatusChangedDelegate const &handler){
+ winrt::event_token OnLoadEnded(EventDelegate const &handler) {
return mOnLoadEndedEvent.add(handler);
};
- void OnLoadEnded(winrt::event_token const& token) noexcept { mOnLoadEndedEvent.remove(token); }
+ void OnLoadEnded(winrt::event_token const &token) noexcept {
+ mOnLoadEndedEvent.remove(token);
+ }
+
+ winrt::event_token OnCaptureGesturesStarted(EventDelegate const &handler) {
+ return mOnCaptureGesturesStartedEvent.add(handler);
+ };
+ void OnCaptureGesturesStarted(winrt::event_token const &token) noexcept {
+ mOnCaptureGesturesStartedEvent.remove(token);
+ }
+
+ winrt::event_token OnCaptureGesturesEnded(EventDelegate const &handler) {
+ return mOnCaptureGesturesEndedEvent.add(handler);
+ };
+ void OnCaptureGesturesEnded(winrt::event_token const &token) noexcept {
+ mOnCaptureGesturesEndedEvent.remove(token);
+ }
virtual void WakeUp();
virtual void OnServoLoadStarted();
@@ -61,8 +86,11 @@ private:
winrt::event<Windows::Foundation::EventHandler<hstring>> mOnURLChangedEvent;
winrt::event<Windows::Foundation::EventHandler<hstring>> mOnTitleChangedEvent;
winrt::event<HistoryChangedDelegate> mOnHistoryChangedEvent;
- winrt::event<LoadStatusChangedDelegate> mOnLoadStartedEvent;
- winrt::event<LoadStatusChangedDelegate> mOnLoadEndedEvent;
+ winrt::event<EventDelegate> mOnLoadStartedEvent;
+ winrt::event<EventDelegate> mOnLoadEndedEvent;
+ winrt::event<EventDelegate> mOnCaptureGesturesStartedEvent;
+ winrt::event<EventDelegate> mOnCaptureGesturesEndedEvent;
+
hstring mInitialURL = L"https://servo.org";
Windows::UI::Xaml::Controls::SwapChainPanel ServoControl::Panel();
diff --git a/support/hololens/ServoApp/ServoControl/ServoControl.idl b/support/hololens/ServoApp/ServoControl/ServoControl.idl
index dcdc9e051f3..f392b1fcbf8 100644
--- a/support/hololens/ServoApp/ServoControl/ServoControl.idl
+++ b/support/hololens/ServoApp/ServoControl/ServoControl.idl
@@ -1,6 +1,6 @@
namespace ServoApp {
- delegate void LoadStatusChangedDelegate();
+ delegate void EventDelegate();
delegate void HistoryChangedDelegate(Boolean back, Boolean forward);
runtimeclass ServoControl : Windows.UI.Xaml.Controls.Control {
@@ -11,8 +11,10 @@ namespace ServoApp {
void Stop();
Windows.Foundation.Uri LoadURIOrSearch(String url);
void Shutdown();
- event LoadStatusChangedDelegate OnLoadStarted;
- event LoadStatusChangedDelegate OnLoadEnded;
+ event EventDelegate OnLoadStarted;
+ event EventDelegate OnLoadEnded;
+ event EventDelegate OnCaptureGesturesStarted;
+ event EventDelegate OnCaptureGesturesEnded;
event HistoryChangedDelegate OnHistoryChanged;
event Windows.Foundation.EventHandler<String> OnTitleChanged;
event Windows.Foundation.EventHandler<String> OnURLChanged;