src/video/x11/SDL_x11video.c
changeset 1178 9867f3d86e44
parent 1168 045f186426e1
child 1191 2bd4cec0de63
     1.1 --- a/src/video/x11/SDL_x11video.c	Sun Nov 20 23:59:26 2005 +0000
     1.2 +++ b/src/video/x11/SDL_x11video.c	Mon Nov 21 00:16:34 2005 +0000
     1.3 @@ -349,6 +349,7 @@
     1.4  		 FocusChangeMask | KeyPressMask | KeyReleaseMask
     1.5  		 | PropertyChangeMask | StructureNotifyMask | KeymapStateMask);
     1.6  
     1.7 +    char * savedclassname = 0;
     1.8      /* Set the class hints so we can get an icon (AfterStep) */
     1.9      {
    1.10  	XClassHint *classhints;
    1.11 @@ -358,6 +359,7 @@
    1.12              if ( ! classname ) {
    1.13                  classname = "SDL_App";
    1.14              }
    1.15 +	    savedclassname = strdup(classname);
    1.16  	    classhints->res_name = classname;
    1.17  	    classhints->res_class = classname;
    1.18  	    pXSetClassHint(SDL_Display, WMwindow, classhints);
    1.19 @@ -365,6 +367,33 @@
    1.20  	}
    1.21      }
    1.22  
    1.23 +    /* Setup the communication with the IM server */
    1.24 +    SDL_IM = NULL;
    1.25 +    SDL_IC = NULL;
    1.26 +
    1.27 +    #ifdef X_HAVE_UTF8_STRING
    1.28 +    SDL_IM = pXOpenIM(SDL_Display, NULL, savedclassname, savedclassname);
    1.29 +    if (SDL_IM == NULL) {
    1.30 +	SDL_SetError("no input method could be opened");
    1.31 +    } else {
    1.32 +	SDL_IC = pXCreateIC(SDL_IM,
    1.33 +			XNClientWindow, WMwindow,
    1.34 +			XNFocusWindow, WMwindow,
    1.35 +			XNInputStyle, XIMPreeditNothing  | XIMStatusNothing,
    1.36 +			XNResourceName, savedclassname,
    1.37 +			XNResourceClass, savedclassname,
    1.38 +			NULL);
    1.39 +	if (SDL_IC == NULL) {
    1.40 +		SDL_SetError("no input context could be created");
    1.41 +		pXCloseIM(SDL_IM);
    1.42 +		SDL_IM = NULL;
    1.43 +	}
    1.44 +    }
    1.45 +    #endif
    1.46 +
    1.47 +    free(savedclassname);
    1.48 +
    1.49 +
    1.50      /* Allow the window to be deleted by the window manager */
    1.51      WM_DELETE_WINDOW = pXInternAtom(SDL_Display, "WM_DELETE_WINDOW", False);
    1.52      pXSetWMProtocols(SDL_Display, WMwindow, &WM_DELETE_WINDOW, 1);
    1.53 @@ -808,7 +837,6 @@
    1.54  					| ButtonPressMask | ButtonReleaseMask
    1.55  					| PointerMotionMask | ExposureMask ));
    1.56  	}
    1.57 -
    1.58  	/* Create the graphics context here, once we have a window */
    1.59  	if ( flags & SDL_OPENGL ) {
    1.60  		if ( X11_GL_CreateContext(this) < 0 ) {
    1.61 @@ -854,7 +882,7 @@
    1.62  	}
    1.63  
    1.64  	/* Update the internal keyboard state */
    1.65 -	X11_SetKeyboardState(SDL_Display, NULL);
    1.66 +	X11_SetKeyboardState(SDL_Display, SDL_IC, NULL);
    1.67  
    1.68  	/* When the window is first mapped, ignore non-modifier keys */
    1.69  	{
    1.70 @@ -892,6 +920,7 @@
    1.71  			screen->flags &= ~SDL_FULLSCREEN;
    1.72  		}
    1.73  	}
    1.74 +	
    1.75  	return(0);
    1.76  }
    1.77  
    1.78 @@ -1231,6 +1260,18 @@
    1.79  		/* Flush any delayed updates */
    1.80  		pXSync(GFX_Display, False);
    1.81  
    1.82 +		/* Close the connection with the IM server */
    1.83 +		#ifdef X_HAVE_UTF8_STRING
    1.84 +		if (SDL_IC == NULL) {
    1.85 +			pXDestroyIC(SDL_IC);
    1.86 +			SDL_IC = NULL;
    1.87 +		}
    1.88 +		if (SDL_IM == NULL) {
    1.89 +			pXCloseIM(SDL_IM);
    1.90 +			SDL_IM = NULL;
    1.91 +		}
    1.92 +		#endif
    1.93 +
    1.94  		/* Start shutting down the windows */
    1.95  		X11_DestroyImage(this, this->screen);
    1.96  		X11_DestroyWindow(this, this->screen);