diff options
| author | Jan Djärv | 2006-08-11 07:30:14 +0000 |
|---|---|---|
| committer | Jan Djärv | 2006-08-11 07:30:14 +0000 |
| commit | 9fc68699c62e1efe177e4dcce268ef74eef4dde9 (patch) | |
| tree | 658cface2d4d446ababd651594adfc04ac7e6018 /src/xselect.c | |
| parent | 82a33a215e1556251d6e0d8c1789d78ede98a88d (diff) | |
| download | emacs-9fc68699c62e1efe177e4dcce268ef74eef4dde9.tar.gz emacs-9fc68699c62e1efe177e4dcce268ef74eef4dde9.zip | |
* xselect.c (Fx_register_dnd_atom): New function.
(syms_of_xselect): Defsubr it.
(x_handle_dnd_message): Check that message_type is in
dpyinfo->x_dnd_atoms before generating lisp event.
Diffstat (limited to 'src/xselect.c')
| -rw-r--r-- | src/xselect.c | 51 |
1 files changed, 49 insertions, 2 deletions
diff --git a/src/xselect.c b/src/xselect.c index fcac2860359..013a52dbdb1 100644 --- a/src/xselect.c +++ b/src/xselect.c | |||
| @@ -2677,8 +2677,48 @@ If the value is 0 or the atom is not known, return the empty string. */) | |||
| 2677 | return ret; | 2677 | return ret; |
| 2678 | } | 2678 | } |
| 2679 | 2679 | ||
| 2680 | /* Convert an XClientMessageEvent to a Lisp event of type DRAG_N_DROP_EVENT. | 2680 | DEFUN ("x-register-dnd-atom", Fx_register_dnd_atom, |
| 2681 | TODO: Check if this client event really is a DND event? */ | 2681 | Sx_register_dnd_atom, 1, 2, 0, |
| 2682 | doc: /* Request that dnd events are made for ClientMessages with ATOM. | ||
| 2683 | ATOM can be a symbol or a string. The ATOM is interned on the display that | ||
| 2684 | FRAME is on. If FRAME is nil, the selected frame is used. */) | ||
| 2685 | (atom, frame) | ||
| 2686 | Lisp_Object atom, frame; | ||
| 2687 | { | ||
| 2688 | Atom x_atom; | ||
| 2689 | struct frame *f = check_x_frame (frame); | ||
| 2690 | size_t i; | ||
| 2691 | struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); | ||
| 2692 | |||
| 2693 | |||
| 2694 | if (SYMBOLP (atom)) | ||
| 2695 | x_atom = symbol_to_x_atom (dpyinfo, FRAME_X_DISPLAY (f), atom); | ||
| 2696 | else if (STRINGP (atom)) | ||
| 2697 | { | ||
| 2698 | BLOCK_INPUT; | ||
| 2699 | x_atom = XInternAtom (FRAME_X_DISPLAY (f), (char *) SDATA (atom), False); | ||
| 2700 | UNBLOCK_INPUT; | ||
| 2701 | } | ||
| 2702 | else | ||
| 2703 | error ("ATOM must be a symbol or a string"); | ||
| 2704 | |||
| 2705 | for (i = 0; i < dpyinfo->x_dnd_atoms_length; ++i) | ||
| 2706 | if (dpyinfo->x_dnd_atoms[i] == x_atom) | ||
| 2707 | return Qnil; | ||
| 2708 | |||
| 2709 | if (dpyinfo->x_dnd_atoms_length == dpyinfo->x_dnd_atoms_size) | ||
| 2710 | { | ||
| 2711 | dpyinfo->x_dnd_atoms_size *= 2; | ||
| 2712 | dpyinfo->x_dnd_atoms = xrealloc (dpyinfo->x_dnd_atoms, | ||
| 2713 | sizeof (*dpyinfo->x_dnd_atoms) | ||
| 2714 | * dpyinfo->x_dnd_atoms_size); | ||
| 2715 | } | ||
| 2716 | |||
| 2717 | dpyinfo->x_dnd_atoms[dpyinfo->x_dnd_atoms_length++] = x_atom; | ||
| 2718 | return Qnil; | ||
| 2719 | } | ||
| 2720 | |||
| 2721 | /* Convert an XClientMessageEvent to a Lisp event of type DRAG_N_DROP_EVENT. */ | ||
| 2682 | 2722 | ||
| 2683 | int | 2723 | int |
| 2684 | x_handle_dnd_message (f, event, dpyinfo, bufp) | 2724 | x_handle_dnd_message (f, event, dpyinfo, bufp) |
| @@ -2694,6 +2734,12 @@ x_handle_dnd_message (f, event, dpyinfo, bufp) | |||
| 2694 | int x, y; | 2734 | int x, y; |
| 2695 | unsigned char *data = (unsigned char *) event->data.b; | 2735 | unsigned char *data = (unsigned char *) event->data.b; |
| 2696 | int idata[5]; | 2736 | int idata[5]; |
| 2737 | size_t i; | ||
| 2738 | |||
| 2739 | for (i = 0; i < dpyinfo->x_dnd_atoms_length; ++i) | ||
| 2740 | if (dpyinfo->x_dnd_atoms[i] == event->message_type) break; | ||
| 2741 | |||
| 2742 | if (i == dpyinfo->x_dnd_atoms_length) return 0; | ||
| 2697 | 2743 | ||
| 2698 | XSETFRAME (frame, f); | 2744 | XSETFRAME (frame, f); |
| 2699 | 2745 | ||
| @@ -2867,6 +2913,7 @@ syms_of_xselect () | |||
| 2867 | 2913 | ||
| 2868 | defsubr (&Sx_get_atom_name); | 2914 | defsubr (&Sx_get_atom_name); |
| 2869 | defsubr (&Sx_send_client_message); | 2915 | defsubr (&Sx_send_client_message); |
| 2916 | defsubr (&Sx_register_dnd_atom); | ||
| 2870 | 2917 | ||
| 2871 | reading_selection_reply = Fcons (Qnil, Qnil); | 2918 | reading_selection_reply = Fcons (Qnil, Qnil); |
| 2872 | staticpro (&reading_selection_reply); | 2919 | staticpro (&reading_selection_reply); |