util: add simple tracing macros

This commit is contained in:
Christian Hergert 2023-02-27 20:23:25 -08:00
parent e4d089fb52
commit edd88dcec3
2 changed files with 33 additions and 2 deletions

View File

@ -30,6 +30,7 @@
#include "mks-mouse.h" #include "mks-mouse.h"
#include "mks-paintable-private.h" #include "mks-paintable-private.h"
#include "mks-screen.h" #include "mks-screen.h"
#include "mks-util-private.h"
#define DEFAULT_UNGRAB_TRIGGER "<Control><Alt>g" #define DEFAULT_UNGRAB_TRIGGER "<Control><Alt>g"
@ -103,6 +104,8 @@ mks_display_attach_cb (GObject *object,
g_autoptr(GdkPaintable) paintable = NULL; g_autoptr(GdkPaintable) paintable = NULL;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
MKS_ENTRY;
g_assert (MKS_IS_SCREEN (screen)); g_assert (MKS_IS_SCREEN (screen));
g_assert (G_IS_ASYNC_RESULT (result)); g_assert (G_IS_ASYNC_RESULT (result));
g_assert (MKS_IS_DISPLAY (self)); g_assert (MKS_IS_DISPLAY (self));
@ -110,9 +113,11 @@ mks_display_attach_cb (GObject *object,
paintable = mks_screen_attach_finish (screen, result, &error); paintable = mks_screen_attach_finish (screen, result, &error);
if (priv->screen != screen) if (priv->screen != screen)
return; MKS_EXIT;
mks_display_picture_set_paintable (priv->picture, MKS_PAINTABLE (paintable)); mks_display_picture_set_paintable (priv->picture, MKS_PAINTABLE (paintable));
MKS_EXIT;
} }
static void static void
@ -121,6 +126,8 @@ mks_display_connect (MksDisplay *self,
{ {
MksDisplayPrivate *priv = mks_display_get_instance_private (self); MksDisplayPrivate *priv = mks_display_get_instance_private (self);
MKS_ENTRY;
g_assert (MKS_IS_DISPLAY (self)); g_assert (MKS_IS_DISPLAY (self));
g_assert (!screen || MKS_IS_SCREEN (screen)); g_assert (!screen || MKS_IS_SCREEN (screen));
@ -136,6 +143,8 @@ mks_display_connect (MksDisplay *self,
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_SCREEN]); g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_SCREEN]);
} }
MKS_EXIT;
} }
static void static void
@ -143,6 +152,8 @@ mks_display_disconnect (MksDisplay *self)
{ {
MksDisplayPrivate *priv = mks_display_get_instance_private (self); MksDisplayPrivate *priv = mks_display_get_instance_private (self);
MKS_ENTRY;
g_assert (MKS_IS_DISPLAY (self)); g_assert (MKS_IS_DISPLAY (self));
g_clear_object (&priv->screen); g_clear_object (&priv->screen);
@ -154,6 +165,8 @@ mks_display_disconnect (MksDisplay *self)
mks_display_picture_set_keyboard (priv->picture, NULL); mks_display_picture_set_keyboard (priv->picture, NULL);
mks_display_picture_set_mouse (priv->picture, NULL); mks_display_picture_set_mouse (priv->picture, NULL);
} }
MKS_EXIT;
} }
static gboolean static gboolean
@ -411,10 +424,12 @@ mks_display_set_screen (MksDisplay *self,
{ {
MksDisplayPrivate *priv = mks_display_get_instance_private (self); MksDisplayPrivate *priv = mks_display_get_instance_private (self);
MKS_ENTRY;
g_return_if_fail (MKS_IS_DISPLAY (self)); g_return_if_fail (MKS_IS_DISPLAY (self));
if (priv->screen == screen) if (priv->screen == screen)
return; MKS_EXIT;
if (priv->screen != NULL) if (priv->screen != NULL)
mks_display_disconnect (self); mks_display_disconnect (self);
@ -423,6 +438,8 @@ mks_display_set_screen (MksDisplay *self,
mks_display_connect (self, screen); mks_display_connect (self, screen);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SCREEN]); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SCREEN]);
MKS_EXIT;
} }
/** /**
@ -449,6 +466,8 @@ mks_display_set_ungrab_trigger (MksDisplay *self,
{ {
MksDisplayPrivate *priv = mks_display_get_instance_private (self); MksDisplayPrivate *priv = mks_display_get_instance_private (self);
MKS_ENTRY;
g_return_if_fail (MKS_IS_DISPLAY (self)); g_return_if_fail (MKS_IS_DISPLAY (self));
g_return_if_fail (!ungrab_trigger || GTK_IS_SHORTCUT_TRIGGER (ungrab_trigger)); g_return_if_fail (!ungrab_trigger || GTK_IS_SHORTCUT_TRIGGER (ungrab_trigger));
@ -458,4 +477,6 @@ mks_display_set_ungrab_trigger (MksDisplay *self,
priv->ungrab_trigger = gtk_shortcut_trigger_parse_string (DEFAULT_UNGRAB_TRIGGER); priv->ungrab_trigger = gtk_shortcut_trigger_parse_string (DEFAULT_UNGRAB_TRIGGER);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_UNGRAB_TRIGGER]); g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_UNGRAB_TRIGGER]);
} }
MKS_EXIT;
} }

View File

@ -32,6 +32,16 @@ G_BEGIN_DECLS
(CAIRO_VERSION_MAJOR == (major) && CAIRO_VERSION_MINOR == (minor) && \ (CAIRO_VERSION_MAJOR == (major) && CAIRO_VERSION_MINOR == (minor) && \
CAIRO_VERSION_MICRO >= (micro))) CAIRO_VERSION_MICRO >= (micro)))
#ifdef MKS_DEBUG
# define MKS_ENTRY G_STMT_START { g_debug("ENTRY: %s():%u", G_STRFUNC, __LINE__) } G_STMT_END
# define MKS_EXIT G_STMT_START { g_debug(" EXIT: %s():%u", G_STRFUNC, __LINE__); return; } G_STMT_END
# define MKS_RETURN(_r) G_STMT_START { g_debug(" EXIT: %s():%u", G_STRFUNC, __LINE__); return (_r); } G_STMT_END
#else
# define MKS_ENTRY G_STMT_START { } G_STMT_END
# define MKS_EXIT G_STMT_START { return; } G_STMT_END
# define MKS_RETURN(_r) G_STMT_START { return (_r); } G_STMT_END
#endif
gboolean mks_scroll_event_is_inverted (GdkEvent *event); gboolean mks_scroll_event_is_inverted (GdkEvent *event);
void mks_socketpair_connection_new (GDBusConnectionFlags flags, void mks_socketpair_connection_new (GDBusConnectionFlags flags,
GCancellable *cancellable, GCancellable *cancellable,