initial commit
[goodguy/history.git] / cinelerra-5.0 / guicast / bcclipboard.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  */
21
22 #ifndef BCCLIPBOARD_H
23 #define BCCLIPBOARD_H
24
25 #include "bcwindowbase.inc"
26 #include "thread.h"
27
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <X11/Xatom.h>
31 #include <X11/Xlib.h>
32
33 // The primary selection is filled by highlighting a region
34 #define PRIMARY_SELECTION 0
35 // The secondary selection is filled by copying
36 #define SECONDARY_SELECTION 1
37
38
39 // Storage for guicast only
40 // The secondary selection has never been reliable either in Cinelerra
41 // or anything else.  We just use the guaranteed solution for any data not
42 // intended for use outside Cinelerra.
43 #define BC_PRIMARY_SELECTION 2
44
45
46
47 class BC_Clipboard : public Thread
48 {
49 public:
50         BC_Clipboard(const char *display_name);
51         ~BC_Clipboard();
52
53         int start_clipboard();
54         void run();
55         int stop_clipboard();
56         long clipboard_len(int clipboard_num);
57         int to_clipboard(const char *data, long len, int clipboard_num);
58         int from_clipboard(char *data, long maxlen, int clipboard_num);
59
60 private:
61         void handle_selectionrequest(XSelectionRequestEvent *request);
62         int handle_request_string(XSelectionRequestEvent *request);
63         int handle_request_targets(XSelectionRequestEvent *request);
64
65         Display *in_display, *out_display;
66         Atom completion_atom, primary, secondary;
67         Atom targets_atom;
68         Atom strtype_atom;
69         Window in_win, out_win;
70         char *data[2];
71         long length[2];
72         char display_name[BCTEXTLEN];
73 };
74
75 #endif