]> rtime.felk.cvut.cz Git - l4.git/blobdiff - l4/pkg/mag/plugins/client_fb/service.cc
update
[l4.git] / l4 / pkg / mag / plugins / client_fb / service.cc
index 7399ac27e58ef4521bf3b22d06ee699ca68c81d4..a48fc827925b3f412390134ad8a947aef5d481b0 100644 (file)
@@ -56,6 +56,25 @@ Service::create(char const *_msg, L4::Ipc_iostream &ios)
   if (w <= 0 || h <= 0 || h >= 10000 || w >= 10000)
     return -L4_ERANGE;
 
+  int px = 50, py = 50;
+
+  if (char *a = strstr(_msg, "pos="))
+    {
+      char *endp;
+      px = strtol(a + 4, &endp, 0);
+      if (*endp == ',')
+        py = strtol(endp + 1, 0, 0);
+    }
+
+  if (px < 10 - w)
+    px = 10 - w;
+  if (px >= ust()->vstack()->canvas()->size().w())
+    px = ust()->vstack()->canvas()->size().w() - 10;
+  if (py < 0)
+    py = 0;
+  if (py >= ust()->vstack()->canvas()->size().h())
+    py = ust()->vstack()->canvas()->size().h() - 10;
+
   Area res(w, h);
   Auto_cap<L4Re::Dataspace>::Cap ds(
       L4Re::Util::cap_alloc.alloc<L4Re::Dataspace>());
@@ -69,7 +88,7 @@ Service::create(char const *_msg, L4::Ipc_iostream &ios)
 
   Texture *smpl = sf->create_texture(res, dsa.get());
 
-  cxx::Ref_ptr<Client_fb> x(new Client_fb(_core, Rect(Point(50, 50), Area(res.w(), res.h() + 16)), Point(0, 0), smpl, ds.get()));
+  cxx::Ref_ptr<Client_fb> x(new Client_fb(_core, Rect(Point(px, py), Area(res.w(), res.h() + 16)), Point(0, 0), smpl, ds.get()));
 
   reg()->register_obj(x);
   x->obj_cap()->dec_refcnt(1);