remove Features5, rework gradient plugin, fix paste_edl track title bug, gl_probe...
[goodguy/cinelerra.git] / cinelerra-5.1 / 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
34 enum {
35         CLIP_PRIMARY,           // XA_PRIMARY
36         CLIP_CLIPBOARD,         // Atom(CLIPBOARD)
37         CLIP_BUFFER0,           // XA_CUT_BUFFER0
38         CLIP_BUFFERS = CLIP_BUFFER0, // CUT_BUFFER api does not need storage
39 };
40 // loads CUT_BUFFER0 if window is closed while selection set
41
42 // The primary selection is filled by highlighting a region
43 #define PRIMARY_SELECTION CLIP_PRIMARY
44
45 // The secondary selection is filled by copying (textbox Ctrl-C)
46 #define SECONDARY_SELECTION CLIP_CLIPBOARD
47
48 // Storage for guicast only
49 #define BC_PRIMARY_SELECTION (CLIP_BUFFER0+2)
50
51 // The secondary selection has never been reliable either in Cinelerra
52 // or anything else.  We just use the CUT_BUFFER2 solution for any data
53 // not intended for use outside Cinelerra.
54
55 class BC_Clipboard : public Thread
56 {
57 public:
58         BC_Clipboard(BC_WindowBase *window);
59         ~BC_Clipboard();
60
61         int start_clipboard();
62         void run();
63         int stop_clipboard();
64         int to_clipboard(BC_WindowBase *owner, const char *data, long len, int clipboard_num);
65         long from_clipboard(char *data, long maxlen, int clipboard_num);
66         long clipboard_len(int clipboard_num);
67
68 private:
69         long from_clipboard(int clipboard_num, char *&bfr, long maxlen);
70         void handle_selectionrequest(XSelectionRequestEvent *request);
71         int handle_request_string(XSelectionRequestEvent *request);
72         int handle_request_targets(XSelectionRequestEvent *request);
73
74         BC_WindowBase *window;
75         Display *in_display, *out_display;
76         Window in_win, out_win;
77         Atom xa_primary, clipboard, targets;
78         Atom completion_atom, string_type;
79
80         char *data_buffer[CLIP_BUFFERS];
81         int data_length[CLIP_BUFFERS];
82 };
83
84 #endif