9 x11_create_window(struct segl_winsys
*winsys
, const char *name
,
10 EGLint width
, EGLint height
, EGLint visual
)
12 XVisualInfo vinfo_template
, *vinfo
= NULL
;
13 EGLint val
, num_vinfo
;
15 XSetWindowAttributes attrs
;
19 vinfo_template
.visualid
= (VisualID
) val
;
20 vinfo
= XGetVisualInfo(winsys
->dpy
, VisualIDMask
, &vinfo_template
, &num_vinfo
);
27 root
= DefaultRootWindow(winsys
->dpy
);
29 /* window attributes */
30 attrs
.background_pixel
= 0;
31 attrs
.border_pixel
= 0;
32 attrs
.colormap
= XCreateColormap(winsys
->dpy
, root
, vinfo
->visual
, AllocNone
);
33 attrs
.event_mask
= StructureNotifyMask
| ExposureMask
| KeyPressMask
;
34 attrs
.override_redirect
= False
;
35 mask
= CWBackPixel
| CWBorderPixel
| CWColormap
| CWEventMask
| CWOverrideRedirect
;
37 win
= XCreateWindow(winsys
->dpy
, root
, x
, y
, width
, height
, 0,
38 vinfo
->depth
, InputOutput
, vinfo
->visual
, mask
, &attrs
);
44 /* set hints and properties */
49 sizehints
.width
= width
;
50 sizehints
.height
= height
;
51 sizehints
.flags
= USSize
| USPosition
;
52 XSetNormalHints(winsys
->dpy
, win
, &sizehints
);
53 XSetStandardProperties(winsys
->dpy
, win
, name
, name
,
54 None
, (char **)NULL
, 0, &sizehints
);
57 XMapWindow(winsys
->dpy
, win
);
63 x11_destroy_window(struct segl_winsys
*winsys
, Window win
)
66 XDestroyWindow(winsys
->dpy
, win
);
71 x11_create_pixmap(struct segl_winsys
*winsys
, EGLint width
, EGLint height
,
74 Window root
= DefaultRootWindow(winsys
->dpy
);
77 pix
= XCreatePixmap(winsys
->dpy
, (Drawable
) root
, width
, height
, depth
);
83 x11_destroy_pixmap(struct segl_winsys
*winsys
, Pixmap pix
)
86 XFreePixmap(winsys
->dpy
, pix
);
90 x11_now(struct segl_winsys
*winsys
)
94 gettimeofday(&tv
, NULL
);
96 return (double) tv
.tv_sec
+ tv
.tv_usec
/ 1000000.0;
100 segl_get_winsys(EGLNativeDisplayType dpy
)
102 struct segl_winsys
*winsys
;
104 winsys
= calloc(1, sizeof(*winsys
));
108 winsys
->create_window
= x11_create_window
;
109 winsys
->destroy_window
= x11_destroy_window
;
110 winsys
->create_pixmap
= x11_create_pixmap
;
111 winsys
->destroy_pixmap
= x11_destroy_pixmap
;
113 winsys
->now
= x11_now
;