mirror of
https://github.com/servo/servo.git
synced 2025-06-23 16:44:33 +01:00
Support launching Servo2d with a URI.
This commit is contained in:
parent
0a5aab6cc2
commit
daabda7fe1
3 changed files with 29 additions and 5 deletions
|
@ -29,7 +29,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Constructs the Landscape Application.
|
* Constructs the Landscape Application.
|
||||||
*/
|
*/
|
||||||
Servo2D();
|
Servo2D(const char* uri);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroys the Landscape Application.
|
* Destroys the Landscape Application.
|
||||||
|
@ -144,4 +144,5 @@ private:
|
||||||
glm::quat controller_orientation_; // The last recorded orientation of the controller (in world coords)
|
glm::quat controller_orientation_; // The last recorded orientation of the controller (in world coords)
|
||||||
bool controller_trigger_down_ = false; // Is the controller trigger currently down?
|
bool controller_trigger_down_ = false; // Is the controller trigger currently down?
|
||||||
ServoInstance* servo_ = nullptr; // the servo instance we're embedding
|
ServoInstance* servo_ = nullptr; // the servo instance we're embedding
|
||||||
|
const char* uri_ = nullptr;
|
||||||
};
|
};
|
||||||
|
|
|
@ -78,7 +78,9 @@ extern "C" void navigate_servo(ServoInstance*, const char* text);
|
||||||
extern "C" void discard_servo(ServoInstance*);
|
extern "C" void discard_servo(ServoInstance*);
|
||||||
|
|
||||||
// Create a Servo2D instance
|
// Create a Servo2D instance
|
||||||
Servo2D::Servo2D() {
|
Servo2D::Servo2D(const char* uri)
|
||||||
|
: uri_(uri ? uri : HOME_PAGE)
|
||||||
|
{
|
||||||
ML_LOG(Debug, "Servo2D Constructor.");
|
ML_LOG(Debug, "Servo2D Constructor.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +173,7 @@ int Servo2D::init() {
|
||||||
EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||||
|
|
||||||
// Hook into servo
|
// Hook into servo
|
||||||
servo_ = init_servo(ctx, surf, dpy, this, logger, history, url, keyboard, HOME_PAGE, VIEWPORT_W, VIEWPORT_H, HIDPI);
|
servo_ = init_servo(ctx, surf, dpy, this, logger, history, url, keyboard, uri_, VIEWPORT_W, VIEWPORT_H, HIDPI);
|
||||||
if (!servo_) {
|
if (!servo_) {
|
||||||
ML_LOG(Error, "Servo2D Failed to init servo instance");
|
ML_LOG(Error, "Servo2D Failed to init servo instance");
|
||||||
abort();
|
abort();
|
||||||
|
|
|
@ -3,11 +3,32 @@
|
||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#include <Servo2D.h>
|
#include <Servo2D.h>
|
||||||
|
#include <ml_lifecycle.h>
|
||||||
#include <ml_logging.h>
|
#include <ml_logging.h>
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
ML_LOG(Debug, "Servo2D Starting.");
|
ML_LOG(Debug, "Servo2D Starting.");
|
||||||
Servo2D myApp;
|
|
||||||
return myApp.run();
|
// Handle optional initialization string passed via 'mldb launch'
|
||||||
|
MLLifecycleInitArgList* list = NULL;
|
||||||
|
MLLifecycleGetInitArgList(&list);
|
||||||
|
const char* uri = NULL;
|
||||||
|
if (nullptr != list) {
|
||||||
|
int64_t list_length = 0;
|
||||||
|
MLLifecycleGetInitArgListLength(list, &list_length);
|
||||||
|
if (list_length > 0) {
|
||||||
|
const MLLifecycleInitArg* iarg = NULL;
|
||||||
|
MLLifecycleGetInitArgByIndex(list, 0, &iarg);
|
||||||
|
if (nullptr != iarg) {
|
||||||
|
MLLifecycleGetInitArgUri(iarg, &uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Servo2D myApp(uri);
|
||||||
|
int rv = myApp.run();
|
||||||
|
|
||||||
|
MLLifecycleFreeInitArgList(&list);
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue