aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-12-08 10:30:50 +0800
committerPo Lu2022-12-08 10:30:50 +0800
commit5d68cc99177569a661da0ac75bb7df1ec4098fda (patch)
tree211b1a5fc42b74ab7690c374290b28683f9b0890 /src
parent7ac9e57bedabcb260d9b73fed16a14bba2b377e9 (diff)
downloademacs-5d68cc99177569a661da0ac75bb7df1ec4098fda.tar.gz
emacs-5d68cc99177569a661da0ac75bb7df1ec4098fda.zip
Remove conversion_fail_tag from selection requests
* src/xselect.c (struct x_selection_request): Delete `conversion_fail_tag'. (x_push_current_selection_request, x_start_selection_transfer): Stop checking against conversion_fail_tag. (x_handle_selection_request): Adjust callers. (x_convert_selection): Remove arg `for_multiple'. Never link nonconvertible data onto frame->converted_selections.
Diffstat (limited to 'src')
-rw-r--r--src/xselect.c50
1 files changed, 12 insertions, 38 deletions
diff --git a/src/xselect.c b/src/xselect.c
index 121b17df1b0..191f0770337 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -16,7 +16,6 @@ GNU General Public License for more details.
16You should have received a copy of the GNU General Public License 16You should have received a copy of the GNU General Public License
17along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ 17along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
18 18
19
20/* Rewritten by jwz */ 19/* Rewritten by jwz */
21 20
22#include <config.h> 21#include <config.h>
@@ -44,7 +43,7 @@ struct prop_location;
44struct selection_data; 43struct selection_data;
45 44
46static void x_decline_selection_request (struct selection_input_event *); 45static void x_decline_selection_request (struct selection_input_event *);
47static bool x_convert_selection (Lisp_Object, Lisp_Object, Atom, bool, 46static bool x_convert_selection (Lisp_Object, Lisp_Object, Atom,
48 struct x_display_info *, bool); 47 struct x_display_info *, bool);
49static bool waiting_for_other_props_on_window (Display *, Window); 48static bool waiting_for_other_props_on_window (Display *, Window);
50static struct prop_location *expect_property_change (Display *, Window, 49static struct prop_location *expect_property_change (Display *, Window,
@@ -544,9 +543,6 @@ struct x_selection_request
544 /* Linked list of the above (in support of MULTIPLE targets). */ 543 /* Linked list of the above (in support of MULTIPLE targets). */
545 struct selection_data *converted_selections; 544 struct selection_data *converted_selections;
546 545
547 /* "Data" to send a requestor for a failed MULTIPLE subtarget. */
548 Atom conversion_fail_tag;
549
550 /* Whether or not conversion was successful. */ 546 /* Whether or not conversion was successful. */
551 bool converted; 547 bool converted;
552}; 548};
@@ -608,7 +604,6 @@ x_push_current_selection_request (struct selection_input_event *se,
608 frame->request = se; 604 frame->request = se;
609 frame->dpyinfo = dpyinfo; 605 frame->dpyinfo = dpyinfo;
610 frame->converted_selections = NULL; 606 frame->converted_selections = NULL;
611 frame->conversion_fail_tag = None;
612 607
613 selection_request_stack = frame; 608 selection_request_stack = frame;
614} 609}
@@ -839,10 +834,6 @@ x_start_selection_transfer (struct x_display_info *dpyinfo, Window requestor,
839 secs = timeout / 1000; 834 secs = timeout / 1000;
840 nsecs = (timeout % 1000) * 1000000; 835 nsecs = (timeout % 1000) * 1000000;
841 836
842 if ((Atom *) data->data
843 == &selection_request_stack->conversion_fail_tag)
844 return;
845
846 transfer = xzalloc (sizeof *transfer); 837 transfer = xzalloc (sizeof *transfer);
847 transfer->requestor = requestor; 838 transfer->requestor = requestor;
848 transfer->dpyinfo = dpyinfo; 839 transfer->dpyinfo = dpyinfo;
@@ -1135,7 +1126,9 @@ x_handle_selection_request (struct selection_input_event *event)
1135 ptrdiff_t j, nselections; 1126 ptrdiff_t j, nselections;
1136 struct selection_data cs; 1127 struct selection_data cs;
1137 1128
1138 if (property == None) goto DONE; 1129 if (property == None)
1130 goto DONE;
1131
1139 multprop 1132 multprop
1140 = x_get_window_property_as_lisp_data (dpyinfo, requestor, property, 1133 = x_get_window_property_as_lisp_data (dpyinfo, requestor, property,
1141 QMULTIPLE, selection, true); 1134 QMULTIPLE, selection, true);
@@ -1147,17 +1140,17 @@ x_handle_selection_request (struct selection_input_event *event)
1147 /* Perform conversions. This can signal. */ 1140 /* Perform conversions. This can signal. */
1148 for (j = 0; j < nselections; j++) 1141 for (j = 0; j < nselections; j++)
1149 { 1142 {
1150 Lisp_Object subtarget = AREF (multprop, 2*j); 1143 Lisp_Object subtarget = AREF (multprop, 2 * j);
1151 Atom subproperty = symbol_to_x_atom (dpyinfo, 1144 Atom subproperty = symbol_to_x_atom (dpyinfo,
1152 AREF (multprop, 2*j+1)); 1145 AREF (multprop, 2*j+1));
1153 bool subsuccess = false; 1146 bool subsuccess = false;
1154 1147
1155 if (subproperty != None) 1148 if (subproperty != None)
1156 subsuccess = x_convert_selection (selection_symbol, subtarget, 1149 subsuccess = x_convert_selection (selection_symbol, subtarget,
1157 subproperty, true, dpyinfo, 1150 subproperty, dpyinfo,
1158 use_alternate); 1151 use_alternate);
1159 if (!subsuccess) 1152 if (!subsuccess)
1160 ASET (multprop, 2*j+1, Qnil); 1153 ASET (multprop, 2 * j + 1, Qnil);
1161 } 1154 }
1162 1155
1163 /* Save conversion results */ 1156 /* Save conversion results */
@@ -1183,8 +1176,7 @@ x_handle_selection_request (struct selection_input_event *event)
1183 1176
1184 success = x_convert_selection (selection_symbol, 1177 success = x_convert_selection (selection_symbol,
1185 target_symbol, property, 1178 target_symbol, property,
1186 false, dpyinfo, 1179 dpyinfo, use_alternate);
1187 use_alternate);
1188 } 1180 }
1189 1181
1190 DONE: 1182 DONE:
@@ -1212,15 +1204,13 @@ x_handle_selection_request (struct selection_input_event *event)
1212 1204
1213/* Perform the requested selection conversion, and write the data to 1205/* Perform the requested selection conversion, and write the data to
1214 the converted_selections linked list, where it can be accessed by 1206 the converted_selections linked list, where it can be accessed by
1215 x_reply_selection_request. If FOR_MULTIPLE, write out 1207 x_reply_selection_request.
1216 the data even if conversion fails, using conversion_fail_tag.
1217 1208
1218 Return true if successful. */ 1209 Return true if successful. */
1219 1210
1220static bool 1211static bool
1221x_convert_selection (Lisp_Object selection_symbol, 1212x_convert_selection (Lisp_Object selection_symbol, Lisp_Object target_symbol,
1222 Lisp_Object target_symbol, Atom property, 1213 Atom property, struct x_display_info *dpyinfo,
1223 bool for_multiple, struct x_display_info *dpyinfo,
1224 bool use_alternate) 1214 bool use_alternate)
1225{ 1215{
1226 Lisp_Object lisp_selection; 1216 Lisp_Object lisp_selection;
@@ -1236,23 +1226,7 @@ x_convert_selection (Lisp_Object selection_symbol,
1236 /* A nil return value means we can't perform the conversion. */ 1226 /* A nil return value means we can't perform the conversion. */
1237 if (NILP (lisp_selection) 1227 if (NILP (lisp_selection)
1238 || (CONSP (lisp_selection) && NILP (XCDR (lisp_selection)))) 1228 || (CONSP (lisp_selection) && NILP (XCDR (lisp_selection))))
1239 { 1229 return false;
1240 if (for_multiple)
1241 {
1242 cs = xmalloc (sizeof *cs);
1243 cs->data = ((unsigned char *)
1244 &selection_request_stack->conversion_fail_tag);
1245 cs->size = 1;
1246 cs->string = Qnil;
1247 cs->format = 32;
1248 cs->type = XA_ATOM;
1249 cs->property = property;
1250 cs->next = frame->converted_selections;
1251 frame->converted_selections = cs;
1252 }
1253
1254 return false;
1255 }
1256 1230
1257 /* Otherwise, record the converted selection to binary. */ 1231 /* Otherwise, record the converted selection to binary. */
1258 cs = xmalloc (sizeof *cs); 1232 cs = xmalloc (sizeof *cs);