]> git.eshelyaron.com Git - emacs.git/commitdiff
Make Emacs build with some other XLib implementations
authorPo Lu <luangruo@yahoo.com>
Fri, 4 Feb 2022 03:28:05 +0000 (03:28 +0000)
committerPo Lu <luangruo@yahoo.com>
Fri, 4 Feb 2022 03:28:05 +0000 (03:28 +0000)
* configure.ac (HAVE_XKB): Check for functions that aren't
always implemented by various XLib implementations.

* src/xfns.c (select_visual): Handle NULL values of vinfo.
(XkbRefreshKeyboardMapping):
(XkbFreeNames):
(XDisplayCells):
(XDestroySubwindows): Define replacement functions where they
aren't available.

* src/xterm.c (x_find_modifier_meanings): Handle NULL values of
various fields.

configure.ac
src/xfns.c
src/xterm.c

index 9f4d5db43f1d2cb2c907d1b305a69fbde9a7860c..2ad5f2312c13c152da8cb3a8031f2ce623514915 100644 (file)
@@ -2620,10 +2620,11 @@ if test "${HAVE_X11}" = "yes"; then
        emacs_cv_xkb=yes, emacs_cv_xkb=no)])
   if test $emacs_cv_xkb = yes; then
     AC_DEFINE(HAVE_XKB, 1, [Define to 1 if you have the Xkb extension.])
+    AC_CHECK_FUNCS(XkbRefreshKeyboardMapping XkbFreeNames)
   fi
 
-  AC_CHECK_FUNCS(XrmSetDatabase XScreenResourceString \
-XScreenNumberOfScreen)
+  AC_CHECK_FUNCS(XrmSetDatabase XScreenResourceString XScreenNumberOfScreen)
+  AC_CHECK_FUNCS(XDisplayCells XDestroySubwindows)
 fi
 
 if test "${window_system}" = "x11"; then
index 1a0e9f50cddd56c0e2b40c770d36300b02e5cc54..deaf4204a9f3e59aea16b226c9d7582f4a8a6c89 100644 (file)
@@ -6413,7 +6413,7 @@ select_visual (struct x_display_info *dpyinfo)
                                    | VisualClassMask),
                              &vinfo_template, &n_visuals);
 
-      if (n_visuals > 0)
+      if (n_visuals > 0 && vinfo)
        {
          dpyinfo->n_planes = vinfo->depth;
          dpyinfo->visual = vinfo->visual;
@@ -8644,6 +8644,54 @@ frame_parm_handler x_frame_parm_handlers[] =
   x_set_alpha_background,
 };
 
+/* Some versions of libX11 don't have symbols for a few functions we
+   need, so define replacements here.  */
+
+#ifdef HAVE_XKB
+#ifndef HAVE_XKBREFRESHKEYBOARDMAPPING
+Status
+XkbRefreshKeyboardMapping (XkbMapNotifyEvent *event)
+{
+  return Success;
+}
+#endif
+
+#ifndef HAVE_XKBFREENAMES
+void
+XkbFreeNames (XkbDescPtr xkb, unsigned int which, Bool free_map)
+{
+  return;
+}
+#endif
+#endif
+
+#ifndef HAVE_XDISPLAYCELLS
+int
+XDisplayCells (Display *dpy, int screen_number)
+{
+  return 1677216;
+}
+#endif
+
+#ifndef HAVE_XDESTROYSUBWINDOWS
+int
+XDestroySubwindows (Display *dpy, Window w)
+{
+  Window root, parent, *children;
+  unsigned int nchildren, i;
+
+  if (XQueryTree (dpy, w, &root, &parent, &children,
+                 &nchildren))
+    {
+      for (i = 0; i < nchildren; ++i)
+       XDestroyWindow (dpy, children[i]);
+      XFree (children);
+    }
+
+  return 0;
+}
+#endif
+
 void
 syms_of_xfns (void)
 {
index c24a2ab68633108ada6bc88bfa48f579c6cd6a8f..2e09c454b24d0304372aaa4c52eea6930ac6e16b 100644 (file)
@@ -5768,7 +5768,8 @@ x_find_modifier_meanings (struct x_display_info *dpyinfo)
   dpyinfo->hyper_mod_mask = 0;
 
 #ifdef HAVE_XKB
-  if (dpyinfo->xkb_desc)
+  if (dpyinfo->xkb_desc
+      && dpyinfo->xkb_desc->server)
     {
       for (i = 0; i < XkbNumVirtualMods; i++)
        {
@@ -5810,6 +5811,14 @@ x_find_modifier_meanings (struct x_display_info *dpyinfo)
   syms = XGetKeyboardMapping (dpyinfo->display,
                              min_code, max_code - min_code + 1,
                              &syms_per_code);
+
+  if (!syms)
+    {
+      dpyinfo->meta_mod_mask = Mod1Mask;
+      dpyinfo->super_mod_mask = Mod2Mask;
+      return;
+    }
+
   mods = XGetModifierMapping (dpyinfo->display);
 
   /* Scan the modifier table to see which modifier bits the Meta and