summaryrefslogtreecommitdiff
path: root/src/lib/evas/canvas/efl_canvas_surface_x11.c
blob: c463a157d8241d0778724c1f1e644112b84fa819 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "efl_canvas_surface.h"

#define MY_CLASS EFL_CANVAS_SURFACE_X11_CLASS

typedef struct _Efl_Canvas_Surface_X11_Data
{
   Efl_Canvas_Surface_Data *base;
   Efl_Canvas_Surface_X11_Pixmap px;
} Efl_Canvas_Surface_X11_Data;

EOLIAN static Eo *
_efl_canvas_surface_x11_efl_object_constructor(Eo *eo, Efl_Canvas_Surface_X11_Data *pd)
{
   Evas_Object_Protected_Data *obj;

   eo = efl_constructor(eo_super(eo, MY_CLASS));
   obj = eo_data_scope_get(eo, EFL_CANVAS_OBJECT_CLASS);
   if (!obj) return NULL;

   if (!ENFN->image_native_init(ENDT, EVAS_NATIVE_SURFACE_X11))
     {
        ERR("X11 is not supported on this platform");
        return NULL;
     }

   pd->base = eo_data_ref(eo, EFL_CANVAS_SURFACE_MIXIN);
   pd->base->surf.version = EVAS_NATIVE_SURFACE_VERSION;
   pd->base->surf.type = EVAS_NATIVE_SURFACE_X11;
   return eo;
}

EOLIAN static void
_efl_canvas_surface_x11_efl_object_destructor(Eo *eo, Efl_Canvas_Surface_X11_Data *pd)
{
   Evas_Object_Protected_Data *obj;

   obj = eo_data_scope_get(eo, EFL_CANVAS_OBJECT_CLASS);

   ENFN->image_native_shutdown(ENDT, EVAS_NATIVE_SURFACE_X11);
   eo_data_unref(eo, pd->base);
   efl_destructor(eo);
}

EOLIAN static Eina_Bool
_efl_canvas_surface_x11_pixmap_set(Eo *eo, Efl_Canvas_Surface_X11_Data *pd EINA_UNUSED, void *visual, unsigned long pixmap)
{
   pd->px.pixmap = pixmap;
   pd->px.visual = visual;
   if (!_evas_image_native_surface_set(eo, &pd->base->surf))
     {
        ERR("failed to set native buffer");
        pd->base->buffer = NULL;
        return EINA_FALSE;
     }
   pd->base->buffer = &pd->px;
   return EINA_TRUE;
}

EOLIAN static void
_efl_canvas_surface_x11_pixmap_get(Eo *eo EINA_UNUSED, Efl_Canvas_Surface_X11_Data *pd, void **visual, unsigned long *pixmap)
{
   if (pixmap) *pixmap = pd->px.pixmap;
   if (visual) *visual = pd->px.visual;
}

EOLIAN static Eina_Bool
_efl_canvas_surface_x11_efl_canvas_surface_native_buffer_set(Eo *eo, Efl_Canvas_Surface_X11_Data *pd, void *buffer)
{
   Efl_Canvas_Surface_X11_Pixmap *px = buffer;

   if (px)
     {
        pd->px.pixmap = px->pixmap;
        pd->px.visual = px->visual;
        pd->base->buffer = &pd->px;
     }
   else
     {
        pd->px.pixmap = 0L;
        pd->px.visual = NULL;
        pd->base->buffer = NULL;
     }
   return efl_canvas_surface_x11_pixmap_set(eo, pd->px.visual, pd->px.pixmap);
}

#include "efl_canvas_surface_x11.eo.c"