comparison src/video/x11/SDL_x11video.c @ 1178:9867f3d86e44

Real Unicode support for X11. Based on updated version of this patch: http://lists.arabeyes.org/archives/developer/2004/June/msg00160.html --ryan.
author Ryan C. Gordon <icculus@icculus.org>
date Mon, 21 Nov 2005 00:16:34 +0000
parents 045f186426e1
children 2bd4cec0de63
comparison
equal deleted inserted replaced
1177:e967ab22e6fd 1178:9867f3d86e44
347 347
348 pXSelectInput(SDL_Display, WMwindow, 348 pXSelectInput(SDL_Display, WMwindow,
349 FocusChangeMask | KeyPressMask | KeyReleaseMask 349 FocusChangeMask | KeyPressMask | KeyReleaseMask
350 | PropertyChangeMask | StructureNotifyMask | KeymapStateMask); 350 | PropertyChangeMask | StructureNotifyMask | KeymapStateMask);
351 351
352 char * savedclassname = 0;
352 /* Set the class hints so we can get an icon (AfterStep) */ 353 /* Set the class hints so we can get an icon (AfterStep) */
353 { 354 {
354 XClassHint *classhints; 355 XClassHint *classhints;
355 classhints = pXAllocClassHint(); 356 classhints = pXAllocClassHint();
356 if(classhints != NULL) { 357 if(classhints != NULL) {
357 char *classname = getenv("SDL_VIDEO_X11_WMCLASS"); 358 char *classname = getenv("SDL_VIDEO_X11_WMCLASS");
358 if ( ! classname ) { 359 if ( ! classname ) {
359 classname = "SDL_App"; 360 classname = "SDL_App";
360 } 361 }
362 savedclassname = strdup(classname);
361 classhints->res_name = classname; 363 classhints->res_name = classname;
362 classhints->res_class = classname; 364 classhints->res_class = classname;
363 pXSetClassHint(SDL_Display, WMwindow, classhints); 365 pXSetClassHint(SDL_Display, WMwindow, classhints);
364 pXFree(classhints); 366 pXFree(classhints);
365 } 367 }
366 } 368 }
369
370 /* Setup the communication with the IM server */
371 SDL_IM = NULL;
372 SDL_IC = NULL;
373
374 #ifdef X_HAVE_UTF8_STRING
375 SDL_IM = pXOpenIM(SDL_Display, NULL, savedclassname, savedclassname);
376 if (SDL_IM == NULL) {
377 SDL_SetError("no input method could be opened");
378 } else {
379 SDL_IC = pXCreateIC(SDL_IM,
380 XNClientWindow, WMwindow,
381 XNFocusWindow, WMwindow,
382 XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
383 XNResourceName, savedclassname,
384 XNResourceClass, savedclassname,
385 NULL);
386 if (SDL_IC == NULL) {
387 SDL_SetError("no input context could be created");
388 pXCloseIM(SDL_IM);
389 SDL_IM = NULL;
390 }
391 }
392 #endif
393
394 free(savedclassname);
395
367 396
368 /* Allow the window to be deleted by the window manager */ 397 /* Allow the window to be deleted by the window manager */
369 WM_DELETE_WINDOW = pXInternAtom(SDL_Display, "WM_DELETE_WINDOW", False); 398 WM_DELETE_WINDOW = pXInternAtom(SDL_Display, "WM_DELETE_WINDOW", False);
370 pXSetWMProtocols(SDL_Display, WMwindow, &WM_DELETE_WINDOW, 1); 399 pXSetWMProtocols(SDL_Display, WMwindow, &WM_DELETE_WINDOW, 1);
371 } 400 }
806 pXSelectInput(SDL_Display, SDL_Window, 835 pXSelectInput(SDL_Display, SDL_Window,
807 ( EnterWindowMask | LeaveWindowMask 836 ( EnterWindowMask | LeaveWindowMask
808 | ButtonPressMask | ButtonReleaseMask 837 | ButtonPressMask | ButtonReleaseMask
809 | PointerMotionMask | ExposureMask )); 838 | PointerMotionMask | ExposureMask ));
810 } 839 }
811
812 /* Create the graphics context here, once we have a window */ 840 /* Create the graphics context here, once we have a window */
813 if ( flags & SDL_OPENGL ) { 841 if ( flags & SDL_OPENGL ) {
814 if ( X11_GL_CreateContext(this) < 0 ) { 842 if ( X11_GL_CreateContext(this) < 0 ) {
815 return(-1); 843 return(-1);
816 } else { 844 } else {
852 CWBackingStore, &a); 880 CWBackingStore, &a);
853 } 881 }
854 } 882 }
855 883
856 /* Update the internal keyboard state */ 884 /* Update the internal keyboard state */
857 X11_SetKeyboardState(SDL_Display, NULL); 885 X11_SetKeyboardState(SDL_Display, SDL_IC, NULL);
858 886
859 /* When the window is first mapped, ignore non-modifier keys */ 887 /* When the window is first mapped, ignore non-modifier keys */
860 { 888 {
861 Uint8 *keys = SDL_GetKeyState(NULL); 889 Uint8 *keys = SDL_GetKeyState(NULL);
862 for ( i = 0; i < SDLK_LAST; ++i ) { 890 for ( i = 0; i < SDLK_LAST; ++i ) {
890 X11_EnterFullScreen(this); 918 X11_EnterFullScreen(this);
891 } else { 919 } else {
892 screen->flags &= ~SDL_FULLSCREEN; 920 screen->flags &= ~SDL_FULLSCREEN;
893 } 921 }
894 } 922 }
923
895 return(0); 924 return(0);
896 } 925 }
897 926
898 static int X11_ResizeWindow(_THIS, 927 static int X11_ResizeWindow(_THIS,
899 SDL_Surface *screen, int w, int h, Uint32 flags) 928 SDL_Surface *screen, int w, int h, Uint32 flags)
1229 /* The event thread should be done, so we can touch SDL_Display */ 1258 /* The event thread should be done, so we can touch SDL_Display */
1230 if ( SDL_Display != NULL ) { 1259 if ( SDL_Display != NULL ) {
1231 /* Flush any delayed updates */ 1260 /* Flush any delayed updates */
1232 pXSync(GFX_Display, False); 1261 pXSync(GFX_Display, False);
1233 1262
1263 /* Close the connection with the IM server */
1264 #ifdef X_HAVE_UTF8_STRING
1265 if (SDL_IC == NULL) {
1266 pXDestroyIC(SDL_IC);
1267 SDL_IC = NULL;
1268 }
1269 if (SDL_IM == NULL) {
1270 pXCloseIM(SDL_IM);
1271 SDL_IM = NULL;
1272 }
1273 #endif
1274
1234 /* Start shutting down the windows */ 1275 /* Start shutting down the windows */
1235 X11_DestroyImage(this, this->screen); 1276 X11_DestroyImage(this, this->screen);
1236 X11_DestroyWindow(this, this->screen); 1277 X11_DestroyWindow(this, this->screen);
1237 X11_FreeVideoModes(this); 1278 X11_FreeVideoModes(this);
1238 if ( SDL_XColorMap != SDL_DisplayColormap ) { 1279 if ( SDL_XColorMap != SDL_DisplayColormap ) {