Commit da05685d authored by Paul Eggert's avatar Paul Eggert Committed by Eli Zaretskii
Browse files

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.

Backport.
parent 97226341
...@@ -450,10 +450,11 @@ x_real_pos_and_offsets (struct frame *f, ...@@ -450,10 +450,11 @@ x_real_pos_and_offsets (struct frame *f,
if (prop) if (prop)
{ {
if (prop->type == target_type 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_x = -fe[0];
outer_y = -fe[2]; outer_y = -fe[2];
......
...@@ -10101,17 +10101,19 @@ get_current_wm_state (struct frame *f, ...@@ -10101,17 +10101,19 @@ get_current_wm_state (struct frame *f,
bool is_hidden = false; bool is_hidden = false;
struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); struct x_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
long max_len = 65536; long max_len = 65536;
unsigned char *tmp_data = NULL;
Atom target_type = XA_ATOM; Atom target_type = XA_ATOM;
/* If XCB is available, we can avoid three XSync calls. */ /* If XCB is available, we can avoid three XSync calls. */
#ifdef USE_XCB #ifdef USE_XCB
xcb_get_property_cookie_t prop_cookie; xcb_get_property_cookie_t prop_cookie;
xcb_get_property_reply_t *prop; xcb_get_property_reply_t *prop;
xcb_atom_t *reply_data;
#else #else
Display *dpy = FRAME_X_DISPLAY (f); Display *dpy = FRAME_X_DISPLAY (f);
unsigned long bytes_remaining; unsigned long bytes_remaining;
int rc, actual_format; int rc, actual_format;
Atom actual_type; Atom actual_type;
unsigned char *tmp_data = NULL;
Atom *reply_data;
#endif #endif
*sticky = false; *sticky = false;
...@@ -10126,8 +10128,10 @@ get_current_wm_state (struct frame *f, ...@@ -10126,8 +10128,10 @@ get_current_wm_state (struct frame *f,
prop = xcb_get_property_reply (dpyinfo->xcb_connection, prop_cookie, NULL); prop = xcb_get_property_reply (dpyinfo->xcb_connection, prop_cookie, NULL);
if (prop && prop->type == target_type) if (prop && prop->type == target_type)
{ {
tmp_data = xcb_get_property_value (prop); int actual_bytes = xcb_get_property_value_length (prop);
actual_size = 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 else
{ {
...@@ -10141,7 +10145,9 @@ get_current_wm_state (struct frame *f, ...@@ -10141,7 +10145,9 @@ get_current_wm_state (struct frame *f,
&actual_type, &actual_format, &actual_size, &actual_type, &actual_format, &actual_size,
&bytes_remaining, &tmp_data); &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; actual_size = 0;
is_hidden = FRAME_ICONIFIED_P (f); is_hidden = FRAME_ICONIFIED_P (f);
...@@ -10152,7 +10158,7 @@ get_current_wm_state (struct frame *f, ...@@ -10152,7 +10158,7 @@ get_current_wm_state (struct frame *f,
for (i = 0; i < actual_size; ++i) 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) if (a == dpyinfo->Xatom_net_wm_state_hidden)
is_hidden = true; is_hidden = true;
else if (a == dpyinfo->Xatom_net_wm_state_maximized_horz) else if (a == dpyinfo->Xatom_net_wm_state_maximized_horz)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment