static void dump_hierarchy(Window w, Window thisw, Window look, int level)
{
   Window root_dummy, parent_dummy, *children;
   unsigned int i, nchildren;
   XWindowAttributes attr;

   XGetWindowAttributes(hacky_display, w, &attr);
   XQueryTree(hacky_display, w, &root_dummy, &parent_dummy, &children, &nchildren);

   for (i = 0; i < level; i++)
   {
         vcos_log_trace(" ");
   }
   vcos_log_trace( "%d %d%s%s",
              attr.map_state, (int)w,
              (w==look)?" <-- LOOK FOR ME!":((w==thisw)?" <-- THIS WINDOW":""),
              children?"":" no children");

   if (children)
   {
      for (i = 0; i < nchildren; i++)
      {
         dump_hierarchy(children[i], thisw, look, level + 1);
      }
      XFree(children);
   }
}
void platform_get_dimensions(EGLDisplay dpy, EGLNativeWindowType win,
      uint32_t *width, uint32_t *height, uint32_t *swapchain_count)
{
   Window w = (Window) win;
   XWindowAttributes attr;
   GC gc;
   Status rc = XGetWindowAttributes(hacky_display, w, &attr);

   // check rc is OK and if it is (vcos_assert(rc == 0);?????)
   *width = attr.width;
   *height = attr.height;
   *swapchain_count = 0;

	 /* Hackily assume if this function is called then they want to fill with GL stuff. So fill window with chromakey. */
   vcos_log_trace("Calling XCreateGC %d",(int)w);

	 gc = XCreateGC(hacky_display, w, 0, NULL);
	 XSetForeground(hacky_display, gc, CHROMA_KEY_565);

   vcos_log_trace("Calling XFillRectangle %d %dx%d",(int)w,attr.width, attr.height);

	 XFillRectangle(hacky_display, w, gc, 0, 0, attr.width, attr.height);

   vcos_log_trace("Calling XFreeGC");

	 XFreeGC(hacky_display, gc);

   vcos_log_trace("Done platform_get_dimensions");
    //debugging
    dump_hierarchy(attr.root, w, 0, 0);
}
Esempio n. 3
0
static void dump_hierarchy(GList *l, char *prefix)
{
	char *newprefix = g_alloca(sizeof(char) * (strlen(prefix) + 2));
	strcpy(newprefix, prefix);
	strcat(newprefix, " ");
	while (l)
	{
		struct boundary *boundary = l->data;
		fprintf(stderr, "%s:childs:%d:%lld:%s\n", prefix, g_list_length(boundary->children), item_bin_get_relationid(boundary->ib), osm_tag_name(boundary->ib));
		dump_hierarchy(boundary->children, newprefix);
		l = g_list_next(l);
	}
}
Esempio n. 4
0
static void
dump_hierarchy(GList *l, char *prefix)
{
	char *newprefix=g_alloca(sizeof(char)*(strlen(prefix)+2));
	strcpy(newprefix, prefix);
	strcat(newprefix," ");
	while (l) {
		struct boundary *boundary=l->data;
		fprintf(stderr,"%s:%s (0x%x,0x%x)-(0x%x,0x%x)\n",prefix,osm_tag_name(boundary->ib),boundary->r.l.x,boundary->r.l.y,boundary->r.h.x,boundary->r.h.y);
		dump_hierarchy(boundary->children, newprefix);
		l=g_list_next(l);
	}
}
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 */
   }
}
Esempio n. 6
0
static GList *
process_boundaries_finish(GList *boundaries_list)
{
	GList *l,*sl;
	GList *ret=NULL;
	l=boundaries_list;
	while (l) {
		struct boundary *boundary=l->data;
		int first=1;
		FILE *f=NULL,*fu=NULL;
		if (boundary->country) {
			char *name=g_strdup_printf("country_%s_poly",boundary->iso2);
			f=tempfile("",name,1);
			g_free(name);
		}
		boundary->sorted_segments=geom_poly_segments_sort(boundary->segments, geom_poly_segment_type_way_right_side);
		sl=boundary->sorted_segments;
		while (sl) {
			struct geom_poly_segment *gs=sl->data;
			struct coord *c=gs->first;
			while (c <= gs->last) {
				if (first) {
					boundary->r.l=*c;
					boundary->r.h=*c;
					first=0;
				} else
					bbox_extend(c, &boundary->r);
				c++;
			}
			if (f) {
				struct item_bin *ib=tmp_item_bin;
				item_bin_init(ib, type_selected_line);
				item_bin_add_coord(ib, gs->first, gs->last-gs->first+1);
				item_bin_write(ib, f);
			}
			if (boundary->country) {
				if (!coord_is_equal(*gs->first,*gs->last)) {
					struct item_bin *ib;
					if (!fu) {
						char *name=g_strdup_printf("country_%s_broken",boundary->iso2);
						fu=tempfile("",name,1);
						g_free(name);
					}
					ib=tmp_item_bin;
					item_bin_init(ib, type_selected_point);
					item_bin_add_coord(ib, gs->first, 1);
					item_bin_write(ib, fu);
					item_bin_init(ib, type_selected_point);
					item_bin_add_coord(ib, gs->last, 1);
					item_bin_write(ib, fu);
				}
			}
			sl=g_list_next(sl);
		}	
		ret=process_boundaries_insert(ret, boundary);
		l=g_list_next(l);
		if (f) 
			fclose(f);
		if (fu) {
			if (boundary->country)
				osm_warning("relation",item_bin_get_relationid(boundary->ib),0,"Broken country polygon '%s'\n",boundary->iso2);
			fclose(fu);
		}
		
	}
#if 0
	printf("hierarchy\n");
#endif
#if 0
	boundaries_list=g_list_sort(boundaries_list, boundary_bbox_compare);
	l=boundaries_list;
	while (l) {
		struct boundary *boundary=l->data;
		GList *l2,*ln;
		ln=l2=g_list_next(l);
		while (l2) {
			struct boundary *boundary2=l2->data;
			if (bbox_contains_bbox(&boundary2->r, &boundary->r)) {
				boundaries_list=g_list_remove(boundaries_list, boundary);
				boundary2->children=g_list_append(boundary2->children, boundary);
#if 0
				printf("found\n");
#endif
				break;
			}
			l2=g_list_next(l2);
		}
		l=ln;
	}
	dump_hierarchy(boundaries_list,"");
#if 0
	printf("hierarchy done\n");
	printf("test\n");
	test(boundaries_list);
#endif
#endif
	return ret;
}