x-selection.h revision 8223e2f2
1/* x-selection.h -- proxies between NSPasteboard and X11 selections 2 3 Copyright (c) 2002, 2008 Apple Computer, 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. */ 43struct propdata { 44 unsigned char *data; 45 size_t length; 46 int format; 47}; 48 49struct 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 56@interface x_selection : NSObject 57{ 58@private 59 60 /* The unmapped window we use for fetching selections. */ 61 Window _selection_window; 62 63 Atom request_atom; 64 65 struct { 66 struct propdata propdata; 67 Window requestor; 68 Atom selection; 69 } pending; 70 71 /* 72 * This is the number of times the user has requested a copy. 73 * Once the copy is completed, we --pending_copy, and if the 74 * pending_copy is > 0 we do it again. 75 */ 76 int pending_copy; 77 /* 78 * This is used for the same purpose as pending_copy, but for the 79 * CLIPBOARD. It also prevents a race with INCR transfers. 80 */ 81 int pending_clipboard; 82 83 struct atom_list atoms[1]; 84} 85 86- (void) x_active:(Time)timestamp; 87- (void) x_inactive:(Time)timestamp; 88 89- (void) x_copy:(Time)timestamp; 90 91- (void) clear_event:(XSelectionClearEvent *)e; 92- (void) request_event:(XSelectionRequestEvent *)e; 93- (void) notify_event:(XSelectionEvent *)e; 94- (void) property_event:(XPropertyEvent *)e; 95- (void) xfixes_selection_notify:(XFixesSelectionNotifyEvent *)e; 96- (void) handle_selection:(Atom)selection type:(Atom)type propdata:(struct propdata *)pdata; 97- (void) claim_clipboard; 98- (BOOL) set_clipboard_manager_status:(BOOL)value; 99- (void) own_clipboard; 100- (void) copy_completed:(Atom)selection; 101 102- (void) reload_preferences; 103- (BOOL) is_active; 104- (void) send_none:(XSelectionRequestEvent *)e; 105@end 106 107/* main.m */ 108extern x_selection *_selection_object; 109 110#endif /* X_SELECTION_H */ 111