14642e01fSmrg/* x-selection.h -- proxies between NSPasteboard and X11 selections
235c4bbdfSmrg *
335c4bbdfSmrg * Copyright (c) 2002-2012 Apple Inc. All rights reserved.
435c4bbdfSmrg *
535c4bbdfSmrg * Permission is hereby granted, free of charge, to any person
635c4bbdfSmrg * obtaining a copy of this software and associated documentation files
735c4bbdfSmrg * (the "Software"), to deal in the Software without restriction,
835c4bbdfSmrg * including without limitation the rights to use, copy, modify, merge,
935c4bbdfSmrg * publish, distribute, sublicense, and/or sell copies of the Software,
1035c4bbdfSmrg * and to permit persons to whom the Software is furnished to do so,
1135c4bbdfSmrg * subject to the following conditions:
1235c4bbdfSmrg *
1335c4bbdfSmrg * The above copyright notice and this permission notice shall be
1435c4bbdfSmrg * included in all copies or substantial portions of the Software.
1535c4bbdfSmrg *
1635c4bbdfSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1735c4bbdfSmrg * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1835c4bbdfSmrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1935c4bbdfSmrg * NONINFRINGEMENT.  IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
2035c4bbdfSmrg * HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
2135c4bbdfSmrg * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2235c4bbdfSmrg * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2335c4bbdfSmrg * DEALINGS IN THE SOFTWARE.
2435c4bbdfSmrg *
2535c4bbdfSmrg * Except as contained in this notice, the name(s) of the above
2635c4bbdfSmrg * copyright holders shall not be used in advertising or otherwise to
2735c4bbdfSmrg * promote the sale, use or other dealings in this Software without
2835c4bbdfSmrg * prior written authorization.
2935c4bbdfSmrg */
304642e01fSmrg
314642e01fSmrg#ifndef X_SELECTION_H
324642e01fSmrg#define X_SELECTION_H 1
334642e01fSmrg
344642e01fSmrg#include "pbproxy.h"
354642e01fSmrg
368223e2f2Smrg#define  Cursor X_Cursor
374642e01fSmrg#include <X11/extensions/Xfixes.h>
388223e2f2Smrg#undef Cursor
394642e01fSmrg
404642e01fSmrg#include <AppKit/NSPasteboard.h>
414642e01fSmrg
424642e01fSmrg/* This stores image data or text. */
434642e01fSmrgstruct propdata {
4435c4bbdfSmrg    unsigned char *data;
4535c4bbdfSmrg    size_t length;
4635c4bbdfSmrg    int format;
474642e01fSmrg};
484642e01fSmrg
494642e01fSmrgstruct atom_list {
504642e01fSmrg    Atom primary, clipboard, text, utf8_string, string, targets, multiple,
5135c4bbdfSmrg         cstring, image_png, image_jpeg, incr, atom, clipboard_manager,
5235c4bbdfSmrg         compound_text, atom_pair;
534642e01fSmrg};
544642e01fSmrg
554642e01fSmrg@interface x_selection : NSObject
564642e01fSmrg{
5735c4bbdfSmrg    @private
584642e01fSmrg
594642e01fSmrg    /* The unmapped window we use for fetching selections. */
604642e01fSmrg    Window _selection_window;
614642e01fSmrg
624642e01fSmrg    Atom request_atom;
6335c4bbdfSmrg
644642e01fSmrg    struct {
654642e01fSmrg        struct propdata propdata;
664642e01fSmrg        Window requestor;
674642e01fSmrg        Atom selection;
684642e01fSmrg    } pending;
694642e01fSmrg
7035c4bbdfSmrg    /*
714642e01fSmrg     * This is the number of times the user has requested a copy.
7235c4bbdfSmrg     * Once the copy is completed, we --pending_copy, and if the
734642e01fSmrg     * pending_copy is > 0 we do it again.
744642e01fSmrg     */
754642e01fSmrg    int pending_copy;
7635c4bbdfSmrg    /*
7735c4bbdfSmrg     * This is used for the same purpose as pending_copy, but for the
784642e01fSmrg     * CLIPBOARD.  It also prevents a race with INCR transfers.
794642e01fSmrg     */
8035c4bbdfSmrg    int pending_clipboard;
8135c4bbdfSmrg
824642e01fSmrg    struct atom_list atoms[1];
834642e01fSmrg}
844642e01fSmrg
8535c4bbdfSmrg- (void)x_active:(Time)timestamp;
8635c4bbdfSmrg- (void)x_inactive:(Time)timestamp;
8735c4bbdfSmrg
8835c4bbdfSmrg- (void)x_copy:(Time)timestamp;
8935c4bbdfSmrg
9035c4bbdfSmrg- (void)clear_event:(XSelectionClearEvent *)e;
9135c4bbdfSmrg- (void)request_event:(XSelectionRequestEvent *)e;
9235c4bbdfSmrg- (void)notify_event:(XSelectionEvent *)e;
9335c4bbdfSmrg- (void)property_event:(XPropertyEvent *)e;
9435c4bbdfSmrg- (void)xfixes_selection_notify:(XFixesSelectionNotifyEvent *)e;
9535c4bbdfSmrg- (void)handle_selection:(Atom) selection type:(Atom) type propdata:(struct
9635c4bbdfSmrg                                                                     propdata
9735c4bbdfSmrg                                                                     *)pdata;
9835c4bbdfSmrg- (void)claim_clipboard;
9935c4bbdfSmrg- (BOOL)set_clipboard_manager_status:(BOOL)value;
10035c4bbdfSmrg- (void)own_clipboard;
10135c4bbdfSmrg- (void)copy_completed:(Atom)selection;
10235c4bbdfSmrg
10335c4bbdfSmrg- (void)reload_preferences;
10435c4bbdfSmrg- (BOOL)is_active;
10535c4bbdfSmrg- (void)send_none:(XSelectionRequestEvent *)e;
1064642e01fSmrg@end
1074642e01fSmrg
1084642e01fSmrg/* main.m */
10935c4bbdfSmrgextern x_selection * _selection_object;
1104642e01fSmrg
1114642e01fSmrg#endif /* X_SELECTION_H */
112