File: appXvCopyPaste.c

package info (click to toggle)
ted 2.6-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 7,928 kB
  • ctags: 8,734
  • sloc: ansic: 71,878; makefile: 2,363; sh: 159
file content (88 lines) | stat: -rw-r--r-- 2,033 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/************************************************************************/
/*  Scan, main module.							*/
/************************************************************************/

#   include	"config.h"

#   include	<stddef.h>
#   include	<stdio.h>
#   include	<stdlib.h>

#   include	<X11/Xlib.h>

#   include	<sioXprop.h>
#   include	<appImage.h>

#   include	<debugon.h>

/********************************************************************************/
/*										*/
/*  get the image from the clipboard that 'xv' simulates on the root window.	*/
/*										*/
/********************************************************************************/

static Atom	XA_XV_CLIPBOARD= None;

int appImgGetXvClipboard(	BitmapDescription *	bd,
				unsigned char **	pBuffer,
				Display *		display,
				int			screen )
    {
    Window		root= XRootWindow( display, screen );

    SimpleInputStream *	sis;

    int			done;

    if  ( XA_XV_CLIPBOARD == None )
	{
	XA_XV_CLIPBOARD= XInternAtom( display, "XV_CLIPBOARD", False );
	if  ( XA_XV_CLIPBOARD == None )
	    { XDEB(XA_XV_CLIPBOARD); return -1;	}
	}

    sis= sioInXpropOpen( display, root, XA_XV_CLIPBOARD );
    if  ( ! sis )
	{ XDEB(sis); return -1;	}

    done= bmXvReadPaste( bd, pBuffer, sis );

    sioInClose( sis );

    if  ( done < 0 )
	{ LDEB(done); return -1;	}

    return 0;
    }

int appImgPutXvClipboard(	const BitmapDescription *	bd,
				const unsigned char *		buffer,
				Display *			display,
				int				screen )
    {
    Window			root= XRootWindow( display, screen );

    SimpleOutputStream *	sos;

    int				done;

    if  ( XA_XV_CLIPBOARD == None )
	{
	XA_XV_CLIPBOARD= XInternAtom( display, "XV_CLIPBOARD", False );
	if  ( XA_XV_CLIPBOARD == None )
	    { XDEB(XA_XV_CLIPBOARD); return -1;	}
	}

    sos= sioOutXpropOpen( display, root, XA_XV_CLIPBOARD, XA_STRING );
    if  ( ! sos )
	{ XDEB(sos); return -1;	}

    done= bmXvWritePaste( bd, buffer, sos );

    sioOutClose( sos );

    if  ( done < 0 )
	{ LDEB(done); return -1;	}

    return 0;
    }