diff options
author | Sam Spilsbury <sam.spilsbury@canonical.com> | 2010-12-10 11:31:00 +0800 |
---|---|---|
committer | Sam Spilsbury <sam.spilsbury@canonical.com> | 2010-12-10 11:31:00 +0800 |
commit | 68d55bfde96278253410730cde4b33c7e38d07d6 (patch) | |
tree | 4dad9e3a7925620392cedf2d6232d28385dbcd1c /src | |
parent | 33f287138c730f81be99e41fbcd54fdc46992f76 (diff) | |
download | unity-window-decorator-68d55bfde96278253410730cde4b33c7e38d07d6.tar.gz unity-window-decorator-68d55bfde96278253410730cde4b33c7e38d07d6.tar.bz2 |
Allow metacity themes to specify shadows. WARNING: requires patched libmetacity private
Diffstat (limited to 'src')
-rw-r--r-- | src/cairo.c | 8 | ||||
-rw-r--r-- | src/decorator.c | 15 | ||||
-rw-r--r-- | src/metacity.c | 109 | ||||
-rw-r--r-- | src/settings.c | 4 |
4 files changed, 112 insertions, 24 deletions
diff --git a/src/cairo.c b/src/cairo.c index beda2ca..d53fd47 100644 --- a/src/cairo.c +++ b/src/cairo.c @@ -903,11 +903,11 @@ cairo_update_shadow (gint shadow_type) opt_active_shadow.shadow_offset_x = shadow_offset_x; opt_active_shadow.shadow_offset_y = shadow_offset_y; - opt_inactive_shadow.shadow_radius = 8.0; - opt_inactive_shadow.shadow_opacity = 0.5; + opt_inactive_shadow.shadow_radius = shadow_radius; + opt_inactive_shadow.shadow_opacity = shadow_opacity; - opt_inactive_shadow.shadow_offset_x = 0; - opt_inactive_shadow.shadow_offset_y = 0; + opt_inactive_shadow.shadow_offset_x = shadow_offset_x; + opt_inactive_shadow.shadow_offset_y = shadow_offset_y; memcpy (opt_inactive_shadow.shadow_color, shadow_color, sizeof (shadow_color)); diff --git a/src/decorator.c b/src/decorator.c index 04d9940..3a9e56e 100644 --- a/src/decorator.c +++ b/src/decorator.c @@ -331,6 +331,9 @@ update_window_decoration_size (WnckWindow *win) XRenderPictFormat *format; int depth; + if (!d) + return FALSE; + xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); wnck_window_get_client_window_geometry (win, &x, &y, &w, &h); @@ -519,6 +522,9 @@ update_shadow (void) border_active_shadow = (*theme_update_shadow) (SHADOW_TYPE_ACTIVE_NORMAL); + if (!border_active_shadow) + border_active_shadow = cairo_update_shadow (SHADOW_TYPE_ACTIVE_NORMAL); + if (border_inactive_shadow) { decor_shadow_destroy (xdisplay, border_inactive_shadow); @@ -527,6 +533,9 @@ update_shadow (void) border_inactive_shadow = (*theme_update_shadow) (SHADOW_TYPE_INACTIVE_NORMAL); + if (!border_inactive_shadow) + border_inactive_shadow = cairo_update_shadow (SHADOW_TYPE_INACTIVE_NORMAL); + if (border_no_shadow) { decor_shadow_destroy (xdisplay, border_no_shadow); @@ -564,6 +573,9 @@ update_shadow (void) max_border_active_shadow = (*theme_update_shadow) (SHADOW_TYPE_ACTIVE_MAX); + if (!max_border_active_shadow) + max_border_active_shadow = cairo_update_shadow (SHADOW_TYPE_ACTIVE_MAX); + if (max_border_inactive_shadow) { decor_shadow_destroy (xdisplay, max_border_inactive_shadow); @@ -572,6 +584,9 @@ update_shadow (void) max_border_inactive_shadow = (*theme_update_shadow) (SHADOW_TYPE_INACTIVE_MAX); + if (!max_border_inactive_shadow) + max_border_inactive_shadow = cairo_update_shadow (SHADOW_TYPE_INACTIVE_MAX); + if (max_border_no_shadow) { decor_shadow_destroy (xdisplay, max_border_active_shadow); diff --git a/src/metacity.c b/src/metacity.c index f0aaf98..ac25fb2 100644 --- a/src/metacity.c +++ b/src/metacity.c @@ -1607,32 +1607,44 @@ meta_update_border_extents (gint text_height) decor_shadow_t * meta_update_shadow (gint shadow_type) { - decor_shadow_options_t opt_active_shadow; - decor_shadow_options_t opt_inactive_shadow; - decor_shadow_options_t opt_no_shadow; + + decor_shadow_options_t opt_shadow; + MetaTheme *theme; + MetaFrameStyle *frame_style; + MetaShadowProperties *shadow_properties; + MetaFrameFlags frame_flags; Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); GdkDisplay *display = gdk_display_get_default (); GdkScreen *screen = gdk_display_get_default_screen (display); - opt_active_shadow.shadow_radius = shadow_radius; - opt_active_shadow.shadow_opacity = shadow_opacity; - - memcpy (opt_active_shadow.shadow_color, shadow_color, sizeof (shadow_color)); - - opt_active_shadow.shadow_offset_x = shadow_offset_x; - opt_active_shadow.shadow_offset_y = shadow_offset_y; - - opt_inactive_shadow.shadow_radius = 8.0; - opt_inactive_shadow.shadow_opacity = 0.5; + memcpy (opt_shadow.shadow_color, shadow_color, sizeof (shadow_color)); + memset (&frame_flags, 0, sizeof (MetaFrameFlags)); - opt_inactive_shadow.shadow_offset_x = 0; - opt_inactive_shadow.shadow_offset_y = 0; - memcpy (opt_inactive_shadow.shadow_color, shadow_color, sizeof (shadow_color)); + theme = meta_theme_get_current (); switch (shadow_type) { case SHADOW_TYPE_ACTIVE_NORMAL: + + frame_flags |= META_FRAME_HAS_FOCUS; + frame_style = meta_theme_get_frame_style (theme, + META_FRAME_TYPE_NORMAL, + frame_flags); + + if (!frame_style) + return NULL; + + shadow_properties = meta_frame_style_get_shadow_properties (frame_style); + + if (!shadow_properties) + return NULL; + + opt_shadow.shadow_radius = shadow_properties->unity_shadow_radius; + opt_shadow.shadow_offset_x = shadow_properties->unity_shadow_x_offset; + opt_shadow.shadow_offset_y = shadow_properties->unity_shadow_y_offset; + opt_shadow.shadow_opacity = 0.5; + return decor_shadow_create (xdisplay, gdk_x11_screen_get_xscreen (screen), 1, 1, @@ -1648,12 +1660,30 @@ meta_update_shadow (gint shadow_type) TRANSLUCENT_CORNER_SIZE, _win_extents.bottom - TRANSLUCENT_CORNER_SIZE, - &opt_active_shadow, + &opt_shadow, &window_active_context, draw_border_shape, 0); break; case SHADOW_TYPE_INACTIVE_NORMAL: + + return cairo_update_shadow (SHADOW_TYPE_INACTIVE_NORMAL); + + frame_style = meta_theme_get_frame_style (theme, + META_FRAME_TYPE_NORMAL, + frame_flags); + if (!frame_style) + return NULL; + + shadow_properties = meta_frame_style_get_shadow_properties (frame_style); + + if (!shadow_properties) + return NULL; + opt_shadow.shadow_radius = shadow_properties->unity_shadow_radius; + opt_shadow.shadow_offset_x = shadow_properties->unity_shadow_x_offset; + opt_shadow.shadow_offset_y = shadow_properties->unity_shadow_y_offset; + opt_shadow.shadow_opacity = 0.5; + return decor_shadow_create (xdisplay, gdk_x11_screen_get_xscreen (screen), 1, 1, @@ -1669,11 +1699,31 @@ meta_update_shadow (gint shadow_type) TRANSLUCENT_CORNER_SIZE, _win_extents.bottom - TRANSLUCENT_CORNER_SIZE, - &opt_inactive_shadow, + &opt_shadow, &window_inactive_context, draw_border_shape, 0); case SHADOW_TYPE_ACTIVE_MAX: + + frame_flags |= META_FRAME_MAXIMIZED; + frame_flags |= META_FRAME_HAS_FOCUS; + + frame_style = meta_theme_get_frame_style (theme, + META_FRAME_TYPE_NORMAL, + frame_flags); + if (!frame_style) + return NULL; + + shadow_properties = meta_frame_style_get_shadow_properties (frame_style); + + if (!shadow_properties) + return NULL; + + opt_shadow.shadow_radius = shadow_properties->unity_shadow_radius; + opt_shadow.shadow_offset_x = shadow_properties->unity_shadow_x_offset; + opt_shadow.shadow_offset_y = shadow_properties->unity_shadow_y_offset; + opt_shadow.shadow_opacity = 0.5; + return decor_shadow_create (xdisplay, gdk_x11_screen_get_xscreen (screen), 1, 1, @@ -1686,11 +1736,30 @@ meta_update_shadow (gint shadow_type) _max_win_extents.top + max_titlebar_height - TRANSLUCENT_CORNER_SIZE, _max_win_extents.bottom - TRANSLUCENT_CORNER_SIZE, - &opt_active_shadow, + &opt_shadow, &max_window_active_context, draw_border_shape, (void *) 1); case SHADOW_TYPE_INACTIVE_MAX: + + frame_flags |= META_FRAME_MAXIMIZED; + + frame_style = meta_theme_get_frame_style (theme, + META_FRAME_TYPE_NORMAL, + frame_flags); + if (!frame_style) + return NULL; + + shadow_properties = meta_frame_style_get_shadow_properties (frame_style); + + if (!shadow_properties) + return NULL; + + opt_shadow.shadow_radius = shadow_properties->unity_shadow_radius; + opt_shadow.shadow_offset_x = shadow_properties->unity_shadow_x_offset; + opt_shadow.shadow_offset_y = shadow_properties->unity_shadow_y_offset; + opt_shadow.shadow_opacity = 0.5; + return decor_shadow_create (xdisplay, gdk_x11_screen_get_xscreen (screen), 1, 1, @@ -1703,7 +1772,7 @@ meta_update_shadow (gint shadow_type) _max_win_extents.top + max_titlebar_height - TRANSLUCENT_CORNER_SIZE, _max_win_extents.bottom - TRANSLUCENT_CORNER_SIZE, - &opt_inactive_shadow, + &opt_shadow, &max_window_active_context, draw_border_shape, (void *) 1); diff --git a/src/settings.c b/src/settings.c index 039905f..074817e 100644 --- a/src/settings.c +++ b/src/settings.c @@ -163,6 +163,8 @@ theme_changed (GConfClient *client) theme_update_border_extents = meta_update_border_extents; theme_get_event_window_position = meta_get_event_window_position; theme_get_button_position = meta_get_button_position; + theme_update_shadow = meta_update_shadow; + theme_get_shadow = meta_get_shadow; } else { @@ -171,6 +173,8 @@ theme_changed (GConfClient *client) theme_update_border_extents = update_border_extents; theme_get_event_window_position = get_event_window_position; theme_get_button_position = get_button_position; + theme_update_shadow = cairo_update_shadow; + theme_get_shadow = get_shadow; } return TRUE; |