From d9b02ea4a3e3201cc7c98b01164536eac5f55532 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 10 Nov 2014 15:23:14 -0500 Subject: gdk: Make debug-updates a per-display setting Add private API to set this per-display, and make the existing gdk_window_set_debug_update function set a global default. --- gdk/gdk-private.c | 4 +++- gdk/gdk-private.h | 8 ++++++++ gdk/gdkdisplay.c | 17 +++++++++++++++++ gdk/gdkdisplayprivate.h | 3 +++ gdk/gdkinternals.h | 1 + gdk/gdkwindow.c | 12 ++++++++---- 6 files changed, 40 insertions(+), 5 deletions(-) diff --git a/gdk/gdk-private.c b/gdk/gdk-private.c index e6588dea67..7b62cc3208 100644 --- a/gdk/gdk-private.c +++ b/gdk/gdk-private.c @@ -14,7 +14,9 @@ gdk__private__ (void) gdk_window_freeze_toplevel_updates, gdk_window_thaw_toplevel_updates, gdk_display_get_rendering_mode, - gdk_display_set_rendering_mode + gdk_display_set_rendering_mode, + gdk_display_get_debug_updates, + gdk_display_set_debug_updates }; return &table; diff --git a/gdk/gdk-private.h b/gdk/gdk-private.h index 9a012e0cdd..474172dfdc 100644 --- a/gdk/gdk-private.h +++ b/gdk/gdk-private.h @@ -27,6 +27,10 @@ GdkRenderingMode gdk_display_get_rendering_mode (GdkDisplay *display); void gdk_display_set_rendering_mode (GdkDisplay *display, GdkRenderingMode mode); +gboolean gdk_display_get_debug_updates (GdkDisplay *display); +void gdk_display_set_debug_updates (GdkDisplay *display, + gboolean debug_updates); + typedef struct { /* add all private functions here, initialize them in gdk-private.c */ gboolean (* gdk_device_grab_info) (GdkDisplay *display, @@ -48,6 +52,10 @@ typedef struct { GdkRenderingMode (* gdk_display_get_rendering_mode) (GdkDisplay *display); void (* gdk_display_set_rendering_mode) (GdkDisplay *display, GdkRenderingMode mode); + + gboolean (* gdk_display_get_debug_updates) (GdkDisplay *display); + void (* gdk_display_set_debug_updates) (GdkDisplay *display, + gboolean debug_updates); } GdkPrivateVTable; GDK_AVAILABLE_IN_ALL diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c index f3a6aaae05..79fc2d8a69 100644 --- a/gdk/gdkdisplay.c +++ b/gdk/gdkdisplay.c @@ -2302,3 +2302,20 @@ gdk_display_set_rendering_mode (GdkDisplay *display, { display->rendering_mode = mode; } + +void +gdk_display_set_debug_updates (GdkDisplay *display, + gboolean debug_updates) +{ + display->debug_updates = debug_updates; + display->debug_updates_set = TRUE; +} + +gboolean +gdk_display_get_debug_updates (GdkDisplay *display) +{ + if (display->debug_updates_set) + return display->debug_updates; + else + return _gdk_debug_updates; +} diff --git a/gdk/gdkdisplayprivate.h b/gdk/gdkdisplayprivate.h index 2f026fe09c..14d8ea6583 100644 --- a/gdk/gdkdisplayprivate.h +++ b/gdk/gdkdisplayprivate.h @@ -121,6 +121,9 @@ struct _GdkDisplay guint has_gl_extension_texture_non_power_of_two : 1; guint has_gl_extension_texture_rectangle : 1; + guint debug_updates : 1; + guint debug_updates_set : 1; + GdkRenderingMode rendering_mode; }; diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index c3246818fc..be1b0ed834 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -108,6 +108,7 @@ extern GdkWindow *_gdk_parent_root; extern guint _gdk_debug_flags; extern guint _gdk_gl_flags; extern GdkRenderingMode _gdk_rendering_mode; +extern gboolean _gdk_debug_updates; #ifdef G_ENABLE_DEBUG diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index fdbdf37fb9..4ebf461e6c 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -3338,7 +3338,7 @@ gdk_cairo_create (GdkWindow *window) /* Code for dirty-region queueing */ static GSList *update_windows = NULL; -static gboolean debug_updates = FALSE; +gboolean _gdk_debug_updates = FALSE; static inline gboolean gdk_window_is_ancestor (GdkWindow *window, @@ -3613,7 +3613,9 @@ gdk_window_process_updates_internal (GdkWindow *window) { GdkWindowImplClass *impl_class; GdkWindow *toplevel; + GdkDisplay *display; + display = gdk_window_get_display (window); toplevel = gdk_window_get_toplevel (window); if (toplevel->geometry_dirty) { @@ -3653,7 +3655,7 @@ gdk_window_process_updates_internal (GdkWindow *window) /* Clip to part visible in impl window */ cairo_region_intersect (expose_region, window->clip_region); - if (debug_updates) + if (gdk_display_get_debug_updates (display)) { cairo_region_t *swap_region = cairo_region_copy (expose_region); cairo_region_subtract (swap_region, window->active_update_area); @@ -4067,6 +4069,7 @@ gdk_window_invalidate_maybe_recurse_full (GdkWindow *window, { cairo_region_t *visible_region; cairo_rectangle_int_t r; + GdkDisplay *display; g_return_if_fail (GDK_IS_WINDOW (window)); @@ -4086,7 +4089,8 @@ gdk_window_invalidate_maybe_recurse_full (GdkWindow *window, invalidate_impl_subwindows (window, region, child_func, user_data, 0, 0); - if (debug_updates) + display = gdk_window_get_display (window); + if (gdk_display_get_debug_updates (display)) draw_ugly_color (window, visible_region, 0); while (window != NULL && @@ -4458,7 +4462,7 @@ gdk_window_thaw_toplevel_updates (GdkWindow *window) void gdk_window_set_debug_updates (gboolean setting) { - debug_updates = setting; + _gdk_debug_updates = setting; } /** -- cgit v1.2.1