2 * cutpaste.c - routines to deal with cut & paste buffers / selection.
6 * Copyright (C) 2002 RealVNC Ltd.
7 * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
9 * This is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This software is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this software; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
30 #include "selection.h"
35 extern WindowPtr *WindowTable; /* Why isn't this in a header file? */
36 extern Selection *CurrentSelections;
37 extern int NumCurrentSelections;
40 static Bool inSetXCutText = FALSE;
43 * rfbSetXCutText sets the cut buffer to be the given string. We also clear
44 * the primary selection. Ideally we'd like to set it to the same thing, but I
45 * can't work out how to do that without some kind of helper X client.
49 rfbSetXCutText(char *str, int len)
54 ChangeWindowProperty(WindowTable[0], XA_CUT_BUFFER0, XA_STRING,
55 8, PropModeReplace, len,
58 while ((i < NumCurrentSelections) &&
59 CurrentSelections[i].selection != XA_PRIMARY)
62 if (i < NumCurrentSelections) {
65 if (CurrentSelections[i].client) {
66 event.u.u.type = SelectionClear;
67 event.u.selectionClear.time = GetTimeInMillis();
68 event.u.selectionClear.window = CurrentSelections[i].window;
69 event.u.selectionClear.atom = CurrentSelections[i].selection;
70 (void) TryClientEvents (CurrentSelections[i].client, &event, 1,
71 NoEventMask, NoEventMask /* CantBeFiltered */,
75 CurrentSelections[i].window = None;
76 CurrentSelections[i].pWin = NULL;
77 CurrentSelections[i].client = NullClient;
80 inSetXCutText = FALSE;
84 void rfbGotXCutText(char *str, int len)
87 rfbSendServerCutText(str, len);