comparison src/xselect.c @ 90580:7f3f771c85fa

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 382-398) - Update from CVS - Update from erc--emacs--22 - Fix ERC bug introduced in last patch - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 123-125) - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-101
author Miles Bader <miles@gnu.org>
date Wed, 16 Aug 2006 14:08:49 +0000
parents 8a8e69664178 237fcefd8610
children 7eeafaaa9eab
comparison
equal deleted inserted replaced
90579:c78f05b8f09e 90580:7f3f771c85fa
2675 UNBLOCK_INPUT; 2675 UNBLOCK_INPUT;
2676 2676
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)
2685 struct frame *f; 2725 struct frame *f;
2686 XClientMessageEvent *event; 2726 XClientMessageEvent *event;
2692 /* format 32 => size 5, format 16 => size 10, format 8 => size 20 */ 2732 /* format 32 => size 5, format 16 => size 10, format 8 => size 20 */
2693 unsigned long size = 160/event->format; 2733 unsigned long size = 160/event->format;
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
2700 /* On a 64 bit machine, the event->data.l array members are 64 bits (long), 2746 /* On a 64 bit machine, the event->data.l array members are 64 bits (long),
2701 but the x_property_data_to_lisp (or rather selection_data_to_lisp_data) 2747 but the x_property_data_to_lisp (or rather selection_data_to_lisp_data)
2865 defsubr (&Sx_rotate_cut_buffers_internal); 2911 defsubr (&Sx_rotate_cut_buffers_internal);
2866 #endif 2912 #endif
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);
2873 reading_selection_window = 0; 2920 reading_selection_window = 0;
2874 reading_which_selection = 0; 2921 reading_which_selection = 0;