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