summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2010-12-10 00:45:02 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2010-12-10 00:45:02 +0800
commit33f287138c730f81be99e41fbcd54fdc46992f76 (patch)
treefc6b51e9b609d080b6cc4c03efb6a5f29379790a /src
parentdd424f2ee3df4da3c364c76b3eea7ffffd3668ec (diff)
downloadunity-window-decorator-33f287138c730f81be99e41fbcd54fdc46992f76.tar.gz
unity-window-decorator-33f287138c730f81be99e41fbcd54fdc46992f76.tar.bz2
Add the ability for themes to specify active/inactive shadows, right now shadow values
are hardcoded
Diffstat (limited to 'src')
-rw-r--r--src/cairo.c114
-rw-r--r--src/decorator.c105
-rw-r--r--src/gtk-window-decorator.c6
-rw-r--r--src/gtk-window-decorator.h26
-rw-r--r--src/metacity.c112
5 files changed, 269 insertions, 94 deletions
diff --git a/src/cairo.c b/src/cairo.c
index b2277a9..beda2ca 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -885,3 +885,117 @@ update_border_extents (gint text_height)
max_titlebar_height = titlebar_height =
(text_height < 17) ? 17 : text_height;
}
+
+decor_shadow_t *
+cairo_update_shadow (gint shadow_type)
+{
+ decor_shadow_options_t opt_active_shadow;
+ decor_shadow_options_t opt_inactive_shadow;
+ 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;
+
+ 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));
+
+ switch (shadow_type)
+ {
+ case SHADOW_TYPE_ACTIVE_NORMAL:
+ return decor_shadow_create (xdisplay,
+ gdk_x11_screen_get_xscreen (screen),
+ 1, 1,
+ _win_extents.left,
+ _win_extents.right,
+ _win_extents.top + titlebar_height,
+ _win_extents.bottom,
+ _win_extents.left -
+ TRANSLUCENT_CORNER_SIZE,
+ _win_extents.right -
+ TRANSLUCENT_CORNER_SIZE,
+ _win_extents.top + titlebar_height -
+ TRANSLUCENT_CORNER_SIZE,
+ _win_extents.bottom -
+ TRANSLUCENT_CORNER_SIZE,
+ &opt_active_shadow,
+ &window_active_context,
+ draw_border_shape,
+ 0);
+ break;
+ case SHADOW_TYPE_INACTIVE_NORMAL:
+ return decor_shadow_create (xdisplay,
+ gdk_x11_screen_get_xscreen (screen),
+ 1, 1,
+ _win_extents.left,
+ _win_extents.right,
+ _win_extents.top + titlebar_height,
+ _win_extents.bottom,
+ _win_extents.left -
+ TRANSLUCENT_CORNER_SIZE,
+ _win_extents.right -
+ TRANSLUCENT_CORNER_SIZE,
+ _win_extents.top + titlebar_height -
+ TRANSLUCENT_CORNER_SIZE,
+ _win_extents.bottom -
+ TRANSLUCENT_CORNER_SIZE,
+ &opt_inactive_shadow,
+ &window_inactive_context,
+ draw_border_shape,
+ 0);
+ case SHADOW_TYPE_ACTIVE_MAX:
+ return decor_shadow_create (xdisplay,
+ gdk_x11_screen_get_xscreen (screen),
+ 1, 1,
+ _max_win_extents.left,
+ _max_win_extents.right,
+ _max_win_extents.top + max_titlebar_height,
+ _max_win_extents.bottom,
+ _max_win_extents.left - TRANSLUCENT_CORNER_SIZE,
+ _max_win_extents.right - TRANSLUCENT_CORNER_SIZE,
+ _max_win_extents.top + max_titlebar_height -
+ TRANSLUCENT_CORNER_SIZE,
+ _max_win_extents.bottom - TRANSLUCENT_CORNER_SIZE,
+ &opt_active_shadow,
+ &max_window_active_context,
+ draw_border_shape,
+ (void *) 1);
+ case SHADOW_TYPE_INACTIVE_MAX:
+ return decor_shadow_create (xdisplay,
+ gdk_x11_screen_get_xscreen (screen),
+ 1, 1,
+ _max_win_extents.left,
+ _max_win_extents.right,
+ _max_win_extents.top + max_titlebar_height,
+ _max_win_extents.bottom,
+ _max_win_extents.left - TRANSLUCENT_CORNER_SIZE,
+ _max_win_extents.right - TRANSLUCENT_CORNER_SIZE,
+ _max_win_extents.top + max_titlebar_height -
+ TRANSLUCENT_CORNER_SIZE,
+ _max_win_extents.bottom - TRANSLUCENT_CORNER_SIZE,
+ &opt_inactive_shadow,
+ &max_window_active_context,
+ draw_border_shape,
+ (void *) 1);
+ default:
+ return NULL;
+ }
+
+ return NULL;
+}
+
+void
+get_shadow (decor_t *d, gint shadow_type)
+{
+}
diff --git a/src/decorator.c b/src/decorator.c
index ce6b523..04d9940 100644
--- a/src/decorator.c
+++ b/src/decorator.c
@@ -319,8 +319,6 @@ update_window_decoration_icon (WnckWindow *win)
}
}
-
-
gboolean
update_window_decoration_size (WnckWindow *win)
{
@@ -409,10 +407,7 @@ update_window_decoration_size (WnckWindow *win)
return TRUE;
}
-/* to save some memory, value is specific to current decorations */
-#define TRANSLUCENT_CORNER_SIZE 3
-
-static void
+void
draw_border_shape (Display *xdisplay,
Pixmap pixmap,
Picture picture,
@@ -483,20 +478,20 @@ update_shadow (void)
opt_active_shadow.shadow_offset_x = shadow_offset_x;
opt_active_shadow.shadow_offset_y = shadow_offset_y;
+ opt_inactive_shadow.shadow_radius = shadow_radius;
+ opt_inactive_shadow.shadow_opacity = shadow_opacity;
+
+ memcpy (opt_inactive_shadow.shadow_color, shadow_color, sizeof (shadow_color));
+
+ opt_inactive_shadow.shadow_offset_x = shadow_offset_x;
+ opt_inactive_shadow.shadow_offset_y = shadow_offset_y;
+
opt_no_shadow.shadow_radius = 0;
opt_no_shadow.shadow_opacity = 0;
opt_no_shadow.shadow_offset_x = 0;
opt_no_shadow.shadow_offset_y = 0;
- opt_inactive_shadow.shadow_radius = 8.0;
- opt_inactive_shadow.shadow_opacity = 0.5;
-
- 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));
-
if (no_border_shadow)
{
decor_shadow_destroy (xdisplay, no_border_shadow);
@@ -511,7 +506,7 @@ update_shadow (void)
0,
0,
0, 0, 0, 0,
- &opt_active_shadow,
+ &opt_inactive_shadow,
&shadow_context,
decor_draw_simple,
0);
@@ -522,25 +517,7 @@ update_shadow (void)
border_active_shadow = NULL;
}
- border_active_shadow = decor_shadow_create (xdisplay,
- gdk_x11_screen_get_xscreen (screen),
- 1, 1,
- _win_extents.left,
- _win_extents.right,
- _win_extents.top + titlebar_height,
- _win_extents.bottom,
- _win_extents.left -
- TRANSLUCENT_CORNER_SIZE,
- _win_extents.right -
- TRANSLUCENT_CORNER_SIZE,
- _win_extents.top + titlebar_height -
- TRANSLUCENT_CORNER_SIZE,
- _win_extents.bottom -
- TRANSLUCENT_CORNER_SIZE,
- &opt_active_shadow,
- &window_active_context,
- draw_border_shape,
- 0);
+ border_active_shadow = (*theme_update_shadow) (SHADOW_TYPE_ACTIVE_NORMAL);
if (border_inactive_shadow)
{
@@ -548,25 +525,7 @@ update_shadow (void)
border_inactive_shadow = NULL;
}
- border_inactive_shadow = decor_shadow_create (xdisplay,
- gdk_x11_screen_get_xscreen (screen),
- 1, 1,
- _win_extents.left,
- _win_extents.right,
- _win_extents.top + titlebar_height,
- _win_extents.bottom,
- _win_extents.left -
- TRANSLUCENT_CORNER_SIZE,
- _win_extents.right -
- TRANSLUCENT_CORNER_SIZE,
- _win_extents.top + titlebar_height -
- TRANSLUCENT_CORNER_SIZE,
- _win_extents.bottom -
- TRANSLUCENT_CORNER_SIZE,
- &opt_inactive_shadow,
- &window_inactive_context,
- draw_border_shape,
- 0);
+ border_inactive_shadow = (*theme_update_shadow) (SHADOW_TYPE_INACTIVE_NORMAL);
if (border_no_shadow)
{
@@ -594,6 +553,8 @@ update_shadow (void)
draw_border_shape,
0);
+ decor_context_t *context = &window_context_no_shadow;
+
if (max_border_active_shadow)
{
@@ -601,23 +562,7 @@ update_shadow (void)
max_border_active_shadow = NULL;
}
- max_border_active_shadow =
- decor_shadow_create (xdisplay,
- gdk_x11_screen_get_xscreen (screen),
- 1, 1,
- _max_win_extents.left,
- _max_win_extents.right,
- _max_win_extents.top + max_titlebar_height,
- _max_win_extents.bottom,
- _max_win_extents.left - TRANSLUCENT_CORNER_SIZE,
- _max_win_extents.right - TRANSLUCENT_CORNER_SIZE,
- _max_win_extents.top + max_titlebar_height -
- TRANSLUCENT_CORNER_SIZE,
- _max_win_extents.bottom - TRANSLUCENT_CORNER_SIZE,
- &opt_active_shadow,
- &max_window_active_context,
- draw_border_shape,
- (void *) 1);
+ max_border_active_shadow = (*theme_update_shadow) (SHADOW_TYPE_ACTIVE_MAX);
if (max_border_inactive_shadow)
{
@@ -625,23 +570,7 @@ update_shadow (void)
max_border_inactive_shadow = NULL;
}
- max_border_inactive_shadow =
- decor_shadow_create (xdisplay,
- gdk_x11_screen_get_xscreen (screen),
- 1, 1,
- _max_win_extents.left,
- _max_win_extents.right,
- _max_win_extents.top + max_titlebar_height,
- _max_win_extents.bottom,
- _max_win_extents.left - TRANSLUCENT_CORNER_SIZE,
- _max_win_extents.right - TRANSLUCENT_CORNER_SIZE,
- _max_win_extents.top + max_titlebar_height -
- TRANSLUCENT_CORNER_SIZE,
- _max_win_extents.bottom - TRANSLUCENT_CORNER_SIZE,
- &opt_inactive_shadow,
- &max_window_inactive_context,
- draw_border_shape,
- (void *) 1);
+ max_border_inactive_shadow = (*theme_update_shadow) (SHADOW_TYPE_INACTIVE_MAX);
if (max_border_no_shadow)
{
@@ -688,7 +617,7 @@ update_shadow (void)
TRANSLUCENT_CORNER_SIZE,
_switcher_extents.bottom -
TRANSLUCENT_CORNER_SIZE,
- &opt_active_shadow,
+ &opt_inactive_shadow,
&switcher_context,
decor_draw_simple,
0);
diff --git a/src/gtk-window-decorator.c b/src/gtk-window-decorator.c
index 8cb4dc8..f5b06e8 100644
--- a/src/gtk-window-decorator.c
+++ b/src/gtk-window-decorator.c
@@ -293,21 +293,21 @@ main (int argc, char *argv[])
theme_update_border_extents = update_border_extents;
theme_get_event_window_position = get_event_window_position;
theme_get_button_position = get_button_position;
- theme_get_shadow = NULL;
+ theme_update_shadow = cairo_update_shadow;
+ theme_get_shadow = get_shadow;
#ifdef USE_METACITY
if (meta_theme)
{
- fprintf (stderr, "found meta theme\n");
meta_theme_set_current (meta_theme, TRUE);
if (meta_theme_get_current ())
{
- fprintf (stderr, "setting to meta\n");
theme_draw_window_decoration = meta_draw_window_decoration;
theme_calc_decoration_size = meta_calc_decoration_size;
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;
}
}
diff --git a/src/gtk-window-decorator.h b/src/gtk-window-decorator.h
index 2dd534a..47f94f6 100644
--- a/src/gtk-window-decorator.h
+++ b/src/gtk-window-decorator.h
@@ -193,6 +193,9 @@ WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY)
#define PROP_MOTIF_WM_HINT_ELEMENTS 3
+/* to save some memory, value is specific to current decorations */
+#define TRANSLUCENT_CORNER_SIZE 3
+
typedef struct {
unsigned long flags;
unsigned long functions;
@@ -422,8 +425,10 @@ gboolean (*theme_get_button_position) (decor_t *d,
gint *w,
gint *h);
-decor_shadow_t * (*theme_get_shadow) (decor_t *d,
- gint shadow_type);
+decor_shadow_t * (*theme_update_shadow) (gint shadow_type);
+
+void (*theme_get_shadow) (decor_t *d,
+ gint shadow_type);
extern char *program_name;
@@ -521,6 +526,14 @@ queue_decor_draw (decor_t *d);
void
copy_to_front_buffer (decor_t *d);
+void
+draw_border_shape (Display *xdisplay,
+ Pixmap pixmap,
+ Picture picture,
+ int width,
+ int height,
+ decor_context_t *c,
+ void *closure);
/* wnck.c*/
@@ -643,6 +656,12 @@ get_event_window_position (decor_t *d,
gint *w,
gint *h);
+decor_shadow_t *
+cairo_update_shadow (gint shadow_type);
+
+void
+get_shadow (decor_t *, gint shadow_type);
+
/* gdk.c */
void
@@ -722,6 +741,9 @@ void
meta_update_button_layout (const char *value);
decor_shadow_t *
+meta_update_shadow (gint shadow_type);
+
+void
meta_get_shadow (decor_t *, gint shadow_type);
#endif
diff --git a/src/metacity.c b/src/metacity.c
index ff4693f..f0aaf98 100644
--- a/src/metacity.c
+++ b/src/metacity.c
@@ -1605,9 +1605,119 @@ meta_update_border_extents (gint text_height)
}
decor_shadow_t *
-meta_get_shadow (decor_t *d, gint shadow_type)
+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;
+ 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;
+
+ 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));
+
+ switch (shadow_type)
+ {
+ case SHADOW_TYPE_ACTIVE_NORMAL:
+ return decor_shadow_create (xdisplay,
+ gdk_x11_screen_get_xscreen (screen),
+ 1, 1,
+ _win_extents.left,
+ _win_extents.right,
+ _win_extents.top + titlebar_height,
+ _win_extents.bottom,
+ _win_extents.left -
+ TRANSLUCENT_CORNER_SIZE,
+ _win_extents.right -
+ TRANSLUCENT_CORNER_SIZE,
+ _win_extents.top + titlebar_height -
+ TRANSLUCENT_CORNER_SIZE,
+ _win_extents.bottom -
+ TRANSLUCENT_CORNER_SIZE,
+ &opt_active_shadow,
+ &window_active_context,
+ draw_border_shape,
+ 0);
+ break;
+ case SHADOW_TYPE_INACTIVE_NORMAL:
+ return decor_shadow_create (xdisplay,
+ gdk_x11_screen_get_xscreen (screen),
+ 1, 1,
+ _win_extents.left,
+ _win_extents.right,
+ _win_extents.top + titlebar_height,
+ _win_extents.bottom,
+ _win_extents.left -
+ TRANSLUCENT_CORNER_SIZE,
+ _win_extents.right -
+ TRANSLUCENT_CORNER_SIZE,
+ _win_extents.top + titlebar_height -
+ TRANSLUCENT_CORNER_SIZE,
+ _win_extents.bottom -
+ TRANSLUCENT_CORNER_SIZE,
+ &opt_inactive_shadow,
+ &window_inactive_context,
+ draw_border_shape,
+ 0);
+ case SHADOW_TYPE_ACTIVE_MAX:
+ return decor_shadow_create (xdisplay,
+ gdk_x11_screen_get_xscreen (screen),
+ 1, 1,
+ _max_win_extents.left,
+ _max_win_extents.right,
+ _max_win_extents.top + max_titlebar_height,
+ _max_win_extents.bottom,
+ _max_win_extents.left - TRANSLUCENT_CORNER_SIZE,
+ _max_win_extents.right - TRANSLUCENT_CORNER_SIZE,
+ _max_win_extents.top + max_titlebar_height -
+ TRANSLUCENT_CORNER_SIZE,
+ _max_win_extents.bottom - TRANSLUCENT_CORNER_SIZE,
+ &opt_active_shadow,
+ &max_window_active_context,
+ draw_border_shape,
+ (void *) 1);
+ case SHADOW_TYPE_INACTIVE_MAX:
+ return decor_shadow_create (xdisplay,
+ gdk_x11_screen_get_xscreen (screen),
+ 1, 1,
+ _max_win_extents.left,
+ _max_win_extents.right,
+ _max_win_extents.top + max_titlebar_height,
+ _max_win_extents.bottom,
+ _max_win_extents.left - TRANSLUCENT_CORNER_SIZE,
+ _max_win_extents.right - TRANSLUCENT_CORNER_SIZE,
+ _max_win_extents.top + max_titlebar_height -
+ TRANSLUCENT_CORNER_SIZE,
+ _max_win_extents.bottom - TRANSLUCENT_CORNER_SIZE,
+ &opt_inactive_shadow,
+ &max_window_active_context,
+ draw_border_shape,
+ (void *) 1);
+ default:
+ return NULL;
+ }
+
return NULL;
}
+void
+meta_get_shadow (decor_t *d, gint shadow_type)
+{
+}
+
+
#endif