Beispiel #1
0
static void *
_canvas_bmp_get(Ecore_Evas *ee, Evas_Coord *w_out, Evas_Coord *h_out)
{
   Ecore_X_Image *img;
   Ecore_X_Window_Attributes att;
   unsigned char *src;
   unsigned int *dst;
   int bpl = 0, rows = 0, bpp = 0;
   Evas_Coord w, h;

   /* Check that this window still exists */
   Eina_List *eeitr, *ees = ecore_evas_ecore_evas_list_get();
   Ecore_Evas *eel;
   Eina_Bool found_evas = EINA_FALSE;

   EINA_LIST_FOREACH(ees, eeitr, eel)
      if (eel == ee)
        {
           found_evas = EINA_TRUE;
           break;
        }

   Ecore_X_Window xwin = (found_evas) ?
      (Ecore_X_Window) ecore_evas_window_get(ee) : 0;

   if (!xwin)
     {
        printf("Can't grab X window.\n");
        *w_out = *h_out = 0;
        return NULL;
     }

   Evas *e = ecore_evas_get(ee);
   evas_output_size_get(e, &w, &h);
   memset(&att, 0, sizeof(Ecore_X_Window_Attributes));
   ecore_x_window_attributes_get(xwin, &att);
   img = ecore_x_image_new(w, h, att.visual, att.depth);
   ecore_x_image_get(img, xwin, 0, 0, 0, 0, w, h);
   src = ecore_x_image_data_get(img, &bpl, &rows, &bpp);
   dst = malloc(w * h * sizeof(int));  /* Will be freed by the user */
   if (!ecore_x_image_is_argb32_get(img))
     {  /* Fill dst buffer with image convert */
        ecore_x_image_to_argb_convert(src, bpp, bpl,
              att.colormap, att.visual,
              0, 0, w, h,
              dst, (w * sizeof(int)), 0, 0);
     }
   else
     {  /* Fill dst buffer by copy */
        memcpy(dst, src, (w * h * sizeof(int)));
     }

   /* dst now holds window bitmap */
   ecore_x_image_free(img);
   *w_out = w;
   *h_out = h;
   return (void *) dst;
}
/* local subsystem functions */
static void
_win_unredirect(E_Comp_Win *cw)
{
   E_CHECK(cw);
   E_CHECK(cw->visible);
   E_CHECK(!(cw->input_only));
   E_CHECK(!(cw->invalid));

   if (cw->obj)
     {
        evas_object_hide(cw->obj);
        evas_object_del(cw->obj);
        cw->obj = NULL;
     }
   if (cw->update_timeout)
     {
        ecore_timer_del(cw->update_timeout);
        cw->update_timeout = NULL;
     }
   if (cw->native)
     {
        evas_object_image_native_surface_set(cw->obj, NULL);
        cw->native = 0;
     }
   if (cw->pixmap)
     {
        ecore_x_pixmap_free(cw->pixmap);
        cw->pixmap = 0;
        cw->pw = 0;
        cw->ph = 0;
     }
   if (cw->xim)
     {
        evas_object_image_size_set(cw->obj, 1, 1);
        evas_object_image_data_set(cw->obj, NULL);
        ecore_x_image_free(cw->xim);
        cw->xim = NULL;
     }
   if (cw->redirected)
     {
        ecore_x_composite_unredirect_window
          (cw->win, ECORE_X_COMPOSITE_UPDATE_MANUAL);
        cw->redirected = 0;
     }
   if (cw->damage)
     {
        e_mod_comp_win_del_damage(cw, cw->damage);
        ecore_x_damage_subtract(cw->damage, 0, 0);
        ecore_x_damage_free(cw->damage);
        cw->damage = 0;
     }
}