summaryrefslogtreecommitdiff
path: root/src/xfns.c
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2023-05-22 11:52:33 +0800
committerPo Lu <luangruo@yahoo.com>2023-05-22 11:54:00 +0800
commit6f940c6a1183dd1660f35e6c82d33183a6892cb4 (patch)
tree5cbe8c7ca8e94f06b4f92267cf0bef3d8bb16fc6 /src/xfns.c
parentc297b828bb716885f92d3117c2abbb1ff21dbb08 (diff)
downloademacs-6f940c6a1183dd1660f35e6c82d33183a6892cb4.tar.gz
Plug various leaks and fix input method initialization
* src/image.c (free_bitmap_record): Free bm->name correctly even if the display connection has been closed. * src/xfns.c (x_window): Use dpyinfo-specific `use_xim' flag. * src/xterm.c (use_xim): Remove global variable. (xim_destroy_callback): Free `xim_styles' if present, and set it to NULL to be on the safe side. (xim_open_dpy): Consult dpyinfo->use_xim instead. Don't leak `xim_styles' if an IM was previously opened. (xim_initialize): Use dpyinfo-specific `use_xim' flag. (xim_close_dpy): Check if `dpyinfo->xim_callback_data' is set before unregistering the instantiation callback. (x_term_init): Determine whether or not to use XIM for each display opened, instead of using the resources of the last display opened to toggle a global flag. (x_delete_terminal): Always call `image_destroy_all_bitmaps' and `xim_close_dpy'. Free storage used to hold bitmap records. * src/xterm.h (struct x_display_info): New field `use_xim'.
Diffstat (limited to 'src/xfns.c')
-rw-r--r--src/xfns.c56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/xfns.c b/src/xfns.c
index 9e004f6a678..234a48c908f 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -4252,9 +4252,9 @@ x_window (struct frame *f, long window_prompting)
#ifdef HAVE_X_I18N
FRAME_XIC (f) = NULL;
- if (use_xim)
+ if (FRAME_DISPLAY_INFO (f)->use_xim)
create_frame_xic (f);
-#endif
+#endif /* HAVE_X_I18N */
f->output_data.x->wm_hints.input = True;
f->output_data.x->wm_hints.flags |= InputHint;
@@ -4355,32 +4355,32 @@ x_window (struct frame *f)
#ifdef HAVE_X_I18N
FRAME_XIC (f) = NULL;
- if (use_xim)
- {
- block_input ();
- create_frame_xic (f);
- if (FRAME_XIC (f))
- {
- /* XIM server might require some X events. */
- unsigned long fevent = NoEventMask;
- XGetICValues (FRAME_XIC (f), XNFilterEvents, &fevent, NULL);
+ if (FRAME_DISPLAY_INFO (f)->use_xim)
+ {
+ block_input ();
+ create_frame_xic (f);
+ if (FRAME_XIC (f))
+ {
+ /* XIM server might require some X events. */
+ unsigned long fevent = NoEventMask;
+ XGetICValues (FRAME_XIC (f), XNFilterEvents, &fevent, NULL);
- if (fevent != NoEventMask)
- {
- XSetWindowAttributes attributes;
- XWindowAttributes wattr;
- unsigned long attribute_mask;
-
- XGetWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
- &wattr);
- attributes.event_mask = wattr.your_event_mask | fevent;
- attribute_mask = CWEventMask;
- XChangeWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
- attribute_mask, &attributes);
- }
- }
- unblock_input ();
- }
+ if (fevent != NoEventMask)
+ {
+ XSetWindowAttributes attributes;
+ XWindowAttributes wattr;
+ unsigned long attribute_mask;
+
+ XGetWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+ &wattr);
+ attributes.event_mask = wattr.your_event_mask | fevent;
+ attribute_mask = CWEventMask;
+ XChangeWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
+ attribute_mask, &attributes);
+ }
+ }
+ unblock_input ();
+ }
#endif
append_wm_protocols (FRAME_DISPLAY_INFO (f), f);
@@ -4427,7 +4427,7 @@ x_window (struct frame *f)
initial_set_up_x_back_buffer (f);
#ifdef HAVE_X_I18N
- if (use_xim)
+ if (FRAME_DISPLAY_INFO (f)->use_xim)
{
create_frame_xic (f);
if (FRAME_XIC (f))