Exemplo n.º 1
0
/*******************************************************************************
				alloc_err()
 ******************************************************************************/
void alloc_err(char *s)
{
	extern dyn_ptr_t Parent;
	char msg[100];

	sprintf(msg, "%s %s\n", s, OVERFLOW);
	errmsg(msg);
	tty_pr_string(SEESTACK);
	if(read_yes())
	  dump_ancestors(Parent);
	exit_term();
	exit(1);
}
uint32_t khrn_platform_get_window_position(EGLNativeWindowType win)
{
   Window w = (Window) win;
   Window dummy;
   XWindowAttributes attr;
   Window look_for_me, root_dummy, root_dummy2, parent_dummy, *children;
   int x, y;
   unsigned int layer, i, nchildren;

   //the assumption is that windows are at the 2nd level i.e. in the below
   //root_dummy/attr.root -> look_for_me -> w
   vcos_log_trace("Start khrn_platform_get_window_position");

   XGetWindowAttributes(hacky_display, w, &attr);

   vcos_log_trace("XGetWindowAttributes");

   if (attr.map_state == IsViewable)
   {
      XTranslateCoordinates(hacky_display, w, attr.root, 0, 0, &x, &y, &dummy);

      vcos_log_trace("XTranslateCoordinates");

      XQueryTree(hacky_display, w, &root_dummy, &look_for_me, &children, &nchildren);
      if (children) XFree(children);
      XQueryTree(hacky_display, attr.root, &root_dummy2, &parent_dummy, &children, &nchildren);

      vcos_log_trace("XQueryTree");

      layer = ~0;

      vcos_log_trace("Dumping hierarchy %d %d (%d)", (int)w, (int)look_for_me, (int)root_dummy);
      dump_hierarchy(attr.root, w, look_for_me, 0);

      if (children)
      {
         for (i = 0; i < nchildren; i++)
         {
            if (children[i] == look_for_me)
               layer = i;
         }
         XFree(children);
      }

      vcos_log_trace("XFree");

      if (layer == ~0)
      {
         vcos_log_error("EGL window isn't child of root", i);

         //to try and find out where this window has gone, let us walk back up the heirarchy
         dump_ancestors(w);
         return ~0;
      }
      else
      {
         vcos_log_trace("End khrn_platform_get_window_position - visible");
         return x | y << 12 | layer << 24;
      }
   }
   else
   {
      vcos_log_trace("End khrn_platform_get_window_position - invisible");

      return ~0;      /* Window is invisible */
   }
}