[gtk+] dnd: Drop GdkScreen from apis
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] dnd: Drop GdkScreen from apis
- Date: Tue, 31 Oct 2017 14:18:28 +0000 (UTC)
commit f8cad1982989c3318c0549bc7ef293f1f0bff63e
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Oct 31 10:16:18 2017 -0400
dnd: Drop GdkScreen from apis
Drop the screen argument from gdk_dnd_find_window_for_screen
and rename the function to gdk_dnd_find_window. The screen
argument does not add anything here since the drag context
is already tied to the display. Update all backends, and
update all callers.
docs/reference/gdk/gdk4-sections.txt | 2 +-
gdk/broadway/gdkdnd-broadway.c | 1 -
gdk/gdkdnd.c | 18 ++++-----
gdk/gdkdnd.h | 13 +++---
gdk/gdkdndprivate.h | 1 -
gdk/quartz/gdkdnd-quartz.c | 1 -
gdk/wayland/gdkdnd-wayland.c | 1 -
gdk/win32/gdkdnd-win32.c | 3 +-
gdk/x11/gdkdnd-x11.c | 73 +++++++++++++--------------------
gtk/gtkdnd.c | 10 ++--
10 files changed, 50 insertions(+), 73 deletions(-)
---
diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt
index a09df69..a0e5441 100644
--- a/docs/reference/gdk/gdk4-sections.txt
+++ b/docs/reference/gdk/gdk4-sections.txt
@@ -898,7 +898,7 @@ gdk_drag_abort
gdk_drop_reply
gdk_drag_drop
gdk_drag_drop_done
-gdk_drag_find_window_for_screen
+gdk_drag_find_window
gdk_drag_begin
gdk_drag_begin_for_device
gdk_drag_begin_from_point
diff --git a/gdk/broadway/gdkdnd-broadway.c b/gdk/broadway/gdkdnd-broadway.c
index 7c5fffe..46a82d4 100644
--- a/gdk/broadway/gdkdnd-broadway.c
+++ b/gdk/broadway/gdkdnd-broadway.c
@@ -113,7 +113,6 @@ _gdk_broadway_window_get_drag_protocol (GdkWindow *window,
static GdkWindow *
gdk_broadway_drag_context_find_window (GdkDragContext *context,
GdkWindow *drag_window,
- GdkScreen *screen,
gint x_root,
gint y_root,
GdkDragProtocol *protocol)
diff --git a/gdk/gdkdnd.c b/gdk/gdkdnd.c
index f6cddd5..0d22e26 100644
--- a/gdk/gdkdnd.c
+++ b/gdk/gdkdnd.c
@@ -362,11 +362,10 @@ gdk_drag_context_class_init (GdkDragContextClass *klass)
}
/**
- * gdk_drag_find_window_for_screen:
+ * gdk_drag_find_window:
* @context: a #GdkDragContext
* @drag_window: a window which may be at the pointer position, but
* should be ignored, since it is put up by the drag source as an icon
- * @screen: the screen where the destination window is sought
* @x_root: the x position of the pointer in root coordinates
* @y_root: the y position of the pointer in root coordinates
* @dest_window: (out): location to store the destination window in
@@ -381,18 +380,17 @@ gdk_drag_context_class_init (GdkDragContextClass *klass)
* Since: 2.2
*/
void
-gdk_drag_find_window_for_screen (GdkDragContext *context,
- GdkWindow *drag_window,
- GdkScreen *screen,
- gint x_root,
- gint y_root,
- GdkWindow **dest_window,
- GdkDragProtocol *protocol)
+gdk_drag_find_window (GdkDragContext *context,
+ GdkWindow *drag_window,
+ gint x_root,
+ gint y_root,
+ GdkWindow **dest_window,
+ GdkDragProtocol *protocol)
{
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
*dest_window = GDK_DRAG_CONTEXT_GET_CLASS (context)
- ->find_window (context, drag_window, screen, x_root, y_root, protocol);
+ ->find_window (context, drag_window, x_root, y_root, protocol);
}
/**
diff --git a/gdk/gdkdnd.h b/gdk/gdkdnd.h
index f86079c..a8b6266 100644
--- a/gdk/gdkdnd.h
+++ b/gdk/gdkdnd.h
@@ -168,13 +168,12 @@ GdkDragContext * gdk_drag_begin_from_point (GdkWindow *window,
gint y_root);
GDK_AVAILABLE_IN_ALL
-void gdk_drag_find_window_for_screen (GdkDragContext *context,
- GdkWindow *drag_window,
- GdkScreen *screen,
- gint x_root,
- gint y_root,
- GdkWindow **dest_window,
- GdkDragProtocol *protocol);
+void gdk_drag_find_window (GdkDragContext *context,
+ GdkWindow *drag_window,
+ gint x_root,
+ gint y_root,
+ GdkWindow **dest_window,
+ GdkDragProtocol *protocol);
GDK_AVAILABLE_IN_ALL
gboolean gdk_drag_motion (GdkDragContext *context,
diff --git a/gdk/gdkdndprivate.h b/gdk/gdkdndprivate.h
index d37ec67..ad2b507 100644
--- a/gdk/gdkdndprivate.h
+++ b/gdk/gdkdndprivate.h
@@ -35,7 +35,6 @@ struct _GdkDragContextClass {
GdkWindow * (*find_window) (GdkDragContext *context,
GdkWindow *drag_window,
- GdkScreen *screen,
gint x_root,
gint y_root,
GdkDragProtocol *protocol);
diff --git a/gdk/quartz/gdkdnd-quartz.c b/gdk/quartz/gdkdnd-quartz.c
index 15b6fed..ac2beb9 100644
--- a/gdk/quartz/gdkdnd-quartz.c
+++ b/gdk/quartz/gdkdnd-quartz.c
@@ -74,7 +74,6 @@ gdk_quartz_drag_context_drag_motion (GdkDragContext *context,
static GdkWindow *
gdk_quartz_drag_context_find_window (GdkDragContext *context,
GdkWindow *drag_window,
- GdkScreen *screen,
gint x_root,
gint y_root,
GdkDragProtocol *protocol)
diff --git a/gdk/wayland/gdkdnd-wayland.c b/gdk/wayland/gdkdnd-wayland.c
index 23fd8ba..16b8f82 100644
--- a/gdk/wayland/gdkdnd-wayland.c
+++ b/gdk/wayland/gdkdnd-wayland.c
@@ -140,7 +140,6 @@ _gdk_wayland_drag_context_emit_event (GdkDragContext *context,
static GdkWindow *
gdk_wayland_drag_context_find_window (GdkDragContext *context,
GdkWindow *drag_window,
- GdkScreen *screen,
gint x_root,
gint y_root,
GdkDragProtocol *protocol)
diff --git a/gdk/win32/gdkdnd-win32.c b/gdk/win32/gdkdnd-win32.c
index f1e9ef5..eded6aa 100644
--- a/gdk/win32/gdkdnd-win32.c
+++ b/gdk/win32/gdkdnd-win32.c
@@ -2013,7 +2013,6 @@ find_window_enum_proc (HWND hwnd,
static GdkWindow *
gdk_win32_drag_context_find_window (GdkDragContext *context,
GdkWindow *drag_window,
- GdkScreen *screen,
gint x_root,
gint y_root,
GdkDragProtocol *protocol)
@@ -2039,7 +2038,7 @@ gdk_win32_drag_context_find_window (GdkDragContext *context,
g_object_ref (dest_window);
}
else
- dest_window = gdk_win32_window_foreign_new_for_display (gdk_screen_get_display (screen), a.result);
+ dest_window = gdk_win32_window_foreign_new_for_display (context->display, a.result);
if (use_ole2_dnd)
*protocol = GDK_DRAG_PROTO_OLE2;
diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c
index 11585dd..7a9a69e 100644
--- a/gdk/x11/gdkdnd-x11.c
+++ b/gdk/x11/gdkdnd-x11.c
@@ -65,7 +65,7 @@ typedef struct {
GList *children;
GHashTable *child_hash;
guint old_event_mask;
- GdkScreen *screen;
+ GdkDisplay *display;
gint ref_count;
} GdkWindowCache;
@@ -83,7 +83,7 @@ struct _GdkX11DragContext
GdkDragAction xdnd_actions; /* What is currently set in XdndActionList */
guint version; /* Xdnd protocol version */
- GSList *window_caches;
+ GdkWindowCache *cache;
GdkWindow *drag_window;
@@ -141,7 +141,7 @@ static GrabKey grab_keys[] = {
/* Forward declarations */
-static GdkWindowCache *gdk_window_cache_get (GdkScreen *screen);
+static GdkWindowCache *gdk_window_cache_get (GdkDisplay *display);
static GdkWindowCache *gdk_window_cache_ref (GdkWindowCache *cache);
static void gdk_window_cache_unref (GdkWindowCache *cache);
@@ -200,7 +200,6 @@ gdk_x11_drag_context_init (GdkX11DragContext *context)
static void gdk_x11_drag_context_finalize (GObject *object);
static GdkWindow * gdk_x11_drag_context_find_window (GdkDragContext *context,
GdkWindow *drag_window,
- GdkScreen *screen,
gint x_root,
gint y_root,
GdkDragProtocol *protocol);
@@ -284,8 +283,8 @@ gdk_x11_drag_context_finalize (GObject *object)
xdnd_manage_source_filter (context, context->source_window, FALSE);
}
- g_slist_free_full (x11_context->window_caches, (GDestroyNotify)gdk_window_cache_unref);
- x11_context->window_caches = NULL;
+ if (x11_context->cache)
+ gdk_window_cache_unref (x11_context->cache);
contexts = g_list_remove (contexts, context);
@@ -411,7 +410,7 @@ gdk_window_cache_shape_filter (GdkXEvent *xev,
XEvent *xevent = (XEvent *)xev;
GdkWindowCache *cache = data;
- GdkX11Display *display = GDK_X11_DISPLAY (gdk_screen_get_display (cache->screen));
+ GdkX11Display *display = GDK_X11_DISPLAY (cache->display);
if (display->have_shapes &&
xevent->type == display->shape_event_base + ShapeNotify)
@@ -560,9 +559,10 @@ gdk_window_cache_filter (GdkXEvent *xev,
}
static GdkWindowCache *
-gdk_window_cache_new (GdkScreen *screen)
+gdk_window_cache_new (GdkDisplay *display)
{
XWindowAttributes xwa;
+ GdkScreen *screen = gdk_display_get_default_screen (display);
Display *xdisplay = GDK_SCREEN_XDISPLAY (screen);
GdkWindow *root_window = gdk_screen_get_root_window (screen);
GdkChildInfoX11 *children;
@@ -575,7 +575,7 @@ gdk_window_cache_new (GdkScreen *screen)
result->children = NULL;
result->child_hash = g_hash_table_new (g_direct_hash, NULL);
- result->screen = screen;
+ result->display = display;
result->ref_count = 1;
XGetWindowAttributes (xdisplay, GDK_WINDOW_XID (root_window), &xwa);
@@ -649,8 +649,7 @@ gdk_window_cache_new (GdkScreen *screen)
static void
gdk_window_cache_destroy (GdkWindowCache *cache)
{
- GdkWindow *root_window = gdk_screen_get_root_window (cache->screen);
- GdkDisplay *display;
+ GdkWindow *root_window = gdk_screen_get_root_window (gdk_display_get_default_screen (cache->display));
XSelectInput (GDK_WINDOW_XDISPLAY (root_window),
GDK_WINDOW_XID (root_window),
@@ -658,11 +657,9 @@ gdk_window_cache_destroy (GdkWindowCache *cache)
gdk_window_remove_filter (root_window, gdk_window_cache_filter, cache);
gdk_window_remove_filter (NULL, gdk_window_cache_shape_filter, cache);
- display = gdk_screen_get_display (cache->screen);
-
- gdk_x11_display_error_trap_push (display);
- g_list_foreach (cache->children, (GFunc)free_cache_child, display);
- gdk_x11_display_error_trap_pop_ignored (display);
+ gdk_x11_display_error_trap_push (cache->display);
+ g_list_foreach (cache->children, (GFunc)free_cache_child, cache->display);
+ gdk_x11_display_error_trap_pop_ignored (cache->display);
g_list_free (cache->children);
g_hash_table_destroy (cache->child_hash);
@@ -693,7 +690,7 @@ gdk_window_cache_unref (GdkWindowCache *cache)
}
GdkWindowCache *
-gdk_window_cache_get (GdkScreen *screen)
+gdk_window_cache_get (GdkDisplay *display)
{
GSList *list;
GdkWindowCache *cache;
@@ -701,11 +698,11 @@ gdk_window_cache_get (GdkScreen *screen)
for (list = window_caches; list; list = list->next)
{
cache = list->data;
- if (cache->screen == screen)
+ if (cache->display == display)
return gdk_window_cache_ref (cache);
}
- cache = gdk_window_cache_new (screen);
+ cache = gdk_window_cache_new (display);
window_caches = g_slist_prepend (window_caches, cache);
@@ -822,7 +819,7 @@ get_client_window_at_coords (GdkWindowCache *cache,
Window retval = None;
GdkDisplay *display;
- display = gdk_screen_get_display (cache->screen);
+ display = cache->display;
gdk_x11_display_error_trap_push (display);
@@ -861,7 +858,7 @@ get_client_window_at_coords (GdkWindowCache *cache,
if (retval)
return retval;
else
- return GDK_WINDOW_XID (gdk_screen_get_root_window (cache->screen));
+ return GDK_WINDOW_XID (gdk_screen_get_root_window (gdk_display_get_default_screen (cache->display)));
}
#ifdef G_ENABLE_DEBUG
@@ -2099,33 +2096,22 @@ _gdk_x11_display_get_drag_protocol (GdkDisplay *display,
static GdkWindowCache *
drag_context_find_window_cache (GdkX11DragContext *context_x11,
- GdkScreen *screen)
+ GdkDisplay *display)
{
- GSList *list;
- GdkWindowCache *cache;
+ if (!context_x11->cache)
+ context_x11->cache = gdk_window_cache_get (display);
- for (list = context_x11->window_caches; list; list = list->next)
- {
- cache = list->data;
- if (cache->screen == screen)
- return cache;
- }
-
- cache = gdk_window_cache_get (screen);
- context_x11->window_caches = g_slist_prepend (context_x11->window_caches, cache);
-
- return cache;
+ return context_x11->cache;
}
static GdkWindow *
gdk_x11_drag_context_find_window (GdkDragContext *context,
GdkWindow *drag_window,
- GdkScreen *screen,
gint x_root,
gint y_root,
GdkDragProtocol *protocol)
{
- GdkX11Screen *screen_x11 = GDK_X11_SCREEN(screen);
+ GdkX11Screen *screen_x11 = GDK_X11_SCREEN(gdk_display_get_default_screen (context->display));
GdkX11DragContext *context_x11 = GDK_X11_DRAG_CONTEXT (context);
GdkWindowCache *window_cache;
GdkDisplay *display;
@@ -2134,7 +2120,7 @@ gdk_x11_drag_context_find_window (GdkDragContext *context,
display = GDK_WINDOW_DISPLAY (context->source_window);
- window_cache = drag_context_find_window_cache (context_x11, screen);
+ window_cache = drag_context_find_window_cache (context_x11, display);
dest = get_client_window_at_coords (window_cache,
drag_window && GDK_WINDOW_IS_X11 (drag_window) ?
@@ -2215,10 +2201,10 @@ gdk_x11_drag_context_drag_motion (GdkDragContext *context,
{
/* This ugly hack is necessary since GTK+ doesn't know about
* the XDND protocol version, and in particular doesn't know
- * that gdk_drag_find_window_for_screen() has the side-effect
+ * that gdk_drag_find_window() has the side-effect
* of setting context_x11->version, and therefore sometimes call
* gdk_drag_motion() without a prior call to
- * gdk_drag_find_window_for_screen(). This happens, e.g.
+ * gdk_drag_find_window(). This happens, e.g.
* when GTK+ is proxying DND events to embedded windows.
*/
if (dest_window)
@@ -2955,10 +2941,9 @@ gdk_drag_update (GdkDragContext *context,
gdk_drag_get_current_actions (mods, GDK_BUTTON_PRIMARY, x11_context->actions,
&action, &possible_actions);
- gdk_drag_find_window_for_screen (context,
- x11_context->drag_window,
- gdk_display_get_default_screen (gdk_display_get_default ()),
- x_root, y_root, &dest_window, &protocol);
+ gdk_drag_find_window (context,
+ x11_context->drag_window,
+ x_root, y_root, &dest_window, &protocol);
gdk_drag_motion (context, dest_window, protocol, x_root, y_root,
action, possible_actions, evtime);
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index 0992347..4986bea 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -2077,15 +2077,15 @@ gtk_drag_update_idle (gpointer data)
{
time = gdk_event_get_time (info->last_event);
gtk_drag_get_event_actions (info->last_event,
- info->button,
+ info->button,
info->possible_actions,
&action, &possible_actions);
gtk_drag_update_icon_window (info);
- gdk_drag_find_window_for_screen (info->context,
- info->icon_window ? gtk_widget_get_window (info->icon_window) : NULL,
- info->cur_screen, info->cur_x, info->cur_y,
- &dest_window, &protocol);
+ gdk_drag_find_window (info->context,
+ info->icon_window ? gtk_widget_get_window (info->icon_window) : NULL,
+ info->cur_x, info->cur_y,
+ &dest_window, &protocol);
if (!gdk_drag_motion (info->context, dest_window, protocol,
info->cur_x, info->cur_y, action,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]