Exemple #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;
}
EflUniquePtr<Ecore_IMF_Context> InputMethodContextEfl::createIMFContext(Evas* canvas)
{
    const char* defaultContextID = ecore_imf_context_default_id_get();
    if (!defaultContextID)
        return nullptr;

    EflUniquePtr<Ecore_IMF_Context> imfContext(ecore_imf_context_add(defaultContextID));
    if (!imfContext)
        return nullptr;

    Ecore_Evas* ecoreEvas = ecore_evas_ecore_evas_get(canvas);
    ecore_imf_context_client_window_set(imfContext.get(), reinterpret_cast<void*>(ecore_evas_window_get(ecoreEvas)));
    ecore_imf_context_client_canvas_set(imfContext.get(), canvas);

    return imfContext;
}