emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 4c4b520: Port recent XCB changes to 64-bit ‘long i


From: Paul Eggert
Subject: [Emacs-diffs] master 4c4b520: Port recent XCB changes to 64-bit ‘long int’
Date: Fri, 13 Nov 2015 17:30:11 +0000

branch: master
commit 4c4b520520cf6b99ce7128331a4e108e58095705
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>

    Port recent XCB changes to 64-bit ‘long int’
    
    For historical reasons, libX11 represents 32-bit values like Atoms as
    ‘long int’ even on platforms where ‘long int’ is 64 bits.  XCB doesn’t
    do that, so adapt the recent XCB code to behave properly on 64-bit
    platforms.  Also, fix what appears to be a bug in the interpretation
    of xcb_get_property_value_length, at least on my Fedora platform
    which is running libxcb-1.11-5.fc21.
    * src/xfns.c (x_real_pos_and_offsets):
    * src/xterm.c (get_current_wm_state):
    xcb_get_property_value_length returns a byte count, not a word count.
    For 32-bit quantities, xcb_get_property_value returns a vector
    of 32-bit words, not of (possibly 64-bit) long int.
---
 src/xfns.c  |    7 ++++---
 src/xterm.c |   16 +++++++++++-----
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/src/xfns.c b/src/xfns.c
index 9d90b7b..313ac52 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -450,10 +450,11 @@ x_real_pos_and_offsets (struct frame *f,
           if (prop)
             {
               if (prop->type == target_type
-                  && xcb_get_property_value_length (prop) == 4
-                  && prop->format == 32)
+                  && prop->format == 32
+                  && (xcb_get_property_value_length (prop)
+                     == 4 * sizeof (int32_t)))
                 {
-                  long *fe = xcb_get_property_value (prop);
+                  int32_t *fe = xcb_get_property_value (prop);
 
                   outer_x = -fe[0];
                   outer_y = -fe[2];
diff --git a/src/xterm.c b/src/xterm.c
index 36a914c..acb6566 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -10101,17 +10101,19 @@ get_current_wm_state (struct frame *f,
   bool is_hidden = false;
   struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
   long max_len = 65536;
-  unsigned char *tmp_data = NULL;
   Atom target_type = XA_ATOM;
   /* If XCB is available, we can avoid three XSync calls.  */
 #ifdef USE_XCB
   xcb_get_property_cookie_t prop_cookie;
   xcb_get_property_reply_t *prop;
+  xcb_atom_t *reply_data;
 #else
   Display *dpy = FRAME_X_DISPLAY (f);
   unsigned long bytes_remaining;
   int rc, actual_format;
   Atom actual_type;
+  unsigned char *tmp_data = NULL;
+  Atom *reply_data;
 #endif
 
   *sticky = false;
@@ -10126,8 +10128,10 @@ get_current_wm_state (struct frame *f,
   prop = xcb_get_property_reply (dpyinfo->xcb_connection, prop_cookie, NULL);
   if (prop && prop->type == target_type)
     {
-      tmp_data = xcb_get_property_value (prop);
-      actual_size = xcb_get_property_value_length (prop);
+      int actual_bytes = xcb_get_property_value_length (prop);
+      eassume (0 <= actual_bytes);
+      actual_size = actual_bytes / sizeof *reply_data;
+      reply_data = xcb_get_property_value (prop);
     }
   else
     {
@@ -10141,7 +10145,9 @@ get_current_wm_state (struct frame *f,
                            &actual_type, &actual_format, &actual_size,
                            &bytes_remaining, &tmp_data);
 
-  if (rc != Success || actual_type != target_type || x_had_errors_p (dpy))
+  if (rc == Success && actual_type == target_type && ! x_had_errors_p (dpy))
+    reply_data = (Atom *) tmp_data;
+  else
     {
       actual_size = 0;
       is_hidden = FRAME_ICONIFIED_P (f);
@@ -10152,7 +10158,7 @@ get_current_wm_state (struct frame *f,
 
   for (i = 0; i < actual_size; ++i)
     {
-      Atom a = ((Atom*)tmp_data)[i];
+      Atom a = reply_data[i];
       if (a == dpyinfo->Xatom_net_wm_state_hidden)
        is_hidden = true;
       else if (a == dpyinfo->Xatom_net_wm_state_maximized_horz)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]