mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
move control to its own directory
This commit is contained in:
parent
663ec48e00
commit
92f57b66d1
12 changed files with 17 additions and 19 deletions
73
support/hololens/ServoApp/ServoControl/Servo.cpp
Normal file
73
support/hololens/ServoApp/ServoControl/Servo.cpp
Normal file
|
@ -0,0 +1,73 @@
|
|||
#include "pch.h"
|
||||
#include "Servo.h"
|
||||
|
||||
namespace winrt::servo {
|
||||
|
||||
void on_load_started() { sServo->Delegate().OnServoLoadStarted(); }
|
||||
void on_load_ended() { sServo->Delegate().OnServoLoadEnded(); }
|
||||
void on_history_changed(bool back, bool forward) {
|
||||
sServo->Delegate().OnServoHistoryChanged(back, forward);
|
||||
}
|
||||
void on_shutdown_complete() { sServo->Delegate().OnServoShutdownComplete(); }
|
||||
void on_alert(const char *message) {
|
||||
sServo->Delegate().OnServoAlert(char2hstring(message));
|
||||
}
|
||||
void on_title_changed(const char *title) {
|
||||
sServo->Delegate().OnServoTitleChanged(char2hstring(title));
|
||||
}
|
||||
void on_url_changed(const char *url) {
|
||||
sServo->Delegate().OnServoURLChanged(char2hstring(url));
|
||||
}
|
||||
void flush() { sServo->Delegate().Flush(); }
|
||||
void make_current() { sServo->Delegate().MakeCurrent(); }
|
||||
void wakeup() { sServo->Delegate().WakeUp(); }
|
||||
bool on_allow_navigation(const char *url) {
|
||||
return sServo->Delegate().OnServoAllowNavigation(char2hstring(url));
|
||||
};
|
||||
void on_animating_changed(bool aAnimating) {
|
||||
sServo->Delegate().OnServoAnimatingChanged(aAnimating);
|
||||
}
|
||||
|
||||
Servo::Servo(GLsizei width, GLsizei height, ServoDelegate &aDelegate)
|
||||
: mWindowHeight(height), mWindowWidth(width), mDelegate(aDelegate) {
|
||||
|
||||
capi::CInitOptions o;
|
||||
o.args = "--pref dom.webxr.enabled";
|
||||
o.url = "https://servo.org";
|
||||
o.width = mWindowWidth;
|
||||
o.height = mWindowHeight;
|
||||
o.density = 1.0;
|
||||
o.enable_subpixel_text_antialiasing = false;
|
||||
o.vr_pointer = NULL;
|
||||
|
||||
sServo = this; // FIXME;
|
||||
|
||||
capi::CHostCallbacks c;
|
||||
c.flush = &flush;
|
||||
c.make_current = &make_current;
|
||||
c.on_alert = &on_alert;
|
||||
c.on_load_started = &on_load_started;
|
||||
c.on_load_ended = &on_load_ended;
|
||||
c.on_title_changed = &on_title_changed;
|
||||
c.on_url_changed = &on_url_changed;
|
||||
c.on_history_changed = &on_history_changed;
|
||||
c.on_animating_changed = &on_animating_changed;
|
||||
c.on_shutdown_complete = &on_shutdown_complete;
|
||||
c.on_allow_navigation = &on_allow_navigation;
|
||||
|
||||
init_with_egl(o, &wakeup, c);
|
||||
}
|
||||
|
||||
Servo::~Servo() { sServo = nullptr; }
|
||||
|
||||
winrt::hstring char2hstring(const char *c_str) {
|
||||
// FIXME: any better way of doing this?
|
||||
auto str = std::string(c_str);
|
||||
int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0);
|
||||
std::wstring str2(size_needed, 0);
|
||||
MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &str2[0], size_needed);
|
||||
winrt::hstring str3 {str2};
|
||||
return str3;
|
||||
}
|
||||
|
||||
} // namespace servo
|
Loading…
Add table
Add a link
Reference in a new issue