Implement missing C callbacks

This commit is contained in:
Paul Rouget 2019-08-19 09:45:40 +02:00
parent 2a9b2fe027
commit b642ff2057
5 changed files with 39 additions and 2 deletions

View file

@ -4,26 +4,37 @@
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);
}
@ -32,6 +43,19 @@ void on_panic(const char *backtrace) {
throw hresult_error(E_FAIL, char2hstring(backtrace));
}
void on_ime_state_changed(bool aShow) {
sServo->Delegate().OnServoIMEStateChanged(aShow);
}
void set_clipboard_contents(const char* content) {
// FIXME
}
const char* get_clipboard_contents() {
// FIXME
return nullptr;
}
Servo::Servo(hstring url, GLsizei width, GLsizei height,
ServoDelegate &aDelegate)
: mWindowHeight(height), mWindowWidth(width), mDelegate(aDelegate) {
@ -59,6 +83,9 @@ Servo::Servo(hstring url, GLsizei width, GLsizei height,
c.on_animating_changed = &on_animating_changed;
c.on_shutdown_complete = &on_shutdown_complete;
c.on_allow_navigation = &on_allow_navigation;
c.on_ime_state_changed = &on_ime_state_changed;
c.get_clipboard_contents = &get_clipboard_contents;
c.set_clipboard_contents = &set_clipboard_contents;
capi::register_panic_handler(&on_panic);