GdkWindow *window,
gboolean add_filter);
-static void gdk_drag_context_init (GdkDragContext *dragcontext);
-static void gdk_drag_context_class_init (GdkDragContextClass *klass);
static void gdk_drag_context_finalize (GObject *object);
-static gpointer parent_class = NULL;
static GList *contexts;
-const static struct {
+static const struct {
const char *atom_name;
GdkFilterFunc func;
-} const xdnd_filters[] = {
+} xdnd_filters[] = {
{ "XdndEnter", xdnd_enter_filter },
{ "XdndLeave", xdnd_leave_filter },
{ "XdndPosition", xdnd_position_filter },
{ "XdndDrop", xdnd_drop_filter },
};
-GType
-gdk_drag_context_get_type (void)
-{
- static GType object_type = 0;
-
- if (!object_type)
- {
- static const GTypeInfo object_info =
- {
- sizeof (GdkDragContextClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) gdk_drag_context_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof (GdkDragContext),
- 0, /* n_preallocs */
- (GInstanceInitFunc) gdk_drag_context_init,
- };
-
- object_type = g_type_register_static (G_TYPE_OBJECT,
- g_intern_static_string ("GdkDragContext"),
- &object_info, 0);
- }
-
- return object_type;
-}
+G_DEFINE_TYPE (GdkDragContext, gdk_drag_context, G_TYPE_OBJECT)
static void
gdk_drag_context_init (GdkDragContext *dragcontext)
{
GdkDragContextPrivateX11 *private;
- private = g_new0 (GdkDragContextPrivateX11, 1);
-
+ private = G_TYPE_INSTANCE_GET_PRIVATE (dragcontext,
+ GDK_TYPE_DRAG_CONTEXT,
+ GdkDragContextPrivateX11);
+
dragcontext->windowing_data = private;
contexts = g_list_prepend (contexts, dragcontext);
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- parent_class = g_type_class_peek_parent (klass);
-
object_class->finalize = gdk_drag_context_finalize;
+
+ g_type_class_add_private (object_class, sizeof (GdkDragContextPrivateX11));
}
static void
contexts = g_list_remove (contexts, context);
- g_free (private);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
+ G_OBJECT_CLASS (gdk_drag_context_parent_class)->finalize (object);
}
/* Drag Contexts */
* Return value: the newly created #GdkDragContext.
**/
GdkDragContext *
-gdk_drag_context_new (void)
+gdk_drag_context_new (void)
{
- return g_object_new (gdk_drag_context_get_type (), NULL);
+ return g_object_new (GDK_TYPE_DRAG_CONTEXT, NULL);
}
/**
XGetWindowAttributes (xdisplay, GDK_WINDOW_XWINDOW (root_window), &xwa);
result->old_event_mask = xwa.your_event_mask;
+
+ if (G_UNLIKELY (!GDK_DISPLAY_X11 (GDK_SCREEN_X11 (screen)->display)->trusted_client))
+ {
+ GList *toplevel_windows, *list;
+ GdkWindow *window;
+ gint x, y, width, height;
+
+ toplevel_windows = gdk_screen_get_toplevel_windows (screen);
+ for (list = toplevel_windows; list; list = list->next) {
+ window = GDK_WINDOW (list->data);
+ gdk_window_get_geometry (window, &x, &y, &width, &height, NULL);
+ gdk_window_cache_add (result, GDK_WINDOW_XID (window),
+ x, y, width, height,
+ gdk_window_is_visible (window));
+ }
+ g_list_free (toplevel_windows);
+ return result;
+ }
+
XSelectInput (xdisplay, GDK_WINDOW_XWINDOW (root_window),
result->old_event_mask | SubstructureNotifyMask);
gdk_window_add_filter (root_window, gdk_window_cache_filter, result);
unsigned int nchildren;
int i;
gboolean found_child = FALSE;
- GdkChildInfoX11 child;
+ GdkChildInfoX11 child = { 0, };
gboolean has_wm_state = FALSE;
if (!_gdk_x11_get_window_child_info (display, win, TRUE,
GdkDisplay *display = GDK_DRAWABLE_DISPLAY (context->source_window);
XEvent xev;
+ if (!G_LIKELY (GDK_DISPLAY_X11 (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;
static guint32
xdnd_check_dest (GdkDisplay *display,
Window win,
- gint *xdnd_version)
+ guint *xdnd_version)
{
gboolean retval = FALSE;
Atom type = None;
_gdk_drag_get_protocol_for_display (GdkDisplay *display,
guint32 xid,
GdkDragProtocol *protocol,
- gint *version)
+ guint *version)
{
GdkWindow *window;
GDK_NOTE (DND, g_message ("Entering local Xdnd window %#x\n", xid));
return xid;
}
- else
- return None;
+ else if (_gdk_x11_display_is_root_window (display, (Window) xid))
+ {
+ *protocol = GDK_DRAG_PROTO_ROOTWIN;
+ GDK_NOTE (DND, g_message ("Entering root window\n"));
+ return xid;
+ }
}
-
- if ((retval = xdnd_check_dest (display, xid, version)))
+ else if ((retval = xdnd_check_dest (display, xid, version)))
{
*protocol = GDK_DRAG_PROTO_XDND;
xdnd_precache_atoms (display);
if (rootwin)
{
+ GDK_NOTE (DND, g_message ("Entering root window\n"));
*protocol = GDK_DRAG_PROTO_ROOTWIN;
return xid;
}
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;