From 31f16913d78ccf89e278816ba2c10ed075c1be19 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Dj=C3=A4rv?= Date: Sat, 5 Feb 2005 16:41:38 +0000 Subject: [PATCH] * xselect.c (Fx_send_client_event, x_handle_dnd_message): Handle the longs in a XClientMessageEvent correctly when long is 64 bits. --- src/ChangeLog | 5 +++++ src/xselect.c | 48 +++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index a759feb6b59..fccfbf7ddd4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2005-02-05 Jan Dj,Ad(Brv + + * xselect.c (Fx_send_client_event, x_handle_dnd_message): Handle + the longs in a XClientMessageEvent correctly when long is 64 bits. + 2005-02-05 Eli Zaretskii * xfaces.c (face_color_supported_p): Use HAVE_WINDOW_SYSTEM diff --git a/src/xselect.c b/src/xselect.c index 5dd63b9c735..daae84b276c 100644 --- a/src/xselect.c +++ b/src/xselect.c @@ -2536,7 +2536,7 @@ x_property_data_to_lisp (f, data, type, format, size) data, size*format/8, type, format); } -/* Get the mouse position frame relative coordinates. */ +/* Get the mouse position in frame relative coordinates. */ static void mouse_position_for_drop (f, x, y) @@ -2635,16 +2635,31 @@ x_handle_dnd_message (f, event, dpyinfo, bufp) Lisp_Object frame; unsigned long size = (8*sizeof (event->data))/event->format; int x, y; + unsigned char *data = (unsigned char *) event->data.b; + int idata[5]; XSETFRAME (frame, f); + /* On a 64 bit machine, the event->data.l array members are 64 bits (long), + but the x_property_data_to_lisp (or rather selection_data_to_lisp_data) + function expects them to be of size int (i.e. 32). So to be able to + use that function, put the data in the form it expects if format is 32. */ + + if (event->format == 32 && event->format < BITS_PER_LONG) + { + int i; + for (i = 0; i < 5; ++i) /* There are only 5 longs in a ClientMessage. */ + idata[i] = (int) event->data.l[i]; + data = (unsigned char *) idata; + } + vec = Fmake_vector (make_number (4), Qnil); AREF (vec, 0) = SYMBOL_NAME (x_atom_to_symbol (FRAME_X_DISPLAY (f), event->message_type)); AREF (vec, 1) = frame; AREF (vec, 2) = make_number (event->format); AREF (vec, 3) = x_property_data_to_lisp (f, - event->data.b, + data, event->message_type, event->format, size); @@ -2697,6 +2712,8 @@ are ignored. */) struct frame *f = check_x_frame (from); int count; int to_root; + int idata[5]; + void *data; CHECK_STRING (message_type); CHECK_NUMBER (format); @@ -2756,10 +2773,31 @@ are ignored. */) when sending to the root window. */ event.xclient.window = to_root ? FRAME_OUTER_WINDOW (f) : wdest; - memset (event.xclient.data.b, 0, sizeof (event.xclient.data.b)); - x_fill_property_data (dpyinfo->display, values, event.xclient.data.b, - event.xclient.format); + + if (event.xclient.format == 32 && event.xclient.format < BITS_PER_LONG) + { + /* x_fill_property_data expects data to hold 32 bit values when + format == 32, but on a 64 bit machine long is 64 bits. + event.xclient.l is an array of long, so we must compensate. */ + memset (idata, 0, sizeof (idata)); + data = idata; + } + else + { + memset (event.xclient.data.b, 0, sizeof (event.xclient.data.b)); + data = event.xclient.data.b; + } + + x_fill_property_data (dpyinfo->display, values, data, event.xclient.format); + + if (data == idata) + { + int i; + for (i = 0; i < 5; ++i) /* There are only 5 longs in a ClientMessage. */ + event.xclient.data.l[i] = (long) idata[i]; + } + /* If event mask is 0 the event is sent to the client that created the destination window. But if we are sending to the root window, there is no such client. Then we set the event mask to 0xffff. The -- 2.39.2