aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-05-30 10:36:43 +0800
committerPo Lu2022-05-30 10:36:43 +0800
commit48ef8ab15f0e884ac97736d1d24af7eecf9313cc (patch)
tree2277d827afa3f7996802c44125b43b22e5ef80e5 /src
parent5b770b60f4f9d7d157774b999b0574aee133e7cb (diff)
downloademacs-48ef8ab15f0e884ac97736d1d24af7eecf9313cc.tar.gz
emacs-48ef8ab15f0e884ac97736d1d24af7eecf9313cc.zip
Try to implement `dnd-indicate-insertion-point' on macOS
* lisp/term/ns-win.el (ns-handle-drag-motion): New function. * src/nsterm.m ([EmacsView draggingUpdated:]): Call that function instead. (syms_of_nsterm): Clean up old style defvars and add new defvar for the DND drag function.
Diffstat (limited to 'src')
-rw-r--r--src/nsterm.m179
1 files changed, 103 insertions, 76 deletions
diff --git a/src/nsterm.m b/src/nsterm.m
index 79e30d6ff91..176ce7d5bb2 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -8596,12 +8596,18 @@ ns_create_font_panel_buttons (id target, SEL select, SEL cancel_action)
8596 8596
8597- (NSDragOperation) draggingUpdated: (id <NSDraggingInfo>) sender 8597- (NSDragOperation) draggingUpdated: (id <NSDraggingInfo>) sender
8598{ 8598{
8599#ifdef NS_IMPL_GNUSTEP
8599 struct input_event ie; 8600 struct input_event ie;
8601#else
8602 Lisp_Object frame;
8603#endif
8600 NSPoint position; 8604 NSPoint position;
8601 int x, y; 8605 int x, y;
8602 8606
8607#ifdef NS_IMPL_GNUSTEP
8603 EVENT_INIT (ie); 8608 EVENT_INIT (ie);
8604 ie.kind = DRAG_N_DROP_EVENT; 8609 ie.kind = DRAG_N_DROP_EVENT;
8610#endif
8605 8611
8606 /* Get rid of mouse face. */ 8612 /* Get rid of mouse face. */
8607 [self mouseExited: [[self window] currentEvent]]; 8613 [self mouseExited: [[self window] currentEvent]];
@@ -8611,6 +8617,7 @@ ns_create_font_panel_buttons (id target, SEL select, SEL cancel_action)
8611 x = lrint (position.x); 8617 x = lrint (position.x);
8612 y = lrint (position.y); 8618 y = lrint (position.y);
8613 8619
8620#ifdef NS_IMPL_GNUSTEP
8614 XSETINT (ie.x, x); 8621 XSETINT (ie.x, x);
8615 XSETINT (ie.y, y); 8622 XSETINT (ie.y, y);
8616 XSETFRAME (ie.frame_or_window, emacsframe); 8623 XSETFRAME (ie.frame_or_window, emacsframe);
@@ -8618,6 +8625,15 @@ ns_create_font_panel_buttons (id target, SEL select, SEL cancel_action)
8618 ie.modifiers = 0; 8625 ie.modifiers = 0;
8619 8626
8620 kbd_buffer_store_event (&ie); 8627 kbd_buffer_store_event (&ie);
8628#else
8629 /* Input events won't be processed until the drop happens on macOS,
8630 so call this function instead. */
8631 XSETFRAME (frame, emacsframe);
8632
8633 safe_call (4, Vns_drag_motion_function, frame,
8634 make_fixnum (x), make_fixnum (y));
8635#endif
8636
8621 return NSDragOperationGeneric; 8637 return NSDragOperationGeneric;
8622} 8638}
8623 8639
@@ -10490,6 +10506,7 @@ syms_of_nsterm (void)
10490 DEFSYM (Qns_drag_operation_copy, "ns-drag-operation-copy"); 10506 DEFSYM (Qns_drag_operation_copy, "ns-drag-operation-copy");
10491 DEFSYM (Qns_drag_operation_link, "ns-drag-operation-link"); 10507 DEFSYM (Qns_drag_operation_link, "ns-drag-operation-link");
10492 DEFSYM (Qns_drag_operation_generic, "ns-drag-operation-generic"); 10508 DEFSYM (Qns_drag_operation_generic, "ns-drag-operation-generic");
10509 DEFSYM (Qns_handle_drag_motion, "ns-handle-drag-motion");
10493 10510
10494 Fput (Qalt, Qmodifier_value, make_fixnum (alt_modifier)); 10511 Fput (Qalt, Qmodifier_value, make_fixnum (alt_modifier));
10495 Fput (Qhyper, Qmodifier_value, make_fixnum (hyper_modifier)); 10512 Fput (Qhyper, Qmodifier_value, make_fixnum (hyper_modifier));
@@ -10497,117 +10514,117 @@ syms_of_nsterm (void)
10497 Fput (Qsuper, Qmodifier_value, make_fixnum (super_modifier)); 10514 Fput (Qsuper, Qmodifier_value, make_fixnum (super_modifier));
10498 Fput (Qcontrol, Qmodifier_value, make_fixnum (ctrl_modifier)); 10515 Fput (Qcontrol, Qmodifier_value, make_fixnum (ctrl_modifier));
10499 10516
10500 DEFVAR_LISP ("ns-input-file", ns_input_file, 10517 DEFVAR_LISP ("ns-input-font", ns_input_font,
10501 "The file specified in the last NS event."); 10518 doc: /* The font specified in the last NS event. */);
10502 ns_input_file =Qnil; 10519 ns_input_font = Qnil;
10503 10520
10504 DEFVAR_LISP ("ns-working-text", ns_working_text, 10521 DEFVAR_LISP ("ns-input-fontsize", ns_input_fontsize,
10505 "String for visualizing working composition sequence."); 10522 doc: /* The fontsize specified in the last NS event. */);
10506 ns_working_text =Qnil; 10523 ns_input_fontsize = Qnil;
10507 10524
10508 DEFVAR_LISP ("ns-input-font", ns_input_font, 10525 DEFVAR_LISP ("ns-input-line", ns_input_line,
10509 "The font specified in the last NS event."); 10526 doc: /* The line specified in the last NS event. */);
10510 ns_input_font =Qnil; 10527 ns_input_line = Qnil;
10511 10528
10512 DEFVAR_LISP ("ns-input-fontsize", ns_input_fontsize, 10529 DEFVAR_LISP ("ns-input-spi-name", ns_input_spi_name,
10513 "The fontsize specified in the last NS event."); 10530 doc: /* The service name specified in the last NS event. */);
10514 ns_input_fontsize =Qnil; 10531 ns_input_spi_name = Qnil;
10515 10532
10516 DEFVAR_LISP ("ns-input-line", ns_input_line, 10533 DEFVAR_LISP ("ns-input-spi-arg", ns_input_spi_arg,
10517 "The line specified in the last NS event."); 10534 doc: /* The service argument specified in the last NS event. */);
10518 ns_input_line =Qnil; 10535 ns_input_spi_arg = Qnil;
10519 10536
10520 DEFVAR_LISP ("ns-input-spi-name", ns_input_spi_name, 10537 DEFVAR_LISP ("ns-input-file", ns_input_file,
10521 "The service name specified in the last NS event."); 10538 doc: /* The file specified in the last NS event. */);
10522 ns_input_spi_name =Qnil; 10539 ns_input_file = Qnil;
10523 10540
10524 DEFVAR_LISP ("ns-input-spi-arg", ns_input_spi_arg, 10541 DEFVAR_LISP ("ns-working-text", ns_working_text,
10525 "The service argument specified in the last NS event."); 10542 doc: /* String for visualizing working composition sequence. */);
10526 ns_input_spi_arg =Qnil; 10543 ns_working_text = Qnil;
10527 10544
10528 DEFVAR_LISP ("ns-alternate-modifier", ns_alternate_modifier, 10545 DEFVAR_LISP ("ns-alternate-modifier", ns_alternate_modifier,
10529 "This variable describes the behavior of the alternate or option key.\n\ 10546 doc: /* This variable describes the behavior of the alternate or option key.
10530Either SYMBOL, describing the behavior for any event,\n\ 10547Either SYMBOL, describing the behavior for any event,
10531or (:ordinary SYMBOL :function SYMBOL :mouse SYMBOL), describing behavior\n\ 10548or (:ordinary SYMBOL :function SYMBOL :mouse SYMBOL), describing behavior
10532separately for ordinary keys, function keys, and mouse events.\n\ 10549separately for ordinary keys, function keys, and mouse events.
10533\n\ 10550
10534Each SYMBOL is `control', `meta', `alt', `super', `hyper' or `none'.\n\ 10551Each SYMBOL is `control', `meta', `alt', `super', `hyper' or `none'.
10535If `none', the key is ignored by Emacs and retains its standard meaning."); 10552If `none', the key is ignored by Emacs and retains its standard meaning. */);
10536 ns_alternate_modifier = Qmeta; 10553 ns_alternate_modifier = Qmeta;
10537 10554
10538 DEFVAR_LISP ("ns-right-alternate-modifier", ns_right_alternate_modifier, 10555 DEFVAR_LISP ("ns-right-alternate-modifier", ns_right_alternate_modifier,
10539 "This variable describes the behavior of the right alternate or option key.\n\ 10556 doc: /* This variable describes the behavior of the right alternate or option key.
10540Either SYMBOL, describing the behavior for any event,\n\ 10557Either SYMBOL, describing the behavior for any event,
10541or (:ordinary SYMBOL :function SYMBOL :mouse SYMBOL), describing behavior\n\ 10558or (:ordinary SYMBOL :function SYMBOL :mouse SYMBOL), describing behavior
10542separately for ordinary keys, function keys, and mouse events.\n\ 10559separately for ordinary keys, function keys, and mouse events.
10543It can also be `left' to use the value of `ns-alternate-modifier' instead.\n\ 10560It can also be `left' to use the value of `ns-alternate-modifier' instead.
10544\n\ 10561
10545Each SYMBOL is `control', `meta', `alt', `super', `hyper' or `none'.\n\ 10562Each SYMBOL is `control', `meta', `alt', `super', `hyper' or `none'.
10546If `none', the key is ignored by Emacs and retains its standard meaning."); 10563If `none', the key is ignored by Emacs and retains its standard meaning. */);
10547 ns_right_alternate_modifier = Qleft; 10564 ns_right_alternate_modifier = Qleft;
10548 10565
10549 DEFVAR_LISP ("ns-command-modifier", ns_command_modifier, 10566 DEFVAR_LISP ("ns-command-modifier", ns_command_modifier,
10550 "This variable describes the behavior of the command key.\n\ 10567 doc: /* This variable describes the behavior of the command key.
10551Either SYMBOL, describing the behavior for any event,\n\ 10568Either SYMBOL, describing the behavior for any event,
10552or (:ordinary SYMBOL :function SYMBOL :mouse SYMBOL), describing behavior\n\ 10569or (:ordinary SYMBOL :function SYMBOL :mouse SYMBOL), describing behavior
10553separately for ordinary keys, function keys, and mouse events.\n\ 10570separately for ordinary keys, function keys, and mouse events.
10554\n\ 10571
10555Each SYMBOL is `control', `meta', `alt', `super', `hyper' or `none'.\n\ 10572Each SYMBOL is `control', `meta', `alt', `super', `hyper' or `none'.
10556If `none', the key is ignored by Emacs and retains its standard meaning."); 10573If `none', the key is ignored by Emacs and retains its standard meaning. */);
10557 ns_command_modifier = Qsuper; 10574 ns_command_modifier = Qsuper;
10558 10575
10559 DEFVAR_LISP ("ns-right-command-modifier", ns_right_command_modifier, 10576 DEFVAR_LISP ("ns-right-command-modifier", ns_right_command_modifier,
10560 "This variable describes the behavior of the right command key.\n\ 10577 doc: /* This variable describes the behavior of the right command key.
10561Either SYMBOL, describing the behavior for any event,\n\ 10578Either SYMBOL, describing the behavior for any event,
10562or (:ordinary SYMBOL :function SYMBOL :mouse SYMBOL), describing behavior\n\ 10579or (:ordinary SYMBOL :function SYMBOL :mouse SYMBOL), describing behavior
10563separately for ordinary keys, function keys, and mouse events.\n\ 10580separately for ordinary keys, function keys, and mouse events.
10564It can also be `left' to use the value of `ns-command-modifier' instead.\n\ 10581It can also be `left' to use the value of `ns-command-modifier' instead.
10565\n\ 10582
10566Each SYMBOL is `control', `meta', `alt', `super', `hyper' or `none'.\n\ 10583Each SYMBOL is `control', `meta', `alt', `super', `hyper' or `none'.
10567If `none', the key is ignored by Emacs and retains its standard meaning."); 10584If `none', the key is ignored by Emacs and retains its standard meaning. */);
10568 ns_right_command_modifier = Qleft; 10585 ns_right_command_modifier = Qleft;
10569 10586
10570 DEFVAR_LISP ("ns-control-modifier", ns_control_modifier, 10587 DEFVAR_LISP ("ns-control-modifier", ns_control_modifier,
10571 "This variable describes the behavior of the control key.\n\ 10588 doc: /* This variable describes the behavior of the control key.
10572Either SYMBOL, describing the behavior for any event,\n\ 10589Either SYMBOL, describing the behavior for any event,
10573or (:ordinary SYMBOL :function SYMBOL :mouse SYMBOL), describing behavior\n\ 10590or (:ordinary SYMBOL :function SYMBOL :mouse SYMBOL), describing behavior
10574separately for ordinary keys, function keys, and mouse events.\n\ 10591separately for ordinary keys, function keys, and mouse events.
10575\n\ 10592
10576Each SYMBOL is `control', `meta', `alt', `super', `hyper' or `none'.\n\ 10593Each SYMBOL is `control', `meta', `alt', `super', `hyper' or `none'.
10577If `none', the key is ignored by Emacs and retains its standard meaning."); 10594If `none', the key is ignored by Emacs and retains its standard meaning. */);
10578 ns_control_modifier = Qcontrol; 10595 ns_control_modifier = Qcontrol;
10579 10596
10580 DEFVAR_LISP ("ns-right-control-modifier", ns_right_control_modifier, 10597 DEFVAR_LISP ("ns-right-control-modifier", ns_right_control_modifier,
10581 "This variable describes the behavior of the right control key.\n\ 10598 doc: /* This variable describes the behavior of the right control key.
10582Either SYMBOL, describing the behavior for any event,\n\ 10599Either SYMBOL, describing the behavior for any event,
10583or (:ordinary SYMBOL :function SYMBOL :mouse SYMBOL), describing behavior\n\ 10600or (:ordinary SYMBOL :function SYMBOL :mouse SYMBOL), describing behavior
10584separately for ordinary keys, function keys, and mouse events.\n\ 10601separately for ordinary keys, function keys, and mouse events.
10585It can also be `left' to use the value of `ns-control-modifier' instead.\n\ 10602It can also be `left' to use the value of `ns-control-modifier' instead.
10586\n\ 10603
10587Each SYMBOL is `control', `meta', `alt', `super', `hyper' or `none'.\n\ 10604Each SYMBOL is `control', `meta', `alt', `super', `hyper' or `none'.
10588If `none', the key is ignored by Emacs and retains its standard meaning."); 10605If `none', the key is ignored by Emacs and retains its standard meaning. */);
10589 ns_right_control_modifier = Qleft; 10606 ns_right_control_modifier = Qleft;
10590 10607
10591 DEFVAR_LISP ("ns-function-modifier", ns_function_modifier, 10608 DEFVAR_LISP ("ns-function-modifier", ns_function_modifier,
10592 "This variable describes the behavior of the function (fn) key.\n\ 10609 doc: /* This variable describes the behavior of the function (fn) key.
10593Either SYMBOL, describing the behavior for any event,\n\ 10610Either SYMBOL, describing the behavior for any event,
10594or (:ordinary SYMBOL :function SYMBOL :mouse SYMBOL), describing behavior\n\ 10611or (:ordinary SYMBOL :function SYMBOL :mouse SYMBOL), describing behavior
10595separately for ordinary keys, function keys, and mouse events.\n\ 10612separately for ordinary keys, function keys, and mouse events.
10596\n\ 10613
10597Each SYMBOL is `control', `meta', `alt', `super', `hyper' or `none'.\n\ 10614Each SYMBOL is `control', `meta', `alt', `super', `hyper' or `none'.
10598If `none', the key is ignored by Emacs and retains its standard meaning."); 10615If `none', the key is ignored by Emacs and retains its standard meaning. */);
10599 ns_function_modifier = Qnone; 10616 ns_function_modifier = Qnone;
10600 10617
10601 DEFVAR_LISP ("ns-antialias-text", ns_antialias_text, 10618 DEFVAR_LISP ("ns-antialias-text", ns_antialias_text,
10602 "Non-nil (the default) means to render text antialiased."); 10619 doc: /* Non-nil (the default) means to render text antialiased. */);
10603 ns_antialias_text = Qt; 10620 ns_antialias_text = Qt;
10604 10621
10605 DEFVAR_LISP ("ns-use-thin-smoothing", ns_use_thin_smoothing, 10622 DEFVAR_LISP ("ns-use-thin-smoothing", ns_use_thin_smoothing,
10606 "Non-nil turns on a font smoothing method that produces thinner strokes."); 10623 doc: /* Non-nil turns on a font smoothing method that produces thinner strokes. */);
10607 ns_use_thin_smoothing = Qnil; 10624 ns_use_thin_smoothing = Qnil;
10608 10625
10609 DEFVAR_LISP ("ns-confirm-quit", ns_confirm_quit, 10626 DEFVAR_LISP ("ns-confirm-quit", ns_confirm_quit,
10610 "Whether to confirm application quit using dialog."); 10627 doc: /* Whether to confirm application quit using dialog. */);
10611 ns_confirm_quit = Qnil; 10628 ns_confirm_quit = Qnil;
10612 10629
10613 DEFVAR_LISP ("ns-auto-hide-menu-bar", ns_auto_hide_menu_bar, 10630 DEFVAR_LISP ("ns-auto-hide-menu-bar", ns_auto_hide_menu_bar,
@@ -10677,6 +10694,16 @@ This variable is ignored on macOS < 10.7 and GNUstep. Default is t. */);
10677 mice with smooth scrolling capability. */); 10694 mice with smooth scrolling capability. */);
10678 Vns_scroll_event_delta_factor = make_float (1.0); 10695 Vns_scroll_event_delta_factor = make_float (1.0);
10679 10696
10697 DEFVAR_LISP ("ns-drag-motion-function", Vns_drag_motion_function,
10698 doc: /* Function called when another program drags items over Emacs.
10699
10700It is called with three arguments FRAME, X, and Y, whenever the user
10701moves the mouse over an Emacs frame as part of a drag-and-drop
10702operation. FRAME is the frame the mouse is on top of, and X and Y are
10703the frame-relative positions of the mouse in the X and Y axises
10704respectively. */);
10705 Vns_drag_motion_function = Qns_handle_drag_motion;
10706
10680 /* Tell Emacs about this window system. */ 10707 /* Tell Emacs about this window system. */
10681 Fprovide (Qns, Qnil); 10708 Fprovide (Qns, Qnil);
10682 10709