aboutsummaryrefslogtreecommitdiffstats
path: root/support
diff options
context:
space:
mode:
authorPaul Rouget <me@paulrouget.com>2019-08-29 06:09:46 +0200
committerPaul Rouget <me@paulrouget.com>2019-08-29 06:53:53 +0200
commit5fe9a6223d74bcf9849c1b8c39e8ea9f2100bc45 (patch)
tree2b029a71de89ce09f3c25ba87e0f6f7d692ebace /support
parent3ade7b680d2d17fb849d10fd69acd7a3010ed8e4 (diff)
downloadservo-5fe9a6223d74bcf9849c1b8c39e8ea9f2100bc45.tar.gz
servo-5fe9a6223d74bcf9849c1b8c39e8ea9f2100bc45.zip
Switch to chromeless mode when app opens from a servo:// link
Diffstat (limited to 'support')
-rw-r--r--support/hololens/ServoApp/App.cpp6
-rw-r--r--support/hololens/ServoApp/BrowserPage.cpp6
-rw-r--r--support/hololens/ServoApp/BrowserPage.h1
-rw-r--r--support/hololens/ServoApp/ServoControl/ServoControl.cpp10
-rw-r--r--support/hololens/ServoApp/ServoControl/ServoControl.h3
-rw-r--r--support/hololens/ServoApp/ServoControl/ServoControl.idl1
-rw-r--r--support/hololens/ServoApp/pch.h1
7 files changed, 26 insertions, 2 deletions
diff --git a/support/hololens/ServoApp/App.cpp b/support/hololens/ServoApp/App.cpp
index 9beeb0b9540..3bb1e776fb8 100644
--- a/support/hololens/ServoApp/App.cpp
+++ b/support/hololens/ServoApp/App.cpp
@@ -71,7 +71,8 @@ void App::OnActivated(IActivatedEventArgs const &args) {
Frame rootFrame{nullptr};
auto content = Window::Current().Content();
- if (content == nullptr) {
+ bool isRunning = content != nullptr;
+ if (!isRunning) {
rootFrame = Frame();
rootFrame.Navigate(xaml_typename<ServoApp::BrowserPage>());
Window::Current().Content(rootFrame);
@@ -81,6 +82,9 @@ void App::OnActivated(IActivatedEventArgs const &args) {
}
auto page = rootFrame.Content().try_as<BrowserPage>();
page->LoadServoURI(protocolActivatedEventArgs.Uri());
+ // If Servo was opened as a result of clicking on a servo:// URL,
+ // we activate transient mode.
+ page->SetTransientMode(!isRunning);
}
}
diff --git a/support/hololens/ServoApp/BrowserPage.cpp b/support/hololens/ServoApp/BrowserPage.cpp
index 617ef66e27d..1a9b2073bbd 100644
--- a/support/hololens/ServoApp/BrowserPage.cpp
+++ b/support/hololens/ServoApp/BrowserPage.cpp
@@ -55,6 +55,12 @@ void BrowserPage::LoadServoURI(Uri uri) {
servoControl().LoadURIOrSearch(raw2);
}
+void BrowserPage::SetTransientMode(bool transient) {
+ servoControl().SetTransientMode(transient);
+ navigationBar().Visibility(transient ? Visibility::Collapsed
+ : Visibility::Visible);
+}
+
void BrowserPage::Shutdown() { servoControl().Shutdown(); }
/**** USER INTERACTIONS WITH UI ****/
diff --git a/support/hololens/ServoApp/BrowserPage.h b/support/hololens/ServoApp/BrowserPage.h
index 1d323eb9e15..e9f2ee8448b 100644
--- a/support/hololens/ServoApp/BrowserPage.h
+++ b/support/hololens/ServoApp/BrowserPage.h
@@ -28,6 +28,7 @@ public:
Windows::UI::Xaml::Input::KeyRoutedEventArgs const &);
void Shutdown();
void LoadServoURI(Windows::Foundation::Uri uri);
+ void SetTransientMode(bool);
private:
void BindServoEvents();
diff --git a/support/hololens/ServoApp/ServoControl/ServoControl.cpp b/support/hololens/ServoApp/ServoControl/ServoControl.cpp
index 56c4938490e..f856aaad679 100644
--- a/support/hololens/ServoApp/ServoControl/ServoControl.cpp
+++ b/support/hololens/ServoApp/ServoControl/ServoControl.cpp
@@ -8,6 +8,7 @@ using namespace winrt::Windows::Graphics::Display;
using namespace winrt::Windows::UI::Xaml;
using namespace winrt::Windows::UI::Core;
using namespace winrt::Windows::Foundation;
+using namespace winrt::Windows::System;
using namespace concurrency;
using namespace winrt::servo;
@@ -270,7 +271,14 @@ void ServoControl::WakeUp() {
RunOnGLThread([=] {});
}
-bool ServoControl::OnServoAllowNavigation(hstring) { return true; }
+bool ServoControl::OnServoAllowNavigation(hstring uri) {
+ if (mTransient) {
+ RunOnUIThread([=] {
+ Launcher::LaunchUriAsync(Uri{uri});
+ });
+ }
+ return !mTransient;
+}
void ServoControl::OnServoAnimatingChanged(bool animating) {
EnterCriticalSection(&mGLLock);
diff --git a/support/hololens/ServoApp/ServoControl/ServoControl.h b/support/hololens/ServoApp/ServoControl/ServoControl.h
index 54d1caf8c12..3191a8e03a7 100644
--- a/support/hololens/ServoApp/ServoControl/ServoControl.h
+++ b/support/hololens/ServoApp/ServoControl/ServoControl.h
@@ -69,6 +69,8 @@ struct ServoControl : ServoControlT<ServoControl>, public servo::ServoDelegate {
mOnCaptureGesturesEndedEvent.remove(token);
}
+ void SetTransientMode(bool transient) { mTransient = transient; }
+
virtual void WakeUp();
virtual void OnServoLoadStarted();
virtual void OnServoLoadEnded();
@@ -94,6 +96,7 @@ private:
float mDPI = 1;
hstring mInitialURL = L"https://servo.org";
+ bool mTransient = false;
Windows::UI::Xaml::Controls::SwapChainPanel ServoControl::Panel();
void CreateRenderSurface();
diff --git a/support/hololens/ServoApp/ServoControl/ServoControl.idl b/support/hololens/ServoApp/ServoControl/ServoControl.idl
index f392b1fcbf8..a8f6328c552 100644
--- a/support/hololens/ServoApp/ServoControl/ServoControl.idl
+++ b/support/hololens/ServoApp/ServoControl/ServoControl.idl
@@ -10,6 +10,7 @@ namespace ServoApp {
void Reload();
void Stop();
Windows.Foundation.Uri LoadURIOrSearch(String url);
+ void SetTransientMode(Boolean transient);
void Shutdown();
event EventDelegate OnLoadStarted;
event EventDelegate OnLoadEnded;
diff --git a/support/hololens/ServoApp/pch.h b/support/hololens/ServoApp/pch.h
index 85f3fabce79..32b151c124e 100644
--- a/support/hololens/ServoApp/pch.h
+++ b/support/hololens/ServoApp/pch.h
@@ -39,6 +39,7 @@
#include <winrt/Windows.Perception.Spatial.h>
#include <winrt/Windows.Storage.h>
#include <winrt/Windows.Storage.Streams.h>
+#include <winrt/windows.system.h>
#include <winrt/Windows.UI.Core.h>
#include <winrt/Windows.UI.Input.Spatial.h>
#include <winrt/Windows.UI.Popups.h>