Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11video.c @ 1951:7177581dc9fa
Initial work on X11 window code in.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 27 Jul 2006 06:53:23 +0000 |
parents | a344e42bce3b |
children | 420716272158 |
comparison
equal
deleted
inserted
replaced
1950:a344e42bce3b | 1951:7177581dc9fa |
---|---|
31 //#include "SDL_gdirender.h" | 31 //#include "SDL_gdirender.h" |
32 | 32 |
33 /* Initialization/Query functions */ | 33 /* Initialization/Query functions */ |
34 static int X11_VideoInit(_THIS); | 34 static int X11_VideoInit(_THIS); |
35 static void X11_VideoQuit(_THIS); | 35 static void X11_VideoQuit(_THIS); |
36 | |
37 /* Find out what class name we should use */ | |
38 static char * | |
39 get_classname() | |
40 { | |
41 char *spot; | |
42 #if defined(__LINUX__) || defined(__FREEBSD__) | |
43 char procfile[1024]; | |
44 char linkfile[1024]; | |
45 int linksize; | |
46 #endif | |
47 | |
48 /* First allow environment variable override */ | |
49 spot = SDL_getenv("SDL_VIDEO_X11_WMCLASS"); | |
50 if (spot) { | |
51 return SDL_strdup(spot); | |
52 } | |
53 | |
54 /* Next look at the application's executable name */ | |
55 #if defined(__LINUX__) || defined(__FREEBSD__) | |
56 #if defined(__LINUX__) | |
57 SDL_snprintf(procfile, SDL_arraysize(procfile), "/proc/%d/exe", getpid()); | |
58 #elif defined(__FREEBSD__) | |
59 SDL_snprintf(procfile, SDL_arraysize(procfile), "/proc/%d/file", | |
60 getpid()); | |
61 #else | |
62 #error Where can we find the executable name? | |
63 #endif | |
64 linksize = readlink(procfile, linkfile, sizeof(linkfile) - 1); | |
65 if (linksize > 0) { | |
66 linkfile[linksize] = '\0'; | |
67 spot = SDL_strrchr(linkfile, '/'); | |
68 if (spot) { | |
69 return SDL_strdup(spot + 1); | |
70 } else { | |
71 return SDL_strdup(linkfile); | |
72 } | |
73 } | |
74 #endif /* __LINUX__ || __FREEBSD__ */ | |
75 | |
76 /* Finally use the default we've used forever */ | |
77 return SDL_strdup("SDL_App"); | |
78 } | |
36 | 79 |
37 /* X11 driver bootstrap functions */ | 80 /* X11 driver bootstrap functions */ |
38 | 81 |
39 static int | 82 static int |
40 X11_Available(void) | 83 X11_Available(void) |
125 device->VideoQuit = X11_VideoQuit; | 168 device->VideoQuit = X11_VideoQuit; |
126 device->GetDisplayModes = X11_GetDisplayModes; | 169 device->GetDisplayModes = X11_GetDisplayModes; |
127 device->SetDisplayMode = X11_SetDisplayMode; | 170 device->SetDisplayMode = X11_SetDisplayMode; |
128 // device->SetDisplayGammaRamp = X11_SetDisplayGammaRamp; | 171 // device->SetDisplayGammaRamp = X11_SetDisplayGammaRamp; |
129 // device->GetDisplayGammaRamp = X11_GetDisplayGammaRamp; | 172 // device->GetDisplayGammaRamp = X11_GetDisplayGammaRamp; |
130 // device->PumpEvents = X11_PumpEvents; | 173 device->PumpEvents = X11_PumpEvents; |
131 | 174 |
132 /* | |
133 device->CreateWindow = X11_CreateWindow; | 175 device->CreateWindow = X11_CreateWindow; |
134 device->CreateWindowFrom = X11_CreateWindowFrom; | 176 device->CreateWindowFrom = X11_CreateWindowFrom; |
135 device->SetWindowTitle = X11_SetWindowTitle; | 177 device->SetWindowTitle = X11_SetWindowTitle; |
136 device->SetWindowPosition = X11_SetWindowPosition; | 178 device->SetWindowPosition = X11_SetWindowPosition; |
137 device->SetWindowSize = X11_SetWindowSize; | 179 device->SetWindowSize = X11_SetWindowSize; |
142 device->MinimizeWindow = X11_MinimizeWindow; | 184 device->MinimizeWindow = X11_MinimizeWindow; |
143 device->RestoreWindow = X11_RestoreWindow; | 185 device->RestoreWindow = X11_RestoreWindow; |
144 device->SetWindowGrab = X11_SetWindowGrab; | 186 device->SetWindowGrab = X11_SetWindowGrab; |
145 device->DestroyWindow = X11_DestroyWindow; | 187 device->DestroyWindow = X11_DestroyWindow; |
146 device->GetWindowWMInfo = X11_GetWindowWMInfo; | 188 device->GetWindowWMInfo = X11_GetWindowWMInfo; |
189 /* | |
147 #ifdef SDL_VIDEO_OPENGL | 190 #ifdef SDL_VIDEO_OPENGL |
148 device->GL_LoadLibrary = X11_GL_LoadLibrary; | 191 device->GL_LoadLibrary = X11_GL_LoadLibrary; |
149 device->GL_GetProcAddress = X11_GL_GetProcAddress; | 192 device->GL_GetProcAddress = X11_GL_GetProcAddress; |
150 device->GL_CreateContext = X11_GL_CreateContext; | 193 device->GL_CreateContext = X11_GL_CreateContext; |
151 device->GL_MakeCurrent = X11_GL_MakeCurrent; | 194 device->GL_MakeCurrent = X11_GL_MakeCurrent; |
168 | 211 |
169 | 212 |
170 int | 213 int |
171 X11_VideoInit(_THIS) | 214 X11_VideoInit(_THIS) |
172 { | 215 { |
216 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; | |
217 | |
218 /* Get the window class name, usually the name of the application */ | |
219 data->classname = get_classname(); | |
220 | |
221 /* Open a connection to the X input manager */ | |
222 #ifdef X_HAVE_UTF8_STRING | |
223 if (SDL_X11_HAVE_UTF8) { | |
224 data->im = | |
225 XOpenIM(data->display, NULL, data->classname, data->classname); | |
226 } | |
227 #endif | |
228 | |
229 /* Save DPMS and screensaver settings */ | |
230 X11_SaveScreenSaver(data->display, &data->screensaver_timeout, | |
231 &data->dpms_enabled); | |
232 X11_DisableScreenSaver(data->display); | |
233 | |
234 /* Look up some useful Atoms */ | |
235 data->WM_DELETE_WINDOW = | |
236 XInternAtom(data->display, "WM_DELETE_WINDOW", False); | |
237 | |
173 X11_InitModes(_this); | 238 X11_InitModes(_this); |
174 | 239 |
175 //#if SDL_VIDEO_RENDER_D3D | 240 //#if SDL_VIDEO_RENDER_D3D |
176 // D3D_AddRenderDriver(_this); | 241 // D3D_AddRenderDriver(_this); |
177 //#endif | 242 //#endif |
186 } | 251 } |
187 | 252 |
188 void | 253 void |
189 X11_VideoQuit(_THIS) | 254 X11_VideoQuit(_THIS) |
190 { | 255 { |
256 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; | |
257 | |
258 if (data->classname) { | |
259 SDL_free(data->classname); | |
260 } | |
261 #ifdef X_HAVE_UTF8_STRING | |
262 if (data->im) { | |
263 XCloseIM(data->im); | |
264 } | |
265 #endif | |
266 X11_RestoreScreenSaver(data->display, data->screensaver_timeout, | |
267 data->dpms_enabled); | |
268 | |
191 X11_QuitModes(_this); | 269 X11_QuitModes(_this); |
192 X11_QuitKeyboard(_this); | 270 X11_QuitKeyboard(_this); |
193 X11_QuitMouse(_this); | 271 X11_QuitMouse(_this); |
194 } | 272 } |
195 | 273 |