dws.h (2887B)
1 /* See LICENSE file for license details */ 2 3 typedef enum { 4 CompositorTypeSrcOver, 5 CompositorTypeEnd 6 } DCompositorType; 7 8 typedef enum { 9 EventTypeKeyPress, 10 EventTypeKeyRelease, 11 EventTypeButtonPress, 12 EventTypeButtonRelease, 13 EventTypePointerMove, 14 EventTypeExpose, 15 } DEventType; 16 17 typedef enum { 18 InputTypeMouse, 19 InputTypeKeyboard, 20 InputTypeEnd 21 } DInputType; 22 23 typedef struct DCompositor DCompositor; 24 typedef struct DDisplay DDisplay; 25 typedef struct DEvent DEvent; 26 typedef struct DImage DImage; 27 typedef struct DInput DInput; 28 typedef struct DRectangle DRectangle; 29 typedef struct DScreen DScreen; 30 typedef struct DSurface DSurface; 31 32 struct DRectangle { 33 int x; 34 int y; 35 unsigned int w; 36 unsigned int h; 37 }; 38 39 struct DCompositor { 40 unsigned int id; 41 DCompositorType type; 42 }; 43 44 struct DDisplay { 45 unsigned int id; 46 DRectangle r; /* virtual rectangle spanned over all screens */ 47 DCompositor *compositor; 48 DSurface *surfaces; 49 DScreen *screens; 50 DInput *inputs; 51 }; 52 53 struct DEvent { 54 unsigned int id; 55 DEventType type; 56 }; 57 58 struct DImage{ 59 unsigned int id; 60 DRectangle r; 61 void *data; 62 }; 63 64 struct DInput { 65 unsigned int id; 66 DInputType type; 67 DInput *next; 68 }; 69 70 struct DScreen { 71 unsigned int id; 72 DDisplay *dpy; 73 DRectangle r; 74 DScreen *next; 75 }; 76 77 struct DSurface { 78 unsigned int id; 79 DDisplay *dpy; 80 DSurface *parent; /* if parent == NULL, then it's the root surface */ 81 DSurface **childs; 82 DSurface *prev; 83 DSurface *next; 84 }; 85 86 DDisplay *DOpen(const char *server); 87 void DClose(DDisplay *dpy); 88 89 DScreen *DGetScreens(DDisplay *dpy); 90 91 DCompositor *DCreateCompositor(DDisplay *dpy, DCompositorType type); 92 void DSetCompositor(DDisplay *dpy, DSurface *root, DCompositor *compositor); 93 94 DSurface *DGetRootSurface(DDisplay *dpy); 95 DSurface *DCreateSurface(DDisplay *dpy, DSurface *parent, DRectangle size); 96 void DMapSurface(DDisplay *dpy, DSurface *surface); 97 void DUnmapSurface(DDisplay *dpy, DSurface *surface); 98 void DResizeSurface(DDisplay *dpy, DSurface *surface, DRectangle newsize); 99 void DDestroySurface(DDisplay *dpy, DSurface *surface); 100 101 void DDrawImage(DDisplay *dpy, DSurface *surface, DRectangle destr, DRectangle srcr, DImage *src); 102 DImage *DCopyImage(DDisplay *dpy, DSurface *surface, DRectangle r); 103 void DFreeImage(DDisplay *dpy, DImage *img); 104 105 DInput *DGetInput(DDisplay *dpy, DInputType type); 106 107 void DAddEventListener(DDisplay *dpy, void (*listener)(DEvent *event)); 108 void DRemoveEventListener(DDisplay *dpy, void (*listener)(DEvent *event)); 109 110 void DCommit(DDisplay *dpy); 111 112 #if 0 113 114 /* hello world example */ 115 DDisplay *dpy = DOpen(NULL); 116 DScreen *screen0 = &DGetScreens(dpy)[0]; 117 DSurface *window = DCreateSurface(dpy, DGetRootSurface(dpy), screen0->r); 118 DMapSurface(dpy, window); 119 DCommit(dpy); 120 DDestroySurface(dpy, window); 121 DClose(dpy); 122 123 #endif