aboutsummaryrefslogtreecommitdiffstats
path: root/src/xselect.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xselect.c')
-rw-r--r--src/xselect.c76
1 files changed, 39 insertions, 37 deletions
diff --git a/src/xselect.c b/src/xselect.c
index 430b7232659..4f1a452023a 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -499,22 +499,23 @@ x_get_local_selection (Lisp_Object selection_symbol, Lisp_Object target_type, in
499static void 499static void
500x_decline_selection_request (struct input_event *event) 500x_decline_selection_request (struct input_event *event)
501{ 501{
502 XSelectionEvent reply; 502 XEvent reply_base;
503 XSelectionEvent *reply = &(reply_base.xselection);
503 504
504 reply.type = SelectionNotify; 505 reply->type = SelectionNotify;
505 reply.display = SELECTION_EVENT_DISPLAY (event); 506 reply->display = SELECTION_EVENT_DISPLAY (event);
506 reply.requestor = SELECTION_EVENT_REQUESTOR (event); 507 reply->requestor = SELECTION_EVENT_REQUESTOR (event);
507 reply.selection = SELECTION_EVENT_SELECTION (event); 508 reply->selection = SELECTION_EVENT_SELECTION (event);
508 reply.time = SELECTION_EVENT_TIME (event); 509 reply->time = SELECTION_EVENT_TIME (event);
509 reply.target = SELECTION_EVENT_TARGET (event); 510 reply->target = SELECTION_EVENT_TARGET (event);
510 reply.property = None; 511 reply->property = None;
511 512
512 /* The reason for the error may be that the receiver has 513 /* The reason for the error may be that the receiver has
513 died in the meantime. Handle that case. */ 514 died in the meantime. Handle that case. */
514 BLOCK_INPUT; 515 BLOCK_INPUT;
515 x_catch_errors (reply.display); 516 x_catch_errors (reply->display);
516 XSendEvent (reply.display, reply.requestor, False, 0L, (XEvent *) &reply); 517 XSendEvent (reply->display, reply->requestor, False, 0L, &reply_base);
517 XFlush (reply.display); 518 XFlush (reply->display);
518 x_uncatch_errors (); 519 x_uncatch_errors ();
519 UNBLOCK_INPUT; 520 UNBLOCK_INPUT;
520} 521}
@@ -617,7 +618,8 @@ static int x_reply_selection_request_cnt;
617static void 618static void
618x_reply_selection_request (struct input_event *event, int format, unsigned char *data, int size, Atom type) 619x_reply_selection_request (struct input_event *event, int format, unsigned char *data, int size, Atom type)
619{ 620{
620 XSelectionEvent reply; 621 XEvent reply_base;
622 XSelectionEvent *reply = &(reply_base.xselection);
621 Display *display = SELECTION_EVENT_DISPLAY (event); 623 Display *display = SELECTION_EVENT_DISPLAY (event);
622 Window window = SELECTION_EVENT_REQUESTOR (event); 624 Window window = SELECTION_EVENT_REQUESTOR (event);
623 int bytes_remaining; 625 int bytes_remaining;
@@ -629,15 +631,15 @@ x_reply_selection_request (struct input_event *event, int format, unsigned char
629 if (max_bytes > MAX_SELECTION_QUANTUM) 631 if (max_bytes > MAX_SELECTION_QUANTUM)
630 max_bytes = MAX_SELECTION_QUANTUM; 632 max_bytes = MAX_SELECTION_QUANTUM;
631 633
632 reply.type = SelectionNotify; 634 reply->type = SelectionNotify;
633 reply.display = display; 635 reply->display = display;
634 reply.requestor = window; 636 reply->requestor = window;
635 reply.selection = SELECTION_EVENT_SELECTION (event); 637 reply->selection = SELECTION_EVENT_SELECTION (event);
636 reply.time = SELECTION_EVENT_TIME (event); 638 reply->time = SELECTION_EVENT_TIME (event);
637 reply.target = SELECTION_EVENT_TARGET (event); 639 reply->target = SELECTION_EVENT_TARGET (event);
638 reply.property = SELECTION_EVENT_PROPERTY (event); 640 reply->property = SELECTION_EVENT_PROPERTY (event);
639 if (reply.property == None) 641 if (reply->property == None)
640 reply.property = reply.target; 642 reply->property = reply->target;
641 643
642 BLOCK_INPUT; 644 BLOCK_INPUT;
643 /* The protected block contains wait_for_property_change, which can 645 /* The protected block contains wait_for_property_change, which can
@@ -648,8 +650,8 @@ x_reply_selection_request (struct input_event *event, int format, unsigned char
648 650
649#ifdef TRACE_SELECTION 651#ifdef TRACE_SELECTION
650 { 652 {
651 char *sel = XGetAtomName (display, reply.selection); 653 char *sel = XGetAtomName (display, reply->selection);
652 char *tgt = XGetAtomName (display, reply.target); 654 char *tgt = XGetAtomName (display, reply->target);
653 TRACE3 ("%s, target %s (%d)", sel, tgt, ++x_reply_selection_request_cnt); 655 TRACE3 ("%s, target %s (%d)", sel, tgt, ++x_reply_selection_request_cnt);
654 if (sel) XFree (sel); 656 if (sel) XFree (sel);
655 if (tgt) XFree (tgt); 657 if (tgt) XFree (tgt);
@@ -664,10 +666,10 @@ x_reply_selection_request (struct input_event *event, int format, unsigned char
664 { 666 {
665 /* Send all the data at once, with minimal handshaking. */ 667 /* Send all the data at once, with minimal handshaking. */
666 TRACE1 ("Sending all %d bytes", bytes_remaining); 668 TRACE1 ("Sending all %d bytes", bytes_remaining);
667 XChangeProperty (display, window, reply.property, type, format, 669 XChangeProperty (display, window, reply->property, type, format,
668 PropModeReplace, data, size); 670 PropModeReplace, data, size);
669 /* At this point, the selection was successfully stored; ack it. */ 671 /* At this point, the selection was successfully stored; ack it. */
670 XSendEvent (display, window, False, 0L, (XEvent *) &reply); 672 XSendEvent (display, window, False, 0L, &reply_base);
671 } 673 }
672 else 674 else
673 { 675 {
@@ -693,19 +695,19 @@ x_reply_selection_request (struct input_event *event, int format, unsigned char
693 error ("Attempt to transfer an INCR to ourself!"); 695 error ("Attempt to transfer an INCR to ourself!");
694 696
695 TRACE2 ("Start sending %d bytes incrementally (%s)", 697 TRACE2 ("Start sending %d bytes incrementally (%s)",
696 bytes_remaining, XGetAtomName (display, reply.property)); 698 bytes_remaining, XGetAtomName (display, reply->property));
697 wait_object = expect_property_change (display, window, reply.property, 699 wait_object = expect_property_change (display, window, reply->property,
698 PropertyDelete); 700 PropertyDelete);
699 701
700 TRACE1 ("Set %s to number of bytes to send", 702 TRACE1 ("Set %s to number of bytes to send",
701 XGetAtomName (display, reply.property)); 703 XGetAtomName (display, reply->property));
702 { 704 {
703 /* XChangeProperty expects an array of long even if long is more than 705 /* XChangeProperty expects an array of long even if long is more than
704 32 bits. */ 706 32 bits. */
705 long value[1]; 707 long value[1];
706 708
707 value[0] = bytes_remaining; 709 value[0] = bytes_remaining;
708 XChangeProperty (display, window, reply.property, dpyinfo->Xatom_INCR, 710 XChangeProperty (display, window, reply->property, dpyinfo->Xatom_INCR,
709 32, PropModeReplace, 711 32, PropModeReplace,
710 (unsigned char *) value, 1); 712 (unsigned char *) value, 1);
711 } 713 }
@@ -714,7 +716,7 @@ x_reply_selection_request (struct input_event *event, int format, unsigned char
714 716
715 /* Tell 'em the INCR data is there... */ 717 /* Tell 'em the INCR data is there... */
716 TRACE0 ("Send SelectionNotify event"); 718 TRACE0 ("Send SelectionNotify event");
717 XSendEvent (display, window, False, 0L, (XEvent *) &reply); 719 XSendEvent (display, window, False, 0L, &reply_base);
718 XFlush (display); 720 XFlush (display);
719 721
720 had_errors = x_had_errors_p (display); 722 had_errors = x_had_errors_p (display);
@@ -725,7 +727,7 @@ x_reply_selection_request (struct input_event *event, int format, unsigned char
725 if (! had_errors) 727 if (! had_errors)
726 { 728 {
727 TRACE1 ("Waiting for ACK (deletion of %s)", 729 TRACE1 ("Waiting for ACK (deletion of %s)",
728 XGetAtomName (display, reply.property)); 730 XGetAtomName (display, reply->property));
729 wait_for_property_change (wait_object); 731 wait_for_property_change (wait_object);
730 } 732 }
731 else 733 else
@@ -741,15 +743,15 @@ x_reply_selection_request (struct input_event *event, int format, unsigned char
741 BLOCK_INPUT; 743 BLOCK_INPUT;
742 744
743 wait_object 745 wait_object
744 = expect_property_change (display, window, reply.property, 746 = expect_property_change (display, window, reply->property,
745 PropertyDelete); 747 PropertyDelete);
746 748
747 TRACE1 ("Sending increment of %d elements", i); 749 TRACE1 ("Sending increment of %d elements", i);
748 TRACE1 ("Set %s to increment data", 750 TRACE1 ("Set %s to increment data",
749 XGetAtomName (display, reply.property)); 751 XGetAtomName (display, reply->property));
750 752
751 /* Append the next chunk of data to the property. */ 753 /* Append the next chunk of data to the property. */
752 XChangeProperty (display, window, reply.property, type, format, 754 XChangeProperty (display, window, reply->property, type, format,
753 PropModeAppend, data, i); 755 PropModeAppend, data, i);
754 bytes_remaining -= i * format_bytes; 756 bytes_remaining -= i * format_bytes;
755 if (format == 32) 757 if (format == 32)
@@ -766,7 +768,7 @@ x_reply_selection_request (struct input_event *event, int format, unsigned char
766 /* Now wait for the requester to ack this chunk by deleting the 768 /* Now wait for the requester to ack this chunk by deleting the
767 property. This can run random lisp code or signal. */ 769 property. This can run random lisp code or signal. */
768 TRACE1 ("Waiting for increment ACK (deletion of %s)", 770 TRACE1 ("Waiting for increment ACK (deletion of %s)",
769 XGetAtomName (display, reply.property)); 771 XGetAtomName (display, reply->property));
770 wait_for_property_change (wait_object); 772 wait_for_property_change (wait_object);
771 } 773 }
772 774
@@ -777,8 +779,8 @@ x_reply_selection_request (struct input_event *event, int format, unsigned char
777 XSelectInput (display, window, 0L); 779 XSelectInput (display, window, 0L);
778 780
779 TRACE1 ("Set %s to a 0-length chunk to indicate EOF", 781 TRACE1 ("Set %s to a 0-length chunk to indicate EOF",
780 XGetAtomName (display, reply.property)); 782 XGetAtomName (display, reply->property));
781 XChangeProperty (display, window, reply.property, type, format, 783 XChangeProperty (display, window, reply->property, type, format,
782 PropModeReplace, data, 0); 784 PropModeReplace, data, 0);
783 TRACE0 ("Done sending incrementally"); 785 TRACE0 ("Done sending incrementally");
784 } 786 }