Commit ba999da1 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Lookup all the atoms in the target list at once.

Sat Jul  5 09:55:38 2003  Owen Taylor  <otaylor@redhat.com>

        * gdk/x11/gdkdnd-x11.c (precache_target_list): Lookup
        all the atoms in the target list at once.

        * gdk/x11/gdkdnd-x11.c (gdk_drag_get_protocol_for_display):
        Local drag short-circuit.

        * gdk/x11/gdkdnd-x11.c (gdk_drag_motion): For the
        local case, poke the actions in directly instead of
        going through xdnd_set_actions.

        * gdk/x11/gdkdnd-x11.c (xdnd_read_actions): Short-circuit
        the local case.

        * gdk/x11/gdkdnd-x11.c (xdnd_manage_source_filter): Don't
        XSelectInput()/add a filter if the drag is local.

        * gdk/x11/gdkdnd-x11.c (gdk_drag_get_selection):
        Simplify handling of "XdndSelection".

        * gdk/x11/gdkevents-x11.c (gdk_event_send_client_message_to_all_recurse): Somehow,
        a WM_STATE => _NET_WM_STATE change hand been made here.

        * gdk/x11/gdkproperty-x11.c (_gdk_x11_precache_atoms): Free
        xatom_names, not atom_names.

        * tests/testdnd.c (target_drag_motion): Make the trashcan
        open again. (Got lost in deprecation cleanup.)
parent e5561940
Sat Jul 5 09:55:38 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkdnd-x11.c (precache_target_list): Lookup
all the atoms in the target list at once.
* gdk/x11/gdkdnd-x11.c (gdk_drag_get_protocol_for_display):
Local drag short-circuit.
* gdk/x11/gdkdnd-x11.c (gdk_drag_motion): For the
local case, poke the actions in directly instead of
going through xdnd_set_actions.
* gdk/x11/gdkdnd-x11.c (xdnd_read_actions): Short-circuit
the local case.
* gdk/x11/gdkdnd-x11.c (xdnd_manage_source_filter): Don't
XSelectInput()/add a filter if the drag is local.
* gdk/x11/gdkdnd-x11.c (gdk_drag_get_selection):
Simplify handling of "XdndSelection".
* gdk/x11/gdkevents-x11.c (gdk_event_send_client_message_to_all_recurse): Somehow,
a WM_STATE => _NET_WM_STATE change hand been made here.
* gdk/x11/gdkproperty-x11.c (_gdk_x11_precache_atoms): Free
xatom_names, not atom_names.
* tests/testdnd.c (target_drag_motion): Make the trashcan
open again. (Got lost in deprecation cleanup.)
Sat Jul 5 00:49:32 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtkdnd.c (gtk_drag_begin): Move the grabs up
earlier, so we don't get a big pile of uncompressed
motion events before the grab takes effect.
* gtk/gtkdnd.c (gtk_drag_update_icon): Call
gdk_window_process_all_updates() so that the area
we are dragging over gets a change to redraw.
* gtk/gtkdnd.c (_gtk_drag_dest_handle_event): Use
gdk_window_get_position(), not gdk_window_get_origin().
* gdk/x11/gdkwindow-x11.[ch] (gdk_window_have_shape_ext)
gdkdisplay-x11.h: use XShapeQueryExtension to
avoid duplicate XQueryExtension when we actually
use it. Remove unnecessary caching in GdkDisplayX11.
Fri Jul 4 23:49:22 2003 Owen Taylor <otaylor@redhat.com> Fri Jul 4 23:49:22 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkasync.[ch] (_gdk_x11_get_window_child_info): * gdk/x11/gdkasync.[ch] (_gdk_x11_get_window_child_info):
......
Sat Jul 5 09:55:38 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkdnd-x11.c (precache_target_list): Lookup
all the atoms in the target list at once.
* gdk/x11/gdkdnd-x11.c (gdk_drag_get_protocol_for_display):
Local drag short-circuit.
* gdk/x11/gdkdnd-x11.c (gdk_drag_motion): For the
local case, poke the actions in directly instead of
going through xdnd_set_actions.
* gdk/x11/gdkdnd-x11.c (xdnd_read_actions): Short-circuit
the local case.
* gdk/x11/gdkdnd-x11.c (xdnd_manage_source_filter): Don't
XSelectInput()/add a filter if the drag is local.
* gdk/x11/gdkdnd-x11.c (gdk_drag_get_selection):
Simplify handling of "XdndSelection".
* gdk/x11/gdkevents-x11.c (gdk_event_send_client_message_to_all_recurse): Somehow,
a WM_STATE => _NET_WM_STATE change hand been made here.
* gdk/x11/gdkproperty-x11.c (_gdk_x11_precache_atoms): Free
xatom_names, not atom_names.
* tests/testdnd.c (target_drag_motion): Make the trashcan
open again. (Got lost in deprecation cleanup.)
Sat Jul 5 00:49:32 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtkdnd.c (gtk_drag_begin): Move the grabs up
earlier, so we don't get a big pile of uncompressed
motion events before the grab takes effect.
* gtk/gtkdnd.c (gtk_drag_update_icon): Call
gdk_window_process_all_updates() so that the area
we are dragging over gets a change to redraw.
* gtk/gtkdnd.c (_gtk_drag_dest_handle_event): Use
gdk_window_get_position(), not gdk_window_get_origin().
* gdk/x11/gdkwindow-x11.[ch] (gdk_window_have_shape_ext)
gdkdisplay-x11.h: use XShapeQueryExtension to
avoid duplicate XQueryExtension when we actually
use it. Remove unnecessary caching in GdkDisplayX11.
Fri Jul 4 23:49:22 2003 Owen Taylor <otaylor@redhat.com> Fri Jul 4 23:49:22 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkasync.[ch] (_gdk_x11_get_window_child_info): * gdk/x11/gdkasync.[ch] (_gdk_x11_get_window_child_info):
......
Sat Jul 5 09:55:38 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkdnd-x11.c (precache_target_list): Lookup
all the atoms in the target list at once.
* gdk/x11/gdkdnd-x11.c (gdk_drag_get_protocol_for_display):
Local drag short-circuit.
* gdk/x11/gdkdnd-x11.c (gdk_drag_motion): For the
local case, poke the actions in directly instead of
going through xdnd_set_actions.
* gdk/x11/gdkdnd-x11.c (xdnd_read_actions): Short-circuit
the local case.
* gdk/x11/gdkdnd-x11.c (xdnd_manage_source_filter): Don't
XSelectInput()/add a filter if the drag is local.
* gdk/x11/gdkdnd-x11.c (gdk_drag_get_selection):
Simplify handling of "XdndSelection".
* gdk/x11/gdkevents-x11.c (gdk_event_send_client_message_to_all_recurse): Somehow,
a WM_STATE => _NET_WM_STATE change hand been made here.
* gdk/x11/gdkproperty-x11.c (_gdk_x11_precache_atoms): Free
xatom_names, not atom_names.
* tests/testdnd.c (target_drag_motion): Make the trashcan
open again. (Got lost in deprecation cleanup.)
Sat Jul 5 00:49:32 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtkdnd.c (gtk_drag_begin): Move the grabs up
earlier, so we don't get a big pile of uncompressed
motion events before the grab takes effect.
* gtk/gtkdnd.c (gtk_drag_update_icon): Call
gdk_window_process_all_updates() so that the area
we are dragging over gets a change to redraw.
* gtk/gtkdnd.c (_gtk_drag_dest_handle_event): Use
gdk_window_get_position(), not gdk_window_get_origin().
* gdk/x11/gdkwindow-x11.[ch] (gdk_window_have_shape_ext)
gdkdisplay-x11.h: use XShapeQueryExtension to
avoid duplicate XQueryExtension when we actually
use it. Remove unnecessary caching in GdkDisplayX11.
Fri Jul 4 23:49:22 2003 Owen Taylor <otaylor@redhat.com> Fri Jul 4 23:49:22 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkasync.[ch] (_gdk_x11_get_window_child_info): * gdk/x11/gdkasync.[ch] (_gdk_x11_get_window_child_info):
......
Sat Jul 5 09:55:38 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkdnd-x11.c (precache_target_list): Lookup
all the atoms in the target list at once.
* gdk/x11/gdkdnd-x11.c (gdk_drag_get_protocol_for_display):
Local drag short-circuit.
* gdk/x11/gdkdnd-x11.c (gdk_drag_motion): For the
local case, poke the actions in directly instead of
going through xdnd_set_actions.
* gdk/x11/gdkdnd-x11.c (xdnd_read_actions): Short-circuit
the local case.
* gdk/x11/gdkdnd-x11.c (xdnd_manage_source_filter): Don't
XSelectInput()/add a filter if the drag is local.
* gdk/x11/gdkdnd-x11.c (gdk_drag_get_selection):
Simplify handling of "XdndSelection".
* gdk/x11/gdkevents-x11.c (gdk_event_send_client_message_to_all_recurse): Somehow,
a WM_STATE => _NET_WM_STATE change hand been made here.
* gdk/x11/gdkproperty-x11.c (_gdk_x11_precache_atoms): Free
xatom_names, not atom_names.
* tests/testdnd.c (target_drag_motion): Make the trashcan
open again. (Got lost in deprecation cleanup.)
Sat Jul 5 00:49:32 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtkdnd.c (gtk_drag_begin): Move the grabs up
earlier, so we don't get a big pile of uncompressed
motion events before the grab takes effect.
* gtk/gtkdnd.c (gtk_drag_update_icon): Call
gdk_window_process_all_updates() so that the area
we are dragging over gets a change to redraw.
* gtk/gtkdnd.c (_gtk_drag_dest_handle_event): Use
gdk_window_get_position(), not gdk_window_get_origin().
* gdk/x11/gdkwindow-x11.[ch] (gdk_window_have_shape_ext)
gdkdisplay-x11.h: use XShapeQueryExtension to
avoid duplicate XQueryExtension when we actually
use it. Remove unnecessary caching in GdkDisplayX11.
Fri Jul 4 23:49:22 2003 Owen Taylor <otaylor@redhat.com> Fri Jul 4 23:49:22 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkasync.[ch] (_gdk_x11_get_window_child_info): * gdk/x11/gdkasync.[ch] (_gdk_x11_get_window_child_info):
......
Sat Jul 5 09:55:38 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkdnd-x11.c (precache_target_list): Lookup
all the atoms in the target list at once.
* gdk/x11/gdkdnd-x11.c (gdk_drag_get_protocol_for_display):
Local drag short-circuit.
* gdk/x11/gdkdnd-x11.c (gdk_drag_motion): For the
local case, poke the actions in directly instead of
going through xdnd_set_actions.
* gdk/x11/gdkdnd-x11.c (xdnd_read_actions): Short-circuit
the local case.
* gdk/x11/gdkdnd-x11.c (xdnd_manage_source_filter): Don't
XSelectInput()/add a filter if the drag is local.
* gdk/x11/gdkdnd-x11.c (gdk_drag_get_selection):
Simplify handling of "XdndSelection".
* gdk/x11/gdkevents-x11.c (gdk_event_send_client_message_to_all_recurse): Somehow,
a WM_STATE => _NET_WM_STATE change hand been made here.
* gdk/x11/gdkproperty-x11.c (_gdk_x11_precache_atoms): Free
xatom_names, not atom_names.
* tests/testdnd.c (target_drag_motion): Make the trashcan
open again. (Got lost in deprecation cleanup.)
Sat Jul 5 00:49:32 2003 Owen Taylor <otaylor@redhat.com>
* gtk/gtkdnd.c (gtk_drag_begin): Move the grabs up
earlier, so we don't get a big pile of uncompressed
motion events before the grab takes effect.
* gtk/gtkdnd.c (gtk_drag_update_icon): Call
gdk_window_process_all_updates() so that the area
we are dragging over gets a change to redraw.
* gtk/gtkdnd.c (_gtk_drag_dest_handle_event): Use
gdk_window_get_position(), not gdk_window_get_origin().
* gdk/x11/gdkwindow-x11.[ch] (gdk_window_have_shape_ext)
gdkdisplay-x11.h: use XShapeQueryExtension to
avoid duplicate XQueryExtension when we actually
use it. Remove unnecessary caching in GdkDisplayX11.
Fri Jul 4 23:49:22 2003 Owen Taylor <otaylor@redhat.com> Fri Jul 4 23:49:22 2003 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkasync.[ch] (_gdk_x11_get_window_child_info): * gdk/x11/gdkasync.[ch] (_gdk_x11_get_window_child_info):
......
...@@ -49,6 +49,7 @@ in this Software without prior written authorization from The Open Group. ...@@ -49,6 +49,7 @@ in this Software without prior written authorization from The Open Group.
typedef struct _ChildInfoChildState ChildInfoChildState; typedef struct _ChildInfoChildState ChildInfoChildState;
typedef struct _ChildInfoState ChildInfoState; typedef struct _ChildInfoState ChildInfoState;
typedef struct _ListChildrenState ListChildrenState;
typedef struct _SendEventState SendEventState; typedef struct _SendEventState SendEventState;
typedef struct _SetInputFocusState SetInputFocusState; typedef struct _SetInputFocusState SetInputFocusState;
...@@ -78,6 +79,14 @@ struct _ChildInfoState ...@@ -78,6 +79,14 @@ struct _ChildInfoState
gboolean child_has_error; gboolean child_has_error;
}; };
struct _ListChildrenState
{
Display *dpy;
gulong get_property_req;
gboolean have_error;
gboolean has_wm_state;
};
struct _SendEventState struct _SendEventState
{ {
Display *dpy; Display *dpy;
...@@ -316,6 +325,116 @@ _gdk_x11_set_input_focus_safe (GdkDisplay *display, ...@@ -316,6 +325,116 @@ _gdk_x11_set_input_focus_safe (GdkDisplay *display,
SyncHandle(); SyncHandle();
} }
static Bool
list_children_handler (Display *dpy,
xReply *rep,
char *buf,
int len,
XPointer data)
{
ListChildrenState *state = (ListChildrenState *)data;
if (dpy->last_request_read != state->get_property_req)
return False;
if (rep->generic.type == X_Error)
{
state->have_error = TRUE;
return False;
}
else
{
xGetPropertyReply replbuf;
xGetPropertyReply *repl;
repl = (xGetPropertyReply *)
_XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
(sizeof(xGetPropertyReply) - sizeof(xReply)) >> 2,
True);
state->has_wm_state = repl->propertyType != None;
/* Since we called GetProperty with longLength of 0, we don't
* have to worry about consuming the property data that would
* normally follow after the reply
*/
return True;
}
}
static gboolean
list_children_and_wm_state (Display *dpy,
Window w,
Atom wm_state_atom,
gboolean *has_wm_state,
Window **children,
unsigned int *nchildren)
{
ListChildrenState state;
_XAsyncHandler async;
long nbytes;
xQueryTreeReply rep;
register xResourceReq *req;
xGetPropertyReq *prop_req;
LockDisplay(dpy);
*children = NULL;
*nchildren = 0;
*has_wm_state = FALSE;
state.have_error = FALSE;
state.has_wm_state = FALSE;
if (wm_state_atom)
{
async.next = dpy->async_handlers;
async.handler = list_children_handler;
async.data = (XPointer) &state;
dpy->async_handlers = &async;
GetReq (GetProperty, prop_req);
prop_req->window = w;
prop_req->property = wm_state_atom;
prop_req->type = AnyPropertyType;
prop_req->delete = False;
prop_req->longOffset = 0;
prop_req->longLength = 0;
state.get_property_req = dpy->request;
}
GetResReq(QueryTree, w, req);
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse))
{
state.have_error = TRUE;
goto out;
}
if (rep.nChildren != 0)
{
nbytes = rep.nChildren << 2;
if (state.have_error)
{
_XEatData(dpy, (unsigned long) nbytes);
goto out;
}
*children = g_new (Window, rep.nChildren);
_XRead32 (dpy, (long *) *children, nbytes);
}
*nchildren = rep.nChildren;
*has_wm_state = state.has_wm_state;
out:
if (wm_state_atom)
DeqAsyncHandler(dpy, &async);
UnlockDisplay(dpy);
SyncHandle();
return !state.have_error;
}
static void static void
handle_get_wa_reply (Display *dpy, handle_get_wa_reply (Display *dpy,
ChildInfoState *state, ChildInfoState *state,
...@@ -454,14 +573,15 @@ gboolean ...@@ -454,14 +573,15 @@ gboolean
_gdk_x11_get_window_child_info (GdkDisplay *display, _gdk_x11_get_window_child_info (GdkDisplay *display,
Window window, Window window,
gboolean get_wm_state, gboolean get_wm_state,
gboolean *win_has_wm_state,
GdkChildInfoX11 **children, GdkChildInfoX11 **children,
guint *nchildren) guint *nchildren)
{ {
Display *dpy; Display *dpy;
_XAsyncHandler async; _XAsyncHandler async;
ChildInfoState state; ChildInfoState state;
Window root, parent;
Atom wm_state_atom; Atom wm_state_atom;
gboolean has_wm_state;
Bool result; Bool result;
guint i; guint i;
...@@ -469,15 +589,32 @@ _gdk_x11_get_window_child_info (GdkDisplay *display, ...@@ -469,15 +589,32 @@ _gdk_x11_get_window_child_info (GdkDisplay *display,
*nchildren = 0; *nchildren = 0;
dpy = GDK_DISPLAY_XDISPLAY (display); dpy = GDK_DISPLAY_XDISPLAY (display);
wm_state_atom = gdk_x11_get_xatom_by_name_for_display (display, "WM_STATE"); if (get_wm_state)
wm_state_atom = gdk_x11_get_xatom_by_name_for_display (display, "WM_STATE");
else
wm_state_atom = None;
gdk_error_trap_push (); gdk_error_trap_push ();
result = XQueryTree (dpy, window, &root, &parent, result = list_children_and_wm_state (dpy, window,
&state.children, &state.nchildren); win_has_wm_state ? wm_state_atom : None,
&has_wm_state,
&state.children, &state.nchildren);
gdk_error_trap_pop (); gdk_error_trap_pop ();
if (!result) if (!result)
return FALSE; return FALSE;
if (has_wm_state)
{
if (win_has_wm_state)
*win_has_wm_state = TRUE;
return TRUE;
}
else
{
if (win_has_wm_state)
*win_has_wm_state = FALSE;
}
state.get_wm_state = get_wm_state; state.get_wm_state = get_wm_state;
state.child_info = g_new (GdkChildInfoX11, state.nchildren); state.child_info = g_new (GdkChildInfoX11, state.nchildren);
state.child_states = g_new (ChildInfoChildState, state.nchildren); state.child_states = g_new (ChildInfoChildState, state.nchildren);
...@@ -547,7 +684,7 @@ _gdk_x11_get_window_child_info (GdkDisplay *display, ...@@ -547,7 +684,7 @@ _gdk_x11_get_window_child_info (GdkDisplay *display,
g_free (state.child_info); g_free (state.child_info);
} }
XFree (state.children); g_free (state.children);
g_free (state.child_states); g_free (state.child_states);
DeqAsyncHandler(dpy, &async); DeqAsyncHandler(dpy, &async);
......
...@@ -59,6 +59,7 @@ void _gdk_x11_set_input_focus_safe (GdkDisplay *display, ...@@ -59,6 +59,7 @@ void _gdk_x11_set_input_focus_safe (GdkDisplay *display,
gboolean _gdk_x11_get_window_child_info (GdkDisplay *display, gboolean _gdk_x11_get_window_child_info (GdkDisplay *display,
Window window, Window window,
gboolean get_wm_state, gboolean get_wm_state,
gboolean *win_has_wm_state,
GdkChildInfoX11 **children, GdkChildInfoX11 **children,
guint *nchildren); guint *nchildren);
......
...@@ -136,6 +136,11 @@ struct _GdkDisplayX11 ...@@ -136,6 +136,11 @@ struct _GdkDisplayX11
/* Startup notification */ /* Startup notification */
gchar *startup_notification_id; gchar *startup_notification_id;
/* Sets of atoms for DND */
guint base_dnd_atoms_precached : 1;
guint xdnd_atoms_precached : 1;
guint motif_atoms_precached : 1;
}; };
struct _GdkDisplayX11Class struct _GdkDisplayX11Class
......
...@@ -67,7 +67,6 @@ struct _GdkDragContextPrivateX11 { ...@@ -67,7 +67,6 @@ struct _GdkDragContextPrivateX11 {
GdkDragContext context; GdkDragContext context;
Atom motif_selection; Atom motif_selection;
Atom xdnd_selection;
guint ref_count; guint ref_count;
guint16 last_x; /* Coordinates from last event */ guint16 last_x; /* Coordinates from last event */
...@@ -304,6 +303,29 @@ gdk_drag_context_find (GdkDisplay *display, ...@@ -304,6 +303,29 @@ gdk_drag_context_find (GdkDisplay *display,
return NULL; return NULL;
} }
static void
precache_target_list (GdkDragContext *context)
{
if (context->targets)
{
GPtrArray *targets = g_ptr_array_new ();
GList *tmp_list;
int i;
for (tmp_list = context->targets; tmp_list; tmp_list = tmp_list->next)
g_ptr_array_add (targets, gdk_atom_name (GDK_POINTER_TO_ATOM (tmp_list->data)));
_gdk_x11_precache_atoms (GDK_WINDOW_DISPLAY (context->source_window),
(const gchar **)targets->pdata,
targets->len);
for (i =0; i < targets->len; i++)
g_free (targets->pdata[i]);
g_ptr_array_free (targets, TRUE);
}
}
/* Utility functions */ /* Utility functions */
static void static void
...@@ -468,7 +490,8 @@ gdk_window_cache_new (GdkScreen *screen) ...@@ -468,7 +490,8 @@ gdk_window_cache_new (GdkScreen *screen)
if (!_gdk_x11_get_window_child_info (gdk_screen_get_display (screen), if (!_gdk_x11_get_window_child_info (gdk_screen_get_display (screen),
GDK_WINDOW_XWINDOW (root_window), GDK_WINDOW_XWINDOW (root_window),
FALSE, &children, &nchildren)) FALSE, NULL,
&children, &nchildren))
return result; return result;
for (i = 0; i < nchildren ; i++) for (i = 0; i < nchildren ; i++)
...@@ -500,33 +523,10 @@ gdk_window_cache_destroy (GdkWindowCache *cache) ...@@ -500,33 +523,10 @@ gdk_window_cache_destroy (GdkWindowCache *cache)
g_free (cache); g_free (cache);
} }
static gboolean
window_has_wm_state (GdkDisplay *display,
Window win)
{
Atom type = None;
int format;
unsigned long nitems, after;
unsigned char *data;
if (XGetWindowProperty (GDK_DISPLAY_XDISPLAY(display), win,
gdk_x11_get_xatom_by_name_for_display (display, "WM_STATE"),
0, 0, False, AnyPropertyType,
&type, &format, &nitems, &after, &data) != Success)
return FALSE;
if (type != None)
{
XFree (data);
return TRUE;
}
return FALSE;
}
static Window static Window
get_client_window_at_coords_recurse (GdkDisplay *display, get_client_window_at_coords_recurse (GdkDisplay *display,
Window win, Window win,
gboolean is_toplevel,
gint x, gint x,
gint y) gint y)
{