ee7e6b2d |
1 | /* this file is all aobut reusing stock SDL's x11 functions */ |
2 | |
3 | #include "SDL_x11reuse.h" |
4 | #define SDL_PrivateVideoData SDL_x11_PrivateVideoData |
5 | #include "../x11/SDL_x11video.h" |
6 | |
7 | /* mess from SDL_x11video.h */ |
8 | #undef SDL_Display |
9 | #undef GFX_Display |
10 | #undef SDL_Screen |
11 | #undef WMwindow |
12 | #undef SDL_iconcolors |
13 | |
14 | struct x11reuse_context { |
15 | SDL_VideoDevice fake_device; |
16 | struct SDL_x11_PrivateVideoData fake_x11private; |
17 | }; |
18 | |
19 | struct x11reuse_context *x11reuse_init(void) |
20 | { |
21 | struct x11reuse_context *retval; |
22 | int ret; |
23 | |
24 | ret = SDL_X11_LoadSymbols(); |
25 | if (ret == 0) { |
26 | fprintf(stderr, "omapsdl: SDL_X11_LoadSymbols failed\n"); |
27 | return NULL; |
28 | } |
29 | |
30 | retval = calloc(1, sizeof(*retval)); |
31 | if (retval == NULL) |
32 | return NULL; |
33 | |
34 | retval->fake_device.hidden = &retval->fake_x11private; |
35 | return retval; |
36 | } |
37 | |
38 | void x11reuse_SetCaption(struct x11reuse_context *context, |
39 | void *display, int screen, void *window, |
40 | const char *title, const char *icon) |
41 | { |
42 | if (context == NULL) |
43 | return; |
44 | |
45 | context->fake_x11private.X11_Display = |
46 | context->fake_x11private.GFX_Display = display; |
47 | context->fake_x11private.WMwindow = (Window)window; |
48 | X11_SetCaptionNoLock(&context->fake_device, title, icon); |
49 | } |
50 | |
51 | void x11reuse_SetIcon(struct x11reuse_context *context, |
52 | void *display, int screen, void *window, |
53 | void *icon, void *mask) |
54 | { |
55 | if (context == NULL) |
56 | return; |
57 | |
58 | context->fake_x11private.X11_Display = |
59 | context->fake_x11private.GFX_Display = display; |
60 | context->fake_x11private.WMwindow = (Window)window; |
61 | X11_SetIcon(&context->fake_device, icon, mask); |
62 | } |