xref: /OK3568_Linux_fs/external/xserver/hw/xquartz/pbproxy/x-selection.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* x-selection.h -- proxies between NSPasteboard and X11 selections
2  *
3  * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person
6  * obtaining a copy of this software and associated documentation files
7  * (the "Software"), to deal in the Software without restriction,
8  * including without limitation the rights to use, copy, modify, merge,
9  * publish, distribute, sublicense, and/or sell copies of the Software,
10  * and to permit persons to whom the Software is furnished to do so,
11  * subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT.  IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
20  * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23  * DEALINGS IN THE SOFTWARE.
24  *
25  * Except as contained in this notice, the name(s) of the above
26  * copyright holders shall not be used in advertising or otherwise to
27  * promote the sale, use or other dealings in this Software without
28  * prior written authorization.
29  */
30 
31 #ifndef X_SELECTION_H
32 #define X_SELECTION_H 1
33 
34 #include "pbproxy.h"
35 
36 #define  Cursor X_Cursor
37 #include <X11/extensions/Xfixes.h>
38 #undef Cursor
39 
40 #include <AppKit/NSPasteboard.h>
41 
42 /* This stores image data or text. */
43 struct propdata {
44     unsigned char *data;
45     size_t length;
46     int format;
47 };
48 
49 struct atom_list {
50     Atom primary, clipboard, text, utf8_string, string, targets, multiple,
51          cstring, image_png, image_jpeg, incr, atom, clipboard_manager,
52          compound_text, atom_pair;
53 };
54 
55 @interface x_selection : NSObject
56 {
57     @private
58 
59     /* The unmapped window we use for fetching selections. */
60     Window _selection_window;
61 
62     Atom request_atom;
63 
64     struct {
65         struct propdata propdata;
66         Window requestor;
67         Atom selection;
68     } pending;
69 
70     /*
71      * This is the number of times the user has requested a copy.
72      * Once the copy is completed, we --pending_copy, and if the
73      * pending_copy is > 0 we do it again.
74      */
75     int pending_copy;
76     /*
77      * This is used for the same purpose as pending_copy, but for the
78      * CLIPBOARD.  It also prevents a race with INCR transfers.
79      */
80     int pending_clipboard;
81 
82     struct atom_list atoms[1];
83 }
84 
85 - (void)x_active:(Time)timestamp;
86 - (void)x_inactive:(Time)timestamp;
87 
88 - (void)x_copy:(Time)timestamp;
89 
90 - (void)clear_event:(XSelectionClearEvent *)e;
91 - (void)request_event:(XSelectionRequestEvent *)e;
92 - (void)notify_event:(XSelectionEvent *)e;
93 - (void)property_event:(XPropertyEvent *)e;
94 - (void)xfixes_selection_notify:(XFixesSelectionNotifyEvent *)e;
95 - (void)handle_selection:(Atom) selection type:(Atom) type propdata:(struct
96                                                                      propdata
97                                                                      *)pdata;
98 - (void)claim_clipboard;
99 - (BOOL)set_clipboard_manager_status:(BOOL)value;
100 - (void)own_clipboard;
101 - (void)copy_completed:(Atom)selection;
102 
103 - (void)reload_preferences;
104 - (BOOL)is_active;
105 - (void)send_none:(XSelectionRequestEvent *)e;
106 @end
107 
108 /* main.m */
109 extern x_selection * _selection_object;
110 
111 #endif /* X_SELECTION_H */
112