aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2023-05-22 21:00:20 +0800
committerPo Lu2023-05-22 21:00:20 +0800
commit6dc9a3eeb755b5b0047b39f2bd7ebdefb10a1dc4 (patch)
tree12dab91f9291e699cb74d4f00b5fa42e83668fb1 /src
parentd341adadc8a1688df888c55410366e42748a3e2d (diff)
parent438b1205c54dbdeff234d14dcf2287cbf6769522 (diff)
downloademacs-6dc9a3eeb755b5b0047b39f2bd7ebdefb10a1dc4.tar.gz
emacs-6dc9a3eeb755b5b0047b39f2bd7ebdefb10a1dc4.zip
Merge remote-tracking branch 'origin/master' into feature/android
Diffstat (limited to 'src')
-rw-r--r--src/image.c14
-rw-r--r--src/xfns.c56
-rw-r--r--src/xterm.c156
-rw-r--r--src/xterm.h11
4 files changed, 148 insertions, 89 deletions
diff --git a/src/image.c b/src/image.c
index 689ff882728..7501838d8c4 100644
--- a/src/image.c
+++ b/src/image.c
@@ -958,9 +958,17 @@ static void
958free_bitmap_record (Display_Info *dpyinfo, Bitmap_Record *bm) 958free_bitmap_record (Display_Info *dpyinfo, Bitmap_Record *bm)
959{ 959{
960#ifdef HAVE_X_WINDOWS 960#ifdef HAVE_X_WINDOWS
961 XFreePixmap (dpyinfo->display, bm->pixmap); 961 /* Free the pixmap and mask. Only do this if DPYINFO->display is
962 if (bm->have_mask) 962 still set, which may not be the case if the connection has
963 XFreePixmap (dpyinfo->display, bm->mask); 963 already been closed in response to an IO error. */
964
965 if (dpyinfo->display)
966 {
967 XFreePixmap (dpyinfo->display, bm->pixmap);
968 if (bm->have_mask)
969 XFreePixmap (dpyinfo->display, bm->mask);
970 }
971
964#ifdef USE_CAIRO 972#ifdef USE_CAIRO
965 if (bm->stipple) 973 if (bm->stipple)
966 cairo_pattern_destroy (bm->stipple); 974 cairo_pattern_destroy (bm->stipple);
diff --git a/src/xfns.c b/src/xfns.c
index b7000462e84..057d0436ebe 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -4252,9 +4252,9 @@ x_window (struct frame *f, long window_prompting)
4252 4252
4253#ifdef HAVE_X_I18N 4253#ifdef HAVE_X_I18N
4254 FRAME_XIC (f) = NULL; 4254 FRAME_XIC (f) = NULL;
4255 if (use_xim) 4255 if (FRAME_DISPLAY_INFO (f)->use_xim)
4256 create_frame_xic (f); 4256 create_frame_xic (f);
4257#endif 4257#endif /* HAVE_X_I18N */
4258 4258
4259 f->output_data.x->wm_hints.input = True; 4259 f->output_data.x->wm_hints.input = True;
4260 f->output_data.x->wm_hints.flags |= InputHint; 4260 f->output_data.x->wm_hints.flags |= InputHint;
@@ -4355,32 +4355,32 @@ x_window (struct frame *f)
4355 4355
4356#ifdef HAVE_X_I18N 4356#ifdef HAVE_X_I18N
4357 FRAME_XIC (f) = NULL; 4357 FRAME_XIC (f) = NULL;
4358 if (use_xim) 4358 if (FRAME_DISPLAY_INFO (f)->use_xim)
4359 { 4359 {
4360 block_input (); 4360 block_input ();
4361 create_frame_xic (f); 4361 create_frame_xic (f);
4362 if (FRAME_XIC (f)) 4362 if (FRAME_XIC (f))
4363 { 4363 {
4364 /* XIM server might require some X events. */ 4364 /* XIM server might require some X events. */
4365 unsigned long fevent = NoEventMask; 4365 unsigned long fevent = NoEventMask;
4366 XGetICValues (FRAME_XIC (f), XNFilterEvents, &fevent, NULL); 4366 XGetICValues (FRAME_XIC (f), XNFilterEvents, &fevent, NULL);
4367 4367
4368 if (fevent != NoEventMask) 4368 if (fevent != NoEventMask)
4369 { 4369 {
4370 XSetWindowAttributes attributes; 4370 XSetWindowAttributes attributes;
4371 XWindowAttributes wattr; 4371 XWindowAttributes wattr;
4372 unsigned long attribute_mask; 4372 unsigned long attribute_mask;
4373 4373
4374 XGetWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 4374 XGetWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
4375 &wattr); 4375 &wattr);
4376 attributes.event_mask = wattr.your_event_mask | fevent; 4376 attributes.event_mask = wattr.your_event_mask | fevent;
4377 attribute_mask = CWEventMask; 4377 attribute_mask = CWEventMask;
4378 XChangeWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 4378 XChangeWindowAttributes (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
4379 attribute_mask, &attributes); 4379 attribute_mask, &attributes);
4380 } 4380 }
4381 } 4381 }
4382 unblock_input (); 4382 unblock_input ();
4383 } 4383 }
4384#endif 4384#endif
4385 4385
4386 append_wm_protocols (FRAME_DISPLAY_INFO (f), f); 4386 append_wm_protocols (FRAME_DISPLAY_INFO (f), f);
@@ -4427,7 +4427,7 @@ x_window (struct frame *f)
4427 initial_set_up_x_back_buffer (f); 4427 initial_set_up_x_back_buffer (f);
4428 4428
4429#ifdef HAVE_X_I18N 4429#ifdef HAVE_X_I18N
4430 if (use_xim) 4430 if (FRAME_DISPLAY_INFO (f)->use_xim)
4431 { 4431 {
4432 create_frame_xic (f); 4432 create_frame_xic (f);
4433 if (FRAME_XIC (f)) 4433 if (FRAME_XIC (f))
diff --git a/src/xterm.c b/src/xterm.c
index 111e4ede2c2..37fabc15e3a 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -798,13 +798,6 @@ typedef int (*Emacs_XIOErrorHandler) (Display *);
798#define USE_CAIRO_XCB_SURFACE 798#define USE_CAIRO_XCB_SURFACE
799#endif 799#endif
800 800
801/* Default to using XIM if available. */
802#ifdef USE_XIM
803bool use_xim = true;
804#else
805bool use_xim = false; /* configure --without-xim */
806#endif
807
808#if XCB_SHAPE_MAJOR_VERSION > 1 \ 801#if XCB_SHAPE_MAJOR_VERSION > 1 \
809 || (XCB_SHAPE_MAJOR_VERSION == 1 && \ 802 || (XCB_SHAPE_MAJOR_VERSION == 1 && \
810 XCB_SHAPE_MINOR_VERSION >= 1) 803 XCB_SHAPE_MINOR_VERSION >= 1)
@@ -26702,7 +26695,12 @@ xim_destroy_callback (XIM xim, XPointer client_data, XPointer call_data)
26702 26695
26703 /* No need to call XCloseIM. */ 26696 /* No need to call XCloseIM. */
26704 dpyinfo->xim = NULL; 26697 dpyinfo->xim = NULL;
26705 XFree (dpyinfo->xim_styles); 26698
26699 /* Also free IM values; those are allocated separately upon
26700 XGetIMValues. */
26701 if (dpyinfo->xim_styles)
26702 XFree (dpyinfo->xim_styles);
26703 dpyinfo->xim_styles = NULL;
26706 unblock_input (); 26704 unblock_input ();
26707} 26705}
26708 26706
@@ -26720,10 +26718,20 @@ xim_open_dpy (struct x_display_info *dpyinfo, char *resource_name)
26720 XIM xim; 26718 XIM xim;
26721 const char *locale; 26719 const char *locale;
26722 26720
26723 if (use_xim) 26721 if (dpyinfo->use_xim)
26724 { 26722 {
26725 if (dpyinfo->xim) 26723 if (dpyinfo->xim)
26726 XCloseIM (dpyinfo->xim); 26724 {
26725 XCloseIM (dpyinfo->xim);
26726
26727 /* Free values left over from the last time the IM
26728 connection was established. */
26729
26730 if (dpyinfo->xim_styles)
26731 XFree (dpyinfo->xim_styles);
26732 dpyinfo->xim_styles = NULL;
26733 }
26734
26727 xim = XOpenIM (dpyinfo->display, dpyinfo->rdb, resource_name, 26735 xim = XOpenIM (dpyinfo->display, dpyinfo->rdb, resource_name,
26728 emacs_class); 26736 emacs_class);
26729 dpyinfo->xim = xim; 26737 dpyinfo->xim = xim;
@@ -26752,7 +26760,6 @@ xim_open_dpy (struct x_display_info *dpyinfo, char *resource_name)
26752 build_string (locale)); 26760 build_string (locale));
26753 } 26761 }
26754 } 26762 }
26755
26756 else 26763 else
26757#endif /* HAVE_XIM */ 26764#endif /* HAVE_XIM */
26758 dpyinfo->xim = NULL; 26765 dpyinfo->xim = NULL;
@@ -26821,7 +26828,7 @@ xim_initialize (struct x_display_info *dpyinfo, char *resource_name)
26821{ 26828{
26822 dpyinfo->xim = NULL; 26829 dpyinfo->xim = NULL;
26823#ifdef HAVE_XIM 26830#ifdef HAVE_XIM
26824 if (use_xim) 26831 if (dpyinfo->use_xim)
26825 { 26832 {
26826#ifdef HAVE_X11R6_XIM 26833#ifdef HAVE_X11R6_XIM
26827 struct xim_inst_t *xim_inst = xmalloc (sizeof *xim_inst); 26834 struct xim_inst_t *xim_inst = xmalloc (sizeof *xim_inst);
@@ -26830,15 +26837,19 @@ xim_initialize (struct x_display_info *dpyinfo, char *resource_name)
26830 dpyinfo->xim_callback_data = xim_inst; 26837 dpyinfo->xim_callback_data = xim_inst;
26831 xim_inst->dpyinfo = dpyinfo; 26838 xim_inst->dpyinfo = dpyinfo;
26832 xim_inst->resource_name = xstrdup (resource_name); 26839 xim_inst->resource_name = xstrdup (resource_name);
26833 ret = XRegisterIMInstantiateCallback 26840
26834 (dpyinfo->display, dpyinfo->rdb, xim_inst->resource_name, 26841 /* The last argument is XPointer in XFree86 but (XPointer *) on
26835 emacs_class, xim_instantiate_callback, 26842 Tru64, at least, but the configure test doesn't work because
26836 /* This is XPointer in XFree86 but (XPointer *) on Tru64, at 26843 xim_instantiate_callback can either be XIMProc or XIDProc, so
26837 least, but the configure test doesn't work because 26844 just cast to void *. */
26838 xim_instantiate_callback can either be XIMProc or 26845
26839 XIDProc, so just cast to void *. */ 26846 ret = XRegisterIMInstantiateCallback (dpyinfo->display,
26840 (void *) xim_inst); 26847 dpyinfo->rdb,
26841 eassert (ret == True); 26848 xim_inst->resource_name,
26849 emacs_class,
26850 xim_instantiate_callback,
26851 (void *) xim_inst);
26852 eassert (ret);
26842#else /* not HAVE_X11R6_XIM */ 26853#else /* not HAVE_X11R6_XIM */
26843 xim_open_dpy (dpyinfo, resource_name); 26854 xim_open_dpy (dpyinfo, resource_name);
26844#endif /* not HAVE_X11R6_XIM */ 26855#endif /* not HAVE_X11R6_XIM */
@@ -26847,32 +26858,56 @@ xim_initialize (struct x_display_info *dpyinfo, char *resource_name)
26847} 26858}
26848 26859
26849 26860
26850/* Close the connection to the XIM server on display DPYINFO. */ 26861/* Close the connection to the XIM server on display DPYINFO.
26862 Unregister any IM instantiation callback previously installed,
26863 close the connection to the IM server if possible, and free any
26864 retrieved IM values. */
26851 26865
26852static void 26866static void
26853xim_close_dpy (struct x_display_info *dpyinfo) 26867xim_close_dpy (struct x_display_info *dpyinfo)
26854{ 26868{
26855#ifdef HAVE_XIM 26869#ifdef HAVE_XIM
26856 if (use_xim)
26857 {
26858#ifdef HAVE_X11R6_XIM 26870#ifdef HAVE_X11R6_XIM
26859 struct xim_inst_t *xim_inst = dpyinfo->xim_callback_data; 26871 struct xim_inst_t *xim_inst;
26872 Bool rc;
26873
26874 /* If dpyinfo->xim_callback_data is not set, then IM support wasn't
26875 initialized, which can happen if Xlib doesn't understand the C
26876 locale being used. */
26877
26878 if (dpyinfo->xim_callback_data)
26879 {
26880 xim_inst = dpyinfo->xim_callback_data;
26860 26881
26861 if (dpyinfo->display) 26882 if (dpyinfo->display)
26862 { 26883 {
26863 Bool ret = XUnregisterIMInstantiateCallback 26884 rc = XUnregisterIMInstantiateCallback (dpyinfo->display,
26864 (dpyinfo->display, dpyinfo->rdb, xim_inst->resource_name, 26885 dpyinfo->rdb,
26865 emacs_class, xim_instantiate_callback, (void *) xim_inst); 26886 xim_inst->resource_name,
26866 eassert (ret == True); 26887 emacs_class,
26888 xim_instantiate_callback,
26889 (void *) xim_inst);
26890 eassert (rc);
26867 } 26891 }
26892
26868 xfree (xim_inst->resource_name); 26893 xfree (xim_inst->resource_name);
26869 xfree (xim_inst); 26894 xfree (xim_inst);
26870#endif /* HAVE_X11R6_XIM */
26871 if (dpyinfo->display)
26872 XCloseIM (dpyinfo->xim);
26873 dpyinfo->xim = NULL;
26874 XFree (dpyinfo->xim_styles);
26875 } 26895 }
26896#endif /* HAVE_X11R6_XIM */
26897
26898 /* Now close the connection to the input method server. This may
26899 access the display connection, and isn't safe if the display has
26900 already been closed. */
26901
26902 if (dpyinfo->display && dpyinfo->xim)
26903 XCloseIM (dpyinfo->xim);
26904 dpyinfo->xim = NULL;
26905
26906 /* Free the list of XIM styles retrieved. */
26907
26908 if (dpyinfo->xim_styles)
26909 XFree (dpyinfo->xim_styles);
26910 dpyinfo->xim_styles = NULL;
26876#endif /* HAVE_XIM */ 26911#endif /* HAVE_XIM */
26877} 26912}
26878 26913
@@ -30825,14 +30860,6 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
30825 dpyinfo->fixes_pointer_blanking = (egetenv ("EMACS_XFIXES") != NULL); 30860 dpyinfo->fixes_pointer_blanking = (egetenv ("EMACS_XFIXES") != NULL);
30826#endif 30861#endif
30827 30862
30828#ifdef HAVE_X_I18N
30829 /* Avoid initializing input methods if the X library does not
30830 support Emacs's locale. When the current locale is not
30831 supported, decoding input method strings becomes undefined. */
30832 if (XSupportsLocale ())
30833 xim_initialize (dpyinfo, resource_name);
30834#endif
30835
30836 xsettings_initialize (dpyinfo); 30863 xsettings_initialize (dpyinfo);
30837 30864
30838 /* This is only needed for distinguishing keyboard and process input. */ 30865 /* This is only needed for distinguishing keyboard and process input. */
@@ -30891,25 +30918,33 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
30891 XSynchronize (dpyinfo->display, True); 30918 XSynchronize (dpyinfo->display, True);
30892 } 30919 }
30893 30920
30921#ifdef HAVE_X_I18N
30894 { 30922 {
30895 AUTO_STRING (useXIM, "useXIM"); 30923 AUTO_STRING (useXIM, "useXIM");
30896 AUTO_STRING (UseXIM, "UseXIM"); 30924 AUTO_STRING (UseXIM, "UseXIM");
30897 Lisp_Object value = gui_display_get_resource (dpyinfo, useXIM, UseXIM, 30925 Lisp_Object value = gui_display_get_resource (dpyinfo, useXIM, UseXIM,
30898 Qnil, Qnil); 30926 Qnil, Qnil);
30927
30928 /* `USE_XIM' controls whether Emacs should use X input methods by
30929 default, not whether or not XIM is available. */
30930
30899#ifdef USE_XIM 30931#ifdef USE_XIM
30932 dpyinfo->use_xim = true;
30933
30900 if (STRINGP (value) 30934 if (STRINGP (value)
30901 && (!strcmp (SSDATA (value), "false") 30935 && (!strcmp (SSDATA (value), "false")
30902 || !strcmp (SSDATA (value), "off"))) 30936 || !strcmp (SSDATA (value), "off")))
30903 use_xim = false; 30937 dpyinfo->use_xim = false;
30904#else 30938#else /* !USE_XIM */
30939 dpyinfo->use_xim = false;
30940
30905 if (STRINGP (value) 30941 if (STRINGP (value)
30906 && (!strcmp (SSDATA (value), "true") 30942 && (!strcmp (SSDATA (value), "true")
30907 || !strcmp (SSDATA (value), "on"))) 30943 || !strcmp (SSDATA (value), "on")))
30908 use_xim = true; 30944 dpyinfo->use_xim = true;
30909#endif 30945#endif /* USE_XIM */
30910 } 30946 }
30911 30947
30912#ifdef HAVE_X_I18N
30913 { 30948 {
30914 AUTO_STRING (inputStyle, "inputStyle"); 30949 AUTO_STRING (inputStyle, "inputStyle");
30915 AUTO_STRING (InputStyle, "InputStyle"); 30950 AUTO_STRING (InputStyle, "InputStyle");
@@ -30931,10 +30966,19 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
30931#ifdef USE_GTK 30966#ifdef USE_GTK
30932 else if (!strcmp (SSDATA (value), "native")) 30967 else if (!strcmp (SSDATA (value), "native"))
30933 dpyinfo->prefer_native_input = true; 30968 dpyinfo->prefer_native_input = true;
30934#endif 30969#endif /* HAVE_GTK */
30935 } 30970 }
30936 } 30971 }
30937#endif 30972
30973 /* Now that defaults have been set up, initialize input method
30974 support. */
30975
30976 /* Avoid initializing input methods if the X library does not
30977 support Emacs's locale. When the current locale is not
30978 supported, decoding input method strings becomes undefined. */
30979 if (XSupportsLocale ())
30980 xim_initialize (dpyinfo, resource_name);
30981#endif /* HAVE_X_I18N */
30938 30982
30939#ifdef HAVE_X_SM 30983#ifdef HAVE_X_SM
30940 /* Only do this for the very first display in the Emacs session. 30984 /* Only do this for the very first display in the Emacs session.
@@ -31327,14 +31371,22 @@ x_delete_terminal (struct terminal *terminal)
31327#ifdef HAVE_X_I18N 31371#ifdef HAVE_X_I18N
31328 /* We must close our connection to the XIM server before closing the 31372 /* We must close our connection to the XIM server before closing the
31329 X display. */ 31373 X display. */
31330 if (dpyinfo->xim) 31374 xim_close_dpy (dpyinfo);
31331 xim_close_dpy (dpyinfo);
31332#endif 31375#endif
31333 31376
31377 /* Destroy all bitmap images created on the display. */
31378 image_destroy_all_bitmaps (dpyinfo);
31379
31380 /* Free the storage allocated to hold bitmap records. */
31381 xfree (dpyinfo->bitmaps);
31382
31383 /* In case someone decides to use `bitmaps' again... */
31384 dpyinfo->bitmaps = NULL;
31385 dpyinfo->bitmaps_last = 0;
31386
31334 /* Normally, the display is available... */ 31387 /* Normally, the display is available... */
31335 if (dpyinfo->display) 31388 if (dpyinfo->display)
31336 { 31389 {
31337 image_destroy_all_bitmaps (dpyinfo);
31338 XSetCloseDownMode (dpyinfo->display, DestroyAll); 31390 XSetCloseDownMode (dpyinfo->display, DestroyAll);
31339 31391
31340 /* Delete the scratch cursor GC, should it exist. */ 31392 /* Delete the scratch cursor GC, should it exist. */
diff --git a/src/xterm.h b/src/xterm.h
index 406a7c5c060..e7171ba072f 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -649,7 +649,11 @@ struct x_display_info
649 649
650 /* The named coding system to use for this input method. */ 650 /* The named coding system to use for this input method. */
651 Lisp_Object xim_coding; 651 Lisp_Object xim_coding;
652#endif 652
653 /* Whether or not X input methods should be used on this
654 display. */
655 bool use_xim;
656#endif /* HAVE_X_I18N */
653 657
654 /* A cache mapping color names to RGB values. */ 658 /* A cache mapping color names to RGB values. */
655 struct color_name_cache_entry **color_names; 659 struct color_name_cache_entry **color_names;
@@ -929,11 +933,6 @@ struct x_display_info
929 Time quit_keysym_time; 933 Time quit_keysym_time;
930}; 934};
931 935
932#ifdef HAVE_X_I18N
933/* Whether or not to use XIM if we have it. */
934extern bool use_xim;
935#endif
936
937#ifdef HAVE_XINPUT2 936#ifdef HAVE_XINPUT2
938/* Defined in xmenu.c. */ 937/* Defined in xmenu.c. */
939extern int popup_activated_flag; 938extern int popup_activated_flag;