Fix doc-string of pop-to-buffer-same-window. (Bug#15492)
[bpt/emacs.git] / src / xsettings.c
index f48c49d..e5a66c4 100644 (file)
@@ -22,6 +22,9 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <float.h>
 #include <limits.h>
 #include <fcntl.h>
+
+#include <byteswap.h>
+
 #include "lisp.h"
 #include "xterm.h"
 #include "xsettings.h"
@@ -170,7 +173,7 @@ enum {
   SEEN_HINTSTYLE  = 0x10,
   SEEN_DPI        = 0x20,
   SEEN_FONT       = 0x40,
-  SEEN_TB_STYLE   = 0x80,
+  SEEN_TB_STYLE   = 0x80
 };
 struct xsettings
 {
@@ -336,9 +339,6 @@ get_prop_window (struct x_display_info *dpyinfo)
   XUngrabServer (dpy);
 }
 
-#define SWAP32(nr) (((nr) << 24) | (((nr) << 8) & 0xff0000)     \
-                    | (((nr) >> 8) & 0xff00) | ((nr) >> 24))
-#define SWAP16(nr) (((nr) << 8) | ((nr) >> 8))
 #define PAD(nr)    (((nr) + 3) & ~3)
 
 /* Parse xsettings and extract those that deal with Xft.
@@ -408,7 +408,7 @@ parse_settings (unsigned char *prop,
 
   if (bytes < 12) return BadLength;
   memcpy (&n_settings, prop+8, 4);
-  if (my_bo != that_bo) n_settings = SWAP32 (n_settings);
+  if (my_bo != that_bo) n_settings = bswap_32 (n_settings);
   bytes_parsed = 12;
 
   memset (settings, 0, sizeof (*settings));
@@ -430,7 +430,7 @@ parse_settings (unsigned char *prop,
 
       memcpy (&nlen, prop+bytes_parsed, 2);
       bytes_parsed += 2;
-      if (my_bo != that_bo) nlen = SWAP16 (nlen);
+      if (my_bo != that_bo) nlen = bswap_16 (nlen);
       if (bytes_parsed+nlen > bytes) return BadLength;
       to_cpy = nlen > 127 ? 127 : nlen;
       memcpy (name, prop+bytes_parsed, to_cpy);
@@ -457,7 +457,7 @@ parse_settings (unsigned char *prop,
           if (want_this)
             {
               memcpy (&ival, prop+bytes_parsed, 4);
-              if (my_bo != that_bo) ival = SWAP32 (ival);
+              if (my_bo != that_bo) ival = bswap_32 (ival);
             }
           bytes_parsed += 4;
           break;
@@ -466,7 +466,7 @@ parse_settings (unsigned char *prop,
           if (bytes_parsed+4 > bytes) return BadLength;
           memcpy (&vlen, prop+bytes_parsed, 4);
           bytes_parsed += 4;
-          if (my_bo != that_bo) vlen = SWAP32 (vlen);
+          if (my_bo != that_bo) vlen = bswap_32 (vlen);
           if (want_this)
             {
               to_cpy = vlen > 127 ? 127 : vlen;
@@ -687,7 +687,7 @@ apply_xft_settings (struct x_display_info *dpyinfo,
     {
       static char const format[] =
        "Antialias: %d, Hinting: %d, RGBA: %d, LCDFilter: %d, "
-       "Hintstyle: %d, DPI: %lf";
+       "Hintstyle: %d, DPI: %f";
       enum
       {
        d_formats = 5,
@@ -696,7 +696,7 @@ apply_xft_settings (struct x_display_info *dpyinfo,
        max_f_integer_digits = DBL_MAX_10_EXP + 1,
        f_precision = 6,
        lf_growth = (sizeof "-." + max_f_integer_digits + f_precision
-                    - sizeof "%lf")
+                    - sizeof "%f")
       };
       char buf[sizeof format + d_formats * d_growth + lf_formats * lf_growth];
 
@@ -754,10 +754,9 @@ read_and_apply_settings (struct x_display_info *dpyinfo, int send_event_p)
 /* Check if EVENT for the display in DPYINFO is XSettings related.  */
 
 void
-xft_settings_event (struct x_display_info *dpyinfo, XEvent *event)
+xft_settings_event (struct x_display_info *dpyinfo, const XEvent *event)
 {
-  int check_window_p = 0;
-  int apply_settings = 0;
+  bool check_window_p = 0, apply_settings_p = 0;
 
   switch (event->type)
     {
@@ -777,7 +776,7 @@ xft_settings_event (struct x_display_info *dpyinfo, XEvent *event)
       if (event->xproperty.window == dpyinfo->xsettings_window
           && event->xproperty.state == PropertyNewValue
           && event->xproperty.atom == dpyinfo->Xatom_xsettings_prop)
-        apply_settings = 1;
+        apply_settings_p = 1;
       break;
     }
 
@@ -787,10 +786,10 @@ xft_settings_event (struct x_display_info *dpyinfo, XEvent *event)
       dpyinfo->xsettings_window = None;
       get_prop_window (dpyinfo);
       if (dpyinfo->xsettings_window != None)
-        apply_settings = 1;
+        apply_settings_p = 1;
     }
 
-  if (apply_settings)
+  if (apply_settings_p)
     read_and_apply_settings (dpyinfo, True);
 }
 
@@ -804,7 +803,7 @@ init_gsettings (void)
   const gchar *const *schemas;
   int schema_found = 0;
 
-#ifdef HAVE_G_TYPE_INIT
+#if ! GLIB_CHECK_VERSION (2, 36, 0)
   g_type_init ();
 #endif
 
@@ -861,7 +860,7 @@ init_gconf (void)
 #if defined (HAVE_GCONF)
   char *s;
 
-#ifdef HAVE_G_TYPE_INIT
+#if ! GLIB_CHECK_VERSION (2, 36, 0)
   g_type_init ();
 #endif