diff options
| author | Dmitry Antipov | 2014-07-18 15:04:37 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2014-07-18 15:04:37 +0400 |
| commit | 1a5db9eb9ebde75aa94e52c8eab8d07868759444 (patch) | |
| tree | 9eb145f20f68fcb3d3afeaad737cd05ea5609c74 /src | |
| parent | 32a608307c53bd8bb1e29015bc36438f0ff0c572 (diff) | |
| download | emacs-1a5db9eb9ebde75aa94e52c8eab8d07868759444.tar.gz emacs-1a5db9eb9ebde75aa94e52c8eab8d07868759444.zip | |
Prefer 'x_display_info *' to 'Display *' in X selection code.
This helps to avoid unneeded calls to x_display_info_for_display.
* xterm.h (struct selection_input_event): Record 'x_display_info *'
instead of 'Display *'.
(SELECTION_EVENT_DPYINFO): New macro.
(SELECTION_EVENT_DISPLAY): Now inline function to prohibit using
it as an lvalue. Mention this in comment.
* xterm.c (handle_one_xevent): Use SELECTION_EVENT_DPYINFO.
* xselect.c (x_get_window_property_as_lisp_data, x_atom_to_symbol)
(selection_data_to_lisp_data, receive_incremental_selection):
Convert to use 'x_display_info *'. Adjust users where appropriate.
(lisp_data_to_selection_data): Likewise. Also pass 'struct
selection data *' as last arg to not return values in args.
(unexpect_property_change): Use common removal technique.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 15 | ||||
| -rw-r--r-- | src/xselect.c | 159 | ||||
| -rw-r--r-- | src/xterm.c | 4 | ||||
| -rw-r--r-- | src/xterm.h | 12 |
4 files changed, 100 insertions, 90 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 01dc819480f..7d244db6b1d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -12,6 +12,21 @@ | |||
| 12 | * xterm.h (x_display_pixel_width, x_display_pixel_height): ... | 12 | * xterm.h (x_display_pixel_width, x_display_pixel_height): ... |
| 13 | inlined from here. | 13 | inlined from here. |
| 14 | 14 | ||
| 15 | Prefer 'x_display_info *' to 'Display *' in X selection code. | ||
| 16 | This helps to avoid unneeded calls to x_display_info_for_display. | ||
| 17 | * xterm.h (struct selection_input_event): Record 'x_display_info *' | ||
| 18 | instead of 'Display *'. | ||
| 19 | (SELECTION_EVENT_DPYINFO): New macro. | ||
| 20 | (SELECTION_EVENT_DISPLAY): Now inline function to prohibit using | ||
| 21 | it as an lvalue. Mention this in comment. | ||
| 22 | * xterm.c (handle_one_xevent): Use SELECTION_EVENT_DPYINFO. | ||
| 23 | * xselect.c (x_get_window_property_as_lisp_data, x_atom_to_symbol) | ||
| 24 | (selection_data_to_lisp_data, receive_incremental_selection): | ||
| 25 | Convert to use 'x_display_info *'. Adjust users where appropriate. | ||
| 26 | (lisp_data_to_selection_data): Likewise. Also pass 'struct | ||
| 27 | selection data *' as last arg to not return values in args. | ||
| 28 | (unexpect_property_change): Use common removal technique. | ||
| 29 | |||
| 15 | 2014-07-17 Dmitry Antipov <dmantipov@yandex.ru> | 30 | 2014-07-17 Dmitry Antipov <dmantipov@yandex.ru> |
| 16 | 31 | ||
| 17 | * print.c (print_preprocess): Adjust to match changed | 32 | * print.c (print_preprocess): Adjust to match changed |
diff --git a/src/xselect.c b/src/xselect.c index eb6f8f3b161..23310b0f867 100644 --- a/src/xselect.c +++ b/src/xselect.c | |||
| @@ -53,15 +53,14 @@ static struct prop_location *expect_property_change (Display *, Window, | |||
| 53 | Atom, int); | 53 | Atom, int); |
| 54 | static void unexpect_property_change (struct prop_location *); | 54 | static void unexpect_property_change (struct prop_location *); |
| 55 | static void wait_for_property_change (struct prop_location *); | 55 | static void wait_for_property_change (struct prop_location *); |
| 56 | static Lisp_Object x_get_window_property_as_lisp_data (Display *, | 56 | static Lisp_Object x_get_window_property_as_lisp_data (struct x_display_info *, |
| 57 | Window, Atom, | 57 | Window, Atom, |
| 58 | Lisp_Object, Atom); | 58 | Lisp_Object, Atom); |
| 59 | static Lisp_Object selection_data_to_lisp_data (Display *, | 59 | static Lisp_Object selection_data_to_lisp_data (struct x_display_info *, |
| 60 | const unsigned char *, | 60 | const unsigned char *, |
| 61 | ptrdiff_t, Atom, int); | 61 | ptrdiff_t, Atom, int); |
| 62 | static void lisp_data_to_selection_data (Display *, Lisp_Object, | 62 | static void lisp_data_to_selection_data (struct x_display_info *, Lisp_Object, |
| 63 | unsigned char **, Atom *, | 63 | struct selection_data *); |
| 64 | ptrdiff_t *, int *, int *); | ||
| 65 | 64 | ||
| 66 | /* Printing traces to stderr. */ | 65 | /* Printing traces to stderr. */ |
| 67 | 66 | ||
| @@ -245,9 +244,8 @@ symbol_to_x_atom (struct x_display_info *dpyinfo, Lisp_Object sym) | |||
| 245 | and calls to intern whenever possible. */ | 244 | and calls to intern whenever possible. */ |
| 246 | 245 | ||
| 247 | static Lisp_Object | 246 | static Lisp_Object |
| 248 | x_atom_to_symbol (Display *dpy, Atom atom) | 247 | x_atom_to_symbol (struct x_display_info *dpyinfo, Atom atom) |
| 249 | { | 248 | { |
| 250 | struct x_display_info *dpyinfo; | ||
| 251 | char *str; | 249 | char *str; |
| 252 | Lisp_Object val; | 250 | Lisp_Object val; |
| 253 | 251 | ||
| @@ -268,7 +266,6 @@ x_atom_to_symbol (Display *dpy, Atom atom) | |||
| 268 | return QATOM; | 266 | return QATOM; |
| 269 | } | 267 | } |
| 270 | 268 | ||
| 271 | dpyinfo = x_display_info_for_display (dpy); | ||
| 272 | if (dpyinfo == NULL) | 269 | if (dpyinfo == NULL) |
| 273 | return Qnil; | 270 | return Qnil; |
| 274 | if (atom == dpyinfo->Xatom_CLIPBOARD) | 271 | if (atom == dpyinfo->Xatom_CLIPBOARD) |
| @@ -295,7 +292,7 @@ x_atom_to_symbol (Display *dpy, Atom atom) | |||
| 295 | return QNULL; | 292 | return QNULL; |
| 296 | 293 | ||
| 297 | block_input (); | 294 | block_input (); |
| 298 | str = XGetAtomName (dpy, atom); | 295 | str = XGetAtomName (dpyinfo->display, atom); |
| 299 | unblock_input (); | 296 | unblock_input (); |
| 300 | TRACE1 ("XGetAtomName --> %s", str); | 297 | TRACE1 ("XGetAtomName --> %s", str); |
| 301 | if (! str) return Qnil; | 298 | if (! str) return Qnil; |
| @@ -750,12 +747,11 @@ x_handle_selection_request (struct input_event *event) | |||
| 750 | struct gcpro gcpro1, gcpro2; | 747 | struct gcpro gcpro1, gcpro2; |
| 751 | Time local_selection_time; | 748 | Time local_selection_time; |
| 752 | 749 | ||
| 753 | Display *display = SELECTION_EVENT_DISPLAY (event); | 750 | struct x_display_info *dpyinfo = SELECTION_EVENT_DPYINFO (event); |
| 754 | struct x_display_info *dpyinfo = x_display_info_for_display (display); | ||
| 755 | Atom selection = SELECTION_EVENT_SELECTION (event); | 751 | Atom selection = SELECTION_EVENT_SELECTION (event); |
| 756 | Lisp_Object selection_symbol = x_atom_to_symbol (display, selection); | 752 | Lisp_Object selection_symbol = x_atom_to_symbol (dpyinfo, selection); |
| 757 | Atom target = SELECTION_EVENT_TARGET (event); | 753 | Atom target = SELECTION_EVENT_TARGET (event); |
| 758 | Lisp_Object target_symbol = x_atom_to_symbol (display, target); | 754 | Lisp_Object target_symbol = x_atom_to_symbol (dpyinfo, target); |
| 759 | Atom property = SELECTION_EVENT_PROPERTY (event); | 755 | Atom property = SELECTION_EVENT_PROPERTY (event); |
| 760 | Lisp_Object local_selection_data; | 756 | Lisp_Object local_selection_data; |
| 761 | int success = 0; | 757 | int success = 0; |
| @@ -800,7 +796,7 @@ x_handle_selection_request (struct input_event *event) | |||
| 800 | 796 | ||
| 801 | if (property == None) goto DONE; | 797 | if (property == None) goto DONE; |
| 802 | multprop | 798 | multprop |
| 803 | = x_get_window_property_as_lisp_data (display, requestor, property, | 799 | = x_get_window_property_as_lisp_data (dpyinfo, requestor, property, |
| 804 | QMULTIPLE, selection); | 800 | QMULTIPLE, selection); |
| 805 | 801 | ||
| 806 | if (!VECTORP (multprop) || ASIZE (multprop) % 2) | 802 | if (!VECTORP (multprop) || ASIZE (multprop) % 2) |
| @@ -904,11 +900,7 @@ x_convert_selection (struct input_event *event, Lisp_Object selection_symbol, | |||
| 904 | cs->wait_object = NULL; | 900 | cs->wait_object = NULL; |
| 905 | cs->next = converted_selections; | 901 | cs->next = converted_selections; |
| 906 | converted_selections = cs; | 902 | converted_selections = cs; |
| 907 | lisp_data_to_selection_data (SELECTION_EVENT_DISPLAY (event), | 903 | lisp_data_to_selection_data (dpyinfo, lisp_selection, cs); |
| 908 | lisp_selection, | ||
| 909 | &(cs->data), &(cs->type), | ||
| 910 | &(cs->size), &(cs->format), | ||
| 911 | &(cs->nofree)); | ||
| 912 | UNGCPRO; | 904 | UNGCPRO; |
| 913 | return 1; | 905 | return 1; |
| 914 | } | 906 | } |
| @@ -920,20 +912,19 @@ x_convert_selection (struct input_event *event, Lisp_Object selection_symbol, | |||
| 920 | static void | 912 | static void |
| 921 | x_handle_selection_clear (struct input_event *event) | 913 | x_handle_selection_clear (struct input_event *event) |
| 922 | { | 914 | { |
| 923 | Display *display = SELECTION_EVENT_DISPLAY (event); | ||
| 924 | Atom selection = SELECTION_EVENT_SELECTION (event); | 915 | Atom selection = SELECTION_EVENT_SELECTION (event); |
| 925 | Time changed_owner_time = SELECTION_EVENT_TIME (event); | 916 | Time changed_owner_time = SELECTION_EVENT_TIME (event); |
| 926 | 917 | ||
| 927 | Lisp_Object selection_symbol, local_selection_data; | 918 | Lisp_Object selection_symbol, local_selection_data; |
| 928 | Time local_selection_time; | 919 | Time local_selection_time; |
| 929 | struct x_display_info *dpyinfo = x_display_info_for_display (display); | 920 | struct x_display_info *dpyinfo = SELECTION_EVENT_DPYINFO (event); |
| 930 | Lisp_Object Vselection_alist; | 921 | Lisp_Object Vselection_alist; |
| 931 | 922 | ||
| 932 | TRACE0 ("x_handle_selection_clear"); | 923 | TRACE0 ("x_handle_selection_clear"); |
| 933 | 924 | ||
| 934 | if (!dpyinfo) return; | 925 | if (!dpyinfo) return; |
| 935 | 926 | ||
| 936 | selection_symbol = x_atom_to_symbol (display, selection); | 927 | selection_symbol = x_atom_to_symbol (dpyinfo, selection); |
| 937 | local_selection_data = LOCAL_SELECTION (selection_symbol, dpyinfo); | 928 | local_selection_data = LOCAL_SELECTION (selection_symbol, dpyinfo); |
| 938 | 929 | ||
| 939 | /* Well, we already believe that we don't own it, so that's just fine. */ | 930 | /* Well, we already believe that we don't own it, so that's just fine. */ |
| @@ -1070,20 +1061,18 @@ expect_property_change (Display *display, Window window, | |||
| 1070 | static void | 1061 | static void |
| 1071 | unexpect_property_change (struct prop_location *location) | 1062 | unexpect_property_change (struct prop_location *location) |
| 1072 | { | 1063 | { |
| 1073 | struct prop_location *prev = 0, *rest = property_change_wait_list; | 1064 | struct prop_location *prop, **pprev = &property_change_wait_list; |
| 1074 | while (rest) | 1065 | |
| 1066 | for (prop = property_change_wait_list; prop; prop = *pprev) | ||
| 1075 | { | 1067 | { |
| 1076 | if (rest == location) | 1068 | if (prop == location) |
| 1077 | { | 1069 | { |
| 1078 | if (prev) | 1070 | *pprev = prop->next; |
| 1079 | prev->next = rest->next; | 1071 | xfree (prop); |
| 1080 | else | 1072 | break; |
| 1081 | property_change_wait_list = rest->next; | ||
| 1082 | xfree (rest); | ||
| 1083 | return; | ||
| 1084 | } | 1073 | } |
| 1085 | prev = rest; | 1074 | else |
| 1086 | rest = rest->next; | 1075 | pprev = &prop->next; |
| 1087 | } | 1076 | } |
| 1088 | } | 1077 | } |
| 1089 | 1078 | ||
| @@ -1245,7 +1234,7 @@ x_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type, | |||
| 1245 | 1234 | ||
| 1246 | /* Otherwise, the selection is waiting for us on the requested property. */ | 1235 | /* Otherwise, the selection is waiting for us on the requested property. */ |
| 1247 | return | 1236 | return |
| 1248 | x_get_window_property_as_lisp_data (display, requestor_window, | 1237 | x_get_window_property_as_lisp_data (dpyinfo, requestor_window, |
| 1249 | target_property, target_type, | 1238 | target_property, target_type, |
| 1250 | selection_atom); | 1239 | selection_atom); |
| 1251 | } | 1240 | } |
| @@ -1391,7 +1380,8 @@ x_get_window_property (Display *display, Window window, Atom property, | |||
| 1391 | /* Use xfree, not XFree, to free the data obtained with this function. */ | 1380 | /* Use xfree, not XFree, to free the data obtained with this function. */ |
| 1392 | 1381 | ||
| 1393 | static void | 1382 | static void |
| 1394 | receive_incremental_selection (Display *display, Window window, Atom property, | 1383 | receive_incremental_selection (struct x_display_info *dpyinfo, |
| 1384 | Window window, Atom property, | ||
| 1395 | Lisp_Object target_type, | 1385 | Lisp_Object target_type, |
| 1396 | unsigned int min_size_bytes, | 1386 | unsigned int min_size_bytes, |
| 1397 | unsigned char **data_ret, | 1387 | unsigned char **data_ret, |
| @@ -1401,6 +1391,8 @@ receive_incremental_selection (Display *display, Window window, Atom property, | |||
| 1401 | { | 1391 | { |
| 1402 | ptrdiff_t offset = 0; | 1392 | ptrdiff_t offset = 0; |
| 1403 | struct prop_location *wait_object; | 1393 | struct prop_location *wait_object; |
| 1394 | Display *display = dpyinfo->display; | ||
| 1395 | |||
| 1404 | if (min (PTRDIFF_MAX, SIZE_MAX) < min_size_bytes) | 1396 | if (min (PTRDIFF_MAX, SIZE_MAX) < min_size_bytes) |
| 1405 | memory_full (SIZE_MAX); | 1397 | memory_full (SIZE_MAX); |
| 1406 | *data_ret = xmalloc (min_size_bytes); | 1398 | *data_ret = xmalloc (min_size_bytes); |
| @@ -1419,10 +1411,10 @@ receive_incremental_selection (Display *display, Window window, Atom property, | |||
| 1419 | block_input (); | 1411 | block_input (); |
| 1420 | XSelectInput (display, window, STANDARD_EVENT_SET | PropertyChangeMask); | 1412 | XSelectInput (display, window, STANDARD_EVENT_SET | PropertyChangeMask); |
| 1421 | TRACE1 (" Delete property %s", | 1413 | TRACE1 (" Delete property %s", |
| 1422 | SDATA (SYMBOL_NAME (x_atom_to_symbol (display, property)))); | 1414 | SDATA (SYMBOL_NAME (x_atom_to_symbol (dpyinfo, property)))); |
| 1423 | XDeleteProperty (display, window, property); | 1415 | XDeleteProperty (display, window, property); |
| 1424 | TRACE1 (" Expect new value of property %s", | 1416 | TRACE1 (" Expect new value of property %s", |
| 1425 | SDATA (SYMBOL_NAME (x_atom_to_symbol (display, property)))); | 1417 | SDATA (SYMBOL_NAME (x_atom_to_symbol (dpyinfo, property)))); |
| 1426 | wait_object = expect_property_change (display, window, property, | 1418 | wait_object = expect_property_change (display, window, property, |
| 1427 | PropertyNewValue); | 1419 | PropertyNewValue); |
| 1428 | XFlush (display); | 1420 | XFlush (display); |
| @@ -1487,8 +1479,8 @@ receive_incremental_selection (Display *display, Window window, Atom property, | |||
| 1487 | if this fails. */ | 1479 | if this fails. */ |
| 1488 | 1480 | ||
| 1489 | static Lisp_Object | 1481 | static Lisp_Object |
| 1490 | x_get_window_property_as_lisp_data (Display *display, Window window, | 1482 | x_get_window_property_as_lisp_data (struct x_display_info *dpyinfo, |
| 1491 | Atom property, | 1483 | Window window, Atom property, |
| 1492 | Lisp_Object target_type, | 1484 | Lisp_Object target_type, |
| 1493 | Atom selection_atom) | 1485 | Atom selection_atom) |
| 1494 | { | 1486 | { |
| @@ -1498,7 +1490,7 @@ x_get_window_property_as_lisp_data (Display *display, Window window, | |||
| 1498 | unsigned char *data = 0; | 1490 | unsigned char *data = 0; |
| 1499 | ptrdiff_t bytes = 0; | 1491 | ptrdiff_t bytes = 0; |
| 1500 | Lisp_Object val; | 1492 | Lisp_Object val; |
| 1501 | struct x_display_info *dpyinfo = x_display_info_for_display (display); | 1493 | Display *display = dpyinfo->display; |
| 1502 | 1494 | ||
| 1503 | TRACE0 ("Reading selection data"); | 1495 | TRACE0 ("Reading selection data"); |
| 1504 | 1496 | ||
| @@ -1515,11 +1507,11 @@ x_get_window_property_as_lisp_data (Display *display, Window window, | |||
| 1515 | signal_error ("Selection owner couldn't convert", | 1507 | signal_error ("Selection owner couldn't convert", |
| 1516 | actual_type | 1508 | actual_type |
| 1517 | ? list2 (target_type, | 1509 | ? list2 (target_type, |
| 1518 | x_atom_to_symbol (display, actual_type)) | 1510 | x_atom_to_symbol (dpyinfo, actual_type)) |
| 1519 | : target_type); | 1511 | : target_type); |
| 1520 | else | 1512 | else |
| 1521 | signal_error ("No selection", | 1513 | signal_error ("No selection", |
| 1522 | x_atom_to_symbol (display, selection_atom)); | 1514 | x_atom_to_symbol (dpyinfo, selection_atom)); |
| 1523 | } | 1515 | } |
| 1524 | 1516 | ||
| 1525 | if (actual_type == dpyinfo->Xatom_INCR) | 1517 | if (actual_type == dpyinfo->Xatom_INCR) |
| @@ -1532,7 +1524,7 @@ x_get_window_property_as_lisp_data (Display *display, Window window, | |||
| 1532 | calls xmalloc itself. */ | 1524 | calls xmalloc itself. */ |
| 1533 | xfree (data); | 1525 | xfree (data); |
| 1534 | unblock_input (); | 1526 | unblock_input (); |
| 1535 | receive_incremental_selection (display, window, property, target_type, | 1527 | receive_incremental_selection (dpyinfo, window, property, target_type, |
| 1536 | min_size_bytes, &data, &bytes, | 1528 | min_size_bytes, &data, &bytes, |
| 1537 | &actual_type, &actual_format, | 1529 | &actual_type, &actual_format, |
| 1538 | &actual_size); | 1530 | &actual_size); |
| @@ -1546,7 +1538,7 @@ x_get_window_property_as_lisp_data (Display *display, Window window, | |||
| 1546 | 1538 | ||
| 1547 | /* It's been read. Now convert it to a lisp object in some semi-rational | 1539 | /* It's been read. Now convert it to a lisp object in some semi-rational |
| 1548 | manner. */ | 1540 | manner. */ |
| 1549 | val = selection_data_to_lisp_data (display, data, bytes, | 1541 | val = selection_data_to_lisp_data (dpyinfo, data, bytes, |
| 1550 | actual_type, actual_format); | 1542 | actual_type, actual_format); |
| 1551 | 1543 | ||
| 1552 | /* Use xfree, not XFree, because x_get_window_property | 1544 | /* Use xfree, not XFree, because x_get_window_property |
| @@ -1587,11 +1579,10 @@ x_get_window_property_as_lisp_data (Display *display, Window window, | |||
| 1587 | 1579 | ||
| 1588 | 1580 | ||
| 1589 | static Lisp_Object | 1581 | static Lisp_Object |
| 1590 | selection_data_to_lisp_data (Display *display, const unsigned char *data, | 1582 | selection_data_to_lisp_data (struct x_display_info *dpyinfo, |
| 1583 | const unsigned char *data, | ||
| 1591 | ptrdiff_t size, Atom type, int format) | 1584 | ptrdiff_t size, Atom type, int format) |
| 1592 | { | 1585 | { |
| 1593 | struct x_display_info *dpyinfo = x_display_info_for_display (display); | ||
| 1594 | |||
| 1595 | if (type == dpyinfo->Xatom_NULL) | 1586 | if (type == dpyinfo->Xatom_NULL) |
| 1596 | return QNULL; | 1587 | return QNULL; |
| 1597 | 1588 | ||
| @@ -1629,13 +1620,13 @@ selection_data_to_lisp_data (Display *display, const unsigned char *data, | |||
| 1629 | int *idata = (int *) data; | 1620 | int *idata = (int *) data; |
| 1630 | 1621 | ||
| 1631 | if (size == sizeof (int)) | 1622 | if (size == sizeof (int)) |
| 1632 | return x_atom_to_symbol (display, (Atom) idata[0]); | 1623 | return x_atom_to_symbol (dpyinfo, (Atom) idata[0]); |
| 1633 | else | 1624 | else |
| 1634 | { | 1625 | { |
| 1635 | Lisp_Object v = make_uninit_vector (size / sizeof (int)); | 1626 | Lisp_Object v = make_uninit_vector (size / sizeof (int)); |
| 1636 | 1627 | ||
| 1637 | for (i = 0; i < size / sizeof (int); i++) | 1628 | for (i = 0; i < size / sizeof (int); i++) |
| 1638 | ASET (v, i, x_atom_to_symbol (display, (Atom) idata[i])); | 1629 | ASET (v, i, x_atom_to_symbol (dpyinfo, (Atom) idata[i])); |
| 1639 | return v; | 1630 | return v; |
| 1640 | } | 1631 | } |
| 1641 | } | 1632 | } |
| @@ -1697,15 +1688,13 @@ cons_to_x_long (Lisp_Object obj) | |||
| 1697 | /* Use xfree, not XFree, to free the data obtained with this function. */ | 1688 | /* Use xfree, not XFree, to free the data obtained with this function. */ |
| 1698 | 1689 | ||
| 1699 | static void | 1690 | static void |
| 1700 | lisp_data_to_selection_data (Display *display, Lisp_Object obj, | 1691 | lisp_data_to_selection_data (struct x_display_info *dpyinfo, |
| 1701 | unsigned char **data_ret, Atom *type_ret, | 1692 | Lisp_Object obj, struct selection_data *cs) |
| 1702 | ptrdiff_t *size_ret, | ||
| 1703 | int *format_ret, int *nofree_ret) | ||
| 1704 | { | 1693 | { |
| 1705 | Lisp_Object type = Qnil; | 1694 | Lisp_Object type = Qnil; |
| 1706 | struct x_display_info *dpyinfo = x_display_info_for_display (display); | ||
| 1707 | 1695 | ||
| 1708 | *nofree_ret = 0; | 1696 | eassert (cs != NULL); |
| 1697 | cs->nofree = 0; | ||
| 1709 | 1698 | ||
| 1710 | if (CONSP (obj) && SYMBOLP (XCAR (obj))) | 1699 | if (CONSP (obj) && SYMBOLP (XCAR (obj))) |
| 1711 | { | 1700 | { |
| @@ -1717,9 +1706,9 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj, | |||
| 1717 | 1706 | ||
| 1718 | if (EQ (obj, QNULL) || (EQ (type, QNULL))) | 1707 | if (EQ (obj, QNULL) || (EQ (type, QNULL))) |
| 1719 | { /* This is not the same as declining */ | 1708 | { /* This is not the same as declining */ |
| 1720 | *format_ret = 32; | 1709 | cs->format = 32; |
| 1721 | *size_ret = 0; | 1710 | cs->size = 0; |
| 1722 | *data_ret = 0; | 1711 | cs->data = NULL; |
| 1723 | type = QNULL; | 1712 | type = QNULL; |
| 1724 | } | 1713 | } |
| 1725 | else if (STRINGP (obj)) | 1714 | else if (STRINGP (obj)) |
| @@ -1729,19 +1718,19 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj, | |||
| 1729 | signal_error ("Non-ASCII string must be encoded in advance", obj); | 1718 | signal_error ("Non-ASCII string must be encoded in advance", obj); |
| 1730 | if (NILP (type)) | 1719 | if (NILP (type)) |
| 1731 | type = QSTRING; | 1720 | type = QSTRING; |
| 1732 | *format_ret = 8; | 1721 | cs->format = 8; |
| 1733 | *size_ret = SBYTES (obj); | 1722 | cs->size = SBYTES (obj); |
| 1734 | *data_ret = SDATA (obj); | 1723 | cs->data = SDATA (obj); |
| 1735 | *nofree_ret = 1; | 1724 | cs->nofree = 1; |
| 1736 | } | 1725 | } |
| 1737 | else if (SYMBOLP (obj)) | 1726 | else if (SYMBOLP (obj)) |
| 1738 | { | 1727 | { |
| 1739 | void *data = xmalloc (sizeof (Atom) + 1); | 1728 | void *data = xmalloc (sizeof (Atom) + 1); |
| 1740 | Atom *x_atom_ptr = data; | 1729 | Atom *x_atom_ptr = data; |
| 1741 | *data_ret = data; | 1730 | cs->data = data; |
| 1742 | *format_ret = 32; | 1731 | cs->format = 32; |
| 1743 | *size_ret = 1; | 1732 | cs->size = 1; |
| 1744 | (*data_ret) [sizeof (Atom)] = 0; | 1733 | cs->data[sizeof (Atom)] = 0; |
| 1745 | *x_atom_ptr = symbol_to_x_atom (dpyinfo, obj); | 1734 | *x_atom_ptr = symbol_to_x_atom (dpyinfo, obj); |
| 1746 | if (NILP (type)) type = QATOM; | 1735 | if (NILP (type)) type = QATOM; |
| 1747 | } | 1736 | } |
| @@ -1749,10 +1738,10 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj, | |||
| 1749 | { | 1738 | { |
| 1750 | void *data = xmalloc (sizeof (short) + 1); | 1739 | void *data = xmalloc (sizeof (short) + 1); |
| 1751 | short *short_ptr = data; | 1740 | short *short_ptr = data; |
| 1752 | *data_ret = data; | 1741 | cs->data = data; |
| 1753 | *format_ret = 16; | 1742 | cs->format = 16; |
| 1754 | *size_ret = 1; | 1743 | cs->size = 1; |
| 1755 | (*data_ret) [sizeof (short)] = 0; | 1744 | cs->data[sizeof (short)] = 0; |
| 1756 | *short_ptr = XINT (obj); | 1745 | *short_ptr = XINT (obj); |
| 1757 | if (NILP (type)) type = QINTEGER; | 1746 | if (NILP (type)) type = QINTEGER; |
| 1758 | } | 1747 | } |
| @@ -1764,10 +1753,10 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj, | |||
| 1764 | { | 1753 | { |
| 1765 | void *data = xmalloc (sizeof (unsigned long) + 1); | 1754 | void *data = xmalloc (sizeof (unsigned long) + 1); |
| 1766 | unsigned long *x_long_ptr = data; | 1755 | unsigned long *x_long_ptr = data; |
| 1767 | *data_ret = data; | 1756 | cs->data = data; |
| 1768 | *format_ret = 32; | 1757 | cs->format = 32; |
| 1769 | *size_ret = 1; | 1758 | cs->size = 1; |
| 1770 | (*data_ret) [sizeof (unsigned long)] = 0; | 1759 | cs->data[sizeof (unsigned long)] = 0; |
| 1771 | *x_long_ptr = cons_to_x_long (obj); | 1760 | *x_long_ptr = cons_to_x_long (obj); |
| 1772 | if (NILP (type)) type = QINTEGER; | 1761 | if (NILP (type)) type = QINTEGER; |
| 1773 | } | 1762 | } |
| @@ -1790,10 +1779,10 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj, | |||
| 1790 | if (!SYMBOLP (AREF (obj, i))) | 1779 | if (!SYMBOLP (AREF (obj, i))) |
| 1791 | signal_error ("All elements of selection vector must have same type", obj); | 1780 | signal_error ("All elements of selection vector must have same type", obj); |
| 1792 | 1781 | ||
| 1793 | *data_ret = data = xnmalloc (size, sizeof *x_atoms); | 1782 | cs->data = data = xnmalloc (size, sizeof *x_atoms); |
| 1794 | x_atoms = data; | 1783 | x_atoms = data; |
| 1795 | *format_ret = 32; | 1784 | cs->format = 32; |
| 1796 | *size_ret = size; | 1785 | cs->size = size; |
| 1797 | for (i = 0; i < size; i++) | 1786 | for (i = 0; i < size; i++) |
| 1798 | x_atoms[i] = symbol_to_x_atom (dpyinfo, AREF (obj, i)); | 1787 | x_atoms[i] = symbol_to_x_atom (dpyinfo, AREF (obj, i)); |
| 1799 | } | 1788 | } |
| @@ -1819,11 +1808,11 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj, | |||
| 1819 | break; | 1808 | break; |
| 1820 | } | 1809 | } |
| 1821 | } | 1810 | } |
| 1822 | *data_ret = data = xnmalloc (size, data_size); | 1811 | cs->data = data = xnmalloc (size, data_size); |
| 1823 | x_atoms = data; | 1812 | x_atoms = data; |
| 1824 | shorts = data; | 1813 | shorts = data; |
| 1825 | *format_ret = format; | 1814 | cs->format = format; |
| 1826 | *size_ret = size; | 1815 | cs->size = size; |
| 1827 | for (i = 0; i < size; i++) | 1816 | for (i = 0; i < size; i++) |
| 1828 | { | 1817 | { |
| 1829 | if (format == 32) | 1818 | if (format == 32) |
| @@ -1836,7 +1825,7 @@ lisp_data_to_selection_data (Display *display, Lisp_Object obj, | |||
| 1836 | else | 1825 | else |
| 1837 | signal_error (/* Qselection_error */ "Unrecognized selection data", obj); | 1826 | signal_error (/* Qselection_error */ "Unrecognized selection data", obj); |
| 1838 | 1827 | ||
| 1839 | *type_ret = symbol_to_x_atom (dpyinfo, type); | 1828 | cs->type = symbol_to_x_atom (dpyinfo, type); |
| 1840 | } | 1829 | } |
| 1841 | 1830 | ||
| 1842 | static Lisp_Object | 1831 | static Lisp_Object |
| @@ -2069,7 +2058,7 @@ On MS-DOS, all this does is return non-nil if we own the selection. */) | |||
| 2069 | the selection owner to None. The NCD server does, the MIT Sun4 server | 2058 | the selection owner to None. The NCD server does, the MIT Sun4 server |
| 2070 | doesn't. So we synthesize one; this means we might get two, but | 2059 | doesn't. So we synthesize one; this means we might get two, but |
| 2071 | that's ok, because the second one won't have any effect. */ | 2060 | that's ok, because the second one won't have any effect. */ |
| 2072 | SELECTION_EVENT_DISPLAY (&event.sie) = dpyinfo->display; | 2061 | SELECTION_EVENT_DPYINFO (&event.sie) = dpyinfo; |
| 2073 | SELECTION_EVENT_SELECTION (&event.sie) = selection_atom; | 2062 | SELECTION_EVENT_SELECTION (&event.sie) = selection_atom; |
| 2074 | SELECTION_EVENT_TIME (&event.sie) = timestamp; | 2063 | SELECTION_EVENT_TIME (&event.sie) = timestamp; |
| 2075 | x_handle_selection_clear (&event.ie); | 2064 | x_handle_selection_clear (&event.ie); |
| @@ -2361,8 +2350,8 @@ x_property_data_to_lisp (struct frame *f, const unsigned char *data, | |||
| 2361 | ptrdiff_t format_bytes = format >> 3; | 2350 | ptrdiff_t format_bytes = format >> 3; |
| 2362 | if (PTRDIFF_MAX / format_bytes < size) | 2351 | if (PTRDIFF_MAX / format_bytes < size) |
| 2363 | memory_full (SIZE_MAX); | 2352 | memory_full (SIZE_MAX); |
| 2364 | return selection_data_to_lisp_data (FRAME_X_DISPLAY (f), | 2353 | return selection_data_to_lisp_data (FRAME_DISPLAY_INFO (f), data, |
| 2365 | data, size * format_bytes, type, format); | 2354 | size * format_bytes, type, format); |
| 2366 | } | 2355 | } |
| 2367 | 2356 | ||
| 2368 | DEFUN ("x-get-atom-name", Fx_get_atom_name, | 2357 | DEFUN ("x-get-atom-name", Fx_get_atom_name, |
| @@ -2474,7 +2463,7 @@ x_handle_dnd_message (struct frame *f, const XClientMessageEvent *event, | |||
| 2474 | } | 2463 | } |
| 2475 | 2464 | ||
| 2476 | vec = Fmake_vector (make_number (4), Qnil); | 2465 | vec = Fmake_vector (make_number (4), Qnil); |
| 2477 | ASET (vec, 0, SYMBOL_NAME (x_atom_to_symbol (FRAME_X_DISPLAY (f), | 2466 | ASET (vec, 0, SYMBOL_NAME (x_atom_to_symbol (FRAME_DISPLAY_INFO (f), |
| 2478 | event->message_type))); | 2467 | event->message_type))); |
| 2479 | ASET (vec, 1, frame); | 2468 | ASET (vec, 1, frame); |
| 2480 | ASET (vec, 2, make_number (event->format)); | 2469 | ASET (vec, 2, make_number (event->format)); |
diff --git a/src/xterm.c b/src/xterm.c index 1d2ae196355..22a24864c9d 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -5966,7 +5966,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 5966 | const XSelectionClearEvent *eventp = &event->xselectionclear; | 5966 | const XSelectionClearEvent *eventp = &event->xselectionclear; |
| 5967 | 5967 | ||
| 5968 | inev.ie.kind = SELECTION_CLEAR_EVENT; | 5968 | inev.ie.kind = SELECTION_CLEAR_EVENT; |
| 5969 | SELECTION_EVENT_DISPLAY (&inev.sie) = eventp->display; | 5969 | SELECTION_EVENT_DPYINFO (&inev.sie) = dpyinfo; |
| 5970 | SELECTION_EVENT_SELECTION (&inev.sie) = eventp->selection; | 5970 | SELECTION_EVENT_SELECTION (&inev.sie) = eventp->selection; |
| 5971 | SELECTION_EVENT_TIME (&inev.sie) = eventp->time; | 5971 | SELECTION_EVENT_TIME (&inev.sie) = eventp->time; |
| 5972 | } | 5972 | } |
| @@ -5982,7 +5982,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 5982 | const XSelectionRequestEvent *eventp = &event->xselectionrequest; | 5982 | const XSelectionRequestEvent *eventp = &event->xselectionrequest; |
| 5983 | 5983 | ||
| 5984 | inev.ie.kind = SELECTION_REQUEST_EVENT; | 5984 | inev.ie.kind = SELECTION_REQUEST_EVENT; |
| 5985 | SELECTION_EVENT_DISPLAY (&inev.sie) = eventp->display; | 5985 | SELECTION_EVENT_DPYINFO (&inev.sie) = dpyinfo; |
| 5986 | SELECTION_EVENT_REQUESTOR (&inev.sie) = eventp->requestor; | 5986 | SELECTION_EVENT_REQUESTOR (&inev.sie) = eventp->requestor; |
| 5987 | SELECTION_EVENT_SELECTION (&inev.sie) = eventp->selection; | 5987 | SELECTION_EVENT_SELECTION (&inev.sie) = eventp->selection; |
| 5988 | SELECTION_EVENT_TARGET (&inev.sie) = eventp->target; | 5988 | SELECTION_EVENT_TARGET (&inev.sie) = eventp->target; |
diff --git a/src/xterm.h b/src/xterm.h index 243deb5b72d..0de9c99ab8f 100644 --- a/src/xterm.h +++ b/src/xterm.h | |||
| @@ -892,15 +892,21 @@ struct scroll_bar | |||
| 892 | struct selection_input_event | 892 | struct selection_input_event |
| 893 | { | 893 | { |
| 894 | int kind; | 894 | int kind; |
| 895 | Display *display; | 895 | struct x_display_info *dpyinfo; |
| 896 | /* We spell it with an "o" here because X does. */ | 896 | /* We spell it with an "o" here because X does. */ |
| 897 | Window requestor; | 897 | Window requestor; |
| 898 | Atom selection, target, property; | 898 | Atom selection, target, property; |
| 899 | Time time; | 899 | Time time; |
| 900 | }; | 900 | }; |
| 901 | 901 | ||
| 902 | #define SELECTION_EVENT_DISPLAY(eventp) \ | 902 | /* Unlike macros below, this can't be used as an lvalue. */ |
| 903 | (((struct selection_input_event *) (eventp))->display) | 903 | INLINE Display * |
| 904 | SELECTION_EVENT_DISPLAY (struct input_event *ev) | ||
| 905 | { | ||
| 906 | return ((struct selection_input_event *) ev)->dpyinfo->display; | ||
| 907 | } | ||
| 908 | #define SELECTION_EVENT_DPYINFO(eventp) \ | ||
| 909 | (((struct selection_input_event *) (eventp))->dpyinfo) | ||
| 904 | /* We spell it with an "o" here because X does. */ | 910 | /* We spell it with an "o" here because X does. */ |
| 905 | #define SELECTION_EVENT_REQUESTOR(eventp) \ | 911 | #define SELECTION_EVENT_REQUESTOR(eventp) \ |
| 906 | (((struct selection_input_event *) (eventp))->requestor) | 912 | (((struct selection_input_event *) (eventp))->requestor) |