aboutsummaryrefslogtreecommitdiffstats
path: root/src/xselect.c
diff options
context:
space:
mode:
authorJoakim Verona2011-02-05 11:23:09 +0100
committerJoakim Verona2011-02-05 11:23:09 +0100
commit4bd51ad5c3445b644dfb017d5b57b10a90aa325f (patch)
tree894801e7308ce4ecc34933f959e28f4b9cff9533 /src/xselect.c
parent13cfe8df462ab8da9f0028e16cc84dcaceaca3d1 (diff)
parent9bcaafce5351d270ac514e23cb69ff1a5fd35229 (diff)
downloademacs-4bd51ad5c3445b644dfb017d5b57b10a90aa325f.tar.gz
emacs-4bd51ad5c3445b644dfb017d5b57b10a90aa325f.zip
merge from upstream. currently seems to have bitroted and i get segfaults
Diffstat (limited to 'src/xselect.c')
-rw-r--r--src/xselect.c82
1 files changed, 28 insertions, 54 deletions
diff --git a/src/xselect.c b/src/xselect.c
index 7479f245a77..96c8b9c4c47 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -1,6 +1,5 @@
1/* X Selection processing for Emacs. 1/* X Selection processing for Emacs.
2 Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2003, 2 Copyright (C) 1993-1997, 2000-2011 Free Software Foundation, Inc.
3 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
4 3
5This file is part of GNU Emacs. 4This file is part of GNU Emacs.
6 5
@@ -27,9 +26,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
27#ifdef HAVE_SYS_TYPES_H 26#ifdef HAVE_SYS_TYPES_H
28#include <sys/types.h> 27#include <sys/types.h>
29#endif 28#endif
30#ifdef HAVE_UNISTD_H 29
31#include <unistd.h> 30#include <unistd.h>
32#endif
33 31
34#include "lisp.h" 32#include "lisp.h"
35#include "xterm.h" /* for all of the X includes */ 33#include "xterm.h" /* for all of the X includes */
@@ -112,8 +110,6 @@ Lisp_Object QUTF8_STRING; /* This is a type of selection. */
112 110
113Lisp_Object Qcompound_text_with_extensions; 111Lisp_Object Qcompound_text_with_extensions;
114 112
115static Lisp_Object Vx_lost_selection_functions;
116static Lisp_Object Vx_sent_selection_functions;
117static Lisp_Object Qforeign_selection; 113static Lisp_Object Qforeign_selection;
118 114
119/* If this is a smaller number than the max-request-size of the display, 115/* If this is a smaller number than the max-request-size of the display,
@@ -130,31 +126,6 @@ static Lisp_Object Qforeign_selection;
130/* Defined in keyboard.c. */ 126/* Defined in keyboard.c. */
131extern unsigned long last_event_timestamp; 127extern unsigned long last_event_timestamp;
132 128
133/* This is an association list whose elements are of the form
134 ( SELECTION-NAME SELECTION-VALUE SELECTION-TIMESTAMP FRAME)
135 SELECTION-NAME is a lisp symbol, whose name is the name of an X Atom.
136 SELECTION-VALUE is the value that emacs owns for that selection.
137 It may be any kind of Lisp object.
138 SELECTION-TIMESTAMP is the time at which emacs began owning this selection,
139 as a cons of two 16-bit numbers (making a 32 bit time.)
140 FRAME is the frame for which we made the selection.
141 If there is an entry in this alist, then it can be assumed that Emacs owns
142 that selection.
143 The only (eq) parts of this list that are visible from Lisp are the
144 selection-values. */
145static Lisp_Object Vselection_alist;
146
147/* This is an alist whose CARs are selection-types (whose names are the same
148 as the names of X Atoms) and whose CDRs are the names of Lisp functions to
149 call to convert the given Emacs selection value to a string representing
150 the given selection type. This is for Lisp-level extension of the emacs
151 selection handling. */
152static Lisp_Object Vselection_converter_alist;
153
154/* If the selection owner takes too long to reply to a selection request,
155 we give up on it. This is in milliseconds (0 = no timeout.) */
156static EMACS_INT x_selection_timeout;
157
158 129
159 130
160/* Define a queue to save up SELECTION_REQUEST_EVENT events for later 131/* Define a queue to save up SELECTION_REQUEST_EVENT events for later
@@ -263,9 +234,9 @@ symbol_to_x_atom (struct x_display_info *dpyinfo, Display *display, Lisp_Object
263 if (EQ (sym, QNULL)) return dpyinfo->Xatom_NULL; 234 if (EQ (sym, QNULL)) return dpyinfo->Xatom_NULL;
264 if (!SYMBOLP (sym)) abort (); 235 if (!SYMBOLP (sym)) abort ();
265 236
266 TRACE1 (" XInternAtom %s", (char *) SDATA (SYMBOL_NAME (sym))); 237 TRACE1 (" XInternAtom %s", SSDATA (SYMBOL_NAME (sym)));
267 BLOCK_INPUT; 238 BLOCK_INPUT;
268 val = XInternAtom (display, (char *) SDATA (SYMBOL_NAME (sym)), False); 239 val = XInternAtom (display, SSDATA (SYMBOL_NAME (sym)), False);
269 UNBLOCK_INPUT; 240 UNBLOCK_INPUT;
270 return val; 241 return val;
271} 242}
@@ -2283,7 +2254,7 @@ x_fill_property_data (Display *dpy, Lisp_Object data, void *ret, int format)
2283 else if (STRINGP (o)) 2254 else if (STRINGP (o))
2284 { 2255 {
2285 BLOCK_INPUT; 2256 BLOCK_INPUT;
2286 val = (long) XInternAtom (dpy, (char *) SDATA (o), False); 2257 val = (long) XInternAtom (dpy, SSDATA (o), False);
2287 UNBLOCK_INPUT; 2258 UNBLOCK_INPUT;
2288 } 2259 }
2289 else 2260 else
@@ -2420,7 +2391,7 @@ FRAME is on. If FRAME is nil, the selected frame is used. */)
2420 else if (STRINGP (atom)) 2391 else if (STRINGP (atom))
2421 { 2392 {
2422 BLOCK_INPUT; 2393 BLOCK_INPUT;
2423 x_atom = XInternAtom (FRAME_X_DISPLAY (f), (char *) SDATA (atom), False); 2394 x_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (atom), False);
2424 UNBLOCK_INPUT; 2395 UNBLOCK_INPUT;
2425 } 2396 }
2426 else 2397 else
@@ -2527,14 +2498,26 @@ are ignored. */)
2527 (Lisp_Object display, Lisp_Object dest, Lisp_Object from, Lisp_Object message_type, Lisp_Object format, Lisp_Object values) 2498 (Lisp_Object display, Lisp_Object dest, Lisp_Object from, Lisp_Object message_type, Lisp_Object format, Lisp_Object values)
2528{ 2499{
2529 struct x_display_info *dpyinfo = check_x_display_info (display); 2500 struct x_display_info *dpyinfo = check_x_display_info (display);
2501
2502 CHECK_STRING (message_type);
2503 x_send_client_event(display, dest, from,
2504 XInternAtom (dpyinfo->display,
2505 SSDATA (message_type),
2506 False),
2507 format, values);
2508
2509 return Qnil;
2510}
2511
2512void
2513x_send_client_event (Lisp_Object display, Lisp_Object dest, Lisp_Object from, Atom message_type, Lisp_Object format, Lisp_Object values)
2514{
2515 struct x_display_info *dpyinfo = check_x_display_info (display);
2530 Window wdest; 2516 Window wdest;
2531 XEvent event; 2517 XEvent event;
2532 Lisp_Object cons;
2533 int size;
2534 struct frame *f = check_x_frame (from); 2518 struct frame *f = check_x_frame (from);
2535 int to_root; 2519 int to_root;
2536 2520
2537 CHECK_STRING (message_type);
2538 CHECK_NUMBER (format); 2521 CHECK_NUMBER (format);
2539 CHECK_CONS (values); 2522 CHECK_CONS (values);
2540 2523
@@ -2555,9 +2538,9 @@ are ignored. */)
2555 } 2538 }
2556 else if (STRINGP (dest)) 2539 else if (STRINGP (dest))
2557 { 2540 {
2558 if (strcmp (SDATA (dest), "PointerWindow") == 0) 2541 if (strcmp (SSDATA (dest), "PointerWindow") == 0)
2559 wdest = PointerWindow; 2542 wdest = PointerWindow;
2560 else if (strcmp (SDATA (dest), "InputFocus") == 0) 2543 else if (strcmp (SSDATA (dest), "InputFocus") == 0)
2561 wdest = InputFocus; 2544 wdest = InputFocus;
2562 else 2545 else
2563 error ("DEST as a string must be one of PointerWindow or InputFocus"); 2546 error ("DEST as a string must be one of PointerWindow or InputFocus");
@@ -2579,13 +2562,9 @@ are ignored. */)
2579 if (wdest == 0) wdest = dpyinfo->root_window; 2562 if (wdest == 0) wdest = dpyinfo->root_window;
2580 to_root = wdest == dpyinfo->root_window; 2563 to_root = wdest == dpyinfo->root_window;
2581 2564
2582 for (cons = values, size = 0; CONSP (cons); cons = XCDR (cons), ++size)
2583 ;
2584
2585 BLOCK_INPUT; 2565 BLOCK_INPUT;
2586 2566
2587 event.xclient.message_type 2567 event.xclient.message_type = message_type;
2588 = XInternAtom (dpyinfo->display, SDATA (message_type), False);
2589 event.xclient.display = dpyinfo->display; 2568 event.xclient.display = dpyinfo->display;
2590 2569
2591 /* Some clients (metacity for example) expects sending window to be here 2570 /* Some clients (metacity for example) expects sending window to be here
@@ -2610,8 +2589,6 @@ are ignored. */)
2610 } 2589 }
2611 x_uncatch_errors (); 2590 x_uncatch_errors ();
2612 UNBLOCK_INPUT; 2591 UNBLOCK_INPUT;
2613
2614 return Qnil;
2615} 2592}
2616 2593
2617 2594
@@ -2641,7 +2618,7 @@ syms_of_xselect (void)
2641 Vselection_alist = Qnil; 2618 Vselection_alist = Qnil;
2642 staticpro (&Vselection_alist); 2619 staticpro (&Vselection_alist);
2643 2620
2644 DEFVAR_LISP ("selection-converter-alist", &Vselection_converter_alist, 2621 DEFVAR_LISP ("selection-converter-alist", Vselection_converter_alist,
2645 doc: /* An alist associating X Windows selection-types with functions. 2622 doc: /* An alist associating X Windows selection-types with functions.
2646These functions are called to convert the selection, with three args: 2623These functions are called to convert the selection, with three args:
2647the name of the selection (typically `PRIMARY', `SECONDARY', or `CLIPBOARD'); 2624the name of the selection (typically `PRIMARY', `SECONDARY', or `CLIPBOARD');
@@ -2656,7 +2633,7 @@ means that a side-effect was executed,
2656and there is no meaningful selection value. */); 2633and there is no meaningful selection value. */);
2657 Vselection_converter_alist = Qnil; 2634 Vselection_converter_alist = Qnil;
2658 2635
2659 DEFVAR_LISP ("x-lost-selection-functions", &Vx_lost_selection_functions, 2636 DEFVAR_LISP ("x-lost-selection-functions", Vx_lost_selection_functions,
2660 doc: /* A list of functions to be called when Emacs loses an X selection. 2637 doc: /* A list of functions to be called when Emacs loses an X selection.
2661\(This happens when some other X client makes its own selection 2638\(This happens when some other X client makes its own selection
2662or when a Lisp program explicitly clears the selection.) 2639or when a Lisp program explicitly clears the selection.)
@@ -2664,7 +2641,7 @@ The functions are called with one argument, the selection type
2664\(a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'). */); 2641\(a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'). */);
2665 Vx_lost_selection_functions = Qnil; 2642 Vx_lost_selection_functions = Qnil;
2666 2643
2667 DEFVAR_LISP ("x-sent-selection-functions", &Vx_sent_selection_functions, 2644 DEFVAR_LISP ("x-sent-selection-functions", Vx_sent_selection_functions,
2668 doc: /* A list of functions to be called when Emacs answers a selection request. 2645 doc: /* A list of functions to be called when Emacs answers a selection request.
2669The functions are called with four arguments: 2646The functions are called with four arguments:
2670 - the selection name (typically `PRIMARY', `SECONDARY', or `CLIPBOARD'); 2647 - the selection name (typically `PRIMARY', `SECONDARY', or `CLIPBOARD');
@@ -2678,7 +2655,7 @@ This hook doesn't let you change the behavior of Emacs's selection replies,
2678it merely informs you that they have happened. */); 2655it merely informs you that they have happened. */);
2679 Vx_sent_selection_functions = Qnil; 2656 Vx_sent_selection_functions = Qnil;
2680 2657
2681 DEFVAR_INT ("x-selection-timeout", &x_selection_timeout, 2658 DEFVAR_INT ("x-selection-timeout", x_selection_timeout,
2682 doc: /* Number of milliseconds to wait for a selection reply. 2659 doc: /* Number of milliseconds to wait for a selection reply.
2683If the selection owner doesn't reply in this time, we give up. 2660If the selection owner doesn't reply in this time, we give up.
2684A value of 0 means wait as long as necessary. This is initialized from the 2661A value of 0 means wait as long as necessary. This is initialized from the
@@ -2708,6 +2685,3 @@ A value of 0 means wait as long as necessary. This is initialized from the
2708 Qforeign_selection = intern_c_string ("foreign-selection"); 2685 Qforeign_selection = intern_c_string ("foreign-selection");
2709 staticpro (&Qforeign_selection); 2686 staticpro (&Qforeign_selection);
2710} 2687}
2711
2712/* arch-tag: 7c293b0f-9918-4f69-8ac7-03e142307236
2713 (do not change this comment) */