[gtk+] Add and use GDK_CHECK_DEBUG macro
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add and use GDK_CHECK_DEBUG macro
- Date: Mon, 29 Feb 2016 02:45:16 +0000 (UTC)
commit ee217dc8236f0d7289f394b9954a9bc188738537
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Feb 28 21:29:35 2016 -0500
Add and use GDK_CHECK_DEBUG macro
This is following what we've already done in GTK+. It avoids
direct access to _gdk_debug_flags all over the place.
gdk/gdkframeclockidle.c | 8 ++++----
gdk/gdkinternals.h | 7 +++++--
gdk/x11/gdkdevice-core-x11.c | 2 +-
gdk/x11/gdkdevice-xi2.c | 2 +-
gdk/x11/gdkdevicemanager-core-x11.c | 2 +-
gdk/x11/gdkdisplay-x11.c | 4 ++--
gdk/x11/gdkdnd-x11.c | 4 ++--
gdk/x11/gdkscreen-x11.c | 2 +-
gdk/x11/gdkvisual-x11.c | 2 +-
gdk/x11/gdkwindow-x11.c | 2 +-
10 files changed, 19 insertions(+), 16 deletions(-)
---
diff --git a/gdk/gdkframeclockidle.c b/gdk/gdkframeclockidle.c
index 82d40cf..0d7e000 100644
--- a/gdk/gdkframeclockidle.c
+++ b/gdk/gdkframeclockidle.c
@@ -386,7 +386,7 @@ gdk_frame_clock_paint_idle (void *data)
{
int iter;
#ifdef G_ENABLE_DEBUG
- if ((_gdk_debug_flags & GDK_DEBUG_FRAMES) != 0)
+ if (GDK_DEBUG_CHECK (FRAMES))
{
if (priv->phase != GDK_FRAME_CLOCK_PHASE_LAYOUT &&
(priv->requested & GDK_FRAME_CLOCK_PHASE_LAYOUT))
@@ -415,7 +415,7 @@ gdk_frame_clock_paint_idle (void *data)
if (priv->freeze_count == 0)
{
#ifdef G_ENABLE_DEBUG
- if ((_gdk_debug_flags & GDK_DEBUG_FRAMES) != 0)
+ if (GDK_DEBUG_CHECK (FRAMES))
{
if (priv->phase != GDK_FRAME_CLOCK_PHASE_PAINT &&
(priv->requested & GDK_FRAME_CLOCK_PHASE_PAINT))
@@ -441,7 +441,7 @@ gdk_frame_clock_paint_idle (void *data)
priv->phase = GDK_FRAME_CLOCK_PHASE_NONE;
#ifdef G_ENABLE_DEBUG
- if ((_gdk_debug_flags & GDK_DEBUG_FRAMES) != 0)
+ if (GDK_DEBUG_CHECK (FRAMES))
timings->frame_end_time = g_get_monotonic_time ();
#endif /* G_ENABLE_DEBUG */
}
@@ -452,7 +452,7 @@ gdk_frame_clock_paint_idle (void *data)
}
#ifdef G_ENABLE_DEBUG
- if ((_gdk_debug_flags & GDK_DEBUG_FRAMES) != 0)
+ if (GDK_DEBUG_CHECK (FRAMES))
{
if (timings && timings->complete)
_gdk_frame_clock_debug_print_timings (clock, timings);
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index bbcc214..ad1947e 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -113,12 +113,15 @@ extern gboolean _gdk_debug_updates;
#ifdef G_ENABLE_DEBUG
-#define GDK_NOTE(type,action) G_STMT_START { \
- if (_gdk_debug_flags & GDK_DEBUG_##type) \
+#define GDK_DEBUG_CHECK(type) G_UNLIKELY (_gdk_debug_flags & GDK_DEBUG_##type)
+
+#define GDK_NOTE(type,action) G_STMT_START { \
+ if (GDK_DEBUG_CHECK (type)) \
{ action; }; } G_STMT_END
#else /* !G_ENABLE_DEBUG */
+#define GDK_DEBUG_CHECK(type) 0
#define GDK_NOTE(type,action)
#endif /* G_ENABLE_DEBUG */
diff --git a/gdk/x11/gdkdevice-core-x11.c b/gdk/x11/gdkdevice-core-x11.c
index 7b8fbd9..8df9cce 100644
--- a/gdk/x11/gdkdevice-core-x11.c
+++ b/gdk/x11/gdkdevice-core-x11.c
@@ -345,7 +345,7 @@ gdk_x11_device_core_grab (GdkDevice *device,
xconfine_to = GDK_WINDOW_XID (confine_to);
#ifdef G_ENABLE_DEBUG
- if (_gdk_debug_flags & GDK_DEBUG_NOGRABS)
+ if (GDK_DEBUG_CHECK (NOGRABS))
status = GrabSuccess;
else
#endif
diff --git a/gdk/x11/gdkdevice-xi2.c b/gdk/x11/gdkdevice-xi2.c
index ddeafa4..cd1849c 100644
--- a/gdk/x11/gdkdevice-xi2.c
+++ b/gdk/x11/gdkdevice-xi2.c
@@ -447,7 +447,7 @@ gdk_x11_device_xi2_grab (GdkDevice *device,
&mask.mask_len);
#ifdef G_ENABLE_DEBUG
- if (_gdk_debug_flags & GDK_DEBUG_NOGRABS)
+ if (GDK_DEBUG_CHECK (NOGRABS))
status = GrabSuccess;
else
#endif
diff --git a/gdk/x11/gdkdevicemanager-core-x11.c b/gdk/x11/gdkdevicemanager-core-x11.c
index a16f931..994d359 100644
--- a/gdk/x11/gdkdevicemanager-core-x11.c
+++ b/gdk/x11/gdkdevicemanager-core-x11.c
@@ -179,7 +179,7 @@ translate_key_event (GdkDisplay *display,
_gdk_x11_event_translate_keyboard_string (&event->key);
#ifdef G_ENABLE_DEBUG
- if (_gdk_debug_flags & GDK_DEBUG_EVENTS)
+ if (GDK_DEBUG_CHECK (EVENTS))
{
g_message ("%s:\t\twindow: %ld key: %12s %d",
event->type == GDK_KEY_PRESS ? "key press " : "key release",
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index c58c29b..64095b2 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -590,7 +590,7 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
case VisibilityNotify:
#ifdef G_ENABLE_DEBUG
- if (_gdk_debug_flags & GDK_DEBUG_EVENTS)
+ if (GDK_DEBUG_CHECK (EVENTS))
switch (xevent->xvisibility.state)
{
case VisibilityFullyObscured:
@@ -1236,7 +1236,7 @@ _gdk_wm_protocols_filter (GdkXEvent *xev,
timings->complete = TRUE;
#ifdef G_ENABLE_DEBUG
- if ((_gdk_debug_flags & GDK_DEBUG_FRAMES) != 0)
+ if (GDK_DEBUG_CHECK (FRAMES))
_gdk_frame_clock_debug_print_timings (clock, timings);
#endif /* G_ENABLE_DEBUG */
}
diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c
index ed923ba..eceb8e9 100644
--- a/gdk/x11/gdkdnd-x11.c
+++ b/gdk/x11/gdkdnd-x11.c
@@ -1500,7 +1500,7 @@ xdnd_read_actions (GdkX11DragContext *context_x11)
context_x11->xdnd_have_actions = TRUE;
#ifdef G_ENABLE_DEBUG
- if (_gdk_debug_flags & GDK_DEBUG_DND)
+ if (GDK_DEBUG_CHECK (DND))
{
GString *action_str = g_string_new (NULL);
if (context->actions & GDK_ACTION_MOVE)
@@ -1763,7 +1763,7 @@ xdnd_enter_filter (GdkXEvent *xev,
}
#ifdef G_ENABLE_DEBUG
- if (_gdk_debug_flags & GDK_DEBUG_DND)
+ if (GDK_DEBUG_CHECK (DND))
print_target_list (context->targets);
#endif /* G_ENABLE_DEBUG */
diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c
index b0c3cd6..82b8aa2 100644
--- a/gdk/x11/gdkscreen-x11.c
+++ b/gdk/x11/gdkscreen-x11.c
@@ -526,7 +526,7 @@ init_fake_xinerama (GdkScreen *screen)
Window win;
gint w, h;
- if (!(_gdk_debug_flags & GDK_DEBUG_XINERAMA))
+ if (!GDK_DEBUG_CHECK (XINERAMA))
return FALSE;
/* Fake Xinerama mode by splitting the screen into 4 monitors.
diff --git a/gdk/x11/gdkvisual-x11.c b/gdk/x11/gdkvisual-x11.c
index e59ebf7..81479d8 100644
--- a/gdk/x11/gdkvisual-x11.c
+++ b/gdk/x11/gdkvisual-x11.c
@@ -248,7 +248,7 @@ _gdk_x11_screen_init_visuals (GdkScreen *screen)
}
#ifdef G_ENABLE_DEBUG
- if (_gdk_debug_flags & GDK_DEBUG_MISC)
+ if (GDK_DEBUG_CHECK (MISC))
{
static const gchar *const visual_names[] =
{
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index 91a4e19..beb08a5 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -407,7 +407,7 @@ gdk_x11_window_end_frame (GdkWindow *window)
if (impl->toplevel->current_counter_value % 2 == 1)
{
#ifdef G_ENABLE_DEBUG
- if ((_gdk_debug_flags & GDK_DEBUG_FRAMES) != 0)
+ if (GDK_DEBUG_CHECK (FRAMES))
{
XImage *image = XGetImage (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XID (window),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]