[gtk+] Drop the Motif DND protocol
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Drop the Motif DND protocol
- Date: Wed, 13 Mar 2013 00:02:44 +0000 (UTC)
commit 0cc688aa92b8fe5452b63fb49c51204498a2988b
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Mar 8 19:30:02 2013 -0500
Drop the Motif DND protocol
The implementation is not working and unused, since XDND is the
de-facto standard under X nowadays.
https://bugzilla.gnome.org/show_bug.cgi?id=695476
gdk/gdkdnd.h | 2 +-
gdk/x11/gdkdnd-x11.c | 1702 ++++----------------------------------------------
gtk/gtkdnd.c | 32 +-
3 files changed, 135 insertions(+), 1601 deletions(-)
---
diff --git a/gdk/gdkdnd.h b/gdk/gdkdnd.h
index c9fa16a..3cadc20 100644
--- a/gdk/gdkdnd.h
+++ b/gdk/gdkdnd.h
@@ -66,7 +66,7 @@ typedef enum
/**
* GdkDragProtocol:
* @GDK_DRAG_PROTO_NONE: no protocol.
- * @GDK_DRAG_PROTO_MOTIF: The Motif DND protocol.
+ * @GDK_DRAG_PROTO_MOTIF: The Motif DND protocol. No longer supported
* @GDK_DRAG_PROTO_XDND: The Xdnd protocol.
* @GDK_DRAG_PROTO_ROOTWIN: An extension to the Xdnd protocol for
* unclaimed root window drops.
diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c
index 6491f78..b5a6b54 100644
--- a/gdk/x11/gdkdnd-x11.c
+++ b/gdk/x11/gdkdnd-x11.c
@@ -19,7 +19,7 @@
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
- * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
+ * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
@@ -74,7 +74,6 @@ struct _GdkX11DragContext
{
GdkDragContext context;
- Atom motif_selection;
guint ref_count;
guint16 last_x; /* Coordinates from last event */
@@ -91,7 +90,6 @@ struct _GdkX11DragContext
guint xdnd_targets_set : 1; /* Whether we've already set XdndTypeList */
guint xdnd_actions_set : 1; /* Whether we've already set XdndActionList */
guint xdnd_have_actions : 1; /* Whether an XdndActionList was provided */
- guint motif_targets_set : 1; /* Whether we've already set motif initiator info */
guint drag_status : 4; /* current status of drag */
guint drop_failed : 1; /* Whether the drop was unsuccessful */
};
@@ -107,12 +105,6 @@ static GdkWindowCache *gdk_window_cache_get (GdkScreen *screen);
static GdkWindowCache *gdk_window_cache_ref (GdkWindowCache *cache);
static void gdk_window_cache_unref (GdkWindowCache *cache);
-static void motif_read_target_table (GdkDisplay *display);
-
-static GdkFilterReturn motif_dnd_filter (GdkXEvent *xev,
- GdkEvent *event,
- gpointer data);
-
static GdkFilterReturn xdnd_enter_filter (GdkXEvent *xev,
GdkEvent *event,
gpointer data);
@@ -143,8 +135,6 @@ static const struct {
const char *atom_name;
GdkFilterFunc func;
} xdnd_filters[] = {
- { "_MOTIF_DRAG_AND_DROP_MESSAGE", motif_dnd_filter },
-
{ "XdndEnter", xdnd_enter_filter },
{ "XdndLeave", xdnd_leave_filter },
{ "XdndPosition", xdnd_position_filter },
@@ -633,1440 +623,178 @@ gdk_window_cache_get (GdkScreen *screen)
return gdk_window_cache_ref (cache);
}
- cache = gdk_window_cache_new (screen);
-
- window_caches = g_slist_prepend (window_caches, cache);
-
- return cache;
-}
-
-static gboolean
-is_pointer_within_shape (GdkDisplay *display,
- GdkCacheChild *child,
- gint x_pos,
- gint y_pos)
-{
- if (!child->shape_selected)
- {
- GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
-
- XShapeSelectInput (display_x11->xdisplay, child->xid, ShapeNotifyMask);
- child->shape_selected = TRUE;
- }
- if (!child->shape_valid)
- {
- GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
- cairo_region_t *input_shape;
-
- child->shape = NULL;
- if (gdk_display_supports_shapes (display))
- child->shape = _gdk_x11_xwindow_get_shape (display_x11->xdisplay,
- child->xid, ShapeBounding);
-#ifdef ShapeInput
- input_shape = NULL;
- if (gdk_display_supports_input_shapes (display))
- input_shape = _gdk_x11_xwindow_get_shape (display_x11->xdisplay,
- child->xid, ShapeInput);
-
- if (child->shape && input_shape)
- {
- cairo_region_intersect (child->shape, input_shape);
- cairo_region_destroy (input_shape);
- }
- else if (input_shape)
- {
- child->shape = input_shape;
- }
-#endif
-
- child->shape_valid = TRUE;
- }
-
- return child->shape == NULL ||
- cairo_region_contains_point (child->shape, x_pos, y_pos);
-}
-
-static Window
-get_client_window_at_coords_recurse (GdkDisplay *display,
- Window win,
- gboolean is_toplevel,
- gint x,
- gint y)
-{
- GdkChildInfoX11 *children;
- unsigned int nchildren;
- int i;
- gboolean found_child = FALSE;
- GdkChildInfoX11 child = { 0, };
- gboolean has_wm_state = FALSE;
-
- if (!_gdk_x11_get_window_child_info (display, win, TRUE,
- is_toplevel? &has_wm_state : NULL,
- &children, &nchildren))
- return None;
-
- if (has_wm_state)
- {
- g_free (children);
-
- return win;
- }
-
- for (i = nchildren - 1; (i >= 0) && !found_child; i--)
- {
- GdkChildInfoX11 *cur_child = &children[i];
-
- if ((cur_child->is_mapped) && (cur_child->window_class == InputOutput) &&
- (x >= cur_child->x) && (x < cur_child->x + cur_child->width) &&
- (y >= cur_child->y) && (y < cur_child->y + cur_child->height))
- {
- x -= cur_child->x;
- y -= cur_child->y;
- child = *cur_child;
- found_child = TRUE;
- }
- }
-
- g_free (children);
-
- if (found_child)
- {
- if (child.has_wm_state)
- return child.window;
- else
- return get_client_window_at_coords_recurse (display, child.window, FALSE, x, y);
- }
- else
- return None;
-}
-
-static Window
-get_client_window_at_coords (GdkWindowCache *cache,
- Window ignore,
- gint x_root,
- gint y_root)
-{
- GList *tmp_list;
- Window retval = None;
- GdkDisplay *display;
-
- display = gdk_screen_get_display (cache->screen);
-
- gdk_x11_display_error_trap_push (display);
-
- tmp_list = cache->children;
-
- while (tmp_list && !retval)
- {
- GdkCacheChild *child = tmp_list->data;
-
- if ((child->xid != ignore) && (child->mapped))
- {
- if ((x_root >= child->x) && (x_root < child->x + child->width) &&
- (y_root >= child->y) && (y_root < child->y + child->height))
- {
- if (!is_pointer_within_shape (display, child,
- x_root - child->x,
- y_root - child->y))
- {
- tmp_list = tmp_list->next;
- continue;
- }
-
- retval = get_client_window_at_coords_recurse (display,
- child->xid, TRUE,
- x_root - child->x,
- y_root - child->y);
- if (!retval)
- retval = child->xid;
- }
- }
- tmp_list = tmp_list->next;
- }
-
- gdk_x11_display_error_trap_pop_ignored (display);
-
- if (retval)
- return retval;
- else
- return GDK_WINDOW_XID (gdk_screen_get_root_window (cache->screen));
-}
-
-/*************************************************************
- ***************************** MOTIF *************************
- *************************************************************/
-
-/* values used in the message type for Motif DND */
-enum {
- XmTOP_LEVEL_ENTER,
- XmTOP_LEVEL_LEAVE,
- XmDRAG_MOTION,
- XmDROP_SITE_ENTER,
- XmDROP_SITE_LEAVE,
- XmDROP_START,
- XmDROP_FINISH,
- XmDRAG_DROP_FINISH,
- XmOPERATION_CHANGED
-};
-
-/* Values used to specify type of protocol to use */
-enum {
- XmDRAG_NONE,
- XmDRAG_DROP_ONLY,
- XmDRAG_PREFER_PREREGISTER,
- XmDRAG_PREREGISTER,
- XmDRAG_PREFER_DYNAMIC,
- XmDRAG_DYNAMIC,
- XmDRAG_PREFER_RECEIVER
-};
-
-/* Operation codes */
-enum {
- XmDROP_NOOP,
- XmDROP_MOVE = 0x01,
- XmDROP_COPY = 0x02,
- XmDROP_LINK = 0x04
-};
-
-/* Drop site status */
-enum {
- XmNO_DROP_SITE = 0x01,
- XmDROP_SITE_INVALID = 0x02,
- XmDROP_SITE_VALID = 0x03
-};
-
-/* completion status */
-enum {
- XmDROP,
- XmDROP_HELP,
- XmDROP_CANCEL,
- XmDROP_INTERRUPT
-};
-
-/* Byte swapping routines. The motif specification leaves it
- * up to us to save a few bytes in the client messages
- */
-#if G_BYTE_ORDER == G_BIG_ENDIAN
-static gchar local_byte_order = 'B';
-#else
-static gchar local_byte_order = 'l';
-#endif
-
-#ifdef G_ENABLE_DEBUG
-static void
-print_target_list (GList *targets)
-{
- while (targets)
- {
- gchar *name = gdk_atom_name (GDK_POINTER_TO_ATOM (targets->data));
- g_message ("\t%s", name);
- g_free (name);
- targets = targets->next;
- }
-}
-#endif /* G_ENABLE_DEBUG */
-
-static guint16
-card16_to_host (guint16 x, gchar byte_order)
-{
- if (byte_order == local_byte_order)
- return x;
- else
- return (x << 8) | (x >> 8);
-}
-
-static guint32
-card32_to_host (guint32 x, gchar byte_order)
-{
- if (byte_order == local_byte_order)
- return x;
- else
- return (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24);
-}
-
-/* Motif packs together fields of varying length into the
- * client message. We can't rely on accessing these
- * through data.s[], data.l[], etc, because on some architectures
- * (i.e., Alpha) these won't be valid for format == 8.
- */
-
-#define MOTIF_XCLIENT_BYTE(xevent,i) \
- (xevent)->xclient.data.b[i]
-#define MOTIF_XCLIENT_SHORT(xevent,i) \
- ((gint16 *)&((xevent)->xclient.data.b[0]))[i]
-#define MOTIF_XCLIENT_LONG(xevent,i) \
- ((gint32 *)&((xevent)->xclient.data.b[0]))[i]
-
-#define MOTIF_UNPACK_BYTE(xevent,i) MOTIF_XCLIENT_BYTE(xevent,i)
-#define MOTIF_UNPACK_SHORT(xevent,i) \
- card16_to_host (MOTIF_XCLIENT_SHORT(xevent,i), MOTIF_XCLIENT_BYTE(xevent, 1))
-#define MOTIF_UNPACK_LONG(xevent,i) \
- card32_to_host (MOTIF_XCLIENT_LONG(xevent,i), MOTIF_XCLIENT_BYTE(xevent, 1))
-
-/***** Dest side ***********/
-
-/* Property placed on source windows */
-typedef struct _MotifDragInitiatorInfo
-{
- guint8 byte_order;
- guint8 protocol_version;
- guint16 targets_index;
- guint32 selection_atom;
-} MotifDragInitiatorInfo;
-
-/* Header for target table on the drag window */
-typedef struct _MotifTargetTableHeader
-{
- guchar byte_order;
- guchar protocol_version;
- guint16 n_lists;
- guint32 total_size;
-} MotifTargetTableHeader;
-
-/* Property placed on target windows */
-typedef struct _MotifDragReceiverInfo
-{
- guint8 byte_order;
- guint8 protocol_version;
- guint8 protocol_style;
- guint8 pad;
- guint32 proxy_window;
- guint16 num_drop_sites;
- guint16 padding;
- guint32 total_size;
-} MotifDragReceiverInfo;
-
-/* Target table handling */
-
-static GdkFilterReturn
-motif_drag_window_filter (GdkXEvent *xevent,
- GdkEvent *event,
- gpointer data)
-{
- XEvent *xev = (XEvent *)xevent;
- GdkDisplay *display = GDK_WINDOW_DISPLAY (event->any.window);
- GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
-
- switch (xev->xany.type)
- {
- case DestroyNotify:
- display_x11->motif_drag_window = None;
- display_x11->motif_drag_gdk_window = NULL;
- break;
- case PropertyNotify:
- if (display_x11->motif_target_lists &&
- (xev->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_TARGETS")))
- motif_read_target_table (display);
- break;
- }
- return GDK_FILTER_REMOVE;
-}
-
-static Window
-motif_lookup_drag_window (GdkDisplay *display,
- Display *lookup_xdisplay)
-{
- Window retval = None;
- gulong bytes_after, nitems;
- Atom type;
- gint format;
- guchar *data;
-
- XGetWindowProperty (lookup_xdisplay, RootWindow (lookup_xdisplay, 0),
- gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_WINDOW"),
- 0, 1, FALSE,
- XA_WINDOW, &type, &format, &nitems, &bytes_after,
- &data);
-
- if ((format == 32) && (nitems == 1) && (bytes_after == 0))
- {
- retval = *(Window *)data;
- GDK_NOTE (DND,
- g_message ("Found drag window %#lx\n", GDK_X11_DISPLAY (display)->motif_drag_window));
- }
-
- if (type != None)
- XFree (data);
-
- return retval;
-}
-
-/* Finds the window where global Motif drag information is stored.
- * If it doesn't exist and 'create' is TRUE, create one.
- */
-static Window
-motif_find_drag_window (GdkDisplay *display,
- gboolean create)
-{
- GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
-
- if (!display_x11->motif_drag_window)
- {
- Atom motif_drag_window_atom = gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_WINDOW");
- display_x11->motif_drag_window = motif_lookup_drag_window (display, display_x11->xdisplay);
-
- if (!display_x11->motif_drag_window && create)
- {
- /* Create a persistant window. (Copied from LessTif) */
- Display *persistant_xdisplay;
- XSetWindowAttributes attr;
- persistant_xdisplay = XOpenDisplay (gdk_display_get_name (display));
- XSetCloseDownMode (persistant_xdisplay, RetainPermanent);
-
- XGrabServer (persistant_xdisplay);
-
- display_x11->motif_drag_window = motif_lookup_drag_window (display, persistant_xdisplay);
-
- if (!display_x11->motif_drag_window)
- {
- attr.override_redirect = True;
- attr.event_mask = PropertyChangeMask;
-
- display_x11->motif_drag_window =
- XCreateWindow (persistant_xdisplay,
- RootWindow (persistant_xdisplay, 0),
- -100, -100, 10, 10, 0, 0,
- InputOnly, (Visual *)CopyFromParent,
- (CWOverrideRedirect | CWEventMask), &attr);
-
- GDK_NOTE (DND,
- g_message ("Created drag window %#lx\n", display_x11->motif_drag_window));
-
- XChangeProperty (persistant_xdisplay,
- RootWindow (persistant_xdisplay, 0),
- motif_drag_window_atom, XA_WINDOW,
- 32, PropModeReplace,
- (guchar *)&motif_drag_window_atom, 1);
- }
- XUngrabServer (persistant_xdisplay);
- XCloseDisplay (persistant_xdisplay);
- }
-
- /* There is a miniscule race condition here if the drag window
- * gets destroyed exactly now.
- */
- if (display_x11->motif_drag_window)
- {
- display_x11->motif_drag_gdk_window =
- gdk_x11_window_foreign_new_for_display (display, display_x11->motif_drag_window);
- gdk_window_add_filter (display_x11->motif_drag_gdk_window,
- motif_drag_window_filter,
- NULL);
- }
- }
-
- return display_x11->motif_drag_window;
-}
-
-static void
-motif_read_target_table (GdkDisplay *display)
-{
- GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
- gulong bytes_after, nitems;
- Atom type;
- gint format;
- gint i, j;
-
- Atom motif_drag_targets_atom = gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_TARGETS");
-
- if (display_x11->motif_target_lists)
- {
- for (i=0; i<display_x11->motif_n_target_lists; i++)
- g_list_free (display_x11->motif_target_lists[i]);
-
- g_free (display_x11->motif_target_lists);
- display_x11->motif_target_lists = NULL;
- display_x11->motif_n_target_lists = 0;
- }
-
- if (motif_find_drag_window (display, FALSE))
- {
- guchar *data;
- MotifTargetTableHeader *header = NULL;
- guchar *target_bytes = NULL;
- guchar *p;
- gboolean success = FALSE;
-
- gdk_x11_display_error_trap_push (display);
- XGetWindowProperty (display_x11->xdisplay,
- display_x11->motif_drag_window,
- motif_drag_targets_atom,
- 0, (sizeof(MotifTargetTableHeader)+3)/4, FALSE,
- motif_drag_targets_atom,
- &type, &format, &nitems, &bytes_after,
- &data);
-
- if (gdk_x11_display_error_trap_pop (display) ||
- (format != 8) || (nitems < sizeof (MotifTargetTableHeader)))
- goto error;
-
- header = (MotifTargetTableHeader *)data;
-
- header->n_lists = card16_to_host (header->n_lists, header->byte_order);
- header->total_size = card32_to_host (header->total_size, header->byte_order);
-
- gdk_x11_display_error_trap_push (display);
- XGetWindowProperty (display_x11->xdisplay,
- display_x11->motif_drag_window,
- motif_drag_targets_atom,
- (sizeof(MotifTargetTableHeader)+3)/4,
- (header->total_size + 3)/4 - (sizeof(MotifTargetTableHeader) + 3)/4,
- FALSE,
- motif_drag_targets_atom, &type, &format, &nitems,
- &bytes_after, &target_bytes);
-
- if (gdk_x11_display_error_trap_pop (display) ||
- (format != 8) || (bytes_after != 0) ||
- (nitems != header->total_size - sizeof(MotifTargetTableHeader)))
- goto error;
-
- display_x11->motif_n_target_lists = header->n_lists;
- display_x11->motif_target_lists = g_new0 (GList *, display_x11->motif_n_target_lists);
-
- p = target_bytes;
- for (i=0; i<header->n_lists; i++)
- {
- gint n_targets;
- guint32 *targets;
-
- if (p + sizeof(guint16) - target_bytes > nitems)
- goto error;
-
- n_targets = card16_to_host (*(gushort *)p, header->byte_order);
-
- /* We need to make a copy of the targets, since it may
- * be unaligned
- */
- targets = g_new (guint32, n_targets);
- memcpy (targets, p + sizeof(guint16), sizeof(guint32) * n_targets);
-
- p += sizeof(guint16) + n_targets * sizeof(guint32);
- if (p - target_bytes > nitems)
- goto error;
-
- for (j=0; j<n_targets; j++)
- display_x11->motif_target_lists[i] =
- g_list_prepend (display_x11->motif_target_lists[i],
- GUINT_TO_POINTER (card32_to_host (targets[j],
- header->byte_order)));
- g_free (targets);
- display_x11->motif_target_lists[i] = g_list_reverse (display_x11->motif_target_lists[i]);
- }
-
- success = TRUE;
-
- error:
- if (header)
- XFree (header);
-
- if (target_bytes)
- XFree (target_bytes);
-
- if (!success)
- {
- if (display_x11->motif_target_lists)
- {
- g_free (display_x11->motif_target_lists);
- display_x11->motif_target_lists = NULL;
- display_x11->motif_n_target_lists = 0;
- }
- g_warning ("Error reading Motif target table\n");
- }
- }
-}
-
-static gint
-targets_sort_func (gconstpointer a, gconstpointer b)
-{
- return (GPOINTER_TO_UINT (a) < GPOINTER_TO_UINT (b)) ?
- -1 : ((GPOINTER_TO_UINT (a) > GPOINTER_TO_UINT (b)) ? 1 : 0);
-}
-
-/* Check if given (sorted) list is in the targets table */
-static gint
-motif_target_table_check (GdkDisplay *display,
- GList *sorted)
-{
- GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
- GList *tmp_list1, *tmp_list2;
- gint i;
-
- for (i=0; i<display_x11->motif_n_target_lists; i++)
- {
- tmp_list1 = display_x11->motif_target_lists[i];
- tmp_list2 = sorted;
-
- while (tmp_list1 && tmp_list2)
- {
- if (tmp_list1->data != tmp_list2->data)
- break;
-
- tmp_list1 = tmp_list1->next;
- tmp_list2 = tmp_list2->next;
- }
- if (!tmp_list1 && !tmp_list2) /* Found it */
- return i;
- }
-
- return -1;
-}
-
-static gint
-motif_add_to_target_table (GdkDisplay *display,
- GList *targets) /* targets is list of GdkAtom */
-{
- GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
- GList *sorted = NULL;
- gint index = -1;
- gint i;
- GList *tmp_list;
-
- /* make a sorted copy of the list */
- while (targets)
- {
- Atom xatom = gdk_x11_atom_to_xatom_for_display (display, GDK_POINTER_TO_ATOM (targets->data));
- sorted = g_list_insert_sorted (sorted, GUINT_TO_POINTER (xatom), targets_sort_func);
- targets = targets->next;
- }
-
- /* First check if it is there already */
-
- if (display_x11->motif_target_lists)
- index = motif_target_table_check (display, sorted);
-
- /* We need to grab the server while doing this, to ensure
- * atomiticity. Ugh
- */
-
- if (index < 0)
- {
- /* We need to make sure that it exists _before_ we grab the
- * server, since we can't open a new connection after we
- * grab the server.
- */
- motif_find_drag_window (display, TRUE);
-
- gdk_x11_display_grab (display);
- motif_read_target_table (display);
-
- /* Check again, in case it was added in the meantime */
- if (display_x11->motif_target_lists)
- index = motif_target_table_check (display, sorted);
-
- if (index < 0)
- {
- guint32 total_size = 0;
- guchar *data;
- guchar *p;
- guint16 *p16;
- MotifTargetTableHeader *header;
-
- if (!display_x11->motif_target_lists)
- {
- display_x11->motif_target_lists = g_new (GList *, 1);
- display_x11->motif_n_target_lists = 1;
- }
- else
- {
- display_x11->motif_n_target_lists++;
- display_x11->motif_target_lists = g_realloc (display_x11->motif_target_lists,
- sizeof(GList *) *
display_x11->motif_n_target_lists);
- }
- display_x11->motif_target_lists[display_x11->motif_n_target_lists - 1] = sorted;
- sorted = NULL;
- index = display_x11->motif_n_target_lists - 1;
-
- total_size = sizeof (MotifTargetTableHeader);
- for (i = 0; i < display_x11->motif_n_target_lists ; i++)
- total_size += sizeof(guint16) + sizeof(guint32) * g_list_length
(display_x11->motif_target_lists[i]);
-
- data = g_malloc (total_size);
-
- header = (MotifTargetTableHeader *)data;
- p = data + sizeof(MotifTargetTableHeader);
-
- header->byte_order = local_byte_order;
- header->protocol_version = 0;
- header->n_lists = display_x11->motif_n_target_lists;
- header->total_size = total_size;
-
- for (i = 0; i < display_x11->motif_n_target_lists ; i++)
- {
- guint16 n_targets = g_list_length (display_x11->motif_target_lists[i]);
- guint32 *targets = g_new (guint32, n_targets);
- guint32 *p32 = targets;
-
- tmp_list = display_x11->motif_target_lists[i];
- while (tmp_list)
- {
- *p32 = GPOINTER_TO_UINT (tmp_list->data);
-
- tmp_list = tmp_list->next;
- p32++;
- }
-
- p16 = (guint16 *)p;
- p += sizeof(guint16);
-
- memcpy (p, targets, n_targets * sizeof(guint32));
-
- *p16 = n_targets;
- p += sizeof(guint32) * n_targets;
- g_free (targets);
- }
-
- XChangeProperty (display_x11->xdisplay,
- display_x11->motif_drag_window,
- gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_TARGETS"),
- gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_TARGETS"),
- 8, PropModeReplace,
- data, total_size);
- }
- gdk_x11_display_ungrab (display);
- }
-
- g_list_free (sorted);
- return index;
-}
-
-/* Translate flags */
-
-static void
-motif_dnd_translate_flags (GdkX11DragContext *context_x11,
- guint16 flags)
-{
- GdkDragContext *context = GDK_DRAG_CONTEXT (context_x11);
- guint recommended_op = flags & 0x000f;
- guint possible_ops = (flags & 0x0f0) >> 4;
-
- switch (recommended_op)
- {
- case XmDROP_MOVE:
- context->suggested_action = GDK_ACTION_MOVE;
- break;
- case XmDROP_COPY:
- context->suggested_action = GDK_ACTION_COPY;
- break;
- case XmDROP_LINK:
- context->suggested_action = GDK_ACTION_LINK;
- break;
- default:
- context->suggested_action = GDK_ACTION_COPY;
- break;
- }
-
- context->actions = 0;
- if (possible_ops & XmDROP_MOVE)
- context->actions |= GDK_ACTION_MOVE;
- if (possible_ops & XmDROP_COPY)
- context->actions |= GDK_ACTION_COPY;
- if (possible_ops & XmDROP_LINK)
- context->actions |= GDK_ACTION_LINK;
-}
-
-static guint16
-motif_dnd_get_flags (GdkDragContext *context)
-{
- guint16 flags = 0;
-
- switch (context->suggested_action)
- {
- case GDK_ACTION_MOVE:
- flags = XmDROP_MOVE;
- break;
- case GDK_ACTION_COPY:
- flags = XmDROP_COPY;
- break;
- case GDK_ACTION_LINK:
- flags = XmDROP_LINK;
- break;
- default:
- flags = XmDROP_NOOP;
- break;
- }
-
- if (context->actions & GDK_ACTION_MOVE)
- flags |= XmDROP_MOVE << 8;
- if (context->actions & GDK_ACTION_COPY)
- flags |= XmDROP_COPY << 8;
- if (context->actions & GDK_ACTION_LINK)
- flags |= XmDROP_LINK << 8;
-
- return flags;
-}
-
-/* Source Side */
-
-static void
-motif_set_targets (GdkX11DragContext *context_x11)
-{
- GdkDragContext *context = GDK_DRAG_CONTEXT (context_x11);
- MotifDragInitiatorInfo info;
- gint i;
- GdkDisplay *display = GDK_WINDOW_DISPLAY (context->source_window);
-
- info.byte_order = local_byte_order;
- info.protocol_version = 0;
- info.targets_index = motif_add_to_target_table (display, context->targets);
-
- for (i = 0; ; i++)
- {
- gchar buf[20];
- g_snprintf (buf, 20, "_GDK_SELECTION_%d", i);
-
- context_x11->motif_selection = gdk_x11_get_xatom_by_name_for_display (display, buf);
- if (!XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display), context_x11->motif_selection))
- break;
- }
-
- info.selection_atom = context_x11->motif_selection;
-
- XChangeProperty (GDK_WINDOW_XDISPLAY (context->source_window),
- GDK_WINDOW_XID (context->source_window),
- context_x11->motif_selection,
- gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_INITIATOR_INFO"),
- 8, PropModeReplace,
- (guchar *)&info, sizeof (info));
-
- context_x11->motif_targets_set = 1;
-}
-
-static guint32
-motif_check_dest (GdkDisplay *display,
- Window win)
-{
- gboolean retval = FALSE;
- guchar *data;
- MotifDragReceiverInfo *info;
- Atom type = None;
- int format;
- unsigned long nitems, after;
- Atom motif_drag_receiver_info_atom = gdk_x11_get_xatom_by_name_for_display (display,
"_MOTIF_DRAG_RECEIVER_INFO");
-
- gdk_x11_display_error_trap_push (display);
- XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), win,
- motif_drag_receiver_info_atom,
- 0, (sizeof(*info)+3)/4, False, AnyPropertyType,
- &type, &format, &nitems, &after,
- &data);
-
- if (gdk_x11_display_error_trap_pop (display) == 0)
- {
- if (type != None)
- {
- info = (MotifDragReceiverInfo *)data;
-
- if ((format == 8) && (nitems == sizeof(*info)))
- {
- if ((info->protocol_version == 0) &&
- ((info->protocol_style == XmDRAG_PREFER_PREREGISTER) ||
- (info->protocol_style == XmDRAG_PREFER_DYNAMIC) ||
- (info->protocol_style == XmDRAG_DYNAMIC)))
- retval = TRUE;
- }
- else
- {
- GDK_NOTE (DND,
- g_warning ("Invalid Motif drag receiver property on window %ld\n", win));
- }
-
- XFree (info);
- }
- }
-
- return retval ? win : None;
-}
-
-static void
-motif_send_enter (GdkX11DragContext *context_x11,
- guint32 time)
-{
- GdkDragContext *context = GDK_DRAG_CONTEXT (context_x11);
- GdkDisplay *display = GDK_WINDOW_DISPLAY (context->source_window);
- XEvent xev;
-
- if (!G_LIKELY (GDK_X11_DISPLAY (display)->trusted_client))
- return; /* Motif Dnd requires getting properties on the root window */
-
- xev.xclient.type = ClientMessage;
- xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_AND_DROP_MESSAGE");
- xev.xclient.format = 8;
- xev.xclient.window = GDK_WINDOW_XID (context->dest_window);
-
- MOTIF_XCLIENT_BYTE (&xev, 0) = XmTOP_LEVEL_ENTER;
- MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
- MOTIF_XCLIENT_SHORT (&xev, 1) = 0;
- MOTIF_XCLIENT_LONG (&xev, 1) = time;
- MOTIF_XCLIENT_LONG (&xev, 2) = GDK_WINDOW_XID (context->source_window);
-
- if (!context_x11->motif_targets_set)
- motif_set_targets (context_x11);
-
- MOTIF_XCLIENT_LONG (&xev, 3) = context_x11->motif_selection;
- MOTIF_XCLIENT_LONG (&xev, 4) = 0;
-
- if (!_gdk_x11_display_send_xevent (display,
- GDK_WINDOW_XID (context->dest_window),
- FALSE, 0, &xev))
- {
- GDK_NOTE (DND,
- g_message ("Send event to %lx failed",
- GDK_WINDOW_XID (context->dest_window)));
- }
-}
-
-static void
-motif_send_leave (GdkX11DragContext *context_x11,
- guint32 time)
-{
- GdkDragContext *context = GDK_DRAG_CONTEXT (context_x11);
- GdkDisplay *display = GDK_WINDOW_DISPLAY (context->source_window);
- XEvent xev;
-
- xev.xclient.type = ClientMessage;
- xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_AND_DROP_MESSAGE");
- xev.xclient.format = 8;
- xev.xclient.window = GDK_WINDOW_XID (context->dest_window);
-
- MOTIF_XCLIENT_BYTE (&xev, 0) = XmTOP_LEVEL_LEAVE;
- MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
- MOTIF_XCLIENT_SHORT (&xev, 1) = 0;
- MOTIF_XCLIENT_LONG (&xev, 1) = time;
- MOTIF_XCLIENT_LONG (&xev, 2) = 0;
- MOTIF_XCLIENT_LONG (&xev, 3) = 0;
- MOTIF_XCLIENT_LONG (&xev, 4) = 0;
-
- if (!_gdk_x11_display_send_xevent (display,
- GDK_WINDOW_XID (context->dest_window),
- FALSE, 0, &xev))
- {
- GDK_NOTE (DND,
- g_message ("Send event to %lx failed",
- GDK_WINDOW_XID (context->dest_window)));
- }
-}
-
-static gboolean
-motif_send_motion (GdkX11DragContext *context_x11,
- gint x_root,
- gint y_root,
- GdkDragAction action,
- guint32 time)
-{
- GdkDragContext *context = GDK_DRAG_CONTEXT (context_x11);
- GdkDisplay *display = GDK_WINDOW_DISPLAY (context->source_window);
- gboolean retval;
- XEvent xev;
-
- xev.xclient.type = ClientMessage;
- xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_AND_DROP_MESSAGE");
- xev.xclient.format = 8;
- xev.xclient.window = GDK_WINDOW_XID (context->dest_window);
-
- MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
- MOTIF_XCLIENT_SHORT (&xev, 1) = motif_dnd_get_flags (context);
- MOTIF_XCLIENT_LONG (&xev, 1) = time;
- MOTIF_XCLIENT_LONG (&xev, 3) = 0;
- MOTIF_XCLIENT_LONG (&xev, 4) = 0;
-
- if ((context->suggested_action != context_x11->old_action) ||
- (context->actions != context_x11->old_actions))
- {
- MOTIF_XCLIENT_BYTE (&xev, 0) = XmOPERATION_CHANGED;
-
- /* context_x11->drag_status = GDK_DRAG_STATUS_ACTION_WAIT; */
- retval = TRUE;
- }
- else
- {
- MOTIF_XCLIENT_BYTE (&xev, 0) = XmDRAG_MOTION;
-
- MOTIF_XCLIENT_SHORT (&xev, 4) = x_root;
- MOTIF_XCLIENT_SHORT (&xev, 5) = y_root;
-
- context_x11->drag_status = GDK_DRAG_STATUS_MOTION_WAIT;
- retval = FALSE;
- }
-
- if (!_gdk_x11_display_send_xevent (display,
- GDK_WINDOW_XID (context->dest_window),
- FALSE, 0, &xev))
- {
- GDK_NOTE (DND,
- g_message ("Send event to %lx failed",
- GDK_WINDOW_XID (context->dest_window)));
- }
-
- return retval;
-}
-
-static void
-motif_send_drop (GdkX11DragContext *context_x11,
- guint32 time)
-{
- GdkDragContext *context = GDK_DRAG_CONTEXT (context_x11);
- GdkDisplay *display = GDK_WINDOW_DISPLAY (context->source_window);
- XEvent xev;
-
- xev.xclient.type = ClientMessage;
- xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_AND_DROP_MESSAGE");
- xev.xclient.format = 8;
- xev.xclient.window = GDK_WINDOW_XID (context->dest_window);
-
- MOTIF_XCLIENT_BYTE (&xev, 0) = XmDROP_START;
- MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
- MOTIF_XCLIENT_SHORT (&xev, 1) = motif_dnd_get_flags (context);
- MOTIF_XCLIENT_LONG (&xev, 1) = time;
-
- MOTIF_XCLIENT_SHORT (&xev, 4) = context_x11->last_x;
- MOTIF_XCLIENT_SHORT (&xev, 5) = context_x11->last_y;
-
- MOTIF_XCLIENT_LONG (&xev, 3) = context_x11->motif_selection;
- MOTIF_XCLIENT_LONG (&xev, 4) = GDK_WINDOW_XID (context->source_window);
-
- if (!_gdk_x11_display_send_xevent (display,
- GDK_WINDOW_XID (context->dest_window),
- FALSE, 0, &xev))
- {
- GDK_NOTE (DND,
- g_message ("Send event to %lx failed",
- GDK_WINDOW_XID (context->dest_window)));
- }
-}
-
-/* Target Side */
-
-static gboolean
-motif_read_initiator_info (GdkDisplay *display,
- Window source_window,
- Atom atom,
- GList **targets,
- Atom *selection)
-{
- GList *tmp_list;
- Atom type;
- gint format;
- gulong nitems;
- gulong bytes_after;
- guchar *data;
- MotifDragInitiatorInfo *initiator_info;
-
- GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
-
- gdk_x11_display_error_trap_push (display);
- XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), source_window, atom,
- 0, sizeof(*initiator_info), FALSE,
- gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_INITIATOR_INFO"),
- &type, &format, &nitems, &bytes_after,
- &data);
-
- if (gdk_x11_display_error_trap_pop (display) ||
- (format != 8) || (nitems != sizeof (MotifDragInitiatorInfo)) ||
- (bytes_after != 0))
- {
- g_warning ("Error reading initiator info\n");
- return FALSE;
- }
-
- initiator_info = (MotifDragInitiatorInfo *)data;
-
- motif_read_target_table (display);
-
- initiator_info->targets_index =
- card16_to_host (initiator_info->targets_index, initiator_info->byte_order);
- initiator_info->selection_atom =
- card32_to_host (initiator_info->selection_atom, initiator_info->byte_order);
-
- if (initiator_info->targets_index >= display_x11->motif_n_target_lists)
- {
- g_warning ("Invalid target index in TOP_LEVEL_ENTER MESSAGE");
- XFree (initiator_info);
- return FALSE;
- }
-
- tmp_list = g_list_last (display_x11->motif_target_lists[initiator_info->targets_index]);
-
- *targets = NULL;
- while (tmp_list)
- {
- GdkAtom atom = gdk_x11_xatom_to_atom_for_display (display, GPOINTER_TO_UINT (tmp_list->data));
- *targets = g_list_prepend (*targets, GDK_ATOM_TO_POINTER (atom));
- tmp_list = tmp_list->prev;
- }
-
-#ifdef G_ENABLE_DEBUG
- if (_gdk_debug_flags & GDK_DEBUG_DND)
- print_target_list (*targets);
-#endif /* G_ENABLE_DEBUG */
-
- *selection = initiator_info->selection_atom;
-
- XFree (initiator_info);
-
- return TRUE;
-}
-
-static GdkDragContext *
-motif_drag_context_new (GdkWindow *dest_window,
- guint32 timestamp,
- guint32 source_window,
- guint32 atom)
-{
- GdkX11DragContext *context_x11;
- GdkDragContext *context;
- GdkDisplay *display = GDK_WINDOW_DISPLAY (dest_window);
- GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
-
- /* FIXME, current_dest_drag really shouldn't be NULL'd
- * if we error below.
- */
- if (display_x11->current_dest_drag != NULL)
- {
- if (timestamp >= display_x11->current_dest_drag->start_time)
- {
- g_object_unref (display_x11->current_dest_drag);
- display_x11->current_dest_drag = NULL;
- }
- else
- return NULL;
- }
-
- context_x11 = g_object_new (GDK_TYPE_X11_DRAG_CONTEXT, NULL);
- context = GDK_DRAG_CONTEXT (context_x11);
-
- context->protocol = GDK_DRAG_PROTO_MOTIF;
- context->is_source = FALSE;
-
- context->source_window = gdk_x11_window_foreign_new_for_display (display, source_window);
- if (!context->source_window)
- {
- g_object_unref (context_x11);
- return NULL;
- }
-
- context->dest_window = dest_window;
- g_object_ref (dest_window);
- context->start_time = timestamp;
-
- if (!motif_read_initiator_info (GDK_WINDOW_DISPLAY (dest_window),
- source_window,
- atom,
- &context->targets,
- &context_x11->motif_selection))
- {
- g_object_unref (context_x11);
- return NULL;
- }
-
- return context;
-}
-
-/*
- * The MOTIF drag protocol has no real provisions for distinguishing
- * multiple simultaneous drops. If the sources grab the pointer
- * when doing drags, that shouldn't happen, in any case. If it
- * does, we can't do much except hope for the best.
- */
-
-static GdkFilterReturn
-motif_top_level_enter (GdkEvent *event,
- guint16 flags,
- guint32 timestamp,
- guint32 source_window,
- guint32 atom)
-{
- GdkX11Display *display_x11 = GDK_X11_DISPLAY (GDK_WINDOW_DISPLAY (event->any.window));
- GdkDragContext *new_context;
-
- GDK_NOTE(DND, g_message ("Motif DND top level enter: flags: %#4x time: %d source_widow: %#4x atom: %d",
- flags, timestamp, source_window, atom));
-
- new_context = motif_drag_context_new (event->any.window, timestamp, source_window, atom);
- if (!new_context)
- return GDK_FILTER_REMOVE;
-
- event->dnd.type = GDK_DRAG_ENTER;
- event->dnd.context = new_context;
- g_object_ref (new_context);
-
- display_x11->current_dest_drag = new_context;
-
- return GDK_FILTER_TRANSLATE;
-}
-
-static GdkFilterReturn
-motif_top_level_leave (GdkEvent *event,
- guint16 flags,
- guint32 timestamp)
-{
- GdkX11Display *display_x11 = GDK_X11_DISPLAY (GDK_WINDOW_DISPLAY (event->any.window));
-
- GDK_NOTE(DND, g_message ("Motif DND top level leave: flags: %#4x time: %d",
- flags, timestamp));
-
- if ((display_x11->current_dest_drag != NULL) &&
- (display_x11->current_dest_drag->protocol == GDK_DRAG_PROTO_MOTIF) &&
- (timestamp >= display_x11->current_dest_drag->start_time))
- {
- event->dnd.type = GDK_DRAG_LEAVE;
- /* Pass ownership of context to the event */
- event->dnd.context = display_x11->current_dest_drag;
-
- display_x11->current_dest_drag = NULL;
-
- return GDK_FILTER_TRANSLATE;
- }
- else
- return GDK_FILTER_REMOVE;
-}
-
-static GdkFilterReturn
-motif_motion (GdkEvent *event,
- guint16 flags,
- guint32 timestamp,
- gint16 x_root,
- gint16 y_root)
-{
- GdkX11DragContext *context_x11;
- GdkX11Display *display_x11 = GDK_X11_DISPLAY (GDK_WINDOW_DISPLAY (event->any.window));
-
- GDK_NOTE(DND, g_message ("Motif DND motion: flags: %#4x time: %d (%d, %d)",
- flags, timestamp, x_root, y_root));
-
- if ((display_x11->current_dest_drag != NULL) &&
- (display_x11->current_dest_drag->protocol == GDK_DRAG_PROTO_MOTIF) &&
- (timestamp >= display_x11->current_dest_drag->start_time))
- {
- context_x11 = GDK_X11_DRAG_CONTEXT (display_x11->current_dest_drag);
-
- event->dnd.type = GDK_DRAG_MOTION;
- event->dnd.context = display_x11->current_dest_drag;
- g_object_ref (display_x11->current_dest_drag);
-
- event->dnd.time = timestamp;
-
- motif_dnd_translate_flags (context_x11, flags);
-
- event->dnd.x_root = x_root;
- event->dnd.y_root = y_root;
-
- context_x11->last_x = x_root;
- context_x11->last_y = y_root;
-
- context_x11->drag_status = GDK_DRAG_STATUS_MOTION_WAIT;
+ cache = gdk_window_cache_new (screen);
- return GDK_FILTER_TRANSLATE;
- }
+ window_caches = g_slist_prepend (window_caches, cache);
- return GDK_FILTER_REMOVE;
+ return cache;
}
-static GdkFilterReturn
-motif_operation_changed (GdkEvent *event,
- guint16 flags,
- guint32 timestamp)
+static gboolean
+is_pointer_within_shape (GdkDisplay *display,
+ GdkCacheChild *child,
+ gint x_pos,
+ gint y_pos)
{
- GdkX11DragContext *context_x11;
- GdkX11Display *display_x11 = GDK_X11_DISPLAY (GDK_WINDOW_DISPLAY (event->any.window));
- GDK_NOTE(DND, g_message ("Motif DND operation changed: flags: %#4x time: %d",
- flags, timestamp));
-
- if ((display_x11->current_dest_drag != NULL) &&
- (display_x11->current_dest_drag->protocol == GDK_DRAG_PROTO_MOTIF) &&
- (timestamp >= display_x11->current_dest_drag->start_time))
+ if (!child->shape_selected)
{
- event->dnd.type = GDK_DRAG_MOTION;
- event->dnd.send_event = FALSE;
- event->dnd.context = display_x11->current_dest_drag;
- g_object_ref (display_x11->current_dest_drag);
-
- event->dnd.time = timestamp;
- context_x11 = GDK_X11_DRAG_CONTEXT (display_x11->current_dest_drag);
+ GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
- motif_dnd_translate_flags (context_x11, flags);
+ XShapeSelectInput (display_x11->xdisplay, child->xid, ShapeNotifyMask);
+ child->shape_selected = TRUE;
+ }
+ if (!child->shape_valid)
+ {
+ GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
+ cairo_region_t *input_shape;
- event->dnd.x_root = context_x11->last_x;
- event->dnd.y_root = context_x11->last_y;
+ child->shape = NULL;
+ if (gdk_display_supports_shapes (display))
+ child->shape = _gdk_x11_xwindow_get_shape (display_x11->xdisplay,
+ child->xid, ShapeBounding);
+#ifdef ShapeInput
+ input_shape = NULL;
+ if (gdk_display_supports_input_shapes (display))
+ input_shape = _gdk_x11_xwindow_get_shape (display_x11->xdisplay,
+ child->xid, ShapeInput);
- context_x11->drag_status = GDK_DRAG_STATUS_ACTION_WAIT;
+ if (child->shape && input_shape)
+ {
+ cairo_region_intersect (child->shape, input_shape);
+ cairo_region_destroy (input_shape);
+ }
+ else if (input_shape)
+ {
+ child->shape = input_shape;
+ }
+#endif
- return GDK_FILTER_TRANSLATE;
+ child->shape_valid = TRUE;
}
- return GDK_FILTER_REMOVE;
+ return child->shape == NULL ||
+ cairo_region_contains_point (child->shape, x_pos, y_pos);
}
-static GdkFilterReturn
-motif_drop_start (GdkEvent *event,
- guint16 flags,
- guint32 timestamp,
- guint32 source_window,
- guint32 atom,
- gint16 x_root,
- gint16 y_root)
+static Window
+get_client_window_at_coords_recurse (GdkDisplay *display,
+ Window win,
+ gboolean is_toplevel,
+ gint x,
+ gint y)
{
- GdkDragContext *new_context;
- GdkX11Display *display_x11 = GDK_X11_DISPLAY (GDK_WINDOW_DISPLAY (event->any.window));
+ GdkChildInfoX11 *children;
+ unsigned int nchildren;
+ int i;
+ gboolean found_child = FALSE;
+ GdkChildInfoX11 child = { 0, };
+ gboolean has_wm_state = FALSE;
- GDK_NOTE(DND, g_message ("Motif DND drop start: flags: %#4x time: %d (%d, %d) source_widow: %#4x atom: %d",
- flags, timestamp, x_root, y_root, source_window, atom));
+ if (!_gdk_x11_get_window_child_info (display, win, TRUE,
+ is_toplevel? &has_wm_state : NULL,
+ &children, &nchildren))
+ return None;
- new_context = motif_drag_context_new (event->any.window, timestamp, source_window, atom);
- if (!new_context)
- return GDK_FILTER_REMOVE;
+ if (has_wm_state)
+ {
+ g_free (children);
- motif_dnd_translate_flags (GDK_X11_DRAG_CONTEXT (new_context), flags);
+ return win;
+ }
- event->dnd.type = GDK_DROP_START;
- event->dnd.context = new_context;
- event->dnd.time = timestamp;
- event->dnd.x_root = x_root;
- event->dnd.y_root = y_root;
+ for (i = nchildren - 1; (i >= 0) && !found_child; i--)
+ {
+ GdkChildInfoX11 *cur_child = &children[i];
- gdk_x11_window_set_user_time (event->any.window, timestamp);
+ if ((cur_child->is_mapped) && (cur_child->window_class == InputOutput) &&
+ (x >= cur_child->x) && (x < cur_child->x + cur_child->width) &&
+ (y >= cur_child->y) && (y < cur_child->y + cur_child->height))
+ {
+ x -= cur_child->x;
+ y -= cur_child->y;
+ child = *cur_child;
+ found_child = TRUE;
+ }
+ }
- g_object_ref (new_context);
- display_x11->current_dest_drag = new_context;
+ g_free (children);
- return GDK_FILTER_TRANSLATE;
+ if (found_child)
+ {
+ if (child.has_wm_state)
+ return child.window;
+ else
+ return get_client_window_at_coords_recurse (display, child.window, FALSE, x, y);
+ }
+ else
+ return None;
}
-static GdkFilterReturn
-motif_drag_status (GdkEvent *event,
- guint16 flags,
- guint32 timestamp)
+static Window
+get_client_window_at_coords (GdkWindowCache *cache,
+ Window ignore,
+ gint x_root,
+ gint y_root)
{
- GdkDragContext *context;
+ GList *tmp_list;
+ Window retval = None;
GdkDisplay *display;
- GDK_NOTE (DND,
- g_message ("Motif status message: flags %x", flags));
+ display = gdk_screen_get_display (cache->screen);
- display = gdk_window_get_display (event->any.window);
- if (!display)
- return GDK_FILTER_REMOVE;
+ gdk_x11_display_error_trap_push (display);
- context = gdk_drag_context_find (display, TRUE, GDK_WINDOW_XID (event->any.window), None);
+ tmp_list = cache->children;
- if (context)
+ while (tmp_list && !retval)
{
- GdkX11DragContext *context_x11 = GDK_X11_DRAG_CONTEXT (context);
- if ((context_x11->drag_status == GDK_DRAG_STATUS_MOTION_WAIT) ||
- (context_x11->drag_status == GDK_DRAG_STATUS_ACTION_WAIT))
- context_x11->drag_status = GDK_DRAG_STATUS_DRAG;
-
- event->dnd.type = GDK_DRAG_STATUS;
- event->dnd.send_event = FALSE;
- event->dnd.context = context;
- g_object_ref (context);
-
- event->dnd.time = timestamp;
+ GdkCacheChild *child = tmp_list->data;
- if ((flags & 0x00f0) >> 4 == XmDROP_SITE_VALID)
+ if ((child->xid != ignore) && (child->mapped))
{
- switch (flags & 0x000f)
+ if ((x_root >= child->x) && (x_root < child->x + child->width) &&
+ (y_root >= child->y) && (y_root < child->y + child->height))
{
- case XmDROP_NOOP:
- context->action = 0;
- break;
- case XmDROP_MOVE:
- context->action = GDK_ACTION_MOVE;
- break;
- case XmDROP_COPY:
- context->action = GDK_ACTION_COPY;
- break;
- case XmDROP_LINK:
- context->action = GDK_ACTION_LINK;
- break;
+ if (!is_pointer_within_shape (display, child,
+ x_root - child->x,
+ y_root - child->y))
+ {
+ tmp_list = tmp_list->next;
+ continue;
+ }
+
+ retval = get_client_window_at_coords_recurse (display,
+ child->xid, TRUE,
+ x_root - child->x,
+ y_root - child->y);
+ if (!retval)
+ retval = child->xid;
}
}
- else
- context->action = 0;
-
- return GDK_FILTER_TRANSLATE;
+ tmp_list = tmp_list->next;
}
- return GDK_FILTER_REMOVE;
-}
-
-static GdkFilterReturn
-motif_dnd_filter (GdkXEvent *xev,
- GdkEvent *event,
- gpointer data)
-{
- XEvent *xevent = (XEvent *)xev;
-
- guint8 reason;
- guint16 flags;
- guint32 timestamp;
- guint32 source_window;
- Atom atom;
- gint16 x_root, y_root;
- gboolean is_reply;
- if (!event->any.window ||
- gdk_window_get_window_type (event->any.window) == GDK_WINDOW_FOREIGN)
- return GDK_FILTER_CONTINUE; /* Not for us */
-
- /* First read some fields common to all Motif DND messages */
- reason = MOTIF_UNPACK_BYTE (xevent, 0);
- flags = MOTIF_UNPACK_SHORT (xevent, 1);
- timestamp = MOTIF_UNPACK_LONG (xevent, 1);
+ gdk_x11_display_error_trap_pop_ignored (display);
- is_reply = ((reason & 0x80) != 0);
+ if (retval)
+ return retval;
+ else
+ return GDK_WINDOW_XID (gdk_screen_get_root_window (cache->screen));
+}
- switch (reason & 0x7f)
+#ifdef G_ENABLE_DEBUG
+static void
+print_target_list (GList *targets)
+{
+ while (targets)
{
- case XmTOP_LEVEL_ENTER:
- source_window = MOTIF_UNPACK_LONG (xevent, 2);
- atom = MOTIF_UNPACK_LONG (xevent, 3);
- return motif_top_level_enter (event, flags, timestamp, source_window, atom);
- case XmTOP_LEVEL_LEAVE:
- return motif_top_level_leave (event, flags, timestamp);
-
- case XmDRAG_MOTION:
- x_root = MOTIF_UNPACK_SHORT (xevent, 4);
- y_root = MOTIF_UNPACK_SHORT (xevent, 5);
-
- if (!is_reply)
- return motif_motion (event, flags, timestamp, x_root, y_root);
- else
- return motif_drag_status (event, flags, timestamp);
-
- case XmDROP_SITE_ENTER:
- return motif_drag_status (event, flags, timestamp);
-
- case XmDROP_SITE_LEAVE:
- return motif_drag_status (event,
- XmNO_DROP_SITE << 8 | XmDROP_NOOP,
- timestamp);
- case XmDROP_START:
- x_root = MOTIF_UNPACK_SHORT (xevent, 4);
- y_root = MOTIF_UNPACK_SHORT (xevent, 5);
- atom = MOTIF_UNPACK_LONG (xevent, 3);
- source_window = MOTIF_UNPACK_LONG (xevent, 4);
-
- if (!is_reply)
- return motif_drop_start (event, flags, timestamp, source_window, atom, x_root, y_root);
-
- break;
- case XmOPERATION_CHANGED:
- if (!is_reply)
- return motif_operation_changed (event, flags, timestamp);
- else
- return motif_drag_status (event, flags, timestamp);
-
- break;
- /* To the best of my knowledge, these next two messages are
- * not part of the protocol, though they are defined in
- * the header files.
- */
- case XmDROP_FINISH:
- case XmDRAG_DROP_FINISH:
- break;
+ gchar *name = gdk_atom_name (GDK_POINTER_TO_ATOM (targets->data));
+ g_message ("\t%s", name);
+ g_free (name);
+ targets = targets->next;
}
-
- return GDK_FILTER_REMOVE;
}
+#endif /* G_ENABLE_DEBUG */
/*************************************************************
***************************** XDND **************************
@@ -2799,11 +1527,9 @@ base_precache_atoms (GdkDisplay *display)
if (!display_x11->base_dnd_atoms_precached)
{
static const char *const precache_atoms[] = {
- "ENLIGHTENMENT_DESKTOP",
"WM_STATE",
"XdndAware",
- "XdndProxy",
- "_MOTIF_DRAG_RECEIVER_INFO"
+ "XdndProxy"
};
_gdk_x11_precache_atoms (display,
@@ -3165,9 +1891,6 @@ gdk_drag_do_leave (GdkX11DragContext *context_x11,
{
switch (context->protocol)
{
- case GDK_DRAG_PROTO_MOTIF:
- motif_send_leave (context_x11, time);
- break;
case GDK_DRAG_PROTO_XDND:
xdnd_send_leave (context_x11);
break;
@@ -3243,12 +1966,6 @@ _gdk_x11_display_get_drag_protocol (GdkDisplay *display,
GDK_NOTE (DND, g_message ("Entering Xdnd window %#x\n", (guint) xid));
return retval;
}
- else if ((retval = motif_check_dest (display, xid)))
- {
- *protocol = GDK_DRAG_PROTO_MOTIF;
- GDK_NOTE (DND, g_message ("Entering motif window %#x\n", (guint) xid));
- return retval;
- }
else
{
/* Check if this is a root window */
@@ -3431,10 +2148,6 @@ gdk_x11_drag_context_drag_motion (GdkDragContext *context,
switch (protocol)
{
- case GDK_DRAG_PROTO_MOTIF:
- motif_send_enter (context_x11, time);
- break;
-
case GDK_DRAG_PROTO_XDND:
xdnd_send_enter (context_x11);
break;
@@ -3489,10 +2202,6 @@ gdk_x11_drag_context_drag_motion (GdkDragContext *context,
{
switch (context->protocol)
{
- case GDK_DRAG_PROTO_MOTIF:
- motif_send_motion (context_x11, x_root, y_root, suggested_action, time);
- break;
-
case GDK_DRAG_PROTO_XDND:
xdnd_send_motion (context_x11, x_root, y_root, suggested_action, time);
break;
@@ -3556,11 +2265,6 @@ gdk_x11_drag_context_drag_drop (GdkDragContext *context,
{
switch (context->protocol)
{
- case GDK_DRAG_PROTO_MOTIF:
- motif_send_leave (context_x11, time);
- motif_send_drop (context_x11, time);
- break;
-
case GDK_DRAG_PROTO_XDND:
xdnd_send_drop (context_x11, time);
break;
@@ -3592,88 +2296,7 @@ gdk_x11_drag_context_drag_status (GdkDragContext *context,
context->action = action;
- if (context->protocol == GDK_DRAG_PROTO_MOTIF)
- {
- gboolean need_coords = FALSE;
-
- xev.xclient.type = ClientMessage;
- xev.xclient.message_type =
- gdk_x11_get_xatom_by_name_for_display (display,
- "_MOTIF_DRAG_AND_DROP_MESSAGE");
- xev.xclient.format = 8;
- xev.xclient.window = GDK_WINDOW_XID (context->source_window);
-
- if (context_x11->drag_status == GDK_DRAG_STATUS_ACTION_WAIT)
- {
- MOTIF_XCLIENT_BYTE (&xev, 0) = XmOPERATION_CHANGED | 0x80;
- }
- else
- {
- if ((action != 0) != (context_x11->old_action != 0))
- {
- if (action != 0)
- {
- MOTIF_XCLIENT_BYTE (&xev, 0) = XmDROP_SITE_ENTER | 0x80;
- need_coords = TRUE;
- }
- else
- {
- MOTIF_XCLIENT_BYTE (&xev, 0) = XmDROP_SITE_LEAVE | 0x80;
- }
- }
- else
- {
- MOTIF_XCLIENT_BYTE (&xev, 0) = XmDRAG_MOTION | 0x80;
- need_coords = TRUE;
- }
- }
-
- MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
-
- switch (action)
- {
- case GDK_ACTION_MOVE:
- MOTIF_XCLIENT_SHORT (&xev, 1) = XmDROP_MOVE;
- break;
- case GDK_ACTION_COPY:
- MOTIF_XCLIENT_SHORT (&xev, 1) = XmDROP_COPY;
- break;
- case GDK_ACTION_LINK:
- MOTIF_XCLIENT_SHORT (&xev, 1) = XmDROP_LINK;
- break;
- default:
- MOTIF_XCLIENT_SHORT (&xev, 1) = XmDROP_NOOP;
- break;
- }
-
- if (action)
- MOTIF_XCLIENT_SHORT (&xev, 1) |= (XmDROP_SITE_VALID << 4);
- else
- MOTIF_XCLIENT_SHORT (&xev, 1) |= (XmNO_DROP_SITE << 4);
-
- MOTIF_XCLIENT_LONG (&xev, 1) = time_;
-
- if (need_coords)
- {
- MOTIF_XCLIENT_SHORT (&xev, 4) = context_x11->last_x;
- MOTIF_XCLIENT_SHORT (&xev, 5) = context_x11->last_y;
- }
- else
- MOTIF_XCLIENT_LONG (&xev, 2) = 0;
-
- MOTIF_XCLIENT_LONG (&xev, 3) = 0;
- MOTIF_XCLIENT_LONG (&xev, 4) = 0;
-
- if (!_gdk_x11_display_send_xevent (display,
- GDK_WINDOW_XID (context->source_window),
- FALSE, 0, &xev))
- {
- GDK_NOTE (DND,
- g_message ("Send event to %lx failed",
- GDK_WINDOW_XID (context->source_window)));
- }
- }
- else if (context->protocol == GDK_DRAG_PROTO_XDND)
+ if (context->protocol == GDK_DRAG_PROTO_XDND)
{
xev.xclient.type = ClientMessage;
xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "XdndStatus");
@@ -3701,40 +2324,6 @@ gdk_x11_drag_context_drop_reply (GdkDragContext *context,
gboolean accepted,
guint32 time_)
{
- GdkX11DragContext *context_x11 = GDK_X11_DRAG_CONTEXT (context);
-
- if (context->protocol == GDK_DRAG_PROTO_MOTIF)
- {
- GdkDisplay *display = GDK_WINDOW_DISPLAY (context->source_window);
- XEvent xev;
-
- xev.xclient.type = ClientMessage;
- xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display,
- "_MOTIF_DRAG_AND_DROP_MESSAGE");
- xev.xclient.format = 8;
-
- MOTIF_XCLIENT_BYTE (&xev, 0) = XmDROP_START | 0x80;
- MOTIF_XCLIENT_BYTE (&xev, 1) = local_byte_order;
- if (accepted)
- MOTIF_XCLIENT_SHORT (&xev, 1) = XmDROP_COPY |
- (XmDROP_SITE_VALID << 4) |
- (XmDROP_NOOP << 8) |
- (XmDROP << 12);
- else
- MOTIF_XCLIENT_SHORT (&xev, 1) = XmDROP_NOOP |
- (XmNO_DROP_SITE << 4) |
- (XmDROP_NOOP << 8) |
- (XmDROP_CANCEL << 12);
- MOTIF_XCLIENT_SHORT (&xev, 2) = context_x11->last_x;
- MOTIF_XCLIENT_SHORT (&xev, 3) = context_x11->last_y;
- MOTIF_XCLIENT_LONG (&xev, 2) = 0;
- MOTIF_XCLIENT_LONG (&xev, 3) = 0;
- MOTIF_XCLIENT_LONG (&xev, 4) = 0;
-
- _gdk_x11_display_send_xevent (display,
- GDK_WINDOW_XID (context->source_window),
- FALSE, 0, &xev);
- }
}
static void
@@ -3780,8 +2369,6 @@ void
_gdk_x11_window_register_dnd (GdkWindow *window)
{
static const gulong xdnd_version = 5;
- MotifDragReceiverInfo info;
- Atom motif_drag_receiver_info_atom;
GdkDisplay *display = gdk_window_get_display (window);
g_return_if_fail (window != NULL);
@@ -3796,26 +2383,6 @@ _gdk_x11_window_register_dnd (GdkWindow *window)
else
g_object_set_data (G_OBJECT (window), "gdk-dnd-registered", GINT_TO_POINTER (TRUE));
- /* Set Motif drag receiver information property */
- motif_drag_receiver_info_atom = gdk_x11_get_xatom_by_name_for_display (display,
- "_MOTIF_DRAG_RECEIVER_INFO");
- /* initialize to zero to avoid writing uninitialized data to socket */
- memset(&info, 0, sizeof(info));
- info.byte_order = local_byte_order;
- info.protocol_version = 0;
- info.protocol_style = XmDRAG_DYNAMIC;
- info.proxy_window = None;
- info.num_drop_sites = 0;
- info.total_size = sizeof(info);
-
- XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
- GDK_WINDOW_XID (window),
- motif_drag_receiver_info_atom,
- motif_drag_receiver_info_atom,
- 8, PropModeReplace,
- (guchar *)&info,
- sizeof (info));
-
/* Set XdndAware */
/* The property needs to be of type XA_ATOM, not XA_INTEGER. Blech */
@@ -3829,10 +2396,7 @@ _gdk_x11_window_register_dnd (GdkWindow *window)
static GdkAtom
gdk_x11_drag_context_get_selection (GdkDragContext *context)
{
- if (context->protocol == GDK_DRAG_PROTO_MOTIF)
- return gdk_x11_xatom_to_atom_for_display (GDK_WINDOW_DISPLAY (context->source_window),
- (GDK_X11_DRAG_CONTEXT (context))->motif_selection);
- else if (context->protocol == GDK_DRAG_PROTO_XDND)
+ if (context->protocol == GDK_DRAG_PROTO_XDND)
return gdk_atom_intern_static_string ("XdndSelection");
else
return GDK_NONE;
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index 4b974a5..2431f98 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -185,8 +185,6 @@ typedef gboolean (* GtkDragDestCallback) (GtkWidget *widget,
/* Enumeration for some targets we handle internally */
enum {
- TARGET_MOTIF_SUCCESS = 0x40000000,
- TARGET_MOTIF_FAILURE,
TARGET_DELETE
};
@@ -1200,12 +1198,6 @@ gtk_drag_finish (GdkDragContext *context,
{
target = gdk_atom_intern_static_string ("DELETE");
}
- else if (gdk_drag_context_get_protocol (context) == GDK_DRAG_PROTO_MOTIF)
- {
- target = gdk_atom_intern_static_string (success ?
- "XmTRANSFER_SUCCESS" :
- "XmTRANSFER_FAILURE");
- }
if (target != GDK_NONE)
{
@@ -1781,8 +1773,6 @@ _gtk_drag_dest_handle_event (GtkWidget *toplevel,
else if (event->type == GDK_DROP_START && !info->proxy_source)
{
gdk_drop_reply (context, found, event->dnd.time);
- if ((gdk_drag_context_get_protocol (context) == GDK_DRAG_PROTO_MOTIF) && !found)
- gtk_drag_finish (context, FALSE, FALSE, event->dnd.time);
}
}
break;
@@ -3575,7 +3565,7 @@ _gtk_drag_source_handle_event (GtkWidget *widget,
{
gboolean result = gdk_drag_context_get_selected_action (context) != 0;
- /* Aha - we can finally pass the MOTIF DROP on... */
+ /* Aha - we can finally pass the DROP on... */
gdk_drop_reply (info->proxy_dest->context, result, info->proxy_dest->proxy_drop_time);
if (result)
gdk_drag_drop (info->context, info->proxy_dest->proxy_drop_time);
@@ -3663,18 +3653,6 @@ gtk_drag_source_check_selection (GtkDragSourceInfo *info,
pair->info);
tmp_list = tmp_list->next;
}
-
- if (gdk_drag_context_get_protocol (info->context) == GDK_DRAG_PROTO_MOTIF)
- {
- gtk_selection_add_target (info->ipc_widget,
- selection,
- gdk_atom_intern_static_string ("XmTRANSFER_SUCCESS"),
- TARGET_MOTIF_SUCCESS);
- gtk_selection_add_target (info->ipc_widget,
- selection,
- gdk_atom_intern_static_string ("XmTRANSFER_FAILURE"),
- TARGET_MOTIF_FAILURE);
- }
gtk_selection_add_target (info->ipc_widget,
selection,
@@ -3922,14 +3900,6 @@ gtk_drag_selection_get (GtkWidget *widget,
info->context);
gtk_selection_data_set (selection_data, null_atom, 8, NULL, 0);
break;
- case TARGET_MOTIF_SUCCESS:
- gtk_drag_drop_finished (info, GTK_DRAG_RESULT_SUCCESS, time);
- gtk_selection_data_set (selection_data, null_atom, 8, NULL, 0);
- break;
- case TARGET_MOTIF_FAILURE:
- gtk_drag_drop_finished (info, GTK_DRAG_RESULT_NO_TARGET, time);
- gtk_selection_data_set (selection_data, null_atom, 8, NULL, 0);
- break;
default:
if (info->proxy_dest)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]