# HG changeset patch # User Jan Dj¸«£rv # Date 1107621698 0 # Node ID f5f2fbf049bc03f8bedf50c7c88eae351887065f # Parent 21898b7a92fd42f180b2c937240b07eb9e487a2a * xselect.c (Fx_send_client_event, x_handle_dnd_message): Handle the longs in a XClientMessageEvent correctly when long is 64 bits. diff -r 21898b7a92fd -r f5f2fbf049bc src/ChangeLog --- a/src/ChangeLog Sat Feb 05 13:46:26 2005 +0000 +++ b/src/ChangeLog Sat Feb 05 16:41:38 2005 +0000 @@ -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 -r 21898b7a92fd -r f5f2fbf049bc src/xselect.c --- a/src/xselect.c Sat Feb 05 13:46:26 2005 +0000 +++ b/src/xselect.c Sat Feb 05 16:41:38 2005 +0000 @@ -2536,7 +2536,7 @@ 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 @@ 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 @@ 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 @@ 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