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>
This commit is contained in:
Jonas Ådahl 2021-12-17 21:41:53 +01:00 committed by Marge Bot
parent 73c010d8b0
commit dd14592314
6 changed files with 45 additions and 6 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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)
{

View File

@ -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 */

View File

@ -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 */

View File

@ -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)
*