diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/pop-demo.c | 8 | ||||
-rw-r--r-- | src/pop-window-view.c | 69 |
2 files changed, 73 insertions, 4 deletions
diff --git a/src/pop-demo.c b/src/pop-demo.c index ac62797..e035d2f 100644 --- a/src/pop-demo.c +++ b/src/pop-demo.c @@ -212,16 +212,20 @@ draw_window_from_stack (PopWindowStack *stack, g_assert (POP_IS_WINDOW_VIEW (view)); +#if 0 visible_region = get_view_visible_region (stack, view); if (!gdk_region_empty (visible_region)) { +#endif cairo_save (cairo_context); pop_window_view_render_to_context (view, cairo_context); cairo_restore (cairo_context); +#if 0 } gdk_region_destroy (visible_region); +#endif } static void @@ -403,12 +407,12 @@ main (int argc, initialize_shape_extension (); overlay_window = pop_overlay_window_new (); -#if 0 overlay_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_app_paintable (GTK_WIDGET (overlay_window), TRUE); gtk_window_set_default_size (GTK_WINDOW (overlay_window), 640, 480); -#endif +#if 0 gtk_widget_realize (GTK_WIDGET (overlay_window)); +#endif g_signal_connect (G_OBJECT (overlay_window), "expose-event", G_CALLBACK (on_expose_event), NULL); diff --git a/src/pop-window-view.c b/src/pop-window-view.c index 660c37a..9e7f3dd 100644 --- a/src/pop-window-view.c +++ b/src/pop-window-view.c @@ -51,6 +51,7 @@ struct _PopWindowViewPrivate GdkRectangle damaged_area; + guint is_mapped : 1; guint is_damaged : 1; gint x, y; @@ -468,6 +469,7 @@ pop_window_view_set_clip_path_from_window (PopWindowView *view) if (status != CAIRO_STATUS_SUCCESS) { + cairo_surface_destroy (surface); XFree (rectangles); return FALSE; } @@ -491,6 +493,40 @@ pop_window_view_set_clip_path_from_window (PopWindowView *view) return TRUE; } +static gboolean +pop_window_view_set_clip_path_for_placeholder (PopWindowView *view) +{ + cairo_t *cairo_context; + cairo_surface_t *surface; + cairo_status_t status; + + g_assert (POP_IS_WINDOW_VIEW (view)); + g_assert (view->priv->clip_path == NULL); + + surface = cairo_image_surface_create (CAIRO_FORMAT_A1, + view->priv->width, view->priv->height); + + status = cairo_surface_status (surface); + + if (status != CAIRO_STATUS_SUCCESS) + { + cairo_surface_destroy (surface); + return FALSE; + } + + cairo_context = cairo_create (surface); + + cairo_rectangle (cairo_context, + view->priv->x, view->priv->y, + view->priv->width, view->priv->height); + + view->priv->clip_path = cairo_copy_path_flat (cairo_context); + cairo_destroy (cairo_context); + cairo_surface_destroy (surface); + + return TRUE; +} + static void pop_window_view_enable_window_geometry_reporting (PopWindowView *view) { @@ -632,6 +668,8 @@ pop_window_view_window_shown (PopWindowView *view) g_print ("window 0x%lx is now visible\n", GDK_WINDOW_XWINDOW (view->priv->window)); + view->priv->is_mapped = TRUE; + #if 0 if (view->priv->pattern == NULL) pop_window_view_create_pattern_from_window (view); @@ -644,6 +682,8 @@ pop_window_view_window_shown (PopWindowView *view) static void pop_window_view_window_hidden (PopWindowView *view) { + + view->priv->is_mapped = FALSE; g_print ("window 0x%lx hidden\n", GDK_WINDOW_XWINDOW (view->priv->window)); pop_window_view_destroy_pattern (view); } @@ -844,7 +884,7 @@ pop_window_view_set_window (PopWindowView *view, } if (gdk_window_is_visible (view->priv->window)) - pop_window_view_window_shown (view); + view->priv->is_mapped = TRUE; g_object_ref (window); @@ -938,6 +978,25 @@ pop_window_view_get_difference (PopWindowView *view, return view_bounding_region; } +static void +pop_window_view_render_placeholder_to_context (PopWindowView *view, + cairo_t *cairo_context) +{ + + cairo_translate (cairo_context, view->priv->x, view->priv->y); + + cairo_set_source_rgba (cairo_context, 1.0, 1.0, 1.0, .75); + cairo_rectangle (cairo_context, 0.0, 0.0, + view->priv->width, view->priv->height); + cairo_clip (cairo_context); + cairo_paint (cairo_context); + + cairo_set_source_rgb (cairo_context, 0.0, 0.0, 0.0); + cairo_rectangle (cairo_context, 0.0, 0.0, + view->priv->width, view->priv->height); + cairo_stroke (cairo_context); +} + void pop_window_view_render_to_context (PopWindowView *view, cairo_t *cairo_context) @@ -946,11 +1005,17 @@ pop_window_view_render_to_context (PopWindowView *view, g_return_if_fail (cairo_context != NULL); if (view->priv->pattern == NULL) - return; + { + if (gdk_window_is_visible (view->priv->window)) + pop_window_view_render_placeholder_to_context (view, cairo_context); + return; + } if (!view->priv->is_damaged && FALSE) return; + g_assert (view->priv->clip_path != NULL); + pop_window_view_report_fixed_damage (view); cairo_translate (cairo_context, view->priv->x, view->priv->y); |