comparison src/xterm.c @ 100402:6a2e1b91fbd1

(struct xim_inst_t): Definition moved to xterm.h. (xim_initialize): Save pointer to callback function data. (xim_close_dpy): Free callback function data. Call XCloseIM, reverting 2008-11-04 change by David Smith. (x_term_init): Don't initialize the image cache here; it will be done in init_frame_faces. Remove ancient "null_pixel" cruft. (x_delete_display): Free x_dnd_atoms member.
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 13 Dec 2008 05:44:38 +0000
parents 7b445d510cbe
children f6aba62369b8
comparison
equal deleted inserted replaced
100401:5a21f5d2ef24 100402:6a2e1b91fbd1
8182 XIM xim; 8182 XIM xim;
8183 8183
8184 #ifdef HAVE_XIM 8184 #ifdef HAVE_XIM
8185 if (use_xim) 8185 if (use_xim)
8186 { 8186 {
8187 if (dpyinfo->xim)
8188 XCloseIM (dpyinfo->xim);
8187 xim = XOpenIM (dpyinfo->display, dpyinfo->xrdb, resource_name, 8189 xim = XOpenIM (dpyinfo->display, dpyinfo->xrdb, resource_name,
8188 EMACS_CLASS); 8190 EMACS_CLASS);
8189 dpyinfo->xim = xim; 8191 dpyinfo->xim = xim;
8190 8192
8191 if (xim) 8193 if (xim)
8210 dpyinfo->xim = NULL; 8212 dpyinfo->xim = NULL;
8211 } 8213 }
8212 8214
8213 8215
8214 #ifdef HAVE_X11R6_XIM 8216 #ifdef HAVE_X11R6_XIM
8215
8216 struct xim_inst_t
8217 {
8218 struct x_display_info *dpyinfo;
8219 char *resource_name;
8220 };
8221 8217
8222 /* XIM instantiate callback function, which is called whenever an XIM 8218 /* XIM instantiate callback function, which is called whenever an XIM
8223 server is available. DISPLAY is the display of the XIM. 8219 server is available. DISPLAY is the display of the XIM.
8224 CLIENT_DATA contains a pointer to an xim_inst_t structure created 8220 CLIENT_DATA contains a pointer to an xim_inst_t structure created
8225 when the callback was registered. */ 8221 when the callback was registered. */
8280 static void 8276 static void
8281 xim_initialize (dpyinfo, resource_name) 8277 xim_initialize (dpyinfo, resource_name)
8282 struct x_display_info *dpyinfo; 8278 struct x_display_info *dpyinfo;
8283 char *resource_name; 8279 char *resource_name;
8284 { 8280 {
8281 dpyinfo->xim = NULL;
8285 #ifdef HAVE_XIM 8282 #ifdef HAVE_XIM
8286 if (use_xim) 8283 if (use_xim)
8287 { 8284 {
8288 #ifdef HAVE_X11R6_XIM 8285 #ifdef HAVE_X11R6_XIM
8289 struct xim_inst_t *xim_inst; 8286 struct xim_inst_t *xim_inst;
8290 int len; 8287 int len;
8291 8288
8292 dpyinfo->xim = NULL;
8293 xim_inst = (struct xim_inst_t *) xmalloc (sizeof (struct xim_inst_t)); 8289 xim_inst = (struct xim_inst_t *) xmalloc (sizeof (struct xim_inst_t));
8290 dpyinfo->xim_callback_data = xim_inst;
8294 xim_inst->dpyinfo = dpyinfo; 8291 xim_inst->dpyinfo = dpyinfo;
8295 len = strlen (resource_name); 8292 len = strlen (resource_name);
8296 xim_inst->resource_name = (char *) xmalloc (len + 1); 8293 xim_inst->resource_name = (char *) xmalloc (len + 1);
8297 bcopy (resource_name, xim_inst->resource_name, len + 1); 8294 bcopy (resource_name, xim_inst->resource_name, len + 1);
8298 XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb, 8295 XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
8301 /* This is XPointer in XFree86 8298 /* This is XPointer in XFree86
8302 but (XPointer *) on Tru64, at 8299 but (XPointer *) on Tru64, at
8303 least, hence the configure test. */ 8300 least, hence the configure test. */
8304 (XRegisterIMInstantiateCallback_arg6) xim_inst); 8301 (XRegisterIMInstantiateCallback_arg6) xim_inst);
8305 #else /* not HAVE_X11R6_XIM */ 8302 #else /* not HAVE_X11R6_XIM */
8306 dpyinfo->xim = NULL;
8307 xim_open_dpy (dpyinfo, resource_name); 8303 xim_open_dpy (dpyinfo, resource_name);
8308 #endif /* not HAVE_X11R6_XIM */ 8304 #endif /* not HAVE_X11R6_XIM */
8309 8305 }
8310 }
8311 else
8312 #endif /* HAVE_XIM */ 8306 #endif /* HAVE_XIM */
8313 dpyinfo->xim = NULL;
8314 } 8307 }
8315 8308
8316 8309
8317 /* Close the connection to the XIM server on display DPYINFO. */ 8310 /* Close the connection to the XIM server on display DPYINFO. */
8318 8311
8326 #ifdef HAVE_X11R6_XIM 8319 #ifdef HAVE_X11R6_XIM
8327 if (dpyinfo->display) 8320 if (dpyinfo->display)
8328 XUnregisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb, 8321 XUnregisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
8329 NULL, EMACS_CLASS, 8322 NULL, EMACS_CLASS,
8330 xim_instantiate_callback, NULL); 8323 xim_instantiate_callback, NULL);
8331 #else /* not HAVE_X11R6_XIM */ 8324 xfree (dpyinfo->xim_callback_data->resource_name);
8332 /* If we have X11R6 xim, this causes a double-free. */ 8325 xfree (dpyinfo->xim_callback_data);
8326 #endif /* HAVE_X11R6_XIM */
8333 if (dpyinfo->display) 8327 if (dpyinfo->display)
8334 XCloseIM (dpyinfo->xim); 8328 XCloseIM (dpyinfo->xim);
8335 #endif /* HAVE_X11R6_XIM */
8336 dpyinfo->xim = NULL; 8329 dpyinfo->xim = NULL;
8337 XFree (dpyinfo->xim_styles); 8330 XFree (dpyinfo->xim_styles);
8338 } 8331 }
8339 #endif /* HAVE_XIM */ 8332 #endif /* HAVE_XIM */
8340 } 8333 }
10240 dpyinfo->mouse_face_defer = 0; 10233 dpyinfo->mouse_face_defer = 0;
10241 dpyinfo->mouse_face_hidden = 0; 10234 dpyinfo->mouse_face_hidden = 0;
10242 dpyinfo->x_focus_frame = 0; 10235 dpyinfo->x_focus_frame = 0;
10243 dpyinfo->x_focus_event_frame = 0; 10236 dpyinfo->x_focus_event_frame = 0;
10244 dpyinfo->x_highlight_frame = 0; 10237 dpyinfo->x_highlight_frame = 0;
10245 dpyinfo->terminal->image_cache = make_image_cache ();
10246 dpyinfo->wm_type = X_WMTYPE_UNKNOWN; 10238 dpyinfo->wm_type = X_WMTYPE_UNKNOWN;
10247 10239
10248 /* See if we can construct pixel values from RGB values. */ 10240 /* See if we can construct pixel values from RGB values. */
10249 dpyinfo->red_bits = dpyinfo->blue_bits = dpyinfo->green_bits = 0; 10241 dpyinfo->red_bits = dpyinfo->blue_bits = dpyinfo->green_bits = 0;
10250 dpyinfo->red_offset = dpyinfo->blue_offset = dpyinfo->green_offset = 0; 10242 dpyinfo->red_offset = dpyinfo->blue_offset = dpyinfo->green_offset = 0;
10368 10360
10369 connection = ConnectionNumber (dpyinfo->display); 10361 connection = ConnectionNumber (dpyinfo->display);
10370 dpyinfo->connection = connection; 10362 dpyinfo->connection = connection;
10371 10363
10372 { 10364 {
10373 char null_bits[1];
10374
10375 null_bits[0] = 0x00;
10376
10377 dpyinfo->null_pixel
10378 = XCreatePixmapFromBitmapData (dpyinfo->display, dpyinfo->root_window,
10379 null_bits, 1, 1, (long) 0, (long) 0,
10380 1);
10381 }
10382
10383 {
10384 extern int gray_bitmap_width, gray_bitmap_height; 10365 extern int gray_bitmap_width, gray_bitmap_height;
10385 extern char *gray_bitmap_bits; 10366 extern char *gray_bitmap_bits;
10386 dpyinfo->gray 10367 dpyinfo->gray
10387 = XCreatePixmapFromBitmapData (dpyinfo->display, dpyinfo->root_window, 10368 = XCreatePixmapFromBitmapData (dpyinfo->display, dpyinfo->root_window,
10388 gray_bitmap_bits, 10369 gray_bitmap_bits,
10547 if (dpyinfo->xim) 10528 if (dpyinfo->xim)
10548 xim_close_dpy (dpyinfo); 10529 xim_close_dpy (dpyinfo);
10549 #endif 10530 #endif
10550 10531
10551 xfree (dpyinfo->x_id_name); 10532 xfree (dpyinfo->x_id_name);
10533 xfree (dpyinfo->x_dnd_atoms);
10552 xfree (dpyinfo->color_cells); 10534 xfree (dpyinfo->color_cells);
10553 xfree (dpyinfo); 10535 xfree (dpyinfo);
10554 } 10536 }
10555 10537
10556 #ifdef USE_X_TOOLKIT 10538 #ifdef USE_X_TOOLKIT