gdk: Change the private export handle api

Make unexport_handle take the handle, so we
can in the future deal with multiple exports.

Update the one caller in gtkwindow.c to pass
the handle.
This commit is contained in:
Matthias Clasen 2023-05-14 17:28:17 -04:00
parent bf87a40b20
commit e5f1e4545d
5 changed files with 28 additions and 14 deletions

View File

@ -135,7 +135,8 @@ gdk_toplevel_default_export_handle_finish (GdkToplevel *toplevel,
}
static void
gdk_toplevel_default_unexport_handle (GdkToplevel *toplevel)
gdk_toplevel_default_unexport_handle (GdkToplevel *toplevel,
const char *handle)
{
}
@ -810,6 +811,7 @@ gdk_toplevel_export_handle_finish (GdkToplevel *toplevel,
/*< private >
* gdk_toplevel_unexport_handle:
* @toplevel: a `GdkToplevel`
* @handle: the handle to unexport
*
* Destroys the handle that was obtained with [method@Gdk.Toplevel.export_handle].
*
@ -819,7 +821,8 @@ gdk_toplevel_export_handle_finish (GdkToplevel *toplevel,
* Since: 4.10
*/
void
gdk_toplevel_unexport_handle (GdkToplevel *toplevel)
gdk_toplevel_unexport_handle (GdkToplevel *toplevel,
const char *handle)
{
GDK_TOPLEVEL_GET_IFACE (toplevel)->unexport_handle (toplevel);
GDK_TOPLEVEL_GET_IFACE (toplevel)->unexport_handle (toplevel, handle);
}

View File

@ -49,7 +49,8 @@ struct _GdkToplevelInterface
GAsyncResult *result,
GError **error);
void (* unexport_handle) (GdkToplevel *toplevel);
void (* unexport_handle) (GdkToplevel *toplevel,
const char *handle);
};
typedef enum
@ -82,7 +83,8 @@ char *gdk_toplevel_export_handle_finish (GdkToplevel *toplevel,
GAsyncResult *result,
GError **error);
void gdk_toplevel_unexport_handle (GdkToplevel *toplevel);
void gdk_toplevel_unexport_handle (GdkToplevel *toplevel,
const char *handle);
G_END_DECLS

View File

@ -1809,7 +1809,8 @@ gdk_wayland_toplevel_real_export_handle_finish (GdkToplevel *toplevel,
}
static void
gdk_wayland_toplevel_real_unexport_handle (GdkToplevel *toplevel)
gdk_wayland_toplevel_real_unexport_handle (GdkToplevel *toplevel,
const char *handle)
{
GdkWaylandToplevel *wayland_toplevel = GDK_WAYLAND_TOPLEVEL (toplevel);
@ -2486,9 +2487,7 @@ gdk_wayland_toplevel_export_handle (GdkToplevel *toplevel,
void
gdk_wayland_toplevel_unexport_handle (GdkToplevel *toplevel)
{
g_return_if_fail (GDK_IS_WAYLAND_TOPLEVEL (toplevel));
gdk_toplevel_unexport_handle (toplevel);
g_warning ("Use gdk_wayland_toplevel_drop_exported_handle()");
}
/**
@ -2507,9 +2506,7 @@ void
gdk_wayland_toplevel_drop_exported_handle (GdkToplevel *toplevel,
const char *handle)
{
g_return_if_fail (GDK_IS_WAYLAND_TOPLEVEL (toplevel));
gdk_toplevel_unexport_handle (toplevel);
gdk_toplevel_unexport_handle (toplevel, handle);
}
static void

View File

@ -5318,7 +5318,8 @@ gdk_x11_toplevel_export_handle_finish (GdkToplevel *toplevel,
}
static void
gdk_x11_toplevel_unexport_handle (GdkToplevel *toplevel)
gdk_x11_toplevel_unexport_handle (GdkToplevel *toplevel,
const char *handle)
{
}

View File

@ -6291,6 +6291,17 @@ prefix_handle (GdkDisplay *display,
return NULL;
}
static const char *
unprefix_handle (const char *handle)
{
if (g_str_has_prefix (handle, "wayland:"))
return handle + strlen ("wayland:");
else if (g_str_has_prefix (handle, "x11:"))
return handle + strlen ("x1!:");
else
return handle;
}
static void
export_handle_done (GObject *source,
GAsyncResult *result,
@ -6341,7 +6352,7 @@ gtk_window_unexport_handle (GtkWindow *window,
{
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
gdk_toplevel_unexport_handle (GDK_TOPLEVEL (priv->surface));
gdk_toplevel_unexport_handle (GDK_TOPLEVEL (priv->surface), unprefix_handle (handle));
}
static GtkPointerFocus *