diff options
| author | Po Lu | 2022-06-21 09:35:07 +0800 |
|---|---|---|
| committer | Po Lu | 2022-06-21 09:35:07 +0800 |
| commit | 32a6d52d43b4c3452687a11b01dfb51ba111fee2 (patch) | |
| tree | 34d247115bb6e44525b78b4c88c09d50d3b20f72 /src | |
| parent | 256fac4886579ec164a1baf84f6059687296b1dd (diff) | |
| download | emacs-32a6d52d43b4c3452687a11b01dfb51ba111fee2.tar.gz emacs-32a6d52d43b4c3452687a11b01dfb51ba111fee2.zip | |
Move selection delayed message to a better location
* lisp/term/x-win.el (gui-backend-get-selection): Remove
`with-delayed-message' here.
* src/xselect.c (x_display_selection_waiting_message)
(x_cancel_atimer): New functions.
(x_get_foreign_selection): Add an atimer that displays the
message after a while.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xselect.c | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/src/xselect.c b/src/xselect.c index fcf0ee944e2..d90916c6b63 100644 --- a/src/xselect.c +++ b/src/xselect.c | |||
| @@ -36,6 +36,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 36 | #include "termhooks.h" | 36 | #include "termhooks.h" |
| 37 | #include "keyboard.h" | 37 | #include "keyboard.h" |
| 38 | #include "pdumper.h" | 38 | #include "pdumper.h" |
| 39 | #include "atimer.h" | ||
| 39 | 40 | ||
| 40 | #include <X11/Xproto.h> | 41 | #include <X11/Xproto.h> |
| 41 | 42 | ||
| @@ -1198,6 +1199,20 @@ x_handle_property_notify (const XPropertyEvent *event) | |||
| 1198 | } | 1199 | } |
| 1199 | } | 1200 | } |
| 1200 | 1201 | ||
| 1202 | static void | ||
| 1203 | x_display_selection_waiting_message (struct atimer *timer) | ||
| 1204 | { | ||
| 1205 | Lisp_Object val; | ||
| 1206 | |||
| 1207 | val = build_string ("Waiting for reply from selection owner..."); | ||
| 1208 | message3_nolog (val); | ||
| 1209 | } | ||
| 1210 | |||
| 1211 | static void | ||
| 1212 | x_cancel_atimer (void *atimer) | ||
| 1213 | { | ||
| 1214 | cancel_atimer (atimer); | ||
| 1215 | } | ||
| 1201 | 1216 | ||
| 1202 | 1217 | ||
| 1203 | /* Variables for communication with x_handle_selection_notify. */ | 1218 | /* Variables for communication with x_handle_selection_notify. */ |
| @@ -1223,9 +1238,14 @@ x_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type, | |||
| 1223 | Atom type_atom = (CONSP (target_type) | 1238 | Atom type_atom = (CONSP (target_type) |
| 1224 | ? symbol_to_x_atom (dpyinfo, XCAR (target_type)) | 1239 | ? symbol_to_x_atom (dpyinfo, XCAR (target_type)) |
| 1225 | : symbol_to_x_atom (dpyinfo, target_type)); | 1240 | : symbol_to_x_atom (dpyinfo, target_type)); |
| 1241 | struct atimer *delayed_message; | ||
| 1242 | struct timespec message_interval; | ||
| 1243 | specpdl_ref count; | ||
| 1244 | |||
| 1245 | count = SPECPDL_INDEX (); | ||
| 1226 | 1246 | ||
| 1227 | if (!FRAME_LIVE_P (f)) | 1247 | if (!FRAME_LIVE_P (f)) |
| 1228 | return Qnil; | 1248 | return unbind_to (count, Qnil); |
| 1229 | 1249 | ||
| 1230 | if (! NILP (time_stamp)) | 1250 | if (! NILP (time_stamp)) |
| 1231 | CONS_TO_INTEGER (time_stamp, Time, requestor_time); | 1251 | CONS_TO_INTEGER (time_stamp, Time, requestor_time); |
| @@ -1257,6 +1277,12 @@ x_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type, | |||
| 1257 | 1277 | ||
| 1258 | unblock_input (); | 1278 | unblock_input (); |
| 1259 | 1279 | ||
| 1280 | message_interval = make_timespec (1, 0); | ||
| 1281 | delayed_message = start_atimer (ATIMER_RELATIVE, message_interval, | ||
| 1282 | x_display_selection_waiting_message, | ||
| 1283 | NULL); | ||
| 1284 | record_unwind_protect_ptr (x_cancel_atimer, delayed_message); | ||
| 1285 | |||
| 1260 | /* This allows quits. Also, don't wait forever. */ | 1286 | /* This allows quits. Also, don't wait forever. */ |
| 1261 | intmax_t timeout = max (0, x_selection_timeout); | 1287 | intmax_t timeout = max (0, x_selection_timeout); |
| 1262 | intmax_t secs = timeout / 1000; | 1288 | intmax_t secs = timeout / 1000; |
| @@ -1288,13 +1314,16 @@ x_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type, | |||
| 1288 | if (NILP (XCAR (reading_selection_reply))) | 1314 | if (NILP (XCAR (reading_selection_reply))) |
| 1289 | error ("Timed out waiting for reply from selection owner"); | 1315 | error ("Timed out waiting for reply from selection owner"); |
| 1290 | if (EQ (XCAR (reading_selection_reply), Qlambda)) | 1316 | if (EQ (XCAR (reading_selection_reply), Qlambda)) |
| 1291 | return Qnil; | 1317 | return unbind_to (count, Qnil); |
| 1292 | 1318 | ||
| 1293 | /* Otherwise, the selection is waiting for us on the requested property. */ | 1319 | /* Otherwise, the selection is waiting for us on the requested property. */ |
| 1294 | return | 1320 | return unbind_to (count, |
| 1295 | x_get_window_property_as_lisp_data (dpyinfo, requestor_window, | 1321 | x_get_window_property_as_lisp_data (dpyinfo, |
| 1296 | target_property, target_type, | 1322 | requestor_window, |
| 1297 | selection_atom, false); | 1323 | target_property, |
| 1324 | target_type, | ||
| 1325 | selection_atom, | ||
| 1326 | false)); | ||
| 1298 | } | 1327 | } |
| 1299 | 1328 | ||
| 1300 | /* Subroutines of x_get_window_property_as_lisp_data */ | 1329 | /* Subroutines of x_get_window_property_as_lisp_data */ |