diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2012-05-15 22:14:27 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-05-15 22:14:27 -0400 |
commit | 42abdf5c801fa29e5f46f965f9f40e14e96cff55 (patch) | |
tree | 46c85c6cdaa145beaf6c6028616cf1852761f675 | |
parent | 291c69cf931c366f62376d47428af142989c9996 (diff) |
window: Move theme rendering code to cairo-util
-rw-r--r-- | clients/cairo-util.c | 52 | ||||
-rw-r--r-- | clients/cairo-util.h | 15 | ||||
-rw-r--r-- | clients/window.c | 62 |
3 files changed, 67 insertions, 62 deletions
diff --git a/clients/cairo-util.c b/clients/cairo-util.c index df5c7df..0f9016e 100644 --- a/clients/cairo-util.c +++ b/clients/cairo-util.c @@ -314,3 +314,55 @@ load_cairo_surface(const char *filename) return cairo_image_surface_create_for_data(data, CAIRO_FORMAT_ARGB32, width, height, stride); } + +void +display_render_theme(struct theme *t) +{ + cairo_t *cr; + cairo_pattern_t *pattern; + + t->margin = 32; + t->width = 6; + t->titlebar_height = 27; + t->frame_radius = 3; + t->shadow = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 128, 128); + cr = cairo_create(t->shadow); + cairo_set_operator(cr, CAIRO_OPERATOR_OVER); + cairo_set_source_rgba(cr, 0, 0, 0, 1); + rounded_rect(cr, 32, 32, 96, 96, t->frame_radius); + cairo_fill(cr); + cairo_destroy(cr); + blur_surface(t->shadow, 64); + + t->active_frame = + cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 128, 128); + cr = cairo_create(t->active_frame); + cairo_set_operator(cr, CAIRO_OPERATOR_OVER); + + pattern = cairo_pattern_create_linear(16, 16, 16, 112); + cairo_pattern_add_color_stop_rgb(pattern, 0.0, 1.0, 1.0, 1.0); + cairo_pattern_add_color_stop_rgb(pattern, 0.2, 0.8, 0.8, 0.8); + cairo_set_source(cr, pattern); + cairo_pattern_destroy(pattern); + + rounded_rect(cr, 0, 0, 128, 128, t->frame_radius); + cairo_fill(cr); + cairo_destroy(cr); + + t->inactive_frame = + cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 128, 128); + cr = cairo_create(t->inactive_frame); + cairo_set_operator(cr, CAIRO_OPERATOR_OVER); + cairo_set_source_rgba(cr, 0.75, 0.75, 0.75, 1); + rounded_rect(cr, 0, 0, 128, 128, t->frame_radius); + cairo_fill(cr); + cairo_destroy(cr); +} + +void +fini_theme(struct theme *t) +{ + cairo_surface_destroy(t->active_frame); + cairo_surface_destroy(t->inactive_frame); + cairo_surface_destroy(t->shadow); +} diff --git a/clients/cairo-util.h b/clients/cairo-util.h index a973e3c..70800a4 100644 --- a/clients/cairo-util.h +++ b/clients/cairo-util.h @@ -43,4 +43,19 @@ rounded_rect(cairo_t *cr, int x0, int y0, int x1, int y1, int radius); cairo_surface_t * load_cairo_surface(const char *filename); +struct theme { + cairo_surface_t *active_frame; + cairo_surface_t *inactive_frame; + cairo_surface_t *shadow; + int frame_radius; + int margin; + int width; + int titlebar_height; +}; + +void +display_render_theme(struct theme *t); +void +fini_theme(struct theme *t); + #endif diff --git a/clients/window.c b/clients/window.c index 6a4cc93..dfc19e7 100644 --- a/clients/window.c +++ b/clients/window.c @@ -66,16 +66,6 @@ struct cursor; struct shm_pool; -struct theme { - cairo_surface_t *active_frame; - cairo_surface_t *inactive_frame; - cairo_surface_t *shadow; - int frame_radius; - int margin; - int width; - int titlebar_height; -}; - struct display { struct wl_display *display; struct wl_compositor *compositor; @@ -3131,58 +3121,6 @@ display_handle_global(struct wl_display *display, uint32_t id, } static void -display_render_theme(struct theme *t) -{ - cairo_t *cr; - cairo_pattern_t *pattern; - - t->margin = 32; - t->width = 6; - t->titlebar_height = 27; - t->frame_radius = 3; - t->shadow = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 128, 128); - cr = cairo_create(t->shadow); - cairo_set_operator(cr, CAIRO_OPERATOR_OVER); - cairo_set_source_rgba(cr, 0, 0, 0, 1); - rounded_rect(cr, 32, 32, 96, 96, t->frame_radius); - cairo_fill(cr); - cairo_destroy(cr); - blur_surface(t->shadow, 64); - - t->active_frame = - cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 128, 128); - cr = cairo_create(t->active_frame); - cairo_set_operator(cr, CAIRO_OPERATOR_OVER); - - pattern = cairo_pattern_create_linear(16, 16, 16, 112); - cairo_pattern_add_color_stop_rgb(pattern, 0.0, 1.0, 1.0, 1.0); - cairo_pattern_add_color_stop_rgb(pattern, 0.2, 0.8, 0.8, 0.8); - cairo_set_source(cr, pattern); - cairo_pattern_destroy(pattern); - - rounded_rect(cr, 0, 0, 128, 128, t->frame_radius); - cairo_fill(cr); - cairo_destroy(cr); - - t->inactive_frame = - cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 128, 128); - cr = cairo_create(t->inactive_frame); - cairo_set_operator(cr, CAIRO_OPERATOR_OVER); - cairo_set_source_rgba(cr, 0.75, 0.75, 0.75, 1); - rounded_rect(cr, 0, 0, 128, 128, t->frame_radius); - cairo_fill(cr); - cairo_destroy(cr); -} - -static void -fini_theme(struct theme *t) -{ - cairo_surface_destroy(t->active_frame); - cairo_surface_destroy(t->inactive_frame); - cairo_surface_destroy(t->shadow); -} - -static void init_xkb(struct display *d) { d->xkb.names.rules = "evdev"; |