[Xfce4-commits] [xfce/xfce4-session] 20/30: balou: fix drawing the preview in the settings dialog
noreply at xfce.org
noreply at xfce.org
Sun May 15 18:03:39 CEST 2016
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository xfce/xfce4-session.
commit cb3edba5a23bbfacc2dc2fe0ad6b0a0ce7c628ee
Author: Eric Koegel <eric.koegel at gmail.com>
Date: Sun Apr 24 11:19:51 2016 +0300
balou: fix drawing the preview in the settings dialog
---
engines/balou/balou-theme.c | 22 +++++++++++++---------
engines/balou/balou-theme.h | 2 +-
engines/balou/balou.c | 7 ++++++-
3 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/engines/balou/balou-theme.c b/engines/balou/balou-theme.c
index 5952cf7..9070d46 100644
--- a/engines/balou/balou-theme.c
+++ b/engines/balou/balou-theme.c
@@ -197,9 +197,10 @@ balou_theme_get_logo (const BalouTheme *theme,
}
+
void
balou_theme_draw_gradient (const BalouTheme *theme,
- GdkWindow *root,
+ cairo_t *cr,
GdkRectangle logobox,
GdkRectangle textbox)
{
@@ -208,9 +209,6 @@ balou_theme_draw_gradient (const BalouTheme *theme,
gint dgreen;
gint dblue;
gint i;
- cairo_t *cr;
-
- cr = gdk_cairo_create (root);
if (gdk_rgba_equal (&theme->bgcolor1, &theme->bgcolor2))
{
@@ -248,8 +246,6 @@ balou_theme_draw_gradient (const BalouTheme *theme,
cairo_fill(cr);
}
}
-
- cairo_destroy (cr);
}
@@ -266,6 +262,7 @@ balou_theme_generate_preview (const BalouTheme *theme,
GdkPixbuf *pixbuf;
GdkPixbuf *scaled;
GdkWindow *root;
+ cairo_surface_t *surface;
cairo_t *cr;
gint pw, ph;
@@ -292,7 +289,11 @@ balou_theme_generate_preview (const BalouTheme *theme,
}
root = gdk_screen_get_root_window (gdk_screen_get_default ());
- cr = gdk_cairo_create(root);
+ surface = gdk_window_create_similar_surface (root,
+ CAIRO_CONTENT_COLOR_ALPHA,
+ gdk_window_get_width (root),
+ gdk_window_get_height (root));
+ cr = cairo_create(surface);
logobox.x = 0;
logobox.y = 0;
@@ -300,7 +301,7 @@ balou_theme_generate_preview (const BalouTheme *theme,
logobox.height = HEIGHT;
textbox.x = 0;
textbox.y = 0;
- balou_theme_draw_gradient (theme, root, logobox, textbox);
+ balou_theme_draw_gradient (theme, cr, logobox, textbox);
pixbuf = balou_theme_get_logo (theme, WIDTH, HEIGHT);
if (pixbuf != NULL)
@@ -314,11 +315,14 @@ balou_theme_generate_preview (const BalouTheme *theme,
g_object_unref (G_OBJECT (pixbuf));
}
- pixbuf = gdk_pixbuf_get_from_window (root, 0, 0, WIDTH, HEIGHT);
+ cairo_surface_flush (surface);
+
+ pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, WIDTH, HEIGHT);
scaled = gdk_pixbuf_scale_simple (pixbuf, width, height, GDK_INTERP_BILINEAR);
g_object_unref (pixbuf);
cairo_destroy(cr);
+ cairo_surface_destroy (surface);
/* store preview */
store_cached_preview (theme, scaled);
diff --git a/engines/balou/balou-theme.h b/engines/balou/balou-theme.h
index 91994d9..2cd5dca 100644
--- a/engines/balou/balou-theme.h
+++ b/engines/balou/balou-theme.h
@@ -42,7 +42,7 @@ GdkPixbuf *balou_theme_get_logo (const BalouTheme *theme,
gint available_width,
gint available_height);
void balou_theme_draw_gradient (const BalouTheme *theme,
- GdkWindow *root,
+ cairo_t *cr,
GdkRectangle logobox,
GdkRectangle textbox);
GdkPixbuf *balou_theme_generate_preview (const BalouTheme *theme,
diff --git a/engines/balou/balou.c b/engines/balou/balou.c
index 211a584..9e85cb5 100644
--- a/engines/balou/balou.c
+++ b/engines/balou/balou.c
@@ -129,6 +129,7 @@ balou_init (Balou *balou,
for (m = 0; m < nmonitors; ++m)
{
+ cairo_t *window_cr;
window = balou->windows + i;
balou_window_init (window, screen, m, root, cursor);
@@ -143,11 +144,15 @@ balou_init (Balou *balou,
window->textbox.y += window->logobox.height;
window->textbox.height -= window->logobox.height;
+ window_cr = gdk_cairo_create (window->window);
+
balou_theme_draw_gradient (balou->theme,
- root,
+ window_cr,
window->logobox,
window->textbox);
+ cairo_destroy (window_cr);
+
if (mainscreen == screen && mainmonitor == m)
balou->mainwin = window;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list