diff options
| author | Eli Zaretskii | 2014-10-14 21:10:37 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2014-10-14 21:10:37 +0300 |
| commit | e3060a0c4d2f418ac786775109d71e5843ccf42e (patch) | |
| tree | 347b37fc39d0db9cd23b3e9f79ee81b4bbc40f08 /src/xselect.c | |
| parent | 1a3eca0656bdb764200e10a4f264138e94b1f3ce (diff) | |
| parent | 980d78b3587560c13a46aef352ed8d5ed744acf6 (diff) | |
| download | emacs-e3060a0c4d2f418ac786775109d71e5843ccf42e.tar.gz emacs-e3060a0c4d2f418ac786775109d71e5843ccf42e.zip | |
Merge from trunk and resolve conflicts.
Diffstat (limited to 'src/xselect.c')
| -rw-r--r-- | src/xselect.c | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/src/xselect.c b/src/xselect.c index 23310b0f867..92e89822293 100644 --- a/src/xselect.c +++ b/src/xselect.c | |||
| @@ -96,13 +96,6 @@ static Lisp_Object Qx_lost_selection_functions, Qx_sent_selection_functions; | |||
| 96 | is not necessarily sizeof (long). */ | 96 | is not necessarily sizeof (long). */ |
| 97 | #define X_LONG_SIZE 4 | 97 | #define X_LONG_SIZE 4 |
| 98 | 98 | ||
| 99 | /* Extreme 'short' and 'long' values suitable for libX11. */ | ||
| 100 | #define X_SHRT_MAX 0x7fff | ||
| 101 | #define X_SHRT_MIN (-1 - X_SHRT_MAX) | ||
| 102 | #define X_LONG_MAX 0x7fffffff | ||
| 103 | #define X_LONG_MIN (-1 - X_LONG_MAX) | ||
| 104 | #define X_ULONG_MAX 0xffffffffUL | ||
| 105 | |||
| 106 | /* If this is a smaller number than the max-request-size of the display, | 99 | /* If this is a smaller number than the max-request-size of the display, |
| 107 | emacs will use INCR selection transfer when the selection is larger | 100 | emacs will use INCR selection transfer when the selection is larger |
| 108 | than this. The max-request-size is usually around 64k, so if you want | 101 | than this. The max-request-size is usually around 64k, so if you want |
| @@ -1908,7 +1901,7 @@ frame_for_x_selection (Lisp_Object object) | |||
| 1908 | } | 1901 | } |
| 1909 | else if (TERMINALP (object)) | 1902 | else if (TERMINALP (object)) |
| 1910 | { | 1903 | { |
| 1911 | struct terminal *t = get_terminal (object, 1); | 1904 | struct terminal *t = decode_live_terminal (object); |
| 1912 | 1905 | ||
| 1913 | if (t->type == output_x_window) | 1906 | if (t->type == output_x_window) |
| 1914 | FOR_EACH_FRAME (tail, frame) | 1907 | FOR_EACH_FRAME (tail, frame) |
| @@ -2159,11 +2152,9 @@ x_clipboard_manager_save (Lisp_Object frame) | |||
| 2159 | static Lisp_Object | 2152 | static Lisp_Object |
| 2160 | x_clipboard_manager_error_1 (Lisp_Object err) | 2153 | x_clipboard_manager_error_1 (Lisp_Object err) |
| 2161 | { | 2154 | { |
| 2162 | Lisp_Object args[2]; | 2155 | AUTO_STRING (format, "X clipboard manager error: %s\n\ |
| 2163 | args[0] = build_string ("X clipboard manager error: %s\n\ | ||
| 2164 | If the problem persists, set `x-select-enable-clipboard-manager' to nil."); | 2156 | If the problem persists, set `x-select-enable-clipboard-manager' to nil."); |
| 2165 | args[1] = CAR (CDR (err)); | 2157 | Fmessage (2, (Lisp_Object []) {format, CAR (CDR (err))}); |
| 2166 | Fmessage (2, args); | ||
| 2167 | return Qnil; | 2158 | return Qnil; |
| 2168 | } | 2159 | } |
| 2169 | 2160 | ||
| @@ -2230,10 +2221,8 @@ x_clipboard_manager_save_all (void) | |||
| 2230 | local_frame = XCAR (XCDR (XCDR (XCDR (local_selection)))); | 2221 | local_frame = XCAR (XCDR (XCDR (XCDR (local_selection)))); |
| 2231 | if (FRAME_LIVE_P (XFRAME (local_frame))) | 2222 | if (FRAME_LIVE_P (XFRAME (local_frame))) |
| 2232 | { | 2223 | { |
| 2233 | Lisp_Object args[1]; | 2224 | AUTO_STRING (saving, "Saving clipboard to X clipboard manager..."); |
| 2234 | args[0] = build_string ("Saving clipboard to X clipboard manager..."); | 2225 | Fmessage (1, &saving); |
| 2235 | Fmessage (1, args); | ||
| 2236 | |||
| 2237 | internal_condition_case_1 (x_clipboard_manager_save, local_frame, | 2226 | internal_condition_case_1 (x_clipboard_manager_save, local_frame, |
| 2238 | Qt, x_clipboard_manager_error_2); | 2227 | Qt, x_clipboard_manager_error_2); |
| 2239 | } | 2228 | } |
| @@ -2288,10 +2277,10 @@ x_check_property_data (Lisp_Object data) | |||
| 2288 | void | 2277 | void |
| 2289 | x_fill_property_data (Display *dpy, Lisp_Object data, void *ret, int format) | 2278 | x_fill_property_data (Display *dpy, Lisp_Object data, void *ret, int format) |
| 2290 | { | 2279 | { |
| 2291 | long val; | 2280 | unsigned long val; |
| 2292 | long *d32 = (long *) ret; | 2281 | unsigned long *d32 = (unsigned long *) ret; |
| 2293 | short *d16 = (short *) ret; | 2282 | unsigned short *d16 = (unsigned short *) ret; |
| 2294 | char *d08 = (char *) ret; | 2283 | unsigned char *d08 = (unsigned char *) ret; |
| 2295 | Lisp_Object iter; | 2284 | Lisp_Object iter; |
| 2296 | 2285 | ||
| 2297 | for (iter = data; CONSP (iter); iter = XCDR (iter)) | 2286 | for (iter = data; CONSP (iter); iter = XCDR (iter)) |
| @@ -2299,7 +2288,22 @@ x_fill_property_data (Display *dpy, Lisp_Object data, void *ret, int format) | |||
| 2299 | Lisp_Object o = XCAR (iter); | 2288 | Lisp_Object o = XCAR (iter); |
| 2300 | 2289 | ||
| 2301 | if (INTEGERP (o) || FLOATP (o) || CONSP (o)) | 2290 | if (INTEGERP (o) || FLOATP (o) || CONSP (o)) |
| 2302 | val = cons_to_signed (o, LONG_MIN, LONG_MAX); | 2291 | { |
| 2292 | if (CONSP (o) | ||
| 2293 | && RANGED_INTEGERP (X_LONG_MIN >> 16, XCAR (o), X_LONG_MAX >> 16) | ||
| 2294 | && RANGED_INTEGERP (- (1 << 15), XCDR (o), -1)) | ||
| 2295 | { | ||
| 2296 | /* cons_to_x_long does not handle negative values for v2. | ||
| 2297 | For XDnd, v2 might be y of a window, and can be negative. | ||
| 2298 | The XDnd spec. is not explicit about negative values, | ||
| 2299 | but let's assume negative v2 is sent modulo 2**16. */ | ||
| 2300 | unsigned long v1 = XINT (XCAR (o)) & 0xffff; | ||
| 2301 | unsigned long v2 = XINT (XCDR (o)) & 0xffff; | ||
| 2302 | val = (v1 << 16) | v2; | ||
| 2303 | } | ||
| 2304 | else | ||
| 2305 | val = cons_to_x_long (o); | ||
| 2306 | } | ||
| 2303 | else if (STRINGP (o)) | 2307 | else if (STRINGP (o)) |
| 2304 | { | 2308 | { |
| 2305 | block_input (); | 2309 | block_input (); |
| @@ -2311,17 +2315,15 @@ x_fill_property_data (Display *dpy, Lisp_Object data, void *ret, int format) | |||
| 2311 | 2315 | ||
| 2312 | if (format == 8) | 2316 | if (format == 8) |
| 2313 | { | 2317 | { |
| 2314 | if (CHAR_MIN <= val && val <= CHAR_MAX) | 2318 | if ((1 << 8) < val && val <= X_ULONG_MAX - (1 << 7)) |
| 2315 | *d08++ = val; | ||
| 2316 | else | ||
| 2317 | error ("Out of 'char' range"); | 2319 | error ("Out of 'char' range"); |
| 2320 | *d08++ = val; | ||
| 2318 | } | 2321 | } |
| 2319 | else if (format == 16) | 2322 | else if (format == 16) |
| 2320 | { | 2323 | { |
| 2321 | if (SHRT_MIN <= val && val <= SHRT_MAX) | 2324 | if ((1 << 16) < val && val <= X_ULONG_MAX - (1 << 15)) |
| 2322 | *d16++ = val; | ||
| 2323 | else | ||
| 2324 | error ("Out of 'short' range"); | 2325 | error ("Out of 'short' range"); |
| 2326 | *d16++ = val; | ||
| 2325 | } | 2327 | } |
| 2326 | else | 2328 | else |
| 2327 | *d32++ = val; | 2329 | *d32++ = val; |
| @@ -2627,12 +2629,14 @@ syms_of_xselect (void) | |||
| 2627 | converted_selections = NULL; | 2629 | converted_selections = NULL; |
| 2628 | conversion_fail_tag = None; | 2630 | conversion_fail_tag = None; |
| 2629 | 2631 | ||
| 2632 | /* FIXME: Duplicate definition in nsselect.c. */ | ||
| 2630 | DEFVAR_LISP ("selection-converter-alist", Vselection_converter_alist, | 2633 | DEFVAR_LISP ("selection-converter-alist", Vselection_converter_alist, |
| 2631 | doc: /* An alist associating X Windows selection-types with functions. | 2634 | doc: /* An alist associating X Windows selection-types with functions. |
| 2632 | These functions are called to convert the selection, with three args: | 2635 | These functions are called to convert the selection, with three args: |
| 2633 | the name of the selection (typically `PRIMARY', `SECONDARY', or `CLIPBOARD'); | 2636 | the name of the selection (typically `PRIMARY', `SECONDARY', or `CLIPBOARD'); |
| 2634 | a desired type to which the selection should be converted; | 2637 | a desired type to which the selection should be converted; |
| 2635 | and the local selection value (whatever was given to `x-own-selection'). | 2638 | and the local selection value (whatever was given to |
| 2639 | `x-own-selection-internal'). | ||
| 2636 | 2640 | ||
| 2637 | The function should return the value to send to the X server | 2641 | The function should return the value to send to the X server |
| 2638 | \(typically a string). A return value of nil | 2642 | \(typically a string). A return value of nil |