4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
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.
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.
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
25 #include "bcwindowbase.inc"
30 #include <X11/Xatom.h>
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
40 // loads CUT_BUFFER0 if window is closed while selection set
42 // The primary selection is filled by highlighting a region
43 #define PRIMARY_SELECTION CLIP_PRIMARY
45 // The secondary selection is filled by copying (textbox Ctrl-C)
46 #define SECONDARY_SELECTION CLIP_CLIPBOARD
48 // Storage for guicast only
49 #define BC_PRIMARY_SELECTION (CLIP_BUFFER0+2)
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.
55 class BC_Clipboard : public Thread
58 BC_Clipboard(BC_WindowBase *window);
61 int start_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);
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);
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;
80 char *data_buffer[CLIP_BUFFERS];
81 int data_length[CLIP_BUFFERS];