Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 37733
Collapse All | Expand All

(-)aterm-0.4.2/src/screen.c (-17 / +76 lines)
Lines 2751-2780 Link Here
2751
/*
2751
/*
2752
 * Respond to a notification that a primary selection has been sent
2752
 * Respond to a notification that a primary selection has been sent
2753
 * EXT: SelectionNotify
2753
 * EXT: SelectionNotify
2754
 *
2755
 * INCR paste (large data) support added by Mina Naguib <webmaster@topfx.com January 15th, 2003
2756
 * INCR DOCUMENTATION IN ICCM: http://tronche.com/gui/x/icccm/sec-2.html#s-2.7.2
2757
 *
2754
 */
2758
 */
2755
/* PROTO */
2759
/* PROTO */
2756
void
2760
void
2757
selection_paste(Window win, unsigned prop, int Delete)
2761
selection_paste(Window win, unsigned prop, int Delete)
2758
{
2762
{
2759
    long            nread;
2763
	long            nread;
2760
    unsigned long   bytes_after, nitems;
2764
	unsigned long   bytes_after, nitems;
2761
    unsigned char  *data;
2765
	unsigned char  *data;
2762
    Atom            actual_type;
2766
	Atom            actual_type;
2763
    int             actual_fmt;
2767
	int             actual_fmt;
2764
2768
2765
    if (prop == None)
2769
	XEvent			ev;
2766
	return;
2770
	XWindowAttributes wa;
2767
    for (nread = 0, bytes_after = 1; bytes_after > 0; nread += nitems) {
2771
	int setpropertyevent = 0;
2768
	if ((XGetWindowProperty(Xdisplay, win, prop, (nread / 4), PROP_SIZE,
2772
2769
				Delete, AnyPropertyType, &actual_type,
2773
	if (prop == None)
2770
				&actual_fmt, &nitems, &bytes_after,
2774
		return;
2771
				&data) != Success)) {
2775
2772
	    XFree(data);
2776
	for (nread = 0, bytes_after = 1; bytes_after > 0; nread += nitems) {
2773
	    return;
2777
		if ((XGetWindowProperty(Xdisplay, win, prop, (nread / 4), PROP_SIZE,
2778
			False, AnyPropertyType, &actual_type,
2779
			&actual_fmt, &nitems, &bytes_after,
2780
			&data) != Success)) {
2781
			XFree(data);
2782
			return;
2783
		}
2784
2785
		if (actual_type == XInternAtom(Xdisplay, "INCR", False)) {
2786
			/*
2787
			* This is an INCR (incremental large) paste
2788
			*/
2789
			XGetWindowAttributes(Xdisplay, win, &wa);
2790
			if ((wa.your_event_mask | PropertyChangeMask) != wa.your_event_mask) {
2791
				/* We need to register the PropertyNotify event */
2792
				XSelectInput(Xdisplay, win, (wa.your_event_mask | PropertyChangeMask) );
2793
				setpropertyevent = 1;
2794
			}
2795
			XDeleteProperty(Xdisplay, win, prop);
2796
			while (1) {
2797
				XWindowEvent(Xdisplay, win, PropertyChangeMask, &ev);
2798
/*				if (ev.type != PropertyNotify || ev.xproperty.state != PropertyNewValue) */
2799
				if (ev.xproperty.state != PropertyNewValue)
2800
					continue;
2801
				if ((XGetWindowProperty(Xdisplay, win, prop, 0, PROP_SIZE,
2802
						True,AnyPropertyType, &actual_type,
2803
						&actual_fmt, &nitems, &bytes_after,
2804
						&data) != Success)) {
2805
					XFree(data);
2806
					/* error */
2807
					break;
2808
				}
2809
				if (nitems == 0) {
2810
					/* end of INCR transfer */
2811
					XFree(data);
2812
					break;
2813
				}
2814
				else {
2815
					PasteIt(data, nitems);
2816
					XFree(data);
2817
				}
2818
			}
2819
			if (setpropertyevent == 1) {
2820
				/* We need to unregister the PropertyNotify event */
2821
				XGetWindowAttributes(Xdisplay, win, &wa);
2822
				XSelectInput(Xdisplay, win, (wa.your_event_mask ^ PropertyChangeMask));
2823
				setpropertyevent = 0;
2824
			}
2825
		}
2826
		else {
2827
			/*
2828
			* This is a normal 1-time paste
2829
			*/
2830
			if (Delete) {
2831
				XDeleteProperty(Xdisplay, win, prop);
2832
			}
2833
			PasteIt(data, nitems);
2834
			XFree(data);
2835
		}
2774
	}
2836
	}
2775
	PasteIt(data, nitems);
2776
	XFree(data);
2777
    }
2778
}
2837
}
2779
2838
2780
/* ------------------------------------------------------------------------- */
2839
/* ------------------------------------------------------------------------- */

Return to bug 37733