aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2015-11-13 09:28:53 -0800
committerPaul Eggert2015-11-13 09:30:00 -0800
commit4c4b520520cf6b99ce7128331a4e108e58095705 (patch)
treef61c9a61cdca1f8550bbb72aec9c703a9c449585 /src
parent4f0ce9c8ef2c5ec1b9cf5bd1af9f54aa6fc335d0 (diff)
downloademacs-4c4b520520cf6b99ce7128331a4e108e58095705.tar.gz
emacs-4c4b520520cf6b99ce7128331a4e108e58095705.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/xfns.c7
-rw-r--r--src/xterm.c16
2 files changed, 15 insertions, 8 deletions
diff --git a/src/xfns.c b/src/xfns.c
index 9d90b7ba35f..313ac52f12a 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -450,10 +450,11 @@ x_real_pos_and_offsets (struct frame *f,
450 if (prop) 450 if (prop)
451 { 451 {
452 if (prop->type == target_type 452 if (prop->type == target_type
453 && xcb_get_property_value_length (prop) == 4 453 && prop->format == 32
454 && prop->format == 32) 454 && (xcb_get_property_value_length (prop)
455 == 4 * sizeof (int32_t)))
455 { 456 {
456 long *fe = xcb_get_property_value (prop); 457 int32_t *fe = xcb_get_property_value (prop);
457 458
458 outer_x = -fe[0]; 459 outer_x = -fe[0];
459 outer_y = -fe[2]; 460 outer_y = -fe[2];
diff --git a/src/xterm.c b/src/xterm.c
index 36a914c8559..acb6566d51d 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -10101,17 +10101,19 @@ get_current_wm_state (struct frame *f,
10101 bool is_hidden = false; 10101 bool is_hidden = false;
10102 struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); 10102 struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
10103 long max_len = 65536; 10103 long max_len = 65536;
10104 unsigned char *tmp_data = NULL;
10105 Atom target_type = XA_ATOM; 10104 Atom target_type = XA_ATOM;
10106 /* If XCB is available, we can avoid three XSync calls. */ 10105 /* If XCB is available, we can avoid three XSync calls. */
10107#ifdef USE_XCB 10106#ifdef USE_XCB
10108 xcb_get_property_cookie_t prop_cookie; 10107 xcb_get_property_cookie_t prop_cookie;
10109 xcb_get_property_reply_t *prop; 10108 xcb_get_property_reply_t *prop;
10109 xcb_atom_t *reply_data;
10110#else 10110#else
10111 Display *dpy = FRAME_X_DISPLAY (f); 10111 Display *dpy = FRAME_X_DISPLAY (f);
10112 unsigned long bytes_remaining; 10112 unsigned long bytes_remaining;
10113 int rc, actual_format; 10113 int rc, actual_format;
10114 Atom actual_type; 10114 Atom actual_type;
10115 unsigned char *tmp_data = NULL;
10116 Atom *reply_data;
10115#endif 10117#endif
10116 10118
10117 *sticky = false; 10119 *sticky = false;
@@ -10126,8 +10128,10 @@ get_current_wm_state (struct frame *f,
10126 prop = xcb_get_property_reply (dpyinfo->xcb_connection, prop_cookie, NULL); 10128 prop = xcb_get_property_reply (dpyinfo->xcb_connection, prop_cookie, NULL);
10127 if (prop && prop->type == target_type) 10129 if (prop && prop->type == target_type)
10128 { 10130 {
10129 tmp_data = xcb_get_property_value (prop); 10131 int actual_bytes = xcb_get_property_value_length (prop);
10130 actual_size = xcb_get_property_value_length (prop); 10132 eassume (0 <= actual_bytes);
10133 actual_size = actual_bytes / sizeof *reply_data;
10134 reply_data = xcb_get_property_value (prop);
10131 } 10135 }
10132 else 10136 else
10133 { 10137 {
@@ -10141,7 +10145,9 @@ get_current_wm_state (struct frame *f,
10141 &actual_type, &actual_format, &actual_size, 10145 &actual_type, &actual_format, &actual_size,
10142 &bytes_remaining, &tmp_data); 10146 &bytes_remaining, &tmp_data);
10143 10147
10144 if (rc != Success || actual_type != target_type || x_had_errors_p (dpy)) 10148 if (rc == Success && actual_type == target_type && ! x_had_errors_p (dpy))
10149 reply_data = (Atom *) tmp_data;
10150 else
10145 { 10151 {
10146 actual_size = 0; 10152 actual_size = 0;
10147 is_hidden = FRAME_ICONIFIED_P (f); 10153 is_hidden = FRAME_ICONIFIED_P (f);
@@ -10152,7 +10158,7 @@ get_current_wm_state (struct frame *f,
10152 10158
10153 for (i = 0; i < actual_size; ++i) 10159 for (i = 0; i < actual_size; ++i)
10154 { 10160 {
10155 Atom a = ((Atom*)tmp_data)[i]; 10161 Atom a = reply_data[i];
10156 if (a == dpyinfo->Xatom_net_wm_state_hidden) 10162 if (a == dpyinfo->Xatom_net_wm_state_hidden)
10157 is_hidden = true; 10163 is_hidden = true;
10158 else if (a == dpyinfo->Xatom_net_wm_state_maximized_horz) 10164 else if (a == dpyinfo->Xatom_net_wm_state_maximized_horz)