aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1994-10-23 09:38:50 +0000
committerRichard M. Stallman1994-10-23 09:38:50 +0000
commit5c3a351a29e199da54777fd712c751ebca8280f7 (patch)
tree20eca436be71ed7e34e1405380be23089df6784c /src
parentf91f7c79c05abceb295cfe8a4b2fa4edbb76f25d (diff)
downloademacs-5c3a351a29e199da54777fd712c751ebca8280f7.tar.gz
emacs-5c3a351a29e199da54777fd712c751ebca8280f7.zip
Use XFlush, not XFlushQueue, throughout.
(Xatom_*): Variables deleted. Use slots in x_display_info structure instead. (symbol_to_x_atom, x_atom_to_symbol): New arg dpyinfo. All callers changed. (xatoms_of_xselect): Function deleted.
Diffstat (limited to 'src')
-rw-r--r--src/xselect.c162
1 files changed, 81 insertions, 81 deletions
diff --git a/src/xselect.c b/src/xselect.c
index e99e7afdf99..b34686c20f8 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -38,10 +38,6 @@ x_reply_selection_request */
38 38
39#define CUT_BUFFER_SUPPORT 39#define CUT_BUFFER_SUPPORT
40 40
41static Atom Xatom_CLIPBOARD, Xatom_TIMESTAMP, Xatom_TEXT, Xatom_DELETE,
42 Xatom_MULTIPLE, Xatom_INCR, Xatom_EMACS_TMP, Xatom_TARGETS, Xatom_NULL,
43 Xatom_ATOM_PAIR;
44
45Lisp_Object QPRIMARY, QSECONDARY, QSTRING, QINTEGER, QCLIPBOARD, QTIMESTAMP, 41Lisp_Object QPRIMARY, QSECONDARY, QSTRING, QINTEGER, QCLIPBOARD, QTIMESTAMP,
46 QTEXT, QDELETE, QMULTIPLE, QINCR, QEMACS_TMP, QTARGETS, QATOM, QNULL, 42 QTEXT, QDELETE, QMULTIPLE, QINCR, QEMACS_TMP, QTARGETS, QATOM, QNULL,
47 QATOM_PAIR; 43 QATOM_PAIR;
@@ -110,7 +106,8 @@ static Lisp_Object x_get_window_property_as_lisp_data ();
110 roundtrip whenever possible. */ 106 roundtrip whenever possible. */
111 107
112static Atom 108static Atom
113symbol_to_x_atom (display, sym) 109symbol_to_x_atom (dpyinfo, display, sym)
110 struct x_display_info *dpyinfo;
114 Display *display; 111 Display *display;
115 Lisp_Object sym; 112 Lisp_Object sym;
116{ 113{
@@ -121,15 +118,15 @@ symbol_to_x_atom (display, sym)
121 if (EQ (sym, QSTRING)) return XA_STRING; 118 if (EQ (sym, QSTRING)) return XA_STRING;
122 if (EQ (sym, QINTEGER)) return XA_INTEGER; 119 if (EQ (sym, QINTEGER)) return XA_INTEGER;
123 if (EQ (sym, QATOM)) return XA_ATOM; 120 if (EQ (sym, QATOM)) return XA_ATOM;
124 if (EQ (sym, QCLIPBOARD)) return Xatom_CLIPBOARD; 121 if (EQ (sym, QCLIPBOARD)) return dpyinfo->Xatom_CLIPBOARD;
125 if (EQ (sym, QTIMESTAMP)) return Xatom_TIMESTAMP; 122 if (EQ (sym, QTIMESTAMP)) return dpyinfo->Xatom_TIMESTAMP;
126 if (EQ (sym, QTEXT)) return Xatom_TEXT; 123 if (EQ (sym, QTEXT)) return dpyinfo->Xatom_TEXT;
127 if (EQ (sym, QDELETE)) return Xatom_DELETE; 124 if (EQ (sym, QDELETE)) return dpyinfo->Xatom_DELETE;
128 if (EQ (sym, QMULTIPLE)) return Xatom_MULTIPLE; 125 if (EQ (sym, QMULTIPLE)) return dpyinfo->Xatom_MULTIPLE;
129 if (EQ (sym, QINCR)) return Xatom_INCR; 126 if (EQ (sym, QINCR)) return dpyinfo->Xatom_INCR;
130 if (EQ (sym, QEMACS_TMP)) return Xatom_EMACS_TMP; 127 if (EQ (sym, QEMACS_TMP)) return dpyinfo->Xatom_EMACS_TMP;
131 if (EQ (sym, QTARGETS)) return Xatom_TARGETS; 128 if (EQ (sym, QTARGETS)) return dpyinfo->Xatom_TARGETS;
132 if (EQ (sym, QNULL)) return Xatom_NULL; 129 if (EQ (sym, QNULL)) return dpyinfo->Xatom_NULL;
133#ifdef CUT_BUFFER_SUPPORT 130#ifdef CUT_BUFFER_SUPPORT
134 if (EQ (sym, QCUT_BUFFER0)) return XA_CUT_BUFFER0; 131 if (EQ (sym, QCUT_BUFFER0)) return XA_CUT_BUFFER0;
135 if (EQ (sym, QCUT_BUFFER1)) return XA_CUT_BUFFER1; 132 if (EQ (sym, QCUT_BUFFER1)) return XA_CUT_BUFFER1;
@@ -156,7 +153,8 @@ symbol_to_x_atom (display, sym)
156 and calls to intern whenever possible. */ 153 and calls to intern whenever possible. */
157 154
158static Lisp_Object 155static Lisp_Object
159x_atom_to_symbol (display, atom) 156x_atom_to_symbol (dpyinfo, display, atom)
157 struct x_display_info *dpyinfo;
160 Display *display; 158 Display *display;
161 Atom atom; 159 Atom atom;
162{ 160{
@@ -195,23 +193,23 @@ x_atom_to_symbol (display, atom)
195#endif 193#endif
196 } 194 }
197 195
198 if (atom == Xatom_CLIPBOARD) 196 if (atom == dpyinfo->Xatom_CLIPBOARD)
199 return QCLIPBOARD; 197 return QCLIPBOARD;
200 if (atom == Xatom_TIMESTAMP) 198 if (atom == dpyinfo->Xatom_TIMESTAMP)
201 return QTIMESTAMP; 199 return QTIMESTAMP;
202 if (atom == Xatom_TEXT) 200 if (atom == dpyinfo->Xatom_TEXT)
203 return QTEXT; 201 return QTEXT;
204 if (atom == Xatom_DELETE) 202 if (atom == dpyinfo->Xatom_DELETE)
205 return QDELETE; 203 return QDELETE;
206 if (atom == Xatom_MULTIPLE) 204 if (atom == dpyinfo->Xatom_MULTIPLE)
207 return QMULTIPLE; 205 return QMULTIPLE;
208 if (atom == Xatom_INCR) 206 if (atom == dpyinfo->Xatom_INCR)
209 return QINCR; 207 return QINCR;
210 if (atom == Xatom_EMACS_TMP) 208 if (atom == dpyinfo->Xatom_EMACS_TMP)
211 return QEMACS_TMP; 209 return QEMACS_TMP;
212 if (atom == Xatom_TARGETS) 210 if (atom == dpyinfo->Xatom_TARGETS)
213 return QTARGETS; 211 return QTARGETS;
214 if (atom == Xatom_NULL) 212 if (atom == dpyinfo->Xatom_NULL)
215 return QNULL; 213 return QNULL;
216 214
217 BLOCK_INPUT; 215 BLOCK_INPUT;
@@ -240,9 +238,10 @@ x_own_selection (selection_name, selection_value)
240 Display *display = FRAME_X_DISPLAY (selected_frame); 238 Display *display = FRAME_X_DISPLAY (selected_frame);
241 Time time = last_event_timestamp; 239 Time time = last_event_timestamp;
242 Atom selection_atom; 240 Atom selection_atom;
241 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (selected_frame);
243 242
244 CHECK_SYMBOL (selection_name, 0); 243 CHECK_SYMBOL (selection_name, 0);
245 selection_atom = symbol_to_x_atom (display, selection_name); 244 selection_atom = symbol_to_x_atom (dpyinfo, display, selection_name);
246 245
247 BLOCK_INPUT; 246 BLOCK_INPUT;
248 x_catch_errors (selected_frame); 247 x_catch_errors (selected_frame);
@@ -415,7 +414,7 @@ x_decline_selection_request (event)
415 BLOCK_INPUT; 414 BLOCK_INPUT;
416 XSendEvent (reply.display, reply.requestor, False, 0L, 415 XSendEvent (reply.display, reply.requestor, False, 0L,
417 (XEvent *) &reply); 416 (XEvent *) &reply);
418 XFlushQueue (); 417 XFlush (reply.display);
419 UNBLOCK_INPUT; 418 UNBLOCK_INPUT;
420} 419}
421 420
@@ -485,6 +484,7 @@ x_reply_selection_request (event, format, data, size, type)
485 int bytes_remaining; 484 int bytes_remaining;
486 int format_bytes = format/8; 485 int format_bytes = format/8;
487 int max_bytes = SELECTION_QUANTUM (display); 486 int max_bytes = SELECTION_QUANTUM (display);
487 struct x_display_info *dpyinfo = x_display_info_for_display (display);
488 488
489 if (max_bytes > MAX_SELECTION_QUANTUM) 489 if (max_bytes > MAX_SELECTION_QUANTUM)
490 max_bytes = MAX_SELECTION_QUANTUM; 490 max_bytes = MAX_SELECTION_QUANTUM;
@@ -516,7 +516,7 @@ x_reply_selection_request (event, format, data, size, type)
516 PropModeReplace, data, size); 516 PropModeReplace, data, size);
517 /* At this point, the selection was successfully stored; ack it. */ 517 /* At this point, the selection was successfully stored; ack it. */
518 XSendEvent (display, window, False, 0L, (XEvent *) &reply); 518 XSendEvent (display, window, False, 0L, (XEvent *) &reply);
519 XFlushQueue (); 519 XFlush (display);
520 UNBLOCK_INPUT; 520 UNBLOCK_INPUT;
521 } 521 }
522 else 522 else
@@ -534,13 +534,13 @@ x_reply_selection_request (event, format, data, size, type)
534 wait_object = expect_property_change (display, window, reply.property, 534 wait_object = expect_property_change (display, window, reply.property,
535 PropertyDelete); 535 PropertyDelete);
536 536
537 XChangeProperty (display, window, reply.property, Xatom_INCR, 537 XChangeProperty (display, window, reply.property, dpyinfo->Xatom_INCR,
538 32, PropModeReplace, (unsigned char *) 538 32, PropModeReplace, (unsigned char *)
539 &bytes_remaining, 1); 539 &bytes_remaining, 1);
540 XSelectInput (display, window, PropertyChangeMask); 540 XSelectInput (display, window, PropertyChangeMask);
541 /* Tell 'em the INCR data is there... */ 541 /* Tell 'em the INCR data is there... */
542 (void) XSendEvent (display, window, False, 0L, (XEvent *) &reply); 542 (void) XSendEvent (display, window, False, 0L, (XEvent *) &reply);
543 XFlushQueue (); 543 XFlush (display);
544 UNBLOCK_INPUT; 544 UNBLOCK_INPUT;
545 545
546 /* First, wait for the requestor to ack by deleting the property. 546 /* First, wait for the requestor to ack by deleting the property.
@@ -566,7 +566,7 @@ x_reply_selection_request (event, format, data, size, type)
566 PropModeAppend, data, i / format_bytes); 566 PropModeAppend, data, i / format_bytes);
567 bytes_remaining -= i; 567 bytes_remaining -= i;
568 data += i; 568 data += i;
569 XFlushQueue (); 569 XFlush (display);
570 UNBLOCK_INPUT; 570 UNBLOCK_INPUT;
571 571
572 /* Now wait for the requestor to ack this chunk by deleting the 572 /* Now wait for the requestor to ack this chunk by deleting the
@@ -585,7 +585,7 @@ x_reply_selection_request (event, format, data, size, type)
585 585
586 XChangeProperty (display, window, reply.property, type, format, 586 XChangeProperty (display, window, reply.property, type, format,
587 PropModeReplace, data, 0); 587 PropModeReplace, data, 0);
588 XFlushQueue (); 588 XFlush (display);
589 UNBLOCK_INPUT; 589 UNBLOCK_INPUT;
590 } 590 }
591} 591}
@@ -605,6 +605,8 @@ x_handle_selection_request (event)
605 Time local_selection_time; 605 Time local_selection_time;
606 Lisp_Object successful_p; 606 Lisp_Object successful_p;
607 int count; 607 int count;
608 struct x_display_info *dpyinfo
609 = x_display_info_for_display (SELECTION_EVENT_DISPLAY (event));
608 610
609 local_selection_data = Qnil; 611 local_selection_data = Qnil;
610 target_symbol = Qnil; 612 target_symbol = Qnil;
@@ -613,7 +615,8 @@ x_handle_selection_request (event)
613 615
614 GCPRO3 (local_selection_data, converted_selection, target_symbol); 616 GCPRO3 (local_selection_data, converted_selection, target_symbol);
615 617
616 selection_symbol = x_atom_to_symbol (SELECTION_EVENT_DISPLAY (event), 618 selection_symbol = x_atom_to_symbol (dpyinfo,
619 SELECTION_EVENT_DISPLAY (event),
617 SELECTION_EVENT_SELECTION (event)); 620 SELECTION_EVENT_SELECTION (event));
618 621
619 local_selection_data = assq_no_quit (selection_symbol, Vselection_alist); 622 local_selection_data = assq_no_quit (selection_symbol, Vselection_alist);
@@ -643,7 +646,7 @@ x_handle_selection_request (event)
643 x_selection_current_request = event; 646 x_selection_current_request = event;
644 record_unwind_protect (x_selection_request_lisp_error, Qnil); 647 record_unwind_protect (x_selection_request_lisp_error, Qnil);
645 648
646 target_symbol = x_atom_to_symbol (SELECTION_EVENT_DISPLAY (event), 649 target_symbol = x_atom_to_symbol (dpyinfo, SELECTION_EVENT_DISPLAY (event),
647 SELECTION_EVENT_TARGET (event)); 650 SELECTION_EVENT_TARGET (event));
648 651
649#if 0 /* #### MULTIPLE doesn't work yet */ 652#if 0 /* #### MULTIPLE doesn't work yet */
@@ -707,8 +710,9 @@ x_handle_selection_clear (event)
707 710
708 Lisp_Object selection_symbol, local_selection_data; 711 Lisp_Object selection_symbol, local_selection_data;
709 Time local_selection_time; 712 Time local_selection_time;
713 struct x_display_info *dpyinfo = x_display_info_for_display (display);
710 714
711 selection_symbol = x_atom_to_symbol (display, selection); 715 selection_symbol = x_atom_to_symbol (dpyinfo, display, selection);
712 716
713 local_selection_data = assq_no_quit (selection_symbol, Vselection_alist); 717 local_selection_data = assq_no_quit (selection_symbol, Vselection_alist);
714 718
@@ -935,7 +939,7 @@ x_handle_property_notify (event)
935#if 0 939#if 0
936 fprintf (stderr, "Saw expected prop-%s on %s\n", 940 fprintf (stderr, "Saw expected prop-%s on %s\n",
937 (event->state == PropertyDelete ? "delete" : "change"), 941 (event->state == PropertyDelete ? "delete" : "change"),
938 (char *) XSYMBOL (x_atom_to_symbol (event->display, 942 (char *) XSYMBOL (x_atom_to_symbol (dpyinfo, event->display,
939 event->atom)) 943 event->atom))
940 ->name->data); 944 ->name->data);
941#endif 945#endif
@@ -960,7 +964,8 @@ x_handle_property_notify (event)
960#if 0 964#if 0
961 fprintf (stderr, "Saw UNexpected prop-%s on %s\n", 965 fprintf (stderr, "Saw UNexpected prop-%s on %s\n",
962 (event->state == PropertyDelete ? "delete" : "change"), 966 (event->state == PropertyDelete ? "delete" : "change"),
963 (char *) XSYMBOL (x_atom_to_symbol (event->display, event->atom)) 967 (char *) XSYMBOL (x_atom_to_symbol (dpyinfo,
968 event->display, event->atom))
964 ->name->data); 969 ->name->data);
965#endif 970#endif
966} 971}
@@ -1031,22 +1036,23 @@ x_get_foreign_selection (selection_symbol, target_type)
1031{ 1036{
1032 Window requestor_window = FRAME_X_WINDOW (selected_frame); 1037 Window requestor_window = FRAME_X_WINDOW (selected_frame);
1033 Display *display = FRAME_X_DISPLAY (selected_frame); 1038 Display *display = FRAME_X_DISPLAY (selected_frame);
1039 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (selected_frame);
1034 Time requestor_time = last_event_timestamp; 1040 Time requestor_time = last_event_timestamp;
1035 Atom target_property = Xatom_EMACS_TMP; 1041 Atom target_property = dpyinfo->Xatom_EMACS_TMP;
1036 Atom selection_atom = symbol_to_x_atom (display, selection_symbol); 1042 Atom selection_atom = symbol_to_x_atom (dpyinfo, display, selection_symbol);
1037 Atom type_atom; 1043 Atom type_atom;
1038 int secs, usecs; 1044 int secs, usecs;
1039 1045
1040 if (CONSP (target_type)) 1046 if (CONSP (target_type))
1041 type_atom = symbol_to_x_atom (display, XCONS (target_type)->car); 1047 type_atom = symbol_to_x_atom (dpyinfo, display, XCONS (target_type)->car);
1042 else 1048 else
1043 type_atom = symbol_to_x_atom (display, target_type); 1049 type_atom = symbol_to_x_atom (dpyinfo, display, target_type);
1044 1050
1045 BLOCK_INPUT; 1051 BLOCK_INPUT;
1046 x_catch_errors (selected_frame); 1052 x_catch_errors (selected_frame);
1047 XConvertSelection (display, selection_atom, type_atom, target_property, 1053 XConvertSelection (display, selection_atom, type_atom, target_property,
1048 requestor_window, requestor_time); 1054 requestor_window, requestor_time);
1049 XFlushQueue (); 1055 XFlush (display);
1050 1056
1051 /* Prepare to block until the reply has been read. */ 1057 /* Prepare to block until the reply has been read. */
1052 reading_selection_window = requestor_window; 1058 reading_selection_window = requestor_window;
@@ -1152,7 +1158,7 @@ x_get_window_property (display, window, property, data_ret, bytes_ret,
1152 xfree ((char *) tmp_data); 1158 xfree ((char *) tmp_data);
1153 } 1159 }
1154 1160
1155 XFlushQueue (); 1161 XFlush (display);
1156 UNBLOCK_INPUT; 1162 UNBLOCK_INPUT;
1157 *bytes_ret = offset; 1163 *bytes_ret = offset;
1158} 1164}
@@ -1193,7 +1199,7 @@ receive_incremental_selection (display, window, property, target_type,
1193 XDeleteProperty (display, window, property); 1199 XDeleteProperty (display, window, property);
1194 wait_object = expect_property_change (display, window, property, 1200 wait_object = expect_property_change (display, window, property,
1195 PropertyNewValue); 1201 PropertyNewValue);
1196 XFlushQueue (); 1202 XFlush (display);
1197 UNBLOCK_INPUT; 1203 UNBLOCK_INPUT;
1198 1204
1199 while (1) 1205 while (1)
@@ -1225,7 +1231,7 @@ receive_incremental_selection (display, window, property, target_type,
1225 XDeleteProperty (display, window, property); 1231 XDeleteProperty (display, window, property);
1226 wait_object = expect_property_change (display, window, property, 1232 wait_object = expect_property_change (display, window, property,
1227 PropertyNewValue); 1233 PropertyNewValue);
1228 XFlushQueue (); 1234 XFlush (display);
1229 UNBLOCK_INPUT; 1235 UNBLOCK_INPUT;
1230 1236
1231#if 0 1237#if 0
@@ -1265,6 +1271,7 @@ x_get_window_property_as_lisp_data (display, window, property, target_type,
1265 unsigned char *data = 0; 1271 unsigned char *data = 0;
1266 int bytes = 0; 1272 int bytes = 0;
1267 Lisp_Object val; 1273 Lisp_Object val;
1274 struct x_display_info *dpyinfo = x_display_info_for_display (display);
1268 1275
1269 x_get_window_property (display, window, property, &data, &bytes, 1276 x_get_window_property (display, window, property, &data, &bytes,
1270 &actual_type, &actual_format, &actual_size, 1); 1277 &actual_type, &actual_format, &actual_size, 1);
@@ -1281,15 +1288,17 @@ x_get_window_property_as_lisp_data (display, window, property, target_type,
1281 Fcons (build_string ("selection owner couldn't convert"), 1288 Fcons (build_string ("selection owner couldn't convert"),
1282 actual_type 1289 actual_type
1283 ? Fcons (target_type, 1290 ? Fcons (target_type,
1284 Fcons (x_atom_to_symbol (display, actual_type), 1291 Fcons (x_atom_to_symbol (dpyinfo, display,
1292 actual_type),
1285 Qnil)) 1293 Qnil))
1286 : Fcons (target_type, Qnil)) 1294 : Fcons (target_type, Qnil))
1287 : Fcons (build_string ("no selection"), 1295 : Fcons (build_string ("no selection"),
1288 Fcons (x_atom_to_symbol (display, selection_atom), 1296 Fcons (x_atom_to_symbol (dpyinfo, display,
1297 selection_atom),
1289 Qnil))); 1298 Qnil)));
1290 } 1299 }
1291 1300
1292 if (actual_type == Xatom_INCR) 1301 if (actual_type == dpyinfo->Xatom_INCR)
1293 { 1302 {
1294 /* That wasn't really the data, just the beginning. */ 1303 /* That wasn't really the data, just the beginning. */
1295 1304
@@ -1305,7 +1314,7 @@ x_get_window_property_as_lisp_data (display, window, property, target_type,
1305 1314
1306 BLOCK_INPUT; 1315 BLOCK_INPUT;
1307 XDeleteProperty (display, window, property); 1316 XDeleteProperty (display, window, property);
1308 XFlushQueue (); 1317 XFlush (display);
1309 UNBLOCK_INPUT; 1318 UNBLOCK_INPUT;
1310 1319
1311 /* It's been read. Now convert it to a lisp object in some semi-rational 1320 /* It's been read. Now convert it to a lisp object in some semi-rational
@@ -1351,8 +1360,9 @@ selection_data_to_lisp_data (display, data, size, type, format)
1351 Atom type; 1360 Atom type;
1352 int size, format; 1361 int size, format;
1353{ 1362{
1363 struct x_display_info *dpyinfo = x_display_info_for_display (display);
1354 1364
1355 if (type == Xatom_NULL) 1365 if (type == dpyinfo->Xatom_NULL)
1356 return QNULL; 1366 return QNULL;
1357 1367
1358 /* Convert any 8-bit data to a string, for compactness. */ 1368 /* Convert any 8-bit data to a string, for compactness. */
@@ -1366,12 +1376,13 @@ selection_data_to_lisp_data (display, data, size, type, format)
1366 { 1376 {
1367 int i; 1377 int i;
1368 if (size == sizeof (Atom)) 1378 if (size == sizeof (Atom))
1369 return x_atom_to_symbol (display, *((Atom *) data)); 1379 return x_atom_to_symbol (dpyinfo, display, *((Atom *) data));
1370 else 1380 else
1371 { 1381 {
1372 Lisp_Object v = Fmake_vector (size / sizeof (Atom), 0); 1382 Lisp_Object v = Fmake_vector (size / sizeof (Atom), 0);
1373 for (i = 0; i < size / sizeof (Atom); i++) 1383 for (i = 0; i < size / sizeof (Atom); i++)
1374 Faset (v, i, x_atom_to_symbol (display, ((Atom *) data) [i])); 1384 Faset (v, i, x_atom_to_symbol (dpyinfo, display,
1385 ((Atom *) data) [i]));
1375 return v; 1386 return v;
1376 } 1387 }
1377 } 1388 }
@@ -1426,6 +1437,7 @@ lisp_data_to_selection_data (display, obj,
1426 int *nofree_ret; 1437 int *nofree_ret;
1427{ 1438{
1428 Lisp_Object type = Qnil; 1439 Lisp_Object type = Qnil;
1440 struct x_display_info *dpyinfo = x_display_info_for_display (display);
1429 1441
1430 *nofree_ret = 0; 1442 *nofree_ret = 0;
1431 1443
@@ -1458,7 +1470,7 @@ lisp_data_to_selection_data (display, obj,
1458 *size_ret = 1; 1470 *size_ret = 1;
1459 *data_ret = (unsigned char *) xmalloc (sizeof (Atom) + 1); 1471 *data_ret = (unsigned char *) xmalloc (sizeof (Atom) + 1);
1460 (*data_ret) [sizeof (Atom)] = 0; 1472 (*data_ret) [sizeof (Atom)] = 0;
1461 (*(Atom **) data_ret) [0] = symbol_to_x_atom (display, obj); 1473 (*(Atom **) data_ret) [0] = symbol_to_x_atom (dpyinfo, display, obj);
1462 if (NILP (type)) type = QATOM; 1474 if (NILP (type)) type = QATOM;
1463 } 1475 }
1464 else if (INTEGERP (obj) 1476 else if (INTEGERP (obj)
@@ -1503,7 +1515,7 @@ lisp_data_to_selection_data (display, obj,
1503 for (i = 0; i < *size_ret; i++) 1515 for (i = 0; i < *size_ret; i++)
1504 if (SYMBOLP (XVECTOR (obj)->contents [i])) 1516 if (SYMBOLP (XVECTOR (obj)->contents [i]))
1505 (*(Atom **) data_ret) [i] 1517 (*(Atom **) data_ret) [i]
1506 = symbol_to_x_atom (display, XVECTOR (obj)->contents [i]); 1518 = symbol_to_x_atom (dpyinfo, display, XVECTOR (obj)->contents [i]);
1507 else 1519 else
1508 Fsignal (Qerror, /* Qselection_error */ 1520 Fsignal (Qerror, /* Qselection_error */
1509 Fcons (build_string 1521 Fcons (build_string
@@ -1530,9 +1542,11 @@ lisp_data_to_selection_data (display, obj,
1530 Fcons (pair, Qnil))); 1542 Fcons (pair, Qnil)));
1531 1543
1532 (*(Atom **) data_ret) [i * 2] 1544 (*(Atom **) data_ret) [i * 2]
1533 = symbol_to_x_atom (display, XVECTOR (pair)->contents [0]); 1545 = symbol_to_x_atom (dpyinfo, display,
1546 XVECTOR (pair)->contents [0]);
1534 (*(Atom **) data_ret) [(i * 2) + 1] 1547 (*(Atom **) data_ret) [(i * 2) + 1]
1535 = symbol_to_x_atom (display, XVECTOR (pair)->contents [1]); 1548 = symbol_to_x_atom (dpyinfo, display,
1549 XVECTOR (pair)->contents [1]);
1536 } 1550 }
1537 else 1551 else
1538 Fsignal (Qerror, 1552 Fsignal (Qerror,
@@ -1572,7 +1586,7 @@ lisp_data_to_selection_data (display, obj,
1572 Fcons (build_string ("unrecognised selection data"), 1586 Fcons (build_string ("unrecognised selection data"),
1573 Fcons (obj, Qnil))); 1587 Fcons (obj, Qnil)));
1574 1588
1575 *type_ret = symbol_to_x_atom (display, type); 1589 *type_ret = symbol_to_x_atom (dpyinfo, display, type);
1576} 1590}
1577 1591
1578static Lisp_Object 1592static Lisp_Object
@@ -1710,9 +1724,11 @@ Disowning it means there is no such selection.")
1710 Atom selection_atom; 1724 Atom selection_atom;
1711 XSelectionClearEvent event; 1725 XSelectionClearEvent event;
1712 Display *display; 1726 Display *display;
1727 struct x_display_info *dpyinfo;
1713 1728
1714 check_x (); 1729 check_x ();
1715 display = FRAME_X_DISPLAY (selected_frame); 1730 display = FRAME_X_DISPLAY (selected_frame);
1731 dpyinfo = FRAME_X_DISPLAY_INFO (selected_frame);
1716 CHECK_SYMBOL (selection, 0); 1732 CHECK_SYMBOL (selection, 0);
1717 if (NILP (time)) 1733 if (NILP (time))
1718 timestamp = last_event_timestamp; 1734 timestamp = last_event_timestamp;
@@ -1722,7 +1738,7 @@ Disowning it means there is no such selection.")
1722 if (NILP (assq_no_quit (selection, Vselection_alist))) 1738 if (NILP (assq_no_quit (selection, Vselection_alist)))
1723 return Qnil; /* Don't disown the selection when we're not the owner. */ 1739 return Qnil; /* Don't disown the selection when we're not the owner. */
1724 1740
1725 selection_atom = symbol_to_x_atom (display, selection); 1741 selection_atom = symbol_to_x_atom (dpyinfo, display, selection);
1726 1742
1727 BLOCK_INPUT; 1743 BLOCK_INPUT;
1728 XSetSelectionOwner (display, selection_atom, None, timestamp); 1744 XSetSelectionOwner (display, selection_atom, None, timestamp);
@@ -1805,7 +1821,8 @@ and t is the same as `SECONDARY'.)")
1805 return Qt; 1821 return Qt;
1806 if (EQ (selection, Qnil)) selection = QPRIMARY; 1822 if (EQ (selection, Qnil)) selection = QPRIMARY;
1807 if (EQ (selection, Qt)) selection = QSECONDARY; 1823 if (EQ (selection, Qt)) selection = QSECONDARY;
1808 atom = symbol_to_x_atom (dpy, selection); 1824 atom = symbol_to_x_atom (FRAME_X_DISPLAY_INFO (selected_frame),
1825 dpy, selection);
1809 if (atom == 0) 1826 if (atom == 0)
1810 return Qnil; 1827 return Qnil;
1811 BLOCK_INPUT; 1828 BLOCK_INPUT;
@@ -1869,12 +1886,14 @@ DEFUN ("x-get-cut-buffer-internal", Fx_get_cut_buffer_internal,
1869 unsigned long size; 1886 unsigned long size;
1870 Lisp_Object ret; 1887 Lisp_Object ret;
1871 Display *display; 1888 Display *display;
1889 struct x_display_info *dpyinfo;
1872 1890
1873 check_x (); 1891 check_x ();
1874 display = FRAME_X_DISPLAY (selected_frame); 1892 display = FRAME_X_DISPLAY (selected_frame);
1893 dpyinfo = FRAME_X_DISPLAY_INFO (selected_frame);
1875 window = RootWindow (display, 0); /* Cut buffers are on screen 0 */ 1894 window = RootWindow (display, 0); /* Cut buffers are on screen 0 */
1876 CHECK_CUT_BUFFER (buffer, 0); 1895 CHECK_CUT_BUFFER (buffer, 0);
1877 buffer_atom = symbol_to_x_atom (display, buffer); 1896 buffer_atom = symbol_to_x_atom (dpyinfo, display, buffer);
1878 1897
1879 x_get_window_property (display, window, buffer_atom, &data, &bytes, 1898 x_get_window_property (display, window, buffer_atom, &data, &bytes,
1880 &type, &format, &size, 0); 1899 &type, &format, &size, 0);
@@ -1883,7 +1902,7 @@ DEFUN ("x-get-cut-buffer-internal", Fx_get_cut_buffer_internal,
1883 if (format != 8 || type != XA_STRING) 1902 if (format != 8 || type != XA_STRING)
1884 Fsignal (Qerror, 1903 Fsignal (Qerror,
1885 Fcons (build_string ("cut buffer doesn't contain 8-bit data"), 1904 Fcons (build_string ("cut buffer doesn't contain 8-bit data"),
1886 Fcons (x_atom_to_symbol (display, type), 1905 Fcons (x_atom_to_symbol (dpyinfo, display, type),
1887 Fcons (make_number (format), Qnil)))); 1906 Fcons (make_number (format), Qnil))));
1888 1907
1889 ret = (bytes ? make_string ((char *) data, bytes) : Qnil); 1908 ret = (bytes ? make_string ((char *) data, bytes) : Qnil);
@@ -1916,7 +1935,8 @@ DEFUN ("x-store-cut-buffer-internal", Fx_store_cut_buffer_internal,
1916 1935
1917 CHECK_CUT_BUFFER (buffer, 0); 1936 CHECK_CUT_BUFFER (buffer, 0);
1918 CHECK_STRING (string, 0); 1937 CHECK_STRING (string, 0);
1919 buffer_atom = symbol_to_x_atom (display, buffer); 1938 buffer_atom = symbol_to_x_atom (FRAME_X_DISPLAY_INFO (selected_frame),
1939 display, buffer);
1920 data = (unsigned char *) XSTRING (string)->data; 1940 data = (unsigned char *) XSTRING (string)->data;
1921 bytes = XSTRING (string)->size; 1941 bytes = XSTRING (string)->size;
1922 bytes_remaining = bytes; 1942 bytes_remaining = bytes;
@@ -1984,26 +2004,6 @@ positive means move values forward, negative means backward.")
1984#endif 2004#endif
1985 2005
1986void 2006void
1987Xatoms_of_xselect ()
1988{
1989#define ATOM(x) XInternAtom (x_current_display, (x), False)
1990
1991 BLOCK_INPUT;
1992 /* Non-predefined atoms that we might end up using a lot */
1993 Xatom_CLIPBOARD = ATOM ("CLIPBOARD");
1994 Xatom_TIMESTAMP = ATOM ("TIMESTAMP");
1995 Xatom_TEXT = ATOM ("TEXT");
1996 Xatom_DELETE = ATOM ("DELETE");
1997 Xatom_MULTIPLE = ATOM ("MULTIPLE");
1998 Xatom_INCR = ATOM ("INCR");
1999 Xatom_EMACS_TMP = ATOM ("_EMACS_TMP_");
2000 Xatom_TARGETS = ATOM ("TARGETS");
2001 Xatom_NULL = ATOM ("NULL");
2002 Xatom_ATOM_PAIR = ATOM ("ATOM_PAIR");
2003 UNBLOCK_INPUT;
2004}
2005
2006void
2007syms_of_xselect () 2007syms_of_xselect ()
2008{ 2008{
2009 defsubr (&Sx_get_selection_internal); 2009 defsubr (&Sx_get_selection_internal);