More events, remove most of the statics, better shutdown

This commit is contained in:
Paul Rouget 2019-07-24 15:14:24 +02:00
parent 7adf022dfa
commit d0436f16b6
8 changed files with 342 additions and 217 deletions

View file

@ -11,13 +11,17 @@
namespace winrt::ServoApp::implementation {
static char sWakeupEvent[] = "SIGNAL_WAKEUP";
static char sShutdownEvent[] = "SIGNAL_SHUTDOWN";
struct Event {
enum { CLICK, SCROLL, BACK, FORWARD } type;
enum { CLICK, SCROLL, BACK, FORWARD, RELOAD, STOP, SHUTDOWN } type;
std::tuple<float, float> clickCoords;
std::tuple<float, float, float, float> scrollCoords;
};
struct BrowserPage : BrowserPageT<BrowserPage> {
struct BrowserPage : BrowserPageT<BrowserPage>,
public servo::ServoDelegate {
public:
BrowserPage();
@ -27,7 +31,10 @@ public:
Windows::UI::Xaml::RoutedEventArgs const &);
void OnBackButtonClicked(Windows::Foundation::IInspectable const &,
Windows::UI::Xaml::RoutedEventArgs const &);
void OnReloadButtonClicked(Windows::Foundation::IInspectable const &,
Windows::UI::Xaml::RoutedEventArgs const &);
void OnStopButtonClicked(Windows::Foundation::IInspectable const &,
Windows::UI::Xaml::RoutedEventArgs const &);
void
OnSurfaceClicked(Windows::Foundation::IInspectable const &,
Windows::UI::Xaml::Input::PointerRoutedEventArgs const &);
@ -36,13 +43,28 @@ public:
IInspectable const &,
Windows::UI::Xaml::Input::ManipulationDeltaRoutedEventArgs const &e);
template <typename Callable> void RunOnUIThread(Callable);
void Shutdown();
virtual void WakeUp();
virtual void OnLoadStarted();
virtual void OnLoadEnded();
virtual void OnHistoryChanged(bool, bool);
virtual void OnShutdownComplete();
virtual void OnTitleChanged(std::wstring);
virtual void OnAlert(std::wstring);
virtual void OnURLChanged(std::wstring);
virtual void Flush();
virtual void MakeCurrent();
virtual bool OnAllowNavigation(std::wstring);
virtual void OnAnimatingChanged(bool);
private:
void OnVisibilityChanged(
Windows::UI::Core::CoreWindow const &,
Windows::UI::Core::VisibilityChangedEventArgs const &args);
void OnPageLoaded(Windows::Foundation::IInspectable const &,
Windows::UI::Xaml::RoutedEventArgs const &);
void CreateRenderSurface();
void DestroyRenderSurface();
void RecoverFromLostDevice();
@ -56,13 +78,15 @@ private:
std::unique_ptr<Concurrency::task<void>> mLoopTask;
winrt::ServoApp::ImmersiveViewSource mImmersiveViewSource;
EGLSurface mRenderSurface{EGL_NO_SURFACE};
std::unique_ptr<Servo> mServo;
std::unique_ptr<servo::Servo> mServo;
void BrowserPage::SendEventToServo(Event event);
std::vector<Event> mEvents;
std::mutex mEventsMutex;
OpenGLES mOpenGLES; // FIXME: shared pointer
bool mAnimating;
};
} // namespace winrt::ServoApp::implementation