1
1
/* selection.c -- selection handling (only retrieving)
2
$Id: selection.c 4301 2008-11-19 20:45:08Z chrisb $
4
4
Copyright (C) 2000 John Harper <john@dcs.warwick.ac.uk>
6
6
Originally adapted from the Jade sources by Mark Probst.
8
This file is part of sawmill.
8
This file is part of sawfish.
10
sawmill is free software; you can redistribute it and/or modify it
10
sawfish is free software; you can redistribute it and/or modify it
11
11
under the terms of the GNU General Public License as published by
12
12
the Free Software Foundation; either version 2, or (at your option)
15
sawmill is distributed in the hope that it will be useful, but
15
sawfish is distributed in the hope that it will be useful, but
16
16
WITHOUT ANY WARRANTY; without even the implied warranty of
17
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
18
GNU General Public License for more details.
20
20
You should have received a copy of the GNU General Public License
21
along with sawmill; see the file COPYING. If not, write to
21
along with sawfish; see the file COPYING. If not, write to
22
22
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
25
25
#include <string.h>
26
26
#include <X11/Xatom.h>
28
28
/* selection functions */
30
static Atom sawmill_selection;
30
static Atom sawfish_selection;
33
33
symbol_to_atom (repv sym)
79
79
Window sel_window = no_focus_window;
80
80
XConvertSelection (dpy, selection, XA_STRING,
81
sawmill_selection, sel_window, last_event_time);
81
sawfish_selection, sel_window, last_event_time);
82
82
XIfEvent (dpy, &ev, selnotify_pred, (XPointer) 0);
83
83
if (ev.xselection.property != None)
89
89
unsigned char *prop;
92
r = XGetWindowProperty (dpy, sel_window, sawmill_selection,
92
r = XGetWindowProperty (dpy, sel_window, sawfish_selection,
93
93
0, 0, False, AnyPropertyType,
94
94
&actual_type, &actual_format,
95
95
&nitems, &bytes_after, &prop);
105
105
while (bytes_after > 0)
107
r = XGetWindowProperty (dpy, sel_window, sawmill_selection,
107
r = XGetWindowProperty (dpy, sel_window, sawfish_selection,
108
108
offset/4, (bytes_after / 4) + 1,
109
109
False, AnyPropertyType,
110
110
&actual_type, &actual_format,
116
116
offset += nitems;
118
XDeleteProperty (dpy, sel_window, sawmill_selection);
118
XDeleteProperty (dpy, sel_window, sawfish_selection);
119
119
rep_STR(res)[offset] = 0;
134
134
rep_ADD_SUBR (Sx_get_selection);
137
sawmill_selection = XInternAtom (dpy, "SAWMILL_SELECTION", False);
137
sawfish_selection = XInternAtom (dpy, "SAWFISH_SELECTION", False);
139
139
return rep_pop_structure (tem);