[mutter] laters: Expose MetaLaters publicly
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] laters: Expose MetaLaters publicly
- Date: Mon, 7 Feb 2022 18:29:53 +0000 (UTC)
commit dd1459231496cee29fce650f51f79eae0e9e7648
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Fri Dec 17 21:41:53 2021 +0100
laters: Expose MetaLaters publicly
Will allow not having to use the context-less meta_later_add().
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2264>
src/compositor/compositor-private.h | 2 --
src/compositor/meta-later-private.h | 3 +--
src/compositor/meta-later.c | 29 +++++++++++++++++++++++++++--
src/meta/compositor.h | 3 +++
src/meta/meta-later.h | 13 +++++++++++++
src/meta/types.h | 1 +
6 files changed, 45 insertions(+), 6 deletions(-)
---
diff --git a/src/compositor/compositor-private.h b/src/compositor/compositor-private.h
index 2916e5e4e6..daf8c31bb3 100644
--- a/src/compositor/compositor-private.h
+++ b/src/compositor/compositor-private.h
@@ -72,8 +72,6 @@ ClutterStage * meta_compositor_get_stage (MetaCompositor *compositor);
gboolean meta_compositor_is_switching_workspace (MetaCompositor *compositor);
-MetaLaters * meta_compositor_get_laters (MetaCompositor *compositor);
-
void meta_compositor_grab_begin (MetaCompositor *compositor);
void meta_compositor_grab_end (MetaCompositor *compositor);
diff --git a/src/compositor/meta-later-private.h b/src/compositor/meta-later-private.h
index c8d0f80a8f..ea9359d155 100644
--- a/src/compositor/meta-later-private.h
+++ b/src/compositor/meta-later-private.h
@@ -18,8 +18,7 @@
#ifndef META_LATER_PRIVATE_H
#define META_LATER_PRIVATE_H
-typedef struct _MetaLaters MetaLaters;
-typedef struct _MetaCompositor MetaCompositor;
+#include <meta/types.h>
MetaLaters * meta_laters_new (MetaCompositor *compositor);
diff --git a/src/compositor/meta-later.c b/src/compositor/meta-later.c
index 43da6d8e68..6c564d6ef3 100644
--- a/src/compositor/meta-later.c
+++ b/src/compositor/meta-later.c
@@ -208,7 +208,25 @@ invoke_later_idle (gpointer data)
}
}
-static unsigned int
+/**
+ * meta_laters_add:
+ * @laters: a #MetaLaters
+ * @when: enumeration value determining the phase at which to run the callback
+ * @func: callback to run later
+ * @user_data: data to pass to the callback
+ * @notify: function to call to destroy @data when it is no longer in use, or %NULL
+ *
+ * Sets up a callback to be called at some later time. @when determines the
+ * particular later occasion at which it is called. This is much like g_idle_add(),
+ * except that the functions interact properly with clutter event handling.
+ * If a "later" function is added from a clutter event handler, and is supposed
+ * to be run before the stage is redrawn, it will be run before that redraw
+ * of the stage, not the next one.
+ *
+ * Return value: an integer ID (guaranteed to be non-zero) that can be used
+ * to cancel the callback and prevent it from being run.
+ */
+unsigned int
meta_laters_add (MetaLaters *laters,
MetaLaterType when,
GSourceFunc func,
@@ -287,7 +305,14 @@ meta_later_add (MetaLaterType when,
when, func, data, notify);
}
-static void
+/**
+ * meta_laters_remove:
+ * @laters: a #MetaLaters
+ * @later_id: the integer ID returned from meta_later_add()
+ *
+ * Removes a callback added with meta_later_add()
+ */
+void
meta_laters_remove (MetaLaters *laters,
unsigned int later_id)
{
diff --git a/src/meta/compositor.h b/src/meta/compositor.h
index 1ccae70d76..e33abad998 100644
--- a/src/meta/compositor.h
+++ b/src/meta/compositor.h
@@ -162,4 +162,7 @@ void meta_compositor_show_window_menu_for_rect (MetaCompositor *compositor,
MetaWindowMenuType menu,
MetaRectangle *rect);
+META_EXPORT
+MetaLaters * meta_compositor_get_laters (MetaCompositor *compositor);
+
#endif /* META_COMPOSITOR_H */
diff --git a/src/meta/meta-later.h b/src/meta/meta-later.h
index 4464fc3bdb..1626024d3b 100644
--- a/src/meta/meta-later.h
+++ b/src/meta/meta-later.h
@@ -20,6 +20,8 @@
#ifndef META_LATER_H
#define META_LATER_H
+#include <meta/types.h>
+
/**
* MetaLaterType:
* @META_LATER_RESIZE: call in a resize processing phase that is done
@@ -50,4 +52,15 @@ guint meta_later_add (MetaLaterType when,
META_EXPORT
void meta_later_remove (guint later_id);
+META_EXPORT
+unsigned int meta_laters_add (MetaLaters *laters,
+ MetaLaterType when,
+ GSourceFunc func,
+ gpointer user_data,
+ GDestroyNotify notify);
+
+META_EXPORT
+void meta_laters_remove (MetaLaters *laters,
+ unsigned int later_id);
+
#endif /* META_LATER_H */
diff --git a/src/meta/types.h b/src/meta/types.h
index 403e62b16e..ba6fa02bed 100644
--- a/src/meta/types.h
+++ b/src/meta/types.h
@@ -32,6 +32,7 @@ typedef struct _MetaX11Display MetaX11Display;
typedef struct _MetaFrame MetaFrame;
typedef struct _MetaWindow MetaWindow;
typedef struct _MetaWorkspace MetaWorkspace;
+typedef struct _MetaLaters MetaLaters;
/**
* MetaGroup: (skip)
*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]