diff -Nru compiz-0.9.12.2+16.10.20160517/debian/changelog compiz-0.9.12.2+16.10.20160525/debian/changelog --- compiz-0.9.12.2+16.10.20160517/debian/changelog 2016-05-25 14:24:17.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/debian/changelog 2016-05-25 14:24:17.000000000 +0000 @@ -1,3 +1,25 @@ +compiz (1:0.9.12.2+16.10.20160525-0ubuntu1) yakkety; urgency=medium + + [ Alberts Muktupāvels ] + * Add GWDTheme, GWDThemeCairo and GWDThemeMetacity. + * GWDTheme: implement calc_decoration_size. + * GWDTheme: implement draw_window_decoration. + * GWDTheme: implement get_button_position. + * GWDTheme: implement get_event_window_position. + * GWDTheme: implement get_shadow. + * GWDTheme: implement get_title_scale. + * GWDTheme: implement update_border_extents. + * Remove GWDSettingsInterface. + * Remove GWDSettingsNotifiedInterface and GDWSettingsNotified. + * gtk-window-decorator: remove global meta_button_layout and + meta_button_layout_set variables. + + [ Alberts Muktupāvels, CI Train Bot ] + * Remove GWDSettingsWritable. + * gtk-window-decorator: don't use GWDSettings as global variable. + + -- Marco Trevisan (Treviño) Wed, 25 May 2016 14:20:56 +0000 + compiz (1:0.9.12.2+16.10.20160517-0ubuntu1) yakkety; urgency=medium [ Alberts Muktupāvels ] diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/actionmenu.c compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/actionmenu.c --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/actionmenu.c 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/actionmenu.c 2016-05-25 14:19:48.000000000 +0000 @@ -53,8 +53,9 @@ if (d->decorated) { - if ((*theme_get_button_position) (d, BUTTON_MENU, width, height, - &bx, &by, &width, &height)) + if (gwd_theme_get_button_position (gwd_theme, d, BUTTON_MENU, + width, height, &bx, &by, + &width, &height)) *x = *x - frame->win_extents.left + bx; } diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/blurprops.c compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/blurprops.c --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/blurprops.c 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/blurprops.c 2016-05-25 14:20:33.000000000 +0000 @@ -20,7 +20,7 @@ */ #include "gtk-window-decorator.h" -#include "gwd-settings-interface.h" +#include "gwd-settings.h" void decor_update_blur_property (decor_t *d, @@ -35,6 +35,7 @@ Region right_region, int right_offset) { + GWDSettings *settings = gwd_theme_get_settings (gwd_theme); Display *xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); long *data = NULL; int size = 0; diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/cairo.c compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/cairo.c --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/cairo.c 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/cairo.c 2016-05-25 14:20:10.000000000 +0000 @@ -24,9 +24,6 @@ */ #include "gtk-window-decorator.h" -#include "gwd-cairo-window-decoration-util.h" - -#define STROKE_ALPHA 0.6f void rounded_rectangle (cairo_t *cr, @@ -154,817 +151,3 @@ &d->border_layout); } } - -static void -draw_close_button (decor_t *d, - cairo_t *cr, - double s) -{ - cairo_rel_move_to (cr, 0.0, s); - - cairo_rel_line_to (cr, s, -s); - cairo_rel_line_to (cr, s, s); - cairo_rel_line_to (cr, s, -s); - cairo_rel_line_to (cr, s, s); - - cairo_rel_line_to (cr, -s, s); - cairo_rel_line_to (cr, s, s); - cairo_rel_line_to (cr, -s, s); - cairo_rel_line_to (cr, -s, -s); - - cairo_rel_line_to (cr, -s, s); - cairo_rel_line_to (cr, -s, -s); - cairo_rel_line_to (cr, s, -s); - - cairo_close_path (cr); -} - -static void -draw_max_button (decor_t *d, - cairo_t *cr, - double s) -{ - cairo_rel_line_to (cr, 12.0, 0.0); - cairo_rel_line_to (cr, 0.0, 12.0); - cairo_rel_line_to (cr, -12.0, 0.0); - - cairo_close_path (cr); - - cairo_rel_move_to (cr, 2.0, s); - - cairo_rel_line_to (cr, 12.0 - 4.0, 0.0); - cairo_rel_line_to (cr, 0.0, 12.0 - s - 2.0); - cairo_rel_line_to (cr, -(12.0 - 4.0), 0.0); - - cairo_close_path (cr); -} - -static void -draw_unmax_button (decor_t *d, - cairo_t *cr, - double s) -{ - cairo_rel_move_to (cr, 1.0, 1.0); - - cairo_rel_line_to (cr, 10.0, 0.0); - cairo_rel_line_to (cr, 0.0, 10.0); - cairo_rel_line_to (cr, -10.0, 0.0); - - cairo_close_path (cr); - - cairo_rel_move_to (cr, 2.0, s); - - cairo_rel_line_to (cr, 10.0 - 4.0, 0.0); - cairo_rel_line_to (cr, 0.0, 10.0 - s - 2.0); - cairo_rel_line_to (cr, -(10.0 - 4.0), 0.0); - - cairo_close_path (cr); -} - -static void -draw_min_button (decor_t *d, - cairo_t *cr, - double s) -{ - cairo_rel_move_to (cr, 0.0, 8.0); - - cairo_rel_line_to (cr, 12.0, 0.0); - cairo_rel_line_to (cr, 0.0, s); - cairo_rel_line_to (cr, -12.0, 0.0); - - cairo_close_path (cr); -} - -typedef void (*draw_proc) (cairo_t *cr); - -static void -button_state_offsets (gdouble x, - gdouble y, - guint state, - gdouble *return_x, - gdouble *return_y) -{ - static double off[] = { 0.0, 0.0, 0.0, 0.5 }; - - *return_x = x + off[state]; - *return_y = y + off[state]; -} - -static void -button_state_paint (cairo_t *cr, - GtkStyleContext *context, - decor_color_t *color, - guint state) -{ - GdkRGBA fg; - -#define IN_STATE (PRESSED_EVENT_WINDOW | IN_EVENT_WINDOW) - - gtk_style_context_save (context); - gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL); - gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &fg); - gtk_style_context_restore (context); - - fg.alpha = STROKE_ALPHA; - - if ((state & IN_STATE) == IN_STATE) - { - if (state & IN_EVENT_WINDOW) - cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); - else - cairo_set_source_rgba (cr, color->r, color->g, color->b, 0.95); - - cairo_fill_preserve (cr); - - gdk_cairo_set_source_rgba (cr, &fg); - - cairo_set_line_width (cr, 1.0); - cairo_stroke (cr); - cairo_set_line_width (cr, 2.0); - } - else - { - gdk_cairo_set_source_rgba (cr, &fg); - cairo_stroke_preserve (cr); - - if (state & IN_EVENT_WINDOW) - cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); - else - cairo_set_source_rgba (cr, color->r, color->g, color->b, 0.95); - - cairo_fill (cr); - } -} - -void -draw_window_decoration (decor_t *d) -{ - cairo_t *cr; - GtkStyleContext *context; - GdkRGBA bg, fg; - cairo_surface_t *surface; - decor_color_t color; - double alpha; - double x1, y1, x2, y2, x, y, h; - int corners = SHADE_LEFT | SHADE_RIGHT | SHADE_TOP | SHADE_BOTTOM; - int top; - int button_x; - - if (!d->surface) - return; - - context = gtk_widget_get_style_context (d->frame->style_window_rgba); - - gtk_style_context_save (context); - gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL); - gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg); - gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &fg); - gtk_style_context_restore (context); - - if (d->state & (WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY | - WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY)) - corners = 0; - - color.r = bg.red; - color.g = bg.green; - color.b = bg.blue; - - if (d->buffer_surface) - surface = d->buffer_surface; - else - surface = d->surface; - - cr = cairo_create (surface); - if (!cr) - return; - - cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); - - top = d->frame->win_extents.top + d->frame->titlebar_height; - - x1 = d->context->left_space - d->frame->win_extents.left; - y1 = d->context->top_space - d->frame->win_extents.top - d->frame->titlebar_height; - x2 = d->width - d->context->right_space + d->frame->win_extents.right; - y2 = d->height - d->context->bottom_space + d->frame->win_extents.bottom; - - h = d->height - d->context->top_space - d->context->bottom_space; - - cairo_set_line_width (cr, 1.0); - - if (!d->frame_window) - draw_shadow_background (d, cr, d->shadow, d->context); - - if (d->active) - { - decor_color_t *title_color = _title_color; - - alpha = decoration_alpha + 0.3; - - fill_rounded_rectangle (cr, - x1 + 0.5, - y1 + 0.5, - d->frame->win_extents.left - 0.5, - top - 0.5, - 5.0, CORNER_TOPLEFT & corners, - &title_color[0], 1.0, &title_color[1], alpha, - SHADE_TOP | SHADE_LEFT); - - fill_rounded_rectangle (cr, - x1 + d->frame->win_extents.left, - y1 + 0.5, - x2 - x1 - d->frame->win_extents.left - - d->frame->win_extents.right, - top - 0.5, - 5.0, 0, - &title_color[0], 1.0, &title_color[1], alpha, - SHADE_TOP); - - fill_rounded_rectangle (cr, - x2 - d->frame->win_extents.right, - y1 + 0.5, - d->frame->win_extents.right - 0.5, - top - 0.5, - 5.0, CORNER_TOPRIGHT & corners, - &title_color[0], 1.0, &title_color[1], alpha, - SHADE_TOP | SHADE_RIGHT); - } - else - { - alpha = decoration_alpha; - - fill_rounded_rectangle (cr, - x1 + 0.5, - y1 + 0.5, - d->frame->win_extents.left - 0.5, - top - 0.5, - 5.0, CORNER_TOPLEFT & corners, - &color, 1.0, &color, alpha, - SHADE_TOP | SHADE_LEFT); - - fill_rounded_rectangle (cr, - x1 + d->frame->win_extents.left, - y1 + 0.5, - x2 - x1 - d->frame->win_extents.left - - d->frame->win_extents.right, - top - 0.5, - 5.0, 0, - &color, 1.0, &color, alpha, - SHADE_TOP); - - fill_rounded_rectangle (cr, - x2 - d->frame->win_extents.right, - y1 + 0.5, - d->frame->win_extents.right - 0.5, - top - 0.5, - 5.0, CORNER_TOPRIGHT & corners, - &color, 1.0, &color, alpha, - SHADE_TOP | SHADE_RIGHT); - } - - fill_rounded_rectangle (cr, - x1 + 0.5, - y1 + top, - d->frame->win_extents.left - 0.5, - h, - 5.0, 0, - &color, 1.0, &color, alpha, - SHADE_LEFT); - - fill_rounded_rectangle (cr, - x2 - d->frame->win_extents.right, - y1 + top, - d->frame->win_extents.right - 0.5, - h, - 5.0, 0, - &color, 1.0, &color, alpha, - SHADE_RIGHT); - - - fill_rounded_rectangle (cr, - x1 + 0.5, - y2 - d->frame->win_extents.bottom, - d->frame->win_extents.left - 0.5, - d->frame->win_extents.bottom - 0.5, - 5.0, CORNER_BOTTOMLEFT & corners, - &color, 1.0, &color, alpha, - SHADE_BOTTOM | SHADE_LEFT); - - fill_rounded_rectangle (cr, - x1 + d->frame->win_extents.left, - y2 - d->frame->win_extents.bottom, - x2 - x1 - d->frame->win_extents.left - - d->frame->win_extents.right, - d->frame->win_extents.bottom - 0.5, - 5.0, 0, - &color, 1.0, &color, alpha, - SHADE_BOTTOM); - - fill_rounded_rectangle (cr, - x2 - d->frame->win_extents.right, - y2 - d->frame->win_extents.bottom, - d->frame->win_extents.right - 0.5, - d->frame->win_extents.bottom - 0.5, - 5.0, CORNER_BOTTOMRIGHT & corners, - &color, 1.0, &color, alpha, - SHADE_BOTTOM | SHADE_RIGHT); - - cairo_rectangle (cr, - d->context->left_space, - d->context->top_space, - d->width - d->context->left_space - - d->context->right_space, - h); - gdk_cairo_set_source_rgba (cr, &bg); - cairo_fill (cr); - - cairo_set_operator (cr, CAIRO_OPERATOR_OVER); - - if (d->active) - { - fg.alpha = 0.7; - gdk_cairo_set_source_rgba (cr, &fg); - - cairo_move_to (cr, x1 + 0.5, y1 + top - 0.5); - cairo_rel_line_to (cr, x2 - x1 - 1.0, 0.0); - - cairo_stroke (cr); - } - - rounded_rectangle (cr, - x1 + 0.5, y1 + 0.5, - x2 - x1 - 1.0, y2 - y1 - 1.0, - 5.0, - (CORNER_TOPLEFT | CORNER_TOPRIGHT | CORNER_BOTTOMLEFT | - CORNER_BOTTOMRIGHT) & corners); - - cairo_clip (cr); - - cairo_translate (cr, 1.0, 1.0); - - rounded_rectangle (cr, - x1 + 0.5, y1 + 0.5, - x2 - x1 - 1.0, y2 - y1 - 1.0, - 5.0, - (CORNER_TOPLEFT | CORNER_TOPRIGHT | CORNER_BOTTOMLEFT | - CORNER_BOTTOMRIGHT) & corners); - - cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.4); - - cairo_stroke (cr); - - cairo_translate (cr, -2.0, -2.0); - - rounded_rectangle (cr, - x1 + 0.5, y1 + 0.5, - x2 - x1 - 1.0, y2 - y1 - 1.0, - 5.0, - (CORNER_TOPLEFT | CORNER_TOPRIGHT | CORNER_BOTTOMLEFT | - CORNER_BOTTOMRIGHT) & corners); - - cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.1); - - cairo_stroke (cr); - - cairo_translate (cr, 1.0, 1.0); - - cairo_reset_clip (cr); - - rounded_rectangle (cr, - x1 + 0.5, y1 + 0.5, - x2 - x1 - 1.0, y2 - y1 - 1.0, - 5.0, - (CORNER_TOPLEFT | CORNER_TOPRIGHT | CORNER_BOTTOMLEFT | - CORNER_BOTTOMRIGHT) & corners); - - fg.alpha = alpha; - gdk_cairo_set_source_rgba (cr, &fg); - - cairo_stroke (cr); - - cairo_set_line_width (cr, 2.0); - - button_x = d->width - d->context->right_space - 13; - - if (d->actions & WNCK_WINDOW_ACTION_CLOSE) - { - button_state_offsets (button_x, - y1 - 3.0 + d->frame->titlebar_height / 2, - d->button_states[BUTTON_CLOSE], &x, &y); - - button_x -= 17; - - if (d->active) - { - cairo_move_to (cr, x, y); - draw_close_button (d, cr, 3.0); - button_state_paint (cr, context, &color, - d->button_states[BUTTON_CLOSE]); - } - else - { - fg.alpha = alpha * 0.75; - gdk_cairo_set_source_rgba (cr, &fg); - - cairo_move_to (cr, x, y); - draw_close_button (d, cr, 3.0); - cairo_fill (cr); - } - } - - if (d->actions & WNCK_WINDOW_ACTION_MAXIMIZE) - { - button_state_offsets (button_x, - y1 - 3.0 + d->frame->titlebar_height / 2, - d->button_states[BUTTON_MAX], &x, &y); - - button_x -= 17; - - cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); - - if (d->active) - { - fg.alpha = STROKE_ALPHA; - gdk_cairo_set_source_rgba (cr, &fg); - - cairo_move_to (cr, x, y); - - if (d->state & (WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY | - WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY)) - draw_unmax_button (d, cr, 4.0); - else - draw_max_button (d, cr, 4.0); - - button_state_paint (cr, context, &color, - d->button_states[BUTTON_MAX]); - } - else - { - fg.alpha = alpha * 0.75; - gdk_cairo_set_source_rgba (cr, &fg); - - cairo_move_to (cr, x, y); - - if (d->state & (WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY | - WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY)) - draw_unmax_button (d, cr, 4.0); - else - draw_max_button (d, cr, 4.0); - - cairo_fill (cr); - } - } - - if (d->actions & WNCK_WINDOW_ACTION_MINIMIZE) - { - button_state_offsets (button_x, - y1 - 3.0 + d->frame->titlebar_height / 2, - d->button_states[BUTTON_MIN], &x, &y); - - button_x -= 17; - - if (d->active) - { - fg.alpha = STROKE_ALPHA; - gdk_cairo_set_source_rgba (cr, &fg); - - - cairo_move_to (cr, x, y); - draw_min_button (d, cr, 4.0); - button_state_paint (cr, context, &color, - d->button_states[BUTTON_MIN]); - } - else - { - fg.alpha = alpha * 0.75; - gdk_cairo_set_source_rgba (cr, &fg); - - cairo_move_to (cr, x, y); - draw_min_button (d, cr, 4.0); - cairo_fill (cr); - } - } - - if (d->layout) - { - if (d->active) - { - cairo_move_to (cr, - d->context->left_space + 21.0, - y1 + 2.0 + (d->frame->titlebar_height - d->frame->text_height) / 2.0); - - fg.alpha = STROKE_ALPHA; - gdk_cairo_set_source_rgba (cr, &fg); - - pango_cairo_layout_path (cr, d->layout); - cairo_stroke (cr); - - cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); - } - else - { - fg.alpha = alpha; - gdk_cairo_set_source_rgba (cr, &fg); - } - - cairo_move_to (cr, - d->context->left_space + 21.0, - y1 + 2.0 + (d->frame->titlebar_height - d->frame->text_height) / 2.0); - - pango_cairo_show_layout (cr, d->layout); - } - - if (d->icon) - { - cairo_translate (cr, d->context->left_space + 1, - y1 - 5.0 + d->frame->titlebar_height / 2); - cairo_set_source (cr, d->icon); - cairo_rectangle (cr, 0.0, 0.0, 16.0, 16.0); - cairo_clip (cr); - - if (d->active) - cairo_paint (cr); - else - cairo_paint_with_alpha (cr, alpha); - } - - cairo_destroy (cr); - - copy_to_front_buffer (d); - - if (d->frame_window) - { - GdkWindow *gdk_frame_window = gtk_widget_get_window (d->decor_window); - GdkPixbuf *pixbuf = gdk_pixbuf_get_from_surface (d->surface, 0, 0, d->width, d->height); - - gtk_image_set_from_pixbuf (GTK_IMAGE (d->decor_image), pixbuf); - g_object_unref (pixbuf); - - gtk_window_resize (GTK_WINDOW (d->decor_window), d->width, d->height); - gdk_window_move (gdk_frame_window, 0, 0); - gdk_window_lower (gdk_frame_window); - } - - if (d->prop_xid) - { - decor_update_window_property (d); - d->prop_xid = 0; - } -} - -static void -calc_button_size (decor_t *d) -{ - gint button_width = 0; - - if (d->actions & WNCK_WINDOW_ACTION_CLOSE) - button_width += 17; - - if (d->actions & (WNCK_WINDOW_ACTION_MAXIMIZE_HORIZONTALLY | - WNCK_WINDOW_ACTION_MAXIMIZE_VERTICALLY | - WNCK_WINDOW_ACTION_UNMAXIMIZE_HORIZONTALLY | - WNCK_WINDOW_ACTION_UNMAXIMIZE_VERTICALLY)) - button_width += 17; - - if (d->actions & WNCK_WINDOW_ACTION_MINIMIZE) - button_width += 17; - - if (button_width) - ++button_width; - - d->button_width = button_width; -} - -gboolean -calc_decoration_size (decor_t *d, - gint w, - gint h, - gint name_width, - gint *width, - gint *height) -{ - decor_layout_t layout; - int top_width; - - if (!d->decorated) - return FALSE; - - /* To avoid wasting texture memory, we only calculate the minimal - * required decoration size then clip and stretch the texture where - * appropriate - */ - - if (!d->frame_window) - { - calc_button_size (d); - - if (w < ICON_SPACE + d->button_width) - return FALSE; - - top_width = name_width + d->button_width + ICON_SPACE; - if (w < top_width) - top_width = MAX (ICON_SPACE + d->button_width, w); - - if (d->active) - decor_get_default_layout (&d->frame->window_context_active, top_width, 1, &layout); - else - decor_get_default_layout (&d->frame->window_context_inactive, top_width, 1, &layout); - - if (!d->context || memcmp (&layout, &d->border_layout, sizeof (layout))) - { - *width = layout.width; - *height = layout.height; - - d->border_layout = layout; - if (d->active) - { - d->context = &d->frame->window_context_active; - d->shadow = d->frame->border_shadow_active; - } - else - { - d->context = &d->frame->window_context_inactive; - d->shadow = d->frame->border_shadow_inactive; - } - - return TRUE; - } - } - else - { - calc_button_size (d); - - /* _default_win_extents + top height */ - - top_width = name_width + d->button_width + ICON_SPACE; - if (w < top_width) - top_width = MAX (ICON_SPACE + d->button_width, w); - - decor_get_default_layout (&d->frame->window_context_no_shadow, - d->client_width, d->client_height, &layout); - - *width = layout.width; - *height = layout.height; - - d->border_layout = layout; - if (d->active) - { - d->context = &d->frame->window_context_active; - d->shadow = d->frame->border_shadow_active; - } - else - { - d->context = &d->frame->window_context_inactive; - d->shadow = d->frame->border_shadow_inactive; - } - - return TRUE; - } - - return FALSE; -} - -static gboolean -button_present (decor_t *d, - gint i) -{ - switch (i) { - case BUTTON_MIN: - if (d->actions & WNCK_WINDOW_ACTION_MINIMIZE) - return TRUE; - break; - case BUTTON_MAX: - if (d->actions & WNCK_WINDOW_ACTION_MAXIMIZE) - return TRUE; - break; - case BUTTON_CLOSE: - if (d->actions & WNCK_WINDOW_ACTION_CLOSE) - return TRUE; - break; - case BUTTON_MENU: - case BUTTON_SHADE: - case BUTTON_ABOVE: - case BUTTON_STICK: - case BUTTON_UNSHADE: - case BUTTON_UNABOVE: - case BUTTON_UNSTICK: - break; - default: - break; - } - - return FALSE; -} - -gboolean -get_button_position (decor_t *d, - gint i, - gint width, - gint height, - gint *x, - gint *y, - gint *w, - gint *h) -{ - if (i > BUTTON_MENU) - return FALSE; - - if (d->frame_window) - { - *x = bpos[i].x + bpos[i].xw * width + d->frame->win_extents.left + 4; - *y = bpos[i].y + bpos[i].yh * height + bpos[i].yth * - (d->frame->titlebar_height - 17) + d->frame->win_extents.top + 2; - } - else - { - *x = bpos[i].x + bpos[i].xw * width; - *y = bpos[i].y + bpos[i].yh * height + bpos[i].yth * - (d->frame->titlebar_height - 17); - } - - *w = bpos[i].w + bpos[i].ww * width; - *h = bpos[i].h + bpos[i].hh * height + bpos[i].hth + - (d->frame->titlebar_height - 17); - - /* hack to position multiple buttons on the right */ - if (i != BUTTON_MENU) { - gint position = 0; - gint button = 0; - while (button != i) { - if (button_present (d, button)) - position++; - button++; - } - *x -= 10 + 16 * position; - } - - return TRUE; -} - -void -get_event_window_position (decor_t *d, - gint i, - gint j, - gint width, - gint height, - gint *x, - gint *y, - gint *w, - gint *h) -{ - if (d->frame_window) - { - *x = pos[i][j].x + pos[i][j].xw * width + d->frame->win_extents.left; - *y = pos[i][j].y + d->frame->win_extents.top + - pos[i][j].yh * height + pos[i][j].yth * (d->frame->titlebar_height - 17); - - if (i == 0 && (j == 0 || j == 2)) - *y -= d->frame->titlebar_height; - } - else - { - *x = pos[i][j].x + pos[i][j].xw * width; - *y = pos[i][j].y + - pos[i][j].yh * height + pos[i][j].yth * (d->frame->titlebar_height - 17); - } - - if ((d->state & WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY) && - (j == 0 || j == 2)) - { - *w = 0; - } - else - { - *w = pos[i][j].w + pos[i][j].ww * width; - } - - if ((d->state & WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY) && - (i == 0 || i == 2)) - { - *h = 0; - } - else - { - *h = pos[i][j].h + - pos[i][j].hh * height + pos[i][j].hth * (d->frame->titlebar_height - 17); - } -} - -gfloat -get_title_scale (decor_frame_t *frame) -{ - return 1.0f; -} - -void -update_border_extents (decor_frame_t *frame) -{ - frame = gwd_decor_frame_ref (frame); - - gwd_cairo_window_decoration_get_extents (&frame->win_extents, - &frame->max_win_extents); - - frame->titlebar_height = frame->max_titlebar_height = - (frame->text_height < 17) ? 17 : frame->text_height; - - gwd_decor_frame_unref (frame); -} diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/CMakeLists.txt compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/CMakeLists.txt --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/CMakeLists.txt 2016-05-17 02:52:35.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/CMakeLists.txt 2016-05-25 14:20:26.000000000 +0000 @@ -29,22 +29,10 @@ add_library (gtk_window_decorator_cairo_window_decoration_util ${CMAKE_CURRENT_SOURCE_DIR}/gwd-cairo-window-decoration-util.c) - add_library (gtk_window_decorator_settings_interface STATIC - ${CMAKE_CURRENT_SOURCE_DIR}/gwd-settings-interface.c) - add_library (gtk_window_decorator_settings STATIC ${CMAKE_CURRENT_SOURCE_DIR}/gwd-settings.c) - add_library (gtk_window_decorator_settings_writable_interface STATIC - ${CMAKE_CURRENT_SOURCE_DIR}/gwd-settings-writable-interface.c) - - add_library (gtk_window_decorator_settings_notified_interface - ${CMAKE_CURRENT_SOURCE_DIR}/gwd-settings-notified-interface.c) - set (GTK_WINDOW_DECORATOR_ADDITIONAL_LIBRARIES - gtk_window_decorator_settings_notified_interface - gtk_window_decorator_settings_interface - gtk_window_decorator_settings_writable_interface gtk_window_decorator_settings gtk_window_decorator_metacity_window_decoration_util gtk_window_decorator_cairo_window_decoration_util) @@ -79,6 +67,10 @@ compiz_install_gsettings_schema (${_gwd_gschema_generated_location} ${_gwd_gschema_dest}) + if (USE_METACITY) + set (gwd_theme_metacity ${CMAKE_CURRENT_SOURCE_DIR}/gwd-theme-metacity.c) + endif (USE_METACITY) + add_executable (gtk-window-decorator gtk-window-decorator.c blurprops.c @@ -87,7 +79,6 @@ frames.c gdk.c switcher.c - metacity.c events.c forcequit.c tooltip.c @@ -97,7 +88,9 @@ wnck.c decorator.c ${CMAKE_CURRENT_SOURCE_DIR}/gwd-settings-xproperty-storage.c - ${CMAKE_CURRENT_SOURCE_DIR}/gwd-settings-notified.c + ${CMAKE_CURRENT_SOURCE_DIR}/gwd-theme.c + ${CMAKE_CURRENT_SOURCE_DIR}/gwd-theme-cairo.c + ${gwd_theme_metacity} ${gwd_schema} ) @@ -107,7 +100,6 @@ set (metacitylibs ${METACITY_LIBRARIES}) endif (USE_METACITY) - target_link_libraries ( gtk-window-decorator decoration diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/decorator.c compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/decorator.c --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/decorator.c 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/decorator.c 2016-05-25 14:20:33.000000000 +0000 @@ -24,6 +24,13 @@ */ #include "gtk-window-decorator.h" +#include "gwd-theme-cairo.h" + +static void +draw_window_decoration (decor_t *decor) +{ + gwd_theme_draw_window_decoration (gwd_theme, decor); +} void destroy_normal_frame (decor_frame_t *frame) @@ -47,6 +54,7 @@ static const PangoFontDescription * get_titlebar_font (decor_frame_t *frame) { + GWDSettings *settings = gwd_theme_get_settings (gwd_theme); const gchar *titlebar_font; g_object_get (settings, "titlebar-font", &titlebar_font, NULL); @@ -230,8 +238,8 @@ h = 0; if (actions & event_window_actions[i][j] && i >= k && i <= l) - (*theme_get_event_window_position) (d, i, j, width, height, - &x, &y, &w, &h); + gwd_theme_get_event_window_position (gwd_theme, d, i, j, width, height, + &x, &y, &w, &h); /* Reparenting mode - create boxes which we monitor motionnotify on */ if (d->frame_window) @@ -294,7 +302,8 @@ /* Reparenting mode - if there is a button position for this * button then set the geometry */ if (d->frame_window && - (*theme_get_button_position) (d, i, width, height, &x, &y, &w, &h)) + gwd_theme_get_button_position (gwd_theme, d, i, width, height, + &x, &y, &w, &h)) { BoxPtr box = &d->button_windows[i].pos; box->x1 = x; @@ -305,8 +314,8 @@ /* Pixmap mode - if there is a button position for this button then map the window * and resize it to this position */ else if (!d->frame_window && - (*theme_get_button_position) (d, i, width, height, - &x, &y, &w, &h)) + gwd_theme_get_button_position (gwd_theme, d, i, width, height, + &x, &y, &w, &h)) { Window x11_win = d->button_windows[i].window; XMapWindow (xdisplay, x11_win); @@ -407,7 +416,7 @@ gint w; /* Cairo mode: w = SHRT_MAX */ - if (theme_draw_window_decoration != draw_window_decoration) + if (!GWD_IS_THEME_CAIRO (gwd_theme)) { w = SHRT_MAX; } @@ -530,7 +539,7 @@ /* Ask the theme to tell us how much space it needs. If this is not successful * update the decoration name and return false */ - if (!(*theme_calc_decoration_size) (d, w, h, name_width, &width, &height)) + if (!gwd_theme_calc_decoration_size (gwd_theme, d, w, h, name_width, &width, &height)) { update_window_decoration_name (win); return FALSE; @@ -705,7 +714,7 @@ d.width = width; d.height = height; d.active = TRUE; - d.draw = theme_draw_window_decoration; + d.draw = draw_window_decoration; d.picture = picture; d.context = c; @@ -959,8 +968,8 @@ opts->active_shadow = &active_o; opts->inactive_shadow = &inactive_o; - (*theme_get_shadow) (frame, opts->active_shadow, TRUE); - (*theme_get_shadow) (frame, opts->inactive_shadow, FALSE); + gwd_theme_get_shadow (gwd_theme, frame, opts->active_shadow, TRUE); + gwd_theme_get_shadow (gwd_theme, frame, opts->inactive_shadow, FALSE); gwd_decor_frame_ref (frame); @@ -987,34 +996,6 @@ } -static void -get_shadow_common (decor_frame_t *d, decor_shadow_options_t *opts, gboolean active) -{ - decor_shadow_options_t *setting_opts = NULL; - - if (active) - g_object_get (settings, "active-shadow", &setting_opts, NULL); - else - g_object_get (settings, "inactive-shadow", &setting_opts, NULL); - - if (setting_opts) - { - memcpy (opts, setting_opts, sizeof (decor_shadow_options_t)); - } -} - -void -cairo_get_shadow (decor_frame_t *frame, decor_shadow_options_t *opts, gboolean active) -{ - get_shadow_common (frame, opts, active); -} - -void -meta_get_shadow (decor_frame_t *frame, decor_shadow_options_t *opts, gboolean active) -{ - get_shadow_common (frame, opts, active); -} - int update_shadow (void) { @@ -1368,7 +1349,7 @@ extents.top += frame->titlebar_height; - default_frames[i].d->draw = theme_draw_window_decoration; + default_frames[i].d->draw = draw_window_decoration; default_frames[i].d->surface = create_native_surface_and_wrap (default_frames[i].d->width, default_frames[i].d->height, frame->style_window_rgba); diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/events.c compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/events.c --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/events.c 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/events.c 2016-05-25 14:20:33.000000000 +0000 @@ -24,7 +24,7 @@ */ #include "gtk-window-decorator.h" -#include "gwd-settings-interface.h" +#include "gwd-settings.h" #define DOUBLE_CLICK_DISTANCE 8.0f @@ -109,6 +109,7 @@ int max, char *tooltip) { + GWDSettings *settings = gwd_theme_get_settings (gwd_theme); decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); guint state = d->button_states[button]; gboolean use_tooltips = FALSE; @@ -457,6 +458,7 @@ handle_mouse_wheel_title_event (WnckWindow *win, unsigned int button) { + GWDSettings *settings = gwd_theme_get_settings (gwd_theme); gint wheel_action = WHEEL_ACTION_NONE; g_object_get (settings, "mouse-wheel-action", &wheel_action, NULL); @@ -484,6 +486,7 @@ decor_event *gtkwd_event, decor_event_type gtkwd_type) { + GWDSettings *settings = gwd_theme_get_settings (gwd_theme); static Window last_button_xwindow = None; static Time last_button_time = 0; gint titlebar_action = 0; @@ -559,6 +562,7 @@ decor_event *gtkwd_event, decor_event_type gtkwd_type) { + GWDSettings *settings = gwd_theme_get_settings (gwd_theme); gint titlebar_action = 0; decor_t *d = g_object_get_data (G_OBJECT (win), "decor"); diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/frames.c compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/frames.c --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/frames.c 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/frames.c 2016-05-25 14:20:33.000000000 +0000 @@ -263,6 +263,7 @@ void decor_frame_refresh (decor_frame_t *frame) { + GWDSettings *settings = gwd_theme_get_settings (gwd_theme); decor_shadow_options_t active_o, inactive_o; decor_shadow_info_t *info; const gchar *titlebar_font = NULL; @@ -280,12 +281,11 @@ frame_update_titlebar_font (frame); - if (strcmp (frame->type, "switcher") != 0 && - strcmp (frame->type, "bare") != 0) - (*theme_update_border_extents) (frame); + if (strcmp (frame->type, "switcher") != 0 && strcmp (frame->type, "bare") != 0) + gwd_theme_update_border_extents (gwd_theme, frame); - (*theme_get_shadow) (frame, &active_o, TRUE); - (*theme_get_shadow) (frame, &inactive_o, FALSE); + gwd_theme_get_shadow (gwd_theme, frame, &active_o, TRUE); + gwd_theme_get_shadow (gwd_theme, frame, &inactive_o, FALSE); info = malloc (sizeof (decor_shadow_info_t)); @@ -542,3 +542,45 @@ frames_table = g_hash_table_new (g_str_hash, g_str_equal); } + +void +set_frame_scale (decor_frame_t *frame, + const gchar *font_str) +{ + gfloat scale = 1.0f; + + gwd_decor_frame_ref (frame); + + if (frame->titlebar_font) { + pango_font_description_free (frame->titlebar_font); + frame->titlebar_font = NULL; + } + + if (font_str) { + gint size; + + frame->titlebar_font = pango_font_description_from_string (font_str); + + scale = gwd_theme_get_title_scale (gwd_theme, frame); + size = MAX (pango_font_description_get_size (frame->titlebar_font) * scale, 1); + + pango_font_description_set_size (frame->titlebar_font, size); + } + + gwd_decor_frame_unref (frame); +} + +void +set_frames_scales (gpointer key, + gpointer value, + gpointer user_data) +{ + decor_frame_t *frame = (decor_frame_t *) value; + gchar *font_str = (gchar *) user_data; + + gwd_decor_frame_ref (frame); + + set_frame_scale (frame, font_str); + + gwd_decor_frame_unref (frame); +} diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gtk-window-decorator.c compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gtk-window-decorator.c --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gtk-window-decorator.c 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gtk-window-decorator.c 2016-05-25 14:20:33.000000000 +0000 @@ -24,27 +24,17 @@ */ #include "gtk-window-decorator.h" -#include "gwd-settings-writable-interface.h" +#include "gwd-metacity-window-decoration-util.h" #include "gwd-settings.h" -#include "gwd-settings-interface.h" -#include "gwd-settings-notified-interface.h" -#include "gwd-settings-notified.h" - -GWDSettingsNotified *notified; -GWDSettingsWritable *writable; -GWDSettings *settings; + +GWDTheme *gwd_theme; gdouble decoration_alpha = 0.5; -#ifdef USE_METACITY -gboolean meta_button_layout_set = FALSE; -#endif gboolean minimal = FALSE; const unsigned short ICON_SPACE = 20; -guint cmdline_options = 0; - Atom frame_input_window_atom; Atom frame_output_window_atom; Atom win_decor_atom; @@ -140,6 +130,50 @@ "normal", "modal_dialog", "dialog", "menu", "utility" }; +static void +update_decorations_cb (GWDSettings *settings, + gpointer user_data) +{ + decorations_changed (wnck_screen_get_default ()); +} + +static void +update_frames_cb (GWDSettings *settings, + gpointer user_data) +{ + const gchar *titlebar_font; + + titlebar_font = gwd_settings_get_titlebar_font (settings); + + gwd_frames_foreach (set_frames_scales, (gpointer) titlebar_font); +} + +static void +update_metacity_theme_cb (GWDSettings *settings, + gpointer user_data) +{ + GWDThemeType type; +#ifdef USE_METACITY + const gchar *metacity_theme; + + metacity_theme = gwd_settings_get_metacity_theme (settings); + + if (gwd_metacity_window_decoration_update_meta_theme (metacity_theme, + meta_theme_get_current, + meta_theme_set_current)) { + type = GWD_THEME_TYPE_METACITY; + } else { + g_log ("gtk-window-decorator", G_LOG_LEVEL_INFO, "using cairo decoration"); + + type = GWD_THEME_TYPE_CAIRO; + } +#else + type = GWD_THEME_TYPE_CAIRO; +#endif + + g_set_object (&gwd_theme, gwd_theme_new (type, settings)); +} + int main (int argc, char *argv[]) { @@ -147,6 +181,7 @@ Display *xdisplay; GdkScreen *gdkscreen; WnckScreen *screen; + GWDSettings *settings; gint i, j, status; gboolean replace = FALSE; unsigned int nchildren; @@ -156,7 +191,7 @@ decor_frame_t *bare_p, *switcher_p; const char *option_meta_theme = NULL; - gint option_blur_type = 0; + gint option_blur_type = BLUR_TYPE_UNSET; program_name = argv[0]; @@ -285,32 +320,21 @@ initialize_decorations (); - notified = gwd_settings_notified_impl_new (screen); + settings = gwd_settings_new (option_blur_type, option_meta_theme); - if (!notified) - return 1; + if (!settings) + return 1; - writable = GWD_SETTINGS_WRITABLE_INTERFACE (gwd_settings_impl_new (option_blur_type != BLUR_TYPE_NONE ? &option_blur_type : NULL, - option_meta_theme ? &option_meta_theme : NULL, - notified)); + g_signal_connect (settings, "update-decorations", + G_CALLBACK (update_decorations_cb), NULL); + g_signal_connect (settings, "update-frames", + G_CALLBACK (update_frames_cb), NULL); + g_signal_connect (settings, "update-metacity-theme", + G_CALLBACK (update_metacity_theme_cb), NULL); - if (!writable) - { - g_object_unref (notified); - return 1; - } - - settings = GWD_SETTINGS_INTERFACE (writable); - - gwd_settings_writable_freeze_updates (writable); + gwd_settings_freeze_updates (settings); - if (!init_settings (writable, - screen)) - { - g_object_unref (writable); - fprintf (stderr, "%s: Failed to get necessary gtk settings\n", argv[0]); - return 1; - } + init_settings (settings); for (i = 0; i < 3; ++i) { @@ -329,9 +353,8 @@ if (!create_tooltip_window ()) { - g_object_unref (writable); + g_object_unref (settings); - free (settings); fprintf (stderr, "%s, Couldn't create tooltip window\n", argv[0]); return 1; } @@ -379,7 +402,7 @@ WINDOW_DECORATION_TYPE_WINDOW); /* Update the decorations based on the settings */ - gwd_settings_writable_thaw_updates (writable); + gwd_settings_thaw_updates (settings); /* Keep the default, bare and switcher decorations around * since otherwise they will be spuriously recreated */ @@ -413,7 +436,9 @@ gwd_decor_frame_unref (bare_p); gwd_decor_frame_unref (switcher_p); + g_clear_object (&gwd_theme); fini_settings (); + g_clear_object (&settings); return 0; } diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gtk-window-decorator.h compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gtk-window-decorator.h --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gtk-window-decorator.h 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gtk-window-decorator.h 2016-05-25 14:20:33.000000000 +0000 @@ -72,12 +72,10 @@ #define _(x) gettext (x) #define N_(x) x -#ifdef USE_METACITY -#include -#endif - #include +#include "gwd-theme.h" + extern const unsigned short ICON_SPACE; #define META_MAXIMIZED (WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY | \ @@ -103,14 +101,9 @@ extern gboolean minimal; -extern GWDSettingsNotified *notified; -extern GWDSettings *settings; -extern GWDSettingsWritable *writable; +extern GWDTheme *gwd_theme; extern gdouble decoration_alpha; -#ifdef USE_METACITY -extern gboolean meta_button_layout_set; -#endif extern Atom frame_input_window_atom; extern Atom frame_output_window_atom; @@ -304,38 +297,6 @@ extern default_frame_references_t default_frames[WINDOW_TYPE_FRAMES_NUM * 2]; const gchar * window_type_frames[WINDOW_TYPE_FRAMES_NUM]; -void (*theme_get_shadow) (decor_frame_t *d, - decor_shadow_options_t *, - gboolean); - -void (*theme_draw_window_decoration) (decor_t *d); -gboolean (*theme_calc_decoration_size) (decor_t *d, - int client_width, - int client_height, - int text_width, - int *width, - int *height); -void (*theme_update_border_extents) (decor_frame_t *frame); -void (*theme_get_event_window_position) (decor_t *d, - - gint i, - gint j, - gint width, - gint height, - gint *x, - gint *y, - gint *w, - gint *h); -gboolean (*theme_get_button_position) (decor_t *d, - gint i, - gint width, - gint height, - gint *x, - gint *y, - gint *w, - gint *h); -gfloat (*theme_get_title_scale) (decor_frame_t *frame); - extern char *program_name; /* list of all decorations */ @@ -533,9 +494,6 @@ decor_context_t *c); void -draw_window_decoration (decor_t *d); - -void fill_rounded_rectangle (cairo_t *cr, double x, double y, @@ -558,44 +516,6 @@ double radius, int corner); -gboolean -calc_decoration_size (decor_t *d, - gint w, - gint h, - gint name_width, - gint *width, - gint *height); - -void -update_border_extents (); - -gboolean -get_button_position (decor_t *d, - gint i, - gint width, - gint height, - gint *x, - gint *y, - gint *w, - gint *h); - -void -get_event_window_position (decor_t *d, - gint i, - gint j, - gint width, - gint height, - gint *x, - gint *y, - gint *w, - gint *h); - -gfloat -get_title_scale (decor_frame_t *frame); - -void -cairo_get_shadow (decor_frame_t *, decor_shadow_options_t *opts, gboolean active); - /* gdk.c */ GdkWindow * @@ -617,59 +537,6 @@ cairo_surface_t * surface_new_from_pixbuf (GdkPixbuf *pixbuf, GtkWidget *parent); -/* metacity.c */ - -#ifdef USE_METACITY - -MetaFrameType -meta_get_frame_type_for_decor_type (const gchar *frame_type); - -void -meta_draw_window_decoration (decor_t *d); - -gboolean -meta_calc_decoration_size (decor_t *d, - gint w, - gint h, - gint name_width, - gint *width, - gint *height); - -gboolean -meta_get_button_position (decor_t *d, - gint i, - gint width, - gint height, - gint *x, - gint *y, - gint *w, - gint *h); - -void -meta_get_event_window_position (decor_t *d, - gint i, - gint j, - gint width, - gint height, - gint *x, - gint *y, - gint *w, - gint *h); - -gfloat -meta_get_title_scale (decor_frame_t *); - -void -meta_update_border_extents (); - -void -meta_update_button_layout (const char *value); - -void -meta_get_shadow (decor_frame_t *, decor_shadow_options_t *opts, gboolean active); - -#endif - /* switcher.c */ #define SWITCHER_ALPHA 0xa0a0 @@ -871,8 +738,8 @@ gpointer value, gpointer user_data); -gboolean -init_settings (GWDSettingsWritable *writable, WnckScreen *screen); +void +init_settings (GWDSettings *settings); void fini_settings (); diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-fwd.h compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-fwd.h --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-fwd.h 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-fwd.h 2016-05-25 14:20:26.000000000 +0000 @@ -25,8 +25,6 @@ G_BEGIN_DECLS typedef struct _GWDSettings GWDSettings; -typedef struct _GWDSettingsWritable GWDSettingsWritable; -typedef struct _GWDSettingsNotified GWDSettingsNotified; typedef struct _GWDSettingsStorage GWDSettingsStorage; typedef struct _GWDSettingsXPropertyStorage GWDSettingsXPropertyStorage; diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings.c compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings.c --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings.c 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings.c 2016-05-25 14:20:26.000000000 +0000 @@ -1,3 +1,5 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */ + /* * Copyright © 2012 Canonical Ltd * @@ -17,862 +19,844 @@ * * Authored By: Sam Spilsbury */ + #include #include #include #include "gwd-settings.h" -#include "gwd-settings-interface.h" -#include "gwd-settings-writable-interface.h" -#include "gwd-settings-notified-interface.h" #include "decoration.h" -#define GWD_SETTINGS_IMPL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GWD_TYPE_SETTINGS_IMPL, GWDSettingsImpl)) -#define GWD_SETTINGS_IMPL_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), GWD_TYPE_SETTINGS_IMPL, GWDSettingsImplClass)) -#define GWD_IS_SETTINGS_IMPL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GWD_TYPE_SETTINGS_IMPL)) -#define GWD_IS_SETTINGS_IMPL_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), GWD_TYPE_SETTINGS_IMPL)) -#define GWD_SETTINGS_IMPL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GWD_TYPE_SETTINGS_IMPL, GWDSettingsImplClass)) +const gboolean USE_TOOLTIPS_DEFAULT = FALSE; + +const gdouble ACTIVE_SHADOW_RADIUS_DEFAULT = 8.0; +const gdouble ACTIVE_SHADOW_OPACITY_DEFAULT = 0.5; +const gint ACTIVE_SHADOW_OFFSET_X_DEFAULT = 1; +const gint ACTIVE_SHADOW_OFFSET_Y_DEFAULT = 1; +const gchar *ACTIVE_SHADOW_COLOR_DEFAULT = "#00000000"; + +const gdouble INACTIVE_SHADOW_RADIUS_DEFAULT = 8.0; +const gdouble INACTIVE_SHADOW_OPACITY_DEFAULT = 0.5; +const gint INACTIVE_SHADOW_OFFSET_X_DEFAULT = 1; +const gint INACTIVE_SHADOW_OFFSET_Y_DEFAULT = 1; +const gchar *INACTIVE_SHADOW_COLOR_DEFAULT = "#00000000"; + +const gint BLUR_TYPE_DEFAULT = BLUR_TYPE_NONE; + +const gchar *METACITY_THEME_DEFAULT = "Adwaita"; +const gdouble METACITY_ACTIVE_OPACITY_DEFAULT = 1.0; +const gdouble METACITY_INACTIVE_OPACITY_DEFAULT = 0.75; +const gboolean METACITY_ACTIVE_SHADE_OPACITY_DEFAULT = TRUE; +const gboolean METACITY_INACTIVE_SHADE_OPACITY_DEFAULT = TRUE; + +const gchar *METACITY_BUTTON_LAYOUT_DEFAULT = ":minimize,maximize,close"; + +const guint DOUBLE_CLICK_ACTION_DEFAULT = CLICK_ACTION_MAXIMIZE; +const guint MIDDLE_CLICK_ACTION_DEFAULT = CLICK_ACTION_LOWER; +const guint RIGHT_CLICK_ACTION_DEFAULT = CLICK_ACTION_MENU; +const guint WHEEL_ACTION_DEFAULT = WHEEL_ACTION_SHADE; + +const gchar *TITLEBAR_FONT_DEFAULT = "Sans 12"; -typedef struct _GWDSettingsImpl +enum { - GObject parent; -} GWDSettingsImpl; + CMDLINE_BLUR = (1 << 0), + CMDLINE_THEME = (1 << 1) +}; -typedef struct _GWDSettingsImplClass +typedef void (*NotifyFunc) (GWDSettings *settings); + +struct _GWDSettings { - GObjectClass parent_class; -} GWDSettingsImplClass; + GObject parent; -static void gwd_settings_interface_init (GWDSettingsInterface *interface); -static void gwd_settings_writable_interface_init (GWDSettingsWritableInterface *interface); + decor_shadow_options_t active_shadow; + decor_shadow_options_t inactive_shadow; + gboolean use_tooltips; + gint blur_type; + gchar *metacity_theme; + gdouble metacity_active_opacity; + gdouble metacity_inactive_opacity; + gboolean metacity_active_shade_opacity; + gboolean metacity_inactive_shade_opacity; + gchar *metacity_button_layout; + gint titlebar_double_click_action; + gint titlebar_middle_click_action; + gint titlebar_right_click_action; + gint mouse_wheel_action; + gchar *titlebar_font; -G_DEFINE_TYPE_WITH_CODE (GWDSettingsImpl, gwd_settings_impl, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (GWD_TYPE_SETTINGS_INTERFACE, - gwd_settings_interface_init) - G_IMPLEMENT_INTERFACE (GWD_TYPE_WRITABLE_SETTINGS_INTERFACE, - gwd_settings_writable_interface_init)) + guint cmdline_opts; -#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GWD_TYPE_SETTINGS_IMPL, GWDSettingsImplPrivate)) + guint freeze_count; + GList *notify_funcs; +}; enum { - GWD_SETTINGS_IMPL_PROPERTY_ACTIVE_SHADOW = 1, - GWD_SETTINGS_IMPL_PROPERTY_INACTIVE_SHADOW = 2, - GWD_SETTINGS_IMPL_PROPERTY_USE_TOOLTIPS = 3, - GWD_SETTINGS_IMPL_PROPERTY_BLUR_CHANGED = 4, - GWD_SETTINGS_IMPL_PROPERTY_METACITY_THEME = 5, - GWD_SETTINGS_IMPL_PROPERTY_ACTIVE_OPACITY = 6, - GWD_SETTINGS_IMPL_PROPERTY_INACTIVE_OPACITY = 7, - GWD_SETTINGS_IMPL_PROPERTY_ACTIVE_SHADE_OPACITY = 8, - GWD_SETTINGS_IMPL_PROPERTY_INACTIVE_SHADE_OPACITY = 9, - GWD_SETTINGS_IMPL_PROPERTY_BUTTON_LAYOUT = 10, - GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_ACTION_DOUBLE_CLICK = 11, - GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_ACTION_MIDDLE_CLICK = 12, - GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_ACTION_RIGHT_CLICK = 13, - GWD_SETTINGS_IMPL_PROPERTY_MOUSE_WHEEL_ACTION = 14, - GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_FONT = 15, - GWD_SETTINGS_IMPL_PROPERTY_CMDLINE_OPTIONS = 16, - GWD_SETTINGS_IMPL_PROPERTY_SETTINGS_NOTIFIED = 17 + PROP_0, + + PROP_ACTIVE_SHADOW, + PROP_INACTIVE_SHADOW, + PROP_USE_TOOLTIPS, + PROP_BLUR, + PROP_METACITY_THEME, + PROP_ACTIVE_OPACITY, + PROP_INACTIVE_OPACITY, + PROP_ACTIVE_SHADE_OPACITY, + PROP_INACTIVE_SHADE_OPACITY, + PROP_BUTTON_LAYOUT, + PROP_TITLEBAR_ACTION_DOUBLE_CLICK, + PROP_TITLEBAR_ACTION_MIDDLE_CLICK, + PROP_TITLEBAR_ACTION_RIGHT_CLICK, + PROP_MOUSE_WHEEL_ACTION, + PROP_TITLEBAR_FONT, + PROP_CMDLINE_OPTIONS, + + LAST_PROP }; +static GParamSpec *settings_properties[LAST_PROP] = { NULL }; + enum { - CMDLINE_BLUR = (1 << 0), - CMDLINE_THEME = (1 << 1) + UPDATE_DECORATIONS, + UPDATE_FRAMES, + UPDATE_METACITY_THEME, + UPDATE_METACITY_BUTTON_LAYOUT, + + LAST_SIGNAL }; -typedef gboolean (*NotifyFunc) (GWDSettingsNotified *); +static guint settings_signals[LAST_SIGNAL] = { 0 }; -typedef struct _GWDSettingsImplPrivate -{ - decor_shadow_options_t active_shadow; - decor_shadow_options_t inactive_shadow; - gboolean use_tooltips; - gint blur_type; - gchar *metacity_theme; - gdouble metacity_active_opacity; - gdouble metacity_inactive_opacity; - gboolean metacity_active_shade_opacity; - gboolean metacity_inactive_shade_opacity; - gchar *metacity_button_layout; - gint titlebar_double_click_action; - gint titlebar_middle_click_action; - gint titlebar_right_click_action; - gint mouse_wheel_action; - gchar *titlebar_font; - guint cmdline_opts; - GWDSettingsNotified *notified; - guint freeze_count; - GList *notify_funcs; -} GWDSettingsImplPrivate; +G_DEFINE_TYPE (GWDSettings, gwd_settings, G_TYPE_OBJECT) static void -append_to_notify_funcs (GWDSettingsImpl *settings, - NotifyFunc func) +update_decorations (GWDSettings *settings) { - GWDSettingsImplPrivate *priv = GET_PRIVATE (settings); - - /* Remove if found, the new one will replace the old one */ - GList *link = g_list_find (priv->notify_funcs, func); - - if (link) - priv->notify_funcs = g_list_remove_link (priv->notify_funcs, link); - - priv->notify_funcs = g_list_append (priv->notify_funcs, (gpointer) func); + g_signal_emit (settings, settings_signals[UPDATE_DECORATIONS], 0); } static void -invoke_notify_func (gpointer data, - gpointer user_data) +update_frames (GWDSettings *settings) { - GWDSettingsNotified *notified = (GWDSettingsNotified *) user_data; - NotifyFunc func = (NotifyFunc) data; - - (*func) (notified); + g_signal_emit (settings, settings_signals[UPDATE_FRAMES], 0); } static void -release_notify_funcs (GWDSettingsImpl *settings) +update_metacity_theme (GWDSettings *settings) { - GWDSettingsImplPrivate *priv = GET_PRIVATE (settings); - - if (priv->freeze_count) - return; - - g_list_foreach (priv->notify_funcs, invoke_notify_func, priv->notified); - g_list_free (priv->notify_funcs); - priv->notify_funcs = NULL; + g_signal_emit (settings, settings_signals[UPDATE_METACITY_THEME], 0); } -gboolean -gwd_settings_shadow_property_changed (GWDSettingsWritable *settings, - gdouble active_shadow_radius, - gdouble active_shadow_opacity, - gdouble active_shadow_offset_x, - gdouble active_shadow_offset_y, - const gchar *active_shadow_color, - gdouble inactive_shadow_radius, - gdouble inactive_shadow_opacity, - gdouble inactive_shadow_offset_x, - gdouble inactive_shadow_offset_y, - const gchar *inactive_shadow_color) +static void +update_metacity_button_layout (GWDSettings *settings) { - GWDSettingsImpl *settings_impl = GWD_SETTINGS_IMPL (settings); - GWDSettingsImplPrivate *priv = GET_PRIVATE (settings_impl); - - decor_shadow_options_t active_shadow, inactive_shadow; - unsigned int c[4]; - gboolean changed = FALSE; - - active_shadow.shadow_radius = active_shadow_radius; - active_shadow.shadow_opacity = active_shadow_opacity; - active_shadow.shadow_offset_x = active_shadow_offset_x; - active_shadow.shadow_offset_y = active_shadow_offset_y; - - if (sscanf (active_shadow_color, - "#%2x%2x%2x%2x", - &c[0], &c[1], &c[2], &c[3]) == 4) - { - active_shadow.shadow_color[0] = c[0] << 8 | c[0]; - active_shadow.shadow_color[1] = c[1] << 8 | c[1]; - active_shadow.shadow_color[2] = c[2] << 8 | c[2]; - } - else - return FALSE; - - if (sscanf (inactive_shadow_color, - "#%2x%2x%2x%2x", - &c[0], &c[1], &c[2], &c[3]) == 4) - { - inactive_shadow.shadow_color[0] = c[0] << 8 | c[0]; - inactive_shadow.shadow_color[1] = c[1] << 8 | c[1]; - inactive_shadow.shadow_color[2] = c[2] << 8 | c[2]; - } - else - return FALSE; - - inactive_shadow.shadow_radius = inactive_shadow_radius; - inactive_shadow.shadow_opacity = inactive_shadow_opacity; - inactive_shadow.shadow_offset_x = inactive_shadow_offset_x; - inactive_shadow.shadow_offset_y = inactive_shadow_offset_y; - - if (decor_shadow_options_cmp (&priv->inactive_shadow, - &inactive_shadow)) - { - changed |= TRUE; - priv->inactive_shadow = inactive_shadow; - } - - if (decor_shadow_options_cmp (&priv->active_shadow, - &active_shadow)) - { - changed |= TRUE; - priv->active_shadow = active_shadow; - } - - if (changed) - { - append_to_notify_funcs (settings_impl, gwd_settings_notified_update_decorations); - release_notify_funcs (settings_impl); - } - - return changed; + g_signal_emit (settings, settings_signals[UPDATE_METACITY_BUTTON_LAYOUT], + 0, settings->metacity_button_layout); } -static gboolean -gwd_settings_use_tooltips_changed (GWDSettingsWritable *settings, - gboolean use_tooltips) +static void +append_to_notify_funcs (GWDSettings *settings, + NotifyFunc func) { - GWDSettingsImpl *settings_impl = GWD_SETTINGS_IMPL (settings); - GWDSettingsImplPrivate *priv = GET_PRIVATE (settings_impl); + /* Remove if found, the new one will replace the old one */ + GList *link = g_list_find (settings->notify_funcs, func); - if (priv->use_tooltips != use_tooltips) - { - priv->use_tooltips = use_tooltips; - append_to_notify_funcs (settings_impl, gwd_settings_notified_update_decorations); - release_notify_funcs (settings_impl); - return TRUE; - } + if (link) + settings->notify_funcs = g_list_remove_link (settings->notify_funcs, link); - return FALSE; + settings->notify_funcs = g_list_append (settings->notify_funcs, (gpointer) func); } -static gboolean -gwd_settings_blur_changed (GWDSettingsWritable *settings, - const gchar *type) - +static void +invoke_notify_func (gpointer data, + gpointer user_data) { - GWDSettingsImpl *settings_impl = GWD_SETTINGS_IMPL (settings); - GWDSettingsImplPrivate *priv = GET_PRIVATE (settings_impl); - gint new_type = -1; - - if (priv->cmdline_opts & CMDLINE_BLUR) - return FALSE; - - if (strcmp (type, "titlebar") == 0) - new_type = BLUR_TYPE_TITLEBAR; - else if (strcmp (type, "all") == 0) - new_type = BLUR_TYPE_ALL; - else if (strcmp (type, "none") == 0) - new_type = BLUR_TYPE_NONE; + NotifyFunc func; + GWDSettings *settings; - if (new_type == -1) - return FALSE; + func = (NotifyFunc) data; + settings = GWD_SETTINGS (user_data); - if (priv->blur_type != new_type) - { - priv->blur_type = new_type; - append_to_notify_funcs (settings_impl, gwd_settings_notified_update_decorations); - release_notify_funcs (settings_impl); - return TRUE; - } - else - return FALSE; + (*func) (settings); } static void -free_and_set_metacity_theme (GWDSettingsWritable *settings, - const gchar *metacity_theme) +release_notify_funcs (GWDSettings *settings) { - GWDSettingsImpl *settings_impl = GWD_SETTINGS_IMPL (settings); - GWDSettingsImplPrivate *priv = GET_PRIVATE (settings_impl); + if (settings->freeze_count) + return; - if (priv->metacity_theme) - g_free (priv->metacity_theme); - - priv->metacity_theme = g_strdup (metacity_theme); + g_list_foreach (settings->notify_funcs, invoke_notify_func, settings); + g_list_free (settings->notify_funcs); + settings->notify_funcs = NULL; } static gboolean -gwd_settings_metacity_theme_changed (GWDSettingsWritable *settings, - gboolean use_metacity_theme, - const gchar *metacity_theme) +get_click_action_value (const gchar *action, + gint *action_value, + gint default_value) { - GWDSettingsImpl *settings_impl = GWD_SETTINGS_IMPL (settings); - GWDSettingsImplPrivate *priv = GET_PRIVATE (settings_impl); - - if (priv->cmdline_opts & CMDLINE_THEME) - return FALSE; + if (!action_value) + return FALSE; - if (!metacity_theme) - return FALSE; + *action_value = -1; - if (use_metacity_theme) - { - if (g_strcmp0 (metacity_theme, priv->metacity_theme) == 0) - return FALSE; + if (strcmp (action, "toggle_shade") == 0) + *action_value = CLICK_ACTION_SHADE; + else if (strcmp (action, "toggle_maximize") == 0) + *action_value = CLICK_ACTION_MAXIMIZE; + else if (strcmp (action, "minimize") == 0) + *action_value = CLICK_ACTION_MINIMIZE; + else if (strcmp (action, "raise") == 0) + *action_value = CLICK_ACTION_RAISE; + else if (strcmp (action, "lower") == 0) + *action_value = CLICK_ACTION_LOWER; + else if (strcmp (action, "menu") == 0) + *action_value = CLICK_ACTION_MENU; + else if (strcmp (action, "none") == 0) + *action_value = CLICK_ACTION_NONE; - free_and_set_metacity_theme (settings, metacity_theme); + if (*action_value == -1) { + *action_value = default_value; + return FALSE; } - else - free_and_set_metacity_theme (settings, ""); - - append_to_notify_funcs (settings_impl, gwd_settings_notified_update_metacity_theme); - append_to_notify_funcs (settings_impl, gwd_settings_notified_update_decorations); - release_notify_funcs (settings_impl); return TRUE; } static gboolean -gwd_settings_opacity_changed (GWDSettingsWritable *settings, - gdouble active_opacity, - gdouble inactive_opacity, - gboolean active_shade_opacity, - gboolean inactive_shade_opacity) -{ - GWDSettingsImpl *settings_impl = GWD_SETTINGS_IMPL (settings); - GWDSettingsImplPrivate *priv = GET_PRIVATE (settings_impl); - - if (priv->metacity_active_opacity == active_opacity && - priv->metacity_inactive_opacity == inactive_opacity && - priv->metacity_active_shade_opacity == active_shade_opacity && - priv->metacity_inactive_shade_opacity == inactive_shade_opacity) - return FALSE; - - priv->metacity_active_opacity = active_opacity; - priv->metacity_inactive_opacity = inactive_opacity; - priv->metacity_active_shade_opacity = active_shade_opacity; - priv->metacity_inactive_shade_opacity = inactive_shade_opacity; +get_wheel_action_value (const gchar *action, + gint *action_value, + gint default_value) +{ + if (!action_value) + return FALSE; - append_to_notify_funcs (settings_impl, gwd_settings_notified_update_decorations); - release_notify_funcs (settings_impl); + *action_value = -1; + + if (strcmp (action, "shade") == 0) + *action_value = WHEEL_ACTION_SHADE; + else if (strcmp (action, "none") == 0) + *action_value = WHEEL_ACTION_NONE; + + if (*action_value == -1) { + *action_value = default_value; + return FALSE; + } return TRUE; } -static gboolean -gwd_settings_button_layout_changed (GWDSettingsWritable *settings, - const gchar *button_layout) +static void +gwd_settings_finalize (GObject *object) { - GWDSettingsImpl *settings_impl = GWD_SETTINGS_IMPL (settings); - GWDSettingsImplPrivate *priv = GET_PRIVATE (settings_impl); - - if (!button_layout) - return FALSE; + GWDSettings *settings; - if (g_strcmp0 (priv->metacity_button_layout, button_layout) == 0) - return FALSE; + settings = GWD_SETTINGS (object); - if (priv->metacity_button_layout) - g_free (priv->metacity_button_layout); + g_clear_pointer (&settings->metacity_theme, g_free); + g_clear_pointer (&settings->metacity_button_layout, g_free); + g_clear_pointer (&settings->titlebar_font, g_free); - priv->metacity_button_layout = g_strdup (button_layout); - - append_to_notify_funcs (settings_impl, gwd_settings_notified_metacity_button_layout); - append_to_notify_funcs (settings_impl, gwd_settings_notified_update_decorations); - release_notify_funcs (settings_impl); + G_OBJECT_CLASS (gwd_settings_parent_class)->finalize (object); +} - return TRUE; +static void +gwd_settings_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GWDSettings *settings; + + settings = GWD_SETTINGS (object); + + switch (property_id) { + case PROP_CMDLINE_OPTIONS: + settings->cmdline_opts = g_value_get_int (value); + break; + + case PROP_BLUR: + settings->blur_type = g_value_get_int (value); + break; + + case PROP_METACITY_THEME: + g_free (settings->metacity_theme); + settings->metacity_theme = g_value_dup_string (value); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } } -static gboolean -gwd_settings_font_changed (GWDSettingsWritable *settings, - gboolean titlebar_uses_system_font, - const gchar *titlebar_font) +static void +gwd_settings_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) { - GWDSettingsImpl *settings_impl = GWD_SETTINGS_IMPL (settings); - GWDSettingsImplPrivate *priv = GET_PRIVATE (settings_impl); + GWDSettings *settings; - const gchar *no_font = NULL; - const gchar *use_font = NULL; + settings = GWD_SETTINGS (object); - if (!titlebar_font) - return FALSE; + switch (property_id) { + case PROP_ACTIVE_SHADOW: + g_value_set_pointer (value, &settings->active_shadow); + break; - if (titlebar_uses_system_font) - use_font = no_font; - else - use_font = titlebar_font; + case PROP_INACTIVE_SHADOW: + g_value_set_pointer (value, &settings->inactive_shadow); + break; - if (g_strcmp0 (priv->titlebar_font, use_font) == 0) - return FALSE; + case PROP_USE_TOOLTIPS: + g_value_set_boolean (value, settings->use_tooltips); + break; - if (priv->titlebar_font) - { - g_free (priv->titlebar_font); - priv->titlebar_font = NULL; - } + case PROP_BLUR: + g_value_set_int (value, settings->blur_type); + break; - priv->titlebar_font = use_font ? g_strdup (use_font) : NULL; + case PROP_METACITY_THEME: + g_value_set_string (value, settings->metacity_theme); + break; - append_to_notify_funcs (settings_impl, gwd_settings_notified_update_decorations); - append_to_notify_funcs (settings_impl, gwd_settings_notified_update_frames); - release_notify_funcs (settings_impl); + case PROP_ACTIVE_OPACITY: + g_value_set_double (value, settings->metacity_active_opacity); + break; - return TRUE; -} + case PROP_INACTIVE_OPACITY: + g_value_set_double (value, settings->metacity_inactive_opacity); + break; -static gboolean -get_click_action_value (const gchar *action, - gint *action_value, - gint default_value) -{ - if (!action_value) - return FALSE; + case PROP_ACTIVE_SHADE_OPACITY: + g_value_set_boolean (value, settings->metacity_active_shade_opacity); + break; - *action_value = -1; + case PROP_INACTIVE_SHADE_OPACITY: + g_value_set_boolean (value, settings->metacity_inactive_shade_opacity); + break; - if (strcmp (action, "toggle_shade") == 0) - *action_value = CLICK_ACTION_SHADE; - else if (strcmp (action, "toggle_maximize") == 0) - *action_value = CLICK_ACTION_MAXIMIZE; - else if (strcmp (action, "minimize") == 0) - *action_value = CLICK_ACTION_MINIMIZE; - else if (strcmp (action, "raise") == 0) - *action_value = CLICK_ACTION_RAISE; - else if (strcmp (action, "lower") == 0) - *action_value = CLICK_ACTION_LOWER; - else if (strcmp (action, "menu") == 0) - *action_value = CLICK_ACTION_MENU; - else if (strcmp (action, "none") == 0) - *action_value = CLICK_ACTION_NONE; + case PROP_BUTTON_LAYOUT: + g_value_set_string (value, settings->metacity_button_layout); + break; - if (*action_value == -1) - { - *action_value = default_value; - return FALSE; - } + case PROP_TITLEBAR_ACTION_DOUBLE_CLICK: + g_value_set_int (value, settings->titlebar_double_click_action); + break; - return TRUE; + case PROP_TITLEBAR_ACTION_MIDDLE_CLICK: + g_value_set_int (value, settings->titlebar_middle_click_action); + break; + + case PROP_TITLEBAR_ACTION_RIGHT_CLICK: + g_value_set_int (value, settings->titlebar_right_click_action); + break; + + case PROP_MOUSE_WHEEL_ACTION: + g_value_set_int (value, settings->mouse_wheel_action); + break; + + case PROP_TITLEBAR_FONT: + g_value_set_string (value, settings->titlebar_font); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } } -static gboolean -get_wheel_action_value (const gchar *action, - gint *action_value, - gint default_value) +static void +gwd_settings_class_init (GWDSettingsClass *settings_class) { - if (!action_value) - return FALSE; + GObjectClass *object_class; - *action_value = -1; + object_class = G_OBJECT_CLASS (settings_class); - if (strcmp (action, "shade") == 0) - *action_value = WHEEL_ACTION_SHADE; - else if (strcmp (action, "none") == 0) - *action_value = WHEEL_ACTION_NONE; + object_class->finalize = gwd_settings_finalize; + object_class->get_property = gwd_settings_get_property; + object_class->set_property = gwd_settings_set_property; - if (*action_value == -1) - { - *action_value = default_value; - return FALSE; - } + settings_properties[PROP_ACTIVE_SHADOW] = + g_param_spec_pointer ("active-shadow", + "Active Shadow", + "Active Shadow Settings", + G_PARAM_READABLE); + + settings_properties[PROP_INACTIVE_SHADOW] = + g_param_spec_pointer ("inactive-shadow", + "Inactive Shadow", + "Inactive Shadow", + G_PARAM_READABLE); + + settings_properties[PROP_USE_TOOLTIPS] = + g_param_spec_boolean ("use-tooltips", + "Use Tooltips", + "Use Tooltips Setting", + USE_TOOLTIPS_DEFAULT, + G_PARAM_READABLE); + + settings_properties[PROP_BLUR] = + g_param_spec_int ("blur", + "Blur Type", + "Blur type property", + BLUR_TYPE_NONE, + BLUR_TYPE_ALL, + BLUR_TYPE_NONE, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); + + settings_properties[PROP_METACITY_THEME] = + g_param_spec_string ("metacity-theme", + "Metacity Theme", + "Metacity Theme Setting", + METACITY_THEME_DEFAULT, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); + + settings_properties[PROP_ACTIVE_OPACITY] = + g_param_spec_double ("metacity-active-opacity", + "Metacity Active Opacity", + "Metacity Active Opacity", + 0.0, + 1.0, + METACITY_ACTIVE_OPACITY_DEFAULT, + G_PARAM_READABLE); + + settings_properties[PROP_INACTIVE_OPACITY] = + g_param_spec_double ("metacity-inactive-opacity", + "Metacity Inactive Opacity", + "Metacity Inactive Opacity", + 0.0, + 1.0, + METACITY_INACTIVE_OPACITY_DEFAULT, + G_PARAM_READABLE); + + settings_properties[PROP_ACTIVE_SHADE_OPACITY] = + g_param_spec_boolean ("metacity-active-shade-opacity", + "Metacity Active Shade Opacity", + "Metacity Active Shade Opacity", + METACITY_ACTIVE_SHADE_OPACITY_DEFAULT, + G_PARAM_READABLE); + + settings_properties[PROP_INACTIVE_SHADE_OPACITY] = + g_param_spec_boolean ("metacity-inactive-shade-opacity", + "Metacity Inactive Shade Opacity", + "Metacity Inactive Shade Opacity", + METACITY_INACTIVE_SHADE_OPACITY_DEFAULT, + G_PARAM_READABLE); + + settings_properties[PROP_BUTTON_LAYOUT] = + g_param_spec_string ("metacity-button-layout", + "Metacity Button Layout", + "Metacity Button Layout", + METACITY_BUTTON_LAYOUT_DEFAULT, + G_PARAM_READABLE); + + settings_properties[PROP_TITLEBAR_ACTION_DOUBLE_CLICK] = + g_param_spec_int ("titlebar-double-click-action", + "Titlebar Action Double Click", + "Titlebar Action Double Click", + CLICK_ACTION_NONE, + CLICK_ACTION_MENU, + DOUBLE_CLICK_ACTION_DEFAULT, + G_PARAM_READABLE); + + settings_properties[PROP_TITLEBAR_ACTION_MIDDLE_CLICK] = + g_param_spec_int ("titlebar-middle-click-action", + "Titlebar Action Middle Click", + "Titlebar Action Middle Click", + CLICK_ACTION_NONE, + CLICK_ACTION_MENU, + MIDDLE_CLICK_ACTION_DEFAULT, + G_PARAM_READABLE); + + settings_properties[PROP_TITLEBAR_ACTION_RIGHT_CLICK] = + g_param_spec_int ("titlebar-right-click-action", + "Titlebar Action Right Click", + "Titlebar Action Right Click", + CLICK_ACTION_NONE, + CLICK_ACTION_MENU, + RIGHT_CLICK_ACTION_DEFAULT, + G_PARAM_READABLE); + + settings_properties[PROP_MOUSE_WHEEL_ACTION] = + g_param_spec_int ("mouse-wheel-action", + "Mouse Wheel Action", + "Mouse Wheel Action", + WHEEL_ACTION_NONE, + WHEEL_ACTION_SHADE, + WHEEL_ACTION_DEFAULT, + G_PARAM_READABLE); + + settings_properties[PROP_TITLEBAR_FONT] = + g_param_spec_string ("titlebar-font", + "Titlebar Font", + "Titlebar Font", + TITLEBAR_FONT_DEFAULT, + G_PARAM_READABLE); + + settings_properties[PROP_CMDLINE_OPTIONS] = + g_param_spec_int ("cmdline-options", + "Command line options", + "Which options were specified on the command line", + 0, G_MAXINT32, 0, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); + + g_object_class_install_properties (object_class, LAST_PROP, + settings_properties); + + settings_signals[UPDATE_DECORATIONS] = + g_signal_new ("update-decorations", + GWD_TYPE_SETTINGS, G_SIGNAL_RUN_LAST, + 0, NULL, NULL, NULL, G_TYPE_NONE, 0); + + settings_signals[UPDATE_FRAMES] = + g_signal_new ("update-frames", + GWD_TYPE_SETTINGS, G_SIGNAL_RUN_LAST, + 0, NULL, NULL, NULL, G_TYPE_NONE, 0); + + settings_signals[UPDATE_METACITY_THEME] = + g_signal_new ("update-metacity-theme", + GWD_TYPE_SETTINGS, G_SIGNAL_RUN_LAST, + 0, NULL, NULL, NULL, G_TYPE_NONE, 0); + + settings_signals[UPDATE_METACITY_BUTTON_LAYOUT] = + g_signal_new ("update-metacity-button-layout", + GWD_TYPE_SETTINGS, G_SIGNAL_RUN_LAST, + 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_TYPE_STRING); +} + +static void +gwd_settings_init (GWDSettings *settings) +{ + settings->use_tooltips = USE_TOOLTIPS_DEFAULT; + settings->active_shadow.shadow_radius = ACTIVE_SHADOW_RADIUS_DEFAULT; + settings->active_shadow.shadow_opacity = ACTIVE_SHADOW_OPACITY_DEFAULT; + settings->active_shadow.shadow_offset_x = ACTIVE_SHADOW_OFFSET_X_DEFAULT; + settings->active_shadow.shadow_offset_y = ACTIVE_SHADOW_OFFSET_Y_DEFAULT; + settings->active_shadow.shadow_color[0] = 0; + settings->active_shadow.shadow_color[1] = 0; + settings->active_shadow.shadow_color[2] = 0; + settings->inactive_shadow.shadow_radius = INACTIVE_SHADOW_RADIUS_DEFAULT; + settings->inactive_shadow.shadow_opacity = INACTIVE_SHADOW_OPACITY_DEFAULT; + settings->inactive_shadow.shadow_offset_x = INACTIVE_SHADOW_OFFSET_X_DEFAULT; + settings->inactive_shadow.shadow_offset_y = INACTIVE_SHADOW_OFFSET_Y_DEFAULT; + settings->inactive_shadow.shadow_color[0] = 0; + settings->inactive_shadow.shadow_color[1] = 0; + settings->inactive_shadow.shadow_color[2] = 0; + settings->blur_type = BLUR_TYPE_DEFAULT; + settings->metacity_theme = g_strdup (METACITY_THEME_DEFAULT); + settings->metacity_active_opacity = METACITY_ACTIVE_OPACITY_DEFAULT; + settings->metacity_inactive_opacity = METACITY_INACTIVE_OPACITY_DEFAULT; + settings->metacity_active_shade_opacity = METACITY_ACTIVE_SHADE_OPACITY_DEFAULT; + settings->metacity_inactive_shade_opacity = METACITY_INACTIVE_SHADE_OPACITY_DEFAULT; + settings->metacity_button_layout = g_strdup (METACITY_BUTTON_LAYOUT_DEFAULT); + settings->titlebar_double_click_action = DOUBLE_CLICK_ACTION_DEFAULT; + settings->titlebar_middle_click_action = MIDDLE_CLICK_ACTION_DEFAULT; + settings->titlebar_right_click_action = RIGHT_CLICK_ACTION_DEFAULT; + settings->mouse_wheel_action = WHEEL_ACTION_DEFAULT; + settings->titlebar_font = g_strdup (TITLEBAR_FONT_DEFAULT); + settings->cmdline_opts = 0; + settings->freeze_count = 0; - return TRUE; + /* Append all notify funcs so that external state can be updated in case + * the settings backend can't do it itself */ + append_to_notify_funcs (settings, update_metacity_theme); + append_to_notify_funcs (settings, update_metacity_button_layout); + append_to_notify_funcs (settings, update_frames); + append_to_notify_funcs (settings, update_decorations); } -static gboolean -gwd_settings_actions_changed (GWDSettingsWritable *settings, - const gchar *action_double_click_titlebar, - const gchar *action_middle_click_titlebar, - const gchar *action_right_click_titlebar, - const gchar *mouse_wheel_action) +GWDSettings * +gwd_settings_new (gint blur, + const gchar *metacity_theme) { - GWDSettingsImpl *settings_impl = GWD_SETTINGS_IMPL (settings); - GWDSettingsImplPrivate *priv = GET_PRIVATE (settings_impl); + guint cmdline_opts; - gboolean ret = FALSE; + cmdline_opts = 0; - ret |= get_click_action_value (action_double_click_titlebar, - &priv->titlebar_double_click_action, - DOUBLE_CLICK_ACTION_DEFAULT); - ret |= get_click_action_value (action_middle_click_titlebar, - &priv->titlebar_middle_click_action, - MIDDLE_CLICK_ACTION_DEFAULT); - ret |= get_click_action_value (action_right_click_titlebar, - &priv->titlebar_right_click_action, - RIGHT_CLICK_ACTION_DEFAULT); - ret |= get_wheel_action_value (mouse_wheel_action, - &priv->mouse_wheel_action, - WHEEL_ACTION_DEFAULT); + if (blur != BLUR_TYPE_UNSET) + cmdline_opts |= CMDLINE_BLUR; - return ret; + if (metacity_theme != NULL) + cmdline_opts |= CMDLINE_THEME; + + return g_object_new (GWD_TYPE_SETTINGS, + "blur", blur != BLUR_TYPE_UNSET ? blur : BLUR_TYPE_DEFAULT, + "metacity-theme", metacity_theme ? metacity_theme : METACITY_THEME_DEFAULT, + "cmdline-options", cmdline_opts, + NULL); } -static void -gwd_settings_freeze_updates (GWDSettingsWritable *writable) +const gchar * +gwd_settings_get_metacity_button_layout (GWDSettings *settings) { - GWDSettingsImplPrivate *priv = GET_PRIVATE (writable); - ++priv->freeze_count; + return settings->metacity_button_layout; } -static void -gwd_settings_thaw_updates (GWDSettingsWritable *writable) +const gchar * +gwd_settings_get_metacity_theme (GWDSettings *settings) { - GWDSettingsImplPrivate *priv = GET_PRIVATE (writable); - - if (priv->freeze_count) - --priv->freeze_count; - - release_notify_funcs (GWD_SETTINGS_IMPL (writable)); + return settings->metacity_theme; } -static void -gwd_settings_writable_interface_init (GWDSettingsWritableInterface *interface) +const gchar * +gwd_settings_get_titlebar_font (GWDSettings *settings) { - interface->shadow_property_changed = gwd_settings_shadow_property_changed; - interface->use_tooltips_changed = gwd_settings_use_tooltips_changed; - interface->blur_changed = gwd_settings_blur_changed; - interface->metacity_theme_changed = gwd_settings_metacity_theme_changed; - interface->opacity_changed = gwd_settings_opacity_changed; - interface->button_layout_changed = gwd_settings_button_layout_changed; - interface->font_changed = gwd_settings_font_changed; - interface->titlebar_actions_changed = gwd_settings_actions_changed; - interface->freeze_updates = gwd_settings_freeze_updates; - interface->thaw_updates = gwd_settings_thaw_updates; + return settings->titlebar_font; } -static void -gwd_settings_interface_init (GWDSettingsInterface *interface) +void +gwd_settings_freeze_updates (GWDSettings *settings) { + ++settings->freeze_count; } -static void -gwd_settings_dispose (GObject *object) +void +gwd_settings_thaw_updates (GWDSettings *settings) { - G_OBJECT_CLASS (gwd_settings_impl_parent_class)->dispose (object); + if (settings->freeze_count) + --settings->freeze_count; + + release_notify_funcs (settings); } -static void -gwd_settings_finalize (GObject *object) +gboolean +gwd_settings_shadow_property_changed (GWDSettings *settings, + gdouble active_shadow_radius, + gdouble active_shadow_opacity, + gdouble active_shadow_offset_x, + gdouble active_shadow_offset_y, + const gchar *active_shadow_color, + gdouble inactive_shadow_radius, + gdouble inactive_shadow_opacity, + gdouble inactive_shadow_offset_x, + gdouble inactive_shadow_offset_y, + const gchar *inactive_shadow_color) { - GWDSettingsImplPrivate *priv = GET_PRIVATE (object); - G_OBJECT_CLASS (gwd_settings_impl_parent_class)->finalize (object); + decor_shadow_options_t active_shadow, inactive_shadow; + unsigned int c[4]; + gboolean changed = FALSE; - if (priv->metacity_theme) - { - g_free (priv->metacity_theme); - priv->metacity_theme = NULL; - } + active_shadow.shadow_radius = active_shadow_radius; + active_shadow.shadow_opacity = active_shadow_opacity; + active_shadow.shadow_offset_x = active_shadow_offset_x; + active_shadow.shadow_offset_y = active_shadow_offset_y; - if (priv->metacity_button_layout) - { - g_free (priv->metacity_button_layout); - priv->metacity_button_layout = NULL; + if (sscanf (active_shadow_color, "#%2x%2x%2x%2x", + &c[0], &c[1], &c[2], &c[3]) == 4) { + active_shadow.shadow_color[0] = c[0] << 8 | c[0]; + active_shadow.shadow_color[1] = c[1] << 8 | c[1]; + active_shadow.shadow_color[2] = c[2] << 8 | c[2]; + } else { + return FALSE; + } + + if (sscanf (inactive_shadow_color, "#%2x%2x%2x%2x", + &c[0], &c[1], &c[2], &c[3]) == 4) { + inactive_shadow.shadow_color[0] = c[0] << 8 | c[0]; + inactive_shadow.shadow_color[1] = c[1] << 8 | c[1]; + inactive_shadow.shadow_color[2] = c[2] << 8 | c[2]; + } else { + return FALSE; } - if (priv->titlebar_font) - { - g_free (priv->titlebar_font); - priv->titlebar_font = NULL; - } + inactive_shadow.shadow_radius = inactive_shadow_radius; + inactive_shadow.shadow_opacity = inactive_shadow_opacity; + inactive_shadow.shadow_offset_x = inactive_shadow_offset_x; + inactive_shadow.shadow_offset_y = inactive_shadow_offset_y; - if (priv->notified) - { - g_object_unref (priv->notified); - priv->notified = NULL; + if (decor_shadow_options_cmp (&settings->inactive_shadow, &inactive_shadow)) { + changed |= TRUE; + settings->inactive_shadow = inactive_shadow; } -} -static void -gwd_settings_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - GWDSettingsImplPrivate *priv = GET_PRIVATE (object); - - switch (property_id) - { - case GWD_SETTINGS_IMPL_PROPERTY_CMDLINE_OPTIONS: - priv->cmdline_opts = g_value_get_int (value); - break; - case GWD_SETTINGS_IMPL_PROPERTY_BLUR_CHANGED: - priv->blur_type = g_value_get_int (value); - break; - case GWD_SETTINGS_IMPL_PROPERTY_METACITY_THEME: - if (priv->metacity_theme) - g_free (priv->metacity_theme); - - priv->metacity_theme = g_value_dup_string (value); - break; - case GWD_SETTINGS_IMPL_PROPERTY_SETTINGS_NOTIFIED: - g_return_if_fail (!priv->notified); - priv->notified = (GWDSettingsNotified *) g_value_get_pointer (value); - default: - break; + if (decor_shadow_options_cmp (&settings->active_shadow, &active_shadow)) { + changed |= TRUE; + settings->active_shadow = active_shadow; } -} -static void -gwd_settings_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - GWDSettingsImplPrivate *priv = GET_PRIVATE (object); - - switch (property_id) - { - case GWD_SETTINGS_IMPL_PROPERTY_ACTIVE_SHADOW: - g_value_set_pointer (value, &priv->active_shadow); - break; - case GWD_SETTINGS_IMPL_PROPERTY_INACTIVE_SHADOW: - g_value_set_pointer (value, &priv->inactive_shadow); - break; - case GWD_SETTINGS_IMPL_PROPERTY_USE_TOOLTIPS: - g_value_set_boolean (value, priv->use_tooltips); - break; - case GWD_SETTINGS_IMPL_PROPERTY_BLUR_CHANGED: - g_value_set_int (value, priv->blur_type); - break; - case GWD_SETTINGS_IMPL_PROPERTY_METACITY_THEME: - g_value_set_string (value, priv->metacity_theme); - break; - case GWD_SETTINGS_IMPL_PROPERTY_ACTIVE_OPACITY: - g_value_set_double (value, priv->metacity_active_opacity); - break; - case GWD_SETTINGS_IMPL_PROPERTY_INACTIVE_OPACITY: - g_value_set_double (value, priv->metacity_inactive_opacity); - break; - case GWD_SETTINGS_IMPL_PROPERTY_ACTIVE_SHADE_OPACITY: - g_value_set_boolean (value, priv->metacity_active_shade_opacity); - break; - case GWD_SETTINGS_IMPL_PROPERTY_INACTIVE_SHADE_OPACITY: - g_value_set_boolean (value, priv->metacity_inactive_shade_opacity); - break; - case GWD_SETTINGS_IMPL_PROPERTY_BUTTON_LAYOUT: - g_value_set_string (value, priv->metacity_button_layout); - break; - case GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_ACTION_DOUBLE_CLICK: - g_value_set_int (value, priv->titlebar_double_click_action); - break; - case GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_ACTION_MIDDLE_CLICK: - g_value_set_int (value, priv->titlebar_middle_click_action); - break; - case GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_ACTION_RIGHT_CLICK: - g_value_set_int (value, priv->titlebar_right_click_action); - break; - case GWD_SETTINGS_IMPL_PROPERTY_MOUSE_WHEEL_ACTION: - g_value_set_int (value, priv->mouse_wheel_action); - break; - case GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_FONT: - g_value_set_string (value, priv->titlebar_font); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; + if (changed) { + append_to_notify_funcs (settings, update_decorations); + release_notify_funcs (settings); } + + return changed; } -static void -gwd_settings_impl_class_init (GWDSettingsImplClass *klass) +gboolean +gwd_settings_use_tooltips_changed (GWDSettings *settings, + gboolean use_tooltips) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + if (settings->use_tooltips == use_tooltips) + return FALSE; - g_type_class_add_private (klass, sizeof (GWDSettingsImplPrivate)); - - object_class->dispose = gwd_settings_dispose; - object_class->finalize = gwd_settings_finalize; - object_class->get_property = gwd_settings_get_property; - object_class->set_property = gwd_settings_set_property; + settings->use_tooltips = use_tooltips; - g_object_class_override_property (object_class, - GWD_SETTINGS_IMPL_PROPERTY_ACTIVE_SHADOW, - "active-shadow"); - g_object_class_override_property (object_class, - GWD_SETTINGS_IMPL_PROPERTY_INACTIVE_SHADOW, - "inactive-shadow"); - g_object_class_override_property (object_class, - GWD_SETTINGS_IMPL_PROPERTY_USE_TOOLTIPS, - "use-tooltips"); - g_object_class_override_property (object_class, - GWD_SETTINGS_IMPL_PROPERTY_BLUR_CHANGED, - "blur"); - g_object_class_override_property (object_class, - GWD_SETTINGS_IMPL_PROPERTY_METACITY_THEME, - "metacity-theme"); - g_object_class_override_property (object_class, - GWD_SETTINGS_IMPL_PROPERTY_ACTIVE_OPACITY, - "metacity-active-opacity"); - g_object_class_override_property (object_class, - GWD_SETTINGS_IMPL_PROPERTY_INACTIVE_OPACITY, - "metacity-inactive-opacity"); - g_object_class_override_property (object_class, - GWD_SETTINGS_IMPL_PROPERTY_ACTIVE_SHADE_OPACITY, - "metacity-active-shade-opacity"); - g_object_class_override_property (object_class, - GWD_SETTINGS_IMPL_PROPERTY_INACTIVE_SHADE_OPACITY, - "metacity-inactive-shade-opacity"); - g_object_class_override_property (object_class, - GWD_SETTINGS_IMPL_PROPERTY_BUTTON_LAYOUT, - "metacity-button-layout"); - g_object_class_override_property (object_class, - GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_ACTION_DOUBLE_CLICK, - "titlebar-double-click-action"); - g_object_class_override_property (object_class, - GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_ACTION_MIDDLE_CLICK, - "titlebar-middle-click-action"); - g_object_class_override_property (object_class, - GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_ACTION_RIGHT_CLICK, - "titlebar-right-click-action"); - g_object_class_override_property (object_class, - GWD_SETTINGS_IMPL_PROPERTY_MOUSE_WHEEL_ACTION, - "mouse-wheel-action"); - g_object_class_override_property (object_class, - GWD_SETTINGS_IMPL_PROPERTY_TITLEBAR_FONT, - "titlebar-font"); - g_object_class_install_property (object_class, - GWD_SETTINGS_IMPL_PROPERTY_CMDLINE_OPTIONS, - g_param_spec_int ("cmdline-options", - "Command line options", - "Which options were specified on the command line", - 0, - G_MAXINT32, - 0, - G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY)); - g_object_class_install_property (object_class, - GWD_SETTINGS_IMPL_PROPERTY_SETTINGS_NOTIFIED, - g_param_spec_pointer ("settings-notified", - "GWDSettingsNotified", - "A GWDSettingsNotified which will be updated", - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY)); -} - -static void gwd_settings_impl_init (GWDSettingsImpl *self) -{ - GWDSettingsImplPrivate *priv = GET_PRIVATE (self); - - priv->use_tooltips = USE_TOOLTIPS_DEFAULT; - priv->active_shadow.shadow_radius = ACTIVE_SHADOW_RADIUS_DEFAULT; - priv->active_shadow.shadow_opacity = ACTIVE_SHADOW_OPACITY_DEFAULT; - priv->active_shadow.shadow_offset_x = ACTIVE_SHADOW_OFFSET_X_DEFAULT; - priv->active_shadow.shadow_offset_y = ACTIVE_SHADOW_OFFSET_Y_DEFAULT; - priv->active_shadow.shadow_color[0] = 0; - priv->active_shadow.shadow_color[1] = 0; - priv->active_shadow.shadow_color[2] = 0; - priv->inactive_shadow.shadow_radius = INACTIVE_SHADOW_RADIUS_DEFAULT; - priv->inactive_shadow.shadow_opacity = INACTIVE_SHADOW_OPACITY_DEFAULT; - priv->inactive_shadow.shadow_offset_x = INACTIVE_SHADOW_OFFSET_X_DEFAULT; - priv->inactive_shadow.shadow_offset_y = INACTIVE_SHADOW_OFFSET_Y_DEFAULT; - priv->inactive_shadow.shadow_color[0] = 0; - priv->inactive_shadow.shadow_color[1] = 0; - priv->inactive_shadow.shadow_color[2] = 0; - priv->blur_type = BLUR_TYPE_DEFAULT; - priv->metacity_theme = g_strdup (METACITY_THEME_DEFAULT); - priv->metacity_active_opacity = METACITY_ACTIVE_OPACITY_DEFAULT; - priv->metacity_inactive_opacity = METACITY_INACTIVE_OPACITY_DEFAULT; - priv->metacity_active_shade_opacity = METACITY_ACTIVE_SHADE_OPACITY_DEFAULT; - priv->metacity_inactive_shade_opacity = METACITY_INACTIVE_SHADE_OPACITY_DEFAULT; - priv->metacity_button_layout = g_strdup (METACITY_BUTTON_LAYOUT_DEFAULT); - priv->titlebar_double_click_action = DOUBLE_CLICK_ACTION_DEFAULT; - priv->titlebar_middle_click_action = MIDDLE_CLICK_ACTION_DEFAULT; - priv->titlebar_right_click_action = RIGHT_CLICK_ACTION_DEFAULT; - priv->mouse_wheel_action = WHEEL_ACTION_DEFAULT; - priv->titlebar_font = g_strdup (TITLEBAR_FONT_DEFAULT); - priv->cmdline_opts = 0; - priv->notified = NULL; - priv->freeze_count = 0; + append_to_notify_funcs (settings, update_decorations); + release_notify_funcs (settings); - /* Append all notify funcs so that external state can be updated in case - * the settings backend can't do it itself */ - append_to_notify_funcs (self, gwd_settings_notified_update_metacity_theme); - append_to_notify_funcs (self, gwd_settings_notified_metacity_button_layout); - append_to_notify_funcs (self, gwd_settings_notified_update_frames); - append_to_notify_funcs (self, gwd_settings_notified_update_decorations); + return TRUE; } -static gboolean -set_blur_construction_value (gint *blur, - GParameter *params, - GValue *blur_value) -{ - if (blur) - { - g_value_set_int (blur_value, *blur); +gboolean +gwd_settings_blur_changed (GWDSettings *settings, + const gchar *type) +{ + gint new_type = BLUR_TYPE_UNSET; - params->name = "blur"; - params->value = *blur_value; + if (settings->cmdline_opts & CMDLINE_BLUR) + return FALSE; - return TRUE; - } + if (strcmp (type, "titlebar") == 0) + new_type = BLUR_TYPE_TITLEBAR; + else if (strcmp (type, "all") == 0) + new_type = BLUR_TYPE_ALL; + else if (strcmp (type, "none") == 0) + new_type = BLUR_TYPE_NONE; - return FALSE; -} + if (new_type == BLUR_TYPE_UNSET) + return FALSE; -static gboolean -set_metacity_theme_construction_value (const gchar **metacity_theme, - GParameter *params, - GValue *metacity_theme_value) -{ - if (metacity_theme) - { - g_value_set_string (metacity_theme_value, *metacity_theme); + if (settings->blur_type == new_type) + return FALSE; - params->name = "metacity-theme"; - params->value = *metacity_theme_value; + settings->blur_type = new_type; - return TRUE; - } + append_to_notify_funcs (settings, update_decorations); + release_notify_funcs (settings); - return FALSE; + return TRUE; } -static guint -set_flag_and_increment (guint n_param, - guint *flags, - guint flag) +gboolean +gwd_settings_metacity_theme_changed (GWDSettings *settings, + gboolean use_metacity_theme, + const gchar *metacity_theme) { - if (!flags) - return n_param; + if (settings->cmdline_opts & CMDLINE_THEME) + return FALSE; + + if (!metacity_theme) + return FALSE; - *flags |= flag; - return n_param + 1; + if (use_metacity_theme) { + if (g_strcmp0 (metacity_theme, settings->metacity_theme) == 0) + return FALSE; + + g_free (settings->metacity_theme); + settings->metacity_theme = g_strdup (metacity_theme); + } else { + g_free (settings->metacity_theme); + settings->metacity_theme = g_strdup (""); + } + + append_to_notify_funcs (settings, update_metacity_theme); + append_to_notify_funcs (settings, update_decorations); + release_notify_funcs (settings); + + return TRUE; } -GWDSettings * -gwd_settings_impl_new (gint *blur, - const gchar **metacity_theme, - GWDSettingsNotified *notified) +gboolean +gwd_settings_opacity_changed (GWDSettings *settings, + gdouble active_opacity, + gdouble inactive_opacity, + gboolean active_shade_opacity, + gboolean inactive_shade_opacity) +{ + if (settings->metacity_active_opacity == active_opacity && + settings->metacity_inactive_opacity == inactive_opacity && + settings->metacity_active_shade_opacity == active_shade_opacity && + settings->metacity_inactive_shade_opacity == inactive_shade_opacity) + return FALSE; + + settings->metacity_active_opacity = active_opacity; + settings->metacity_inactive_opacity = inactive_opacity; + settings->metacity_active_shade_opacity = active_shade_opacity; + settings->metacity_inactive_shade_opacity = inactive_shade_opacity; + + append_to_notify_funcs (settings, update_decorations); + release_notify_funcs (settings); + + return TRUE; +} + +gboolean +gwd_settings_button_layout_changed (GWDSettings *settings, + const gchar *button_layout) { - /* Always N command line parameters + 2 for command line - * options enum & notified */ - const guint gwd_settings_impl_n_construction_params = 4; - GParameter param[gwd_settings_impl_n_construction_params]; - GWDSettings *settings = NULL; + if (!button_layout) + return FALSE; - int n_param = 0; - guint cmdline_opts = 0; + if (g_strcmp0 (settings->metacity_button_layout, button_layout) == 0) + return FALSE; - GValue blur_value = G_VALUE_INIT; - GValue metacity_theme_value = G_VALUE_INIT; - GValue cmdline_opts_value = G_VALUE_INIT; - GValue settings_notified_value = G_VALUE_INIT; + g_free (settings->metacity_button_layout); + settings->metacity_button_layout = g_strdup (button_layout); - g_value_init (&blur_value, G_TYPE_INT); - g_value_init (&metacity_theme_value, G_TYPE_STRING); - g_value_init (&cmdline_opts_value, G_TYPE_INT); - g_value_init (&settings_notified_value, G_TYPE_POINTER); + append_to_notify_funcs (settings, update_metacity_button_layout); + append_to_notify_funcs (settings, update_decorations); + release_notify_funcs (settings); - if (set_blur_construction_value (blur, ¶m[n_param], &blur_value)) - n_param = set_flag_and_increment (n_param, &cmdline_opts, CMDLINE_BLUR); + return TRUE; +} - if (set_metacity_theme_construction_value (metacity_theme, ¶m[n_param], &metacity_theme_value)) - n_param = set_flag_and_increment (n_param, &cmdline_opts, CMDLINE_THEME); +gboolean +gwd_settings_font_changed (GWDSettings *settings, + gboolean titlebar_uses_system_font, + const gchar *titlebar_font) +{ + const gchar *no_font = NULL; + const gchar *use_font = NULL; - g_value_set_int (&cmdline_opts_value, cmdline_opts); + if (!titlebar_font) + return FALSE; - param[n_param].name = "cmdline-options"; - param[n_param].value = cmdline_opts_value; + if (titlebar_uses_system_font) + use_font = no_font; + else + use_font = titlebar_font; - ++n_param; + if (g_strcmp0 (settings->titlebar_font, use_font) == 0) + return FALSE; - g_value_set_pointer (&settings_notified_value, notified); + g_free (settings->titlebar_font); + settings->titlebar_font = use_font ? g_strdup (use_font) : NULL; - param[n_param].name = "settings-notified"; - param[n_param].value = settings_notified_value; + append_to_notify_funcs (settings, update_decorations); + append_to_notify_funcs (settings, update_frames); + release_notify_funcs (settings); - ++n_param; + return TRUE; +} - settings = GWD_SETTINGS_INTERFACE (g_object_newv (GWD_TYPE_SETTINGS_IMPL, n_param, param)); +gboolean +gwd_settings_titlebar_actions_changed (GWDSettings *settings, + const gchar *action_double_click_titlebar, + const gchar *action_middle_click_titlebar, + const gchar *action_right_click_titlebar, + const gchar *mouse_wheel_action) +{ + gboolean ret = FALSE; - g_value_unset (&blur_value); - g_value_unset (&metacity_theme_value); - g_value_unset (&cmdline_opts_value); + ret |= get_click_action_value (action_double_click_titlebar, + &settings->titlebar_double_click_action, + DOUBLE_CLICK_ACTION_DEFAULT); + ret |= get_click_action_value (action_middle_click_titlebar, + &settings->titlebar_middle_click_action, + MIDDLE_CLICK_ACTION_DEFAULT); + ret |= get_click_action_value (action_right_click_titlebar, + &settings->titlebar_right_click_action, + RIGHT_CLICK_ACTION_DEFAULT); + ret |= get_wheel_action_value (mouse_wheel_action, + &settings->mouse_wheel_action, + WHEEL_ACTION_DEFAULT); - return settings; + return ret; } diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings.h compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings.h --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings.h 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings.h 2016-05-25 14:20:26.000000000 +0000 @@ -1,3 +1,5 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */ + /* * Copyright © 2012 Canonical Ltd * @@ -17,21 +19,141 @@ * * Authored By: Sam Spilsbury */ -#ifndef _COMPIZ_GWD_SETTINGS_H -#define _COMPIZ_GWD_SETTINGS_H + +#ifndef GWD_SETTINGS_H +#define GWD_SETTINGS_H #include #include G_BEGIN_DECLS -#define GWD_TYPE_SETTINGS_IMPL (gwd_settings_impl_get_type ()) -GType gwd_settings_impl_get_type (); +enum +{ + BLUR_TYPE_UNSET = -1, + BLUR_TYPE_NONE = 0, + BLUR_TYPE_TITLEBAR = 1, + BLUR_TYPE_ALL = 2 +}; + +enum +{ + CLICK_ACTION_NONE, + CLICK_ACTION_SHADE, + CLICK_ACTION_MAXIMIZE, + CLICK_ACTION_MINIMIZE, + CLICK_ACTION_RAISE, + CLICK_ACTION_LOWER, + CLICK_ACTION_MENU +}; + +enum +{ + WHEEL_ACTION_NONE, + WHEEL_ACTION_SHADE +}; + +extern const gboolean USE_TOOLTIPS_DEFAULT; + +extern const gdouble ACTIVE_SHADOW_RADIUS_DEFAULT; +extern const gdouble ACTIVE_SHADOW_OPACITY_DEFAULT; +extern const gint ACTIVE_SHADOW_OFFSET_X_DEFAULT; +extern const gint ACTIVE_SHADOW_OFFSET_Y_DEFAULT; +extern const gchar *ACTIVE_SHADOW_COLOR_DEFAULT; + +extern const gdouble INACTIVE_SHADOW_RADIUS_DEFAULT; +extern const gdouble INACTIVE_SHADOW_OPACITY_DEFAULT; +extern const gint INACTIVE_SHADOW_OFFSET_X_DEFAULT; +extern const gint INACTIVE_SHADOW_OFFSET_Y_DEFAULT; +extern const gchar *INACTIVE_SHADOW_COLOR_DEFAULT; + +extern const gint BLUR_TYPE_DEFAULT; + +extern const gchar *METACITY_THEME_DEFAULT; +extern const gdouble METACITY_ACTIVE_OPACITY_DEFAULT; +extern const gdouble METACITY_INACTIVE_OPACITY_DEFAULT; +extern const gboolean METACITY_ACTIVE_SHADE_OPACITY_DEFAULT; +extern const gboolean METACITY_INACTIVE_SHADE_OPACITY_DEFAULT; + +extern const gchar *METACITY_BUTTON_LAYOUT_DEFAULT; + +extern const guint DOUBLE_CLICK_ACTION_DEFAULT; +extern const guint MIDDLE_CLICK_ACTION_DEFAULT; +extern const guint RIGHT_CLICK_ACTION_DEFAULT; +extern const guint WHEEL_ACTION_DEFAULT; + +extern const gchar *TITLEBAR_FONT_DEFAULT; + +#define GWD_TYPE_SETTINGS gwd_settings_get_type () +G_DECLARE_FINAL_TYPE (GWDSettings, gwd_settings, GWD, SETTINGS, GObject) GWDSettings * -gwd_settings_impl_new (gint *blur, - const gchar **metacity_theme, - GWDSettingsNotified *notified); +gwd_settings_new (gint blur, + const gchar *metacity_theme); + +const gchar * +gwd_settings_get_metacity_button_layout (GWDSettings *settings); + +const gchar * +gwd_settings_get_metacity_theme (GWDSettings *settings); + +const gchar * +gwd_settings_get_titlebar_font (GWDSettings *settings); + +void +gwd_settings_freeze_updates (GWDSettings *settings); + +void +gwd_settings_thaw_updates (GWDSettings *settings); + +gboolean +gwd_settings_shadow_property_changed (GWDSettings *settings, + gdouble active_shadow_radius, + gdouble active_shadow_opacity, + gdouble active_shadow_offset_x, + gdouble active_shadow_offset_y, + const gchar *active_shadow_color, + gdouble inactive_shadow_radius, + gdouble inactive_shadow_opacity, + gdouble inactive_shadow_offset_x, + gdouble inactive_shadow_offset_y, + const gchar *inactive_shadow_color); + +gboolean +gwd_settings_use_tooltips_changed (GWDSettings *settings, + gboolean use_tooltips); + +gboolean +gwd_settings_blur_changed (GWDSettings *settings, + const gchar *blur_type); + +gboolean +gwd_settings_metacity_theme_changed (GWDSettings *settings, + gboolean use_metacity_theme, + const gchar *metacity_theme); + +gboolean +gwd_settings_opacity_changed (GWDSettings *settings, + gdouble active_opacity, + gdouble inactive_opacity, + gboolean active_shade_opacity, + gboolean inactive_shade_opacity); + +gboolean +gwd_settings_button_layout_changed (GWDSettings *settings, + const gchar *button_layout); + +gboolean +gwd_settings_font_changed (GWDSettings *settings, + gboolean titlebar_uses_system_font, + const gchar *titlebar_font); + +gboolean +gwd_settings_titlebar_actions_changed (GWDSettings *settings, + const gchar *action_double_click_titlebar, + const gchar *action_middle_click_titlebar, + const gchar *action_right_click_titlebar, + const gchar *mouse_wheel_action); G_END_DECLS diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-interface.c compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-interface.c --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-interface.c 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-interface.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,165 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Authored By: Sam Spilsbury - */ -#include "gwd-settings-interface.h" - -const gboolean USE_TOOLTIPS_DEFAULT = FALSE; - -const gdouble ACTIVE_SHADOW_RADIUS_DEFAULT = 8.0; -const gdouble ACTIVE_SHADOW_OPACITY_DEFAULT = 0.5; -const gint ACTIVE_SHADOW_OFFSET_X_DEFAULT = 1; -const gint ACTIVE_SHADOW_OFFSET_Y_DEFAULT = 1; -const gchar *ACTIVE_SHADOW_COLOR_DEFAULT = "#00000000"; - -const gdouble INACTIVE_SHADOW_RADIUS_DEFAULT = 8.0; -const gdouble INACTIVE_SHADOW_OPACITY_DEFAULT = 0/5; -const gint INACTIVE_SHADOW_OFFSET_X_DEFAULT = 1; -const gint INACTIVE_SHADOW_OFFSET_Y_DEFAULT = 1; -const gchar *INACTIVE_SHADOW_COLOR_DEFAULT = "#00000000"; - -const gint BLUR_TYPE_DEFAULT = BLUR_TYPE_NONE; - -const gchar *METACITY_THEME_DEFAULT = "Adwaita"; -const gdouble METACITY_ACTIVE_OPACITY_DEFAULT = 1.0; -const gdouble METACITY_INACTIVE_OPACITY_DEFAULT = 0.75; -const gboolean METACITY_ACTIVE_SHADE_OPACITY_DEFAULT = TRUE; -const gboolean METACITY_INACTIVE_SHADE_OPACITY_DEFAULT = TRUE; - -const gchar * METACITY_BUTTON_LAYOUT_DEFAULT = ":minimize,maximize,close"; - -const guint DOUBLE_CLICK_ACTION_DEFAULT = CLICK_ACTION_MAXIMIZE; -const guint MIDDLE_CLICK_ACTION_DEFAULT = CLICK_ACTION_LOWER; -const guint RIGHT_CLICK_ACTION_DEFAULT = CLICK_ACTION_MENU; -const guint WHEEL_ACTION_DEFAULT = WHEEL_ACTION_NONE; - -const gchar * TITLEBAR_FONT_DEFAULT = "Sans 12"; - -static void gwd_settings_interface_default_init (GWDSettingsInterface *settings_interface); - -G_DEFINE_INTERFACE (GWDSettings, gwd_settings_interface, G_TYPE_OBJECT); - -static void gwd_settings_interface_default_init (GWDSettingsInterface *settings_interface) -{ - g_object_interface_install_property (settings_interface, - g_param_spec_pointer ("active-shadow", - "Active Shadow", - "Active Shadow Settings", - G_PARAM_READABLE)); - g_object_interface_install_property (settings_interface, - g_param_spec_pointer ("inactive-shadow", - "Inactive Shadow", - "Inactive Shadow", - G_PARAM_READABLE)); - g_object_interface_install_property (settings_interface, - g_param_spec_boolean ("use-tooltips", - "Use Tooltips", - "Use Tooltips Setting", - USE_TOOLTIPS_DEFAULT, - G_PARAM_READABLE)); - g_object_interface_install_property (settings_interface, - g_param_spec_int ("blur", - "Blur Type", - "Blur type property", - BLUR_TYPE_NONE, - BLUR_TYPE_ALL, - BLUR_TYPE_NONE, - G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY)); - g_object_interface_install_property (settings_interface, - g_param_spec_string ("metacity-theme", - "Metacity Theme", - "Metacity Theme Setting", - METACITY_THEME_DEFAULT, - G_PARAM_READABLE | - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY)); - g_object_interface_install_property (settings_interface, - g_param_spec_double ("metacity-active-opacity", - "Metacity Active Opacity", - "Metacity Active Opacity", - 0.0, - 1.0, - METACITY_ACTIVE_OPACITY_DEFAULT, - G_PARAM_READABLE)); - g_object_interface_install_property (settings_interface, - g_param_spec_double ("metacity-inactive-opacity", - "Metacity Inactive Opacity", - "Metacity Inactive Opacity", - 0.0, - 1.0, - METACITY_INACTIVE_OPACITY_DEFAULT, - G_PARAM_READABLE)); - g_object_interface_install_property (settings_interface, - g_param_spec_boolean ("metacity-active-shade-opacity", - "Metacity Active Shade Opacity", - "Metacity Active Shade Opacity", - METACITY_ACTIVE_SHADE_OPACITY_DEFAULT, - G_PARAM_READABLE)); - g_object_interface_install_property (settings_interface, - g_param_spec_boolean ("metacity-inactive-shade-opacity", - "Metacity Inactive Shade Opacity", - "Metacity Inactive Shade Opacity", - METACITY_INACTIVE_SHADE_OPACITY_DEFAULT, - G_PARAM_READABLE)); - g_object_interface_install_property (settings_interface, - g_param_spec_string ("metacity-button-layout", - "Metacity Button Layout", - "Metacity Button Layout", - METACITY_BUTTON_LAYOUT_DEFAULT, - G_PARAM_READABLE)); - g_object_interface_install_property (settings_interface, - g_param_spec_int ("titlebar-double-click-action", - "Titlebar Action Double Click", - "Titlebar Action Double Click", - CLICK_ACTION_NONE, - CLICK_ACTION_MENU, - CLICK_ACTION_MAXIMIZE, - G_PARAM_READABLE)); - g_object_interface_install_property (settings_interface, - g_param_spec_int ("titlebar-middle-click-action", - "Titlebar Action Middle Click", - "Titlebar Action Middle Click", - CLICK_ACTION_NONE, - CLICK_ACTION_MENU, - CLICK_ACTION_LOWER, - G_PARAM_READABLE)); - g_object_interface_install_property (settings_interface, - g_param_spec_int ("titlebar-right-click-action", - "Titlebar Action Right Click", - "Titlebar Action Right Click", - CLICK_ACTION_NONE, - CLICK_ACTION_MENU, - CLICK_ACTION_MENU, - G_PARAM_READABLE)); - g_object_interface_install_property (settings_interface, - g_param_spec_int ("mouse-wheel-action", - "Mouse Wheel Action", - "Mouse Wheel Action", - WHEEL_ACTION_NONE, - WHEEL_ACTION_SHADE, - WHEEL_ACTION_SHADE, - G_PARAM_READABLE)); - g_object_interface_install_property (settings_interface, - g_param_spec_string ("titlebar-font", - "Titlebar Font", - "Titlebar Font", - TITLEBAR_FONT_DEFAULT, - G_PARAM_READABLE)); -} diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-interface.h compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-interface.h --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-interface.h 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-interface.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,103 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Authored By: Sam Spilsbury - */ -#ifndef _COMPIZ_GWD_SETTINGS_INTERFACE_H -#define _COMPIZ_GWD_SETTINGS_INTERFACE_H - -#include -#include - -G_BEGIN_DECLS - -#define GWD_SETTINGS_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - GWD_TYPE_SETTINGS_INTERFACE, \ - GWDSettings)) -#define GWD_SETTINGS_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE(obj, \ - GWD_TYPE_SETTINGS_INTERFACE, \ - GWDSettingsInterface)) -#define GWD_TYPE_SETTINGS_INTERFACE (gwd_settings_interface_get_type ()) - -typedef struct _GWDSettingsInterface GWDSettingsInterface; - -struct _GWDSettingsInterface -{ - GTypeInterface parent; -}; - -enum -{ - BLUR_TYPE_NONE = 0, - BLUR_TYPE_TITLEBAR = 1, - BLUR_TYPE_ALL = 2 -}; - -enum -{ - CLICK_ACTION_NONE, - CLICK_ACTION_SHADE, - CLICK_ACTION_MAXIMIZE, - CLICK_ACTION_MINIMIZE, - CLICK_ACTION_RAISE, - CLICK_ACTION_LOWER, - CLICK_ACTION_MENU -}; - -enum { - WHEEL_ACTION_NONE, - WHEEL_ACTION_SHADE -}; - -extern const gboolean USE_TOOLTIPS_DEFAULT; - -extern const gdouble ACTIVE_SHADOW_RADIUS_DEFAULT; -extern const gdouble ACTIVE_SHADOW_OPACITY_DEFAULT; -extern const gint ACTIVE_SHADOW_OFFSET_X_DEFAULT; -extern const gint ACTIVE_SHADOW_OFFSET_Y_DEFAULT; -extern const gchar *ACTIVE_SHADOW_COLOR_DEFAULT; - -extern const gdouble INACTIVE_SHADOW_RADIUS_DEFAULT; -extern const gdouble INACTIVE_SHADOW_OPACITY_DEFAULT; -extern const gint INACTIVE_SHADOW_OFFSET_X_DEFAULT; -extern const gint INACTIVE_SHADOW_OFFSET_Y_DEFAULT; -extern const gchar *INACTIVE_SHADOW_COLOR_DEFAULT; - -extern const guint DRAGGABLE_BORDER_WIDTH_DEFAULT; -extern const gboolean ATTACH_MODAL_DIALOGS_DEFAULT; -extern const gint BLUR_TYPE_DEFAULT; - -extern const gchar *METACITY_THEME_DEFAULT; -extern const gdouble METACITY_ACTIVE_OPACITY_DEFAULT; -extern const gdouble METACITY_INACTIVE_OPACITY_DEFAULT; -extern const gboolean METACITY_ACTIVE_SHADE_OPACITY_DEFAULT; -extern const gboolean METACITY_INACTIVE_SHADE_OPACITY_DEFAULT; - -extern const gchar * METACITY_BUTTON_LAYOUT_DEFAULT; - -extern const guint DOUBLE_CLICK_ACTION_DEFAULT; -extern const guint MIDDLE_CLICK_ACTION_DEFAULT; -extern const guint RIGHT_CLICK_ACTION_DEFAULT; -extern const guint WHEEL_ACTION_DEFAULT; - -extern const gchar * TITLEBAR_FONT_DEFAULT; - -GType gwd_settings_interface_get_type (void); - -G_END_DECLS - -#endif diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-notified.c compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-notified.c --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-notified.c 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-notified.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,270 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Authored By: Sam Spilsbury - */ -#include - -#include "gwd-settings-notified-interface.h" -#include "gwd-settings-notified.h" -#include "gwd-metacity-window-decoration-util.h" - -#include "gtk-window-decorator.h" - -#define GWD_SETTINGS_NOTIFIED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GWD_TYPE_SETTINGS_NOTIFIED, GWDSettingsNotifiedImpl)); -#define GWD_SETTINGS_NOTIFIED_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), GWD_TYPE_SETTINGS_NOTIFIED, GWDSettingsNotifiedImplClass)); -#define GWD_IS_MOCK_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GWD_TYPE_SETTINGS_NOTIFIED)); -#define GWD_IS_MOCK_SETTINGS_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), GWD_TYPE_SETTINGS_NOTIFIED)); -#define GWD_SETTINGS_NOTIFIED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GWD_TYPE_SETTINGS_NOTIFIED, GWDSettingsNotifiedImplClass)); - -typedef struct _GWDSettingsNotifiedImpl -{ - GObject parent; -} GWDSettingsNotifiedImpl; - -typedef struct _GWDSettingsNotifiedImplClass -{ - GObjectClass parent_class; -} GWDSettingsNotifiedImplClass; - -enum -{ - GWD_SETTINGS_NOTIFIED_IMPL_PROPERTY_WNCK_SCREEN = 1 -}; - -static void gwd_settings_notified_impl_interface_init (GWDSettingsNotifiedInterface *interface); - -G_DEFINE_TYPE_WITH_CODE (GWDSettingsNotifiedImpl, gwd_settings_notified_impl, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (GWD_TYPE_SETTINGS_NOTIFIED_INTERFACE, - gwd_settings_notified_impl_interface_init)) - -#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GWD_TYPE_SETTINGS_NOTIFIED, GWDSettingsNotifiedImplPrivate)) - -typedef struct _GWDSettingsNotifiedImplPrivate -{ - WnckScreen *screen; -} GWDSettingsNotifiedImplPrivate; - -static gboolean -gwd_settings_notified_impl_update_decorations (GWDSettingsNotified *notified) -{ - GWDSettingsNotifiedImplPrivate *priv = GET_PRIVATE (notified); - decorations_changed (priv->screen); - return TRUE; -} - -void -set_frame_scale (decor_frame_t *frame, - const gchar *font_str) -{ - gfloat scale = 1.0f; - - gwd_decor_frame_ref (frame); - - if (frame->titlebar_font) - { - pango_font_description_free (frame->titlebar_font); - frame->titlebar_font = NULL; - } - - if (font_str) - { - gint size; - - frame->titlebar_font = pango_font_description_from_string (font_str); - - scale = (*theme_get_title_scale) (frame); - size = MAX (pango_font_description_get_size (frame->titlebar_font) * scale, 1); - - pango_font_description_set_size (frame->titlebar_font, size); - } - - gwd_decor_frame_unref (frame); -} - -void -set_frames_scales (gpointer key, - gpointer value, - gpointer user_data) -{ - decor_frame_t *frame = (decor_frame_t *) value; - gchar *font_str = (gchar *) user_data; - - gwd_decor_frame_ref (frame); - - set_frame_scale (frame, font_str); - - gwd_decor_frame_unref (frame); -} - -static gboolean -gwd_settings_notified_impl_update_frames (GWDSettingsNotified *notified) -{ - const gchar *titlebar_font = NULL; - g_object_get (settings, "titlebar-font", &titlebar_font, NULL); - - gwd_frames_foreach (set_frames_scales, (gpointer) titlebar_font); - return TRUE; -} - -static gboolean -gwd_settings_notified_impl_update_metacity_theme (GWDSettingsNotified *notified) -{ -#ifdef USE_METACITY - const gchar *meta_theme = NULL; - g_object_get (settings, "metacity-theme", &meta_theme, NULL); - - if (gwd_metacity_window_decoration_update_meta_theme (meta_theme, - meta_theme_get_current, - meta_theme_set_current)) - { - 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_get_title_scale = meta_get_title_scale; - theme_get_shadow = meta_get_shadow; - } - else - { - g_log ("gtk-window-decorator", G_LOG_LEVEL_INFO, "using cairo decoration"); - theme_draw_window_decoration = draw_window_decoration; - theme_calc_decoration_size = calc_decoration_size; - 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_title_scale = get_title_scale; - theme_get_shadow = cairo_get_shadow; - } - - return TRUE; -#else - theme_draw_window_decoration = draw_window_decoration; - theme_calc_decoration_size = calc_decoration_size; - 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_title_scale = get_title_scale; - theme_get_shadow = cairo_get_shadow; - - return FALSE; -#endif -} - -static gboolean -gwd_settings_notified_impl_update_metacity_button_layout (GWDSettingsNotified *notified) -{ -#ifdef USE_METACITY - const gchar *button_layout; - g_object_get (settings, "metacity-button-layout", &button_layout, NULL); - - if (button_layout) - { - meta_update_button_layout (button_layout); - - meta_button_layout_set = TRUE; - - return TRUE; - } - - if (meta_button_layout_set) - { - meta_button_layout_set = FALSE; - return TRUE; - } - -#endif - return FALSE; -} - -static void gwd_settings_notified_impl_interface_init (GWDSettingsNotifiedInterface *interface) -{ - interface->update_decorations = gwd_settings_notified_impl_update_decorations; - interface->update_frames = gwd_settings_notified_impl_update_frames; - interface->update_metacity_button_layout = gwd_settings_notified_impl_update_metacity_button_layout; - interface->update_metacity_theme = gwd_settings_notified_impl_update_metacity_theme; -} - -static void gwd_settings_notified_impl_finalize (GObject *object) -{ - G_OBJECT_CLASS (gwd_settings_notified_impl_parent_class)->finalize (object); -} - -static void gwd_settings_notified_impl_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - GWDSettingsNotifiedImplPrivate *priv = GET_PRIVATE (object); - - switch (property_id) - { - case GWD_SETTINGS_NOTIFIED_IMPL_PROPERTY_WNCK_SCREEN: - g_return_if_fail (!priv->screen); - priv->screen = g_value_get_object (value); - break; - default: - break; - } -} - -static void gwd_settings_notified_impl_class_init (GWDSettingsNotifiedImplClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (klass, sizeof (GWDSettingsNotifiedImplPrivate)); - - object_class->finalize = gwd_settings_notified_impl_finalize; - object_class->set_property = gwd_settings_notified_impl_set_property; - - g_object_class_install_property (object_class, - GWD_SETTINGS_NOTIFIED_IMPL_PROPERTY_WNCK_SCREEN, - g_param_spec_object ("wnck-screen", - "WnckScreen", - "A WnckScreen", - WNCK_TYPE_SCREEN, - G_PARAM_WRITABLE | - G_PARAM_CONSTRUCT_ONLY)); -} - -void gwd_settings_notified_impl_init (GWDSettingsNotifiedImpl *self) -{ -} - -GWDSettingsNotified * -gwd_settings_notified_impl_new (WnckScreen *screen) -{ - static const guint gwd_settings_notified_impl_n_construction_properties = 1; - GValue wnck_screen_value = G_VALUE_INIT; - GParameter params[gwd_settings_notified_impl_n_construction_properties]; - GWDSettingsNotified *notified = NULL; - - g_value_init (&wnck_screen_value, G_TYPE_OBJECT); - g_value_set_object (&wnck_screen_value, G_OBJECT (screen)); - - params[0].name = "wnck-screen"; - params[0].value = wnck_screen_value; - - notified = GWD_SETTINGS_NOTIFIED_INTERFACE (g_object_newv (GWD_TYPE_SETTINGS_NOTIFIED, - gwd_settings_notified_impl_n_construction_properties, - params)); - - g_value_unset (&wnck_screen_value); - - return notified; -} diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-notified.h compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-notified.h --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-notified.h 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-notified.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,38 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Authored By: Sam Spilsbury - */ -#ifndef _COMPIZ_GWD_SETTINGS_NOTIFIED_H -#define _COMPIZ_GWD_SETTINGS_NOTIFIED_H - -#include -#define WNCK_I_KNOW_THIS_IS_UNSTABLE -#include -#include - -G_BEGIN_DECLS - -#define GWD_TYPE_SETTINGS_NOTIFIED (gwd_settings_notified_impl_get_type ()) -GType gwd_settings_notified_impl_get_type (); - -GWDSettingsNotified * -gwd_settings_notified_impl_new (WnckScreen *screen); - -G_END_DECLS - -#endif diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-notified-interface.c compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-notified-interface.c --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-notified-interface.c 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-notified-interface.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Authored By: Sam Spilsbury - */ -#include "gwd-settings-notified-interface.h" - -static void gwd_settings_notified_interface_default_init (GWDSettingsNotifiedInterface *settings_interface); - -G_DEFINE_INTERFACE (GWDSettingsNotified, gwd_settings_notified_interface, G_TYPE_OBJECT); - -static void gwd_settings_notified_interface_default_init (GWDSettingsNotifiedInterface *settings_interface) -{ -} - -gboolean -gwd_settings_notified_update_decorations (GWDSettingsNotified *notified) -{ - GWDSettingsNotifiedInterface *iface = GWD_SETTINGS_NOTIFIED_GET_INTERFACE (notified); - return (*iface->update_decorations) (notified); -} - -gboolean -gwd_settings_notified_update_frames (GWDSettingsNotified *notified) -{ - GWDSettingsNotifiedInterface *iface = GWD_SETTINGS_NOTIFIED_GET_INTERFACE (notified); - return (*iface->update_frames) (notified); -} - -gboolean -gwd_settings_notified_update_metacity_theme (GWDSettingsNotified *notified) -{ - GWDSettingsNotifiedInterface *iface = GWD_SETTINGS_NOTIFIED_GET_INTERFACE (notified); - return (*iface->update_metacity_theme) (notified); -} - -gboolean -gwd_settings_notified_metacity_button_layout (GWDSettingsNotified *notified) -{ - GWDSettingsNotifiedInterface *iface = GWD_SETTINGS_NOTIFIED_GET_INTERFACE (notified); - return (*iface->update_metacity_button_layout) (notified); -} diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-notified-interface.h compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-notified-interface.h --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-notified-interface.h 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-notified-interface.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,64 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Authored By: Sam Spilsbury - */ -#ifndef _COMPIZ_GWD_SETTINGS_NOTIFIED_INTERFACE_H -#define _COMPIZ_GWD_SETTINGS_NOTIFIED_INTERFACE_H - -#include -#include - -G_BEGIN_DECLS - -#define GWD_SETTINGS_NOTIFIED_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - GWD_TYPE_SETTINGS_NOTIFIED_INTERFACE, \ - GWDSettingsNotified)) -#define GWD_SETTINGS_NOTIFIED_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE(obj, \ - GWD_TYPE_SETTINGS_NOTIFIED_INTERFACE, \ - GWDSettingsNotifiedInterface)) -#define GWD_TYPE_SETTINGS_NOTIFIED_INTERFACE (gwd_settings_notified_interface_get_type ()) - -typedef struct _GWDSettingsNotifiedInterface GWDSettingsNotifiedInterface; - -struct _GWDSettingsNotifiedInterface -{ - GTypeInterface parent; - - gboolean (*update_decorations) (GWDSettingsNotified *notified); - gboolean (*update_frames) (GWDSettingsNotified *notified); - gboolean (*update_metacity_theme) (GWDSettingsNotified *notified); - gboolean (*update_metacity_button_layout) (GWDSettingsNotified *notified); -}; - -gboolean -gwd_settings_notified_update_decorations (GWDSettingsNotified *notified); - -gboolean -gwd_settings_notified_update_frames (GWDSettingsNotified *notified); - -gboolean -gwd_settings_notified_update_metacity_theme (GWDSettingsNotified *notified); - -gboolean -gwd_settings_notified_metacity_button_layout (GWDSettingsNotified *notified); - -GType gwd_settings_notified_interface_get_type (void); - -G_END_DECLS - -#endif diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-storage.c compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-storage.c --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-storage.c 2016-05-17 02:52:40.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-storage.c 2016-05-25 14:20:26.000000000 +0000 @@ -24,7 +24,7 @@ #include -#include "gwd-settings-writable-interface.h" +#include "gwd-settings.h" #include "gwd-settings-storage.h" const gchar * ORG_COMPIZ_GWD = "org.compiz.gwd"; @@ -58,24 +58,24 @@ struct _GWDSettingsStorage { - GObject parent; + GObject parent; - GWDSettingsWritable *writable; - gboolean connect; + GWDSettings *settings; + gboolean connect; - GSettings *gwd; - GSettings *desktop; - GSettings *metacity; - GSettings *marco; + GSettings *gwd; + GSettings *desktop; + GSettings *metacity; + GSettings *marco; - gboolean is_mate_desktop; + gboolean is_mate_desktop; }; enum { PROP_0, - PROP_WRITABLE, + PROP_SETTINGS, PROP_CONNECT, LAST_PROP @@ -221,7 +221,7 @@ storage = GWD_SETTINGS_STORAGE (object); - g_clear_object (&storage->writable); + g_clear_object (&storage->settings); g_clear_object (&storage->gwd); g_clear_object (&storage->desktop); @@ -242,8 +242,8 @@ storage = GWD_SETTINGS_STORAGE (object); switch (property_id) { - case PROP_WRITABLE: - storage->writable = g_value_dup_object (value); + case PROP_SETTINGS: + storage->settings = g_value_dup_object (value); break; case PROP_CONNECT: @@ -267,10 +267,9 @@ object_class->dispose = gwd_settings_storage_dispose; object_class->set_property = gwd_settings_storage_set_property; - storage_properties[PROP_WRITABLE] = - g_param_spec_object ("writable", "GWDWritableSettings", - "A GWDWritableSettings object", - GWD_TYPE_WRITABLE_SETTINGS_INTERFACE, + storage_properties[PROP_SETTINGS] = + g_param_spec_object ("settings", "GWDSettings", "GWDSettings", + GWD_TYPE_SETTINGS, G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS); @@ -316,11 +315,11 @@ } GWDSettingsStorage * -gwd_settings_storage_new (GWDSettingsWritable *writable, - gboolean connect) +gwd_settings_storage_new (GWDSettings *settings, + gboolean connect) { return g_object_new (GWD_TYPE_SETTINGS_STORAGE, - "writable", writable, + "settings", settings, "connect", connect, NULL); } @@ -335,7 +334,7 @@ use_tooltips = g_settings_get_boolean (storage->gwd, ORG_COMPIZ_GWD_KEY_USE_TOOLTIPS); - return gwd_settings_writable_use_tooltips_changed (storage->writable, use_tooltips); + return gwd_settings_use_tooltips_changed (storage->settings, use_tooltips); } gboolean @@ -348,7 +347,7 @@ return FALSE; blur_type = g_settings_get_string (storage->gwd, ORG_COMPIZ_GWD_KEY_BLUR_TYPE); - retval = gwd_settings_writable_blur_changed (storage->writable, blur_type); + retval = gwd_settings_blur_changed (storage->settings, blur_type); g_free (blur_type); return retval; @@ -373,7 +372,7 @@ else return FALSE; - retval = gwd_settings_writable_metacity_theme_changed (storage->writable, use_metacity_theme, theme); + retval = gwd_settings_metacity_theme_changed (storage->settings, use_metacity_theme, theme); g_free (theme); return retval; @@ -395,8 +394,8 @@ active_shade = g_settings_get_boolean (storage->gwd, ORG_COMPIZ_GWD_KEY_METACITY_THEME_ACTIVE_SHADE_OPACITY); inactive_shade = g_settings_get_boolean (storage->gwd, ORG_COMPIZ_GWD_KEY_METACITY_THEME_INACTIVE_SHADE_OPACITY); - return gwd_settings_writable_opacity_changed (storage->writable, active, inactive, - active_shade, inactive_shade); + return gwd_settings_opacity_changed (storage->settings, active, inactive, + active_shade, inactive_shade); } gboolean @@ -412,7 +411,7 @@ else return FALSE; - retval = gwd_settings_writable_button_layout_changed (storage->writable, button_layout); + retval = gwd_settings_button_layout_changed (storage->settings, button_layout); g_free (button_layout); return retval; @@ -434,7 +433,7 @@ } else return FALSE; - retval = gwd_settings_writable_font_changed (storage->writable, titlebar_system_font, titlebar_font); + retval = gwd_settings_font_changed (storage->settings, titlebar_system_font, titlebar_font); g_free (titlebar_font); return retval; @@ -469,9 +468,9 @@ mouse_wheel_action = g_settings_get_string (storage->gwd, ORG_COMPIZ_GWD_KEY_MOUSE_WHEEL_ACTION); - retval = gwd_settings_writable_titlebar_actions_changed (storage->writable, double_click_action, - middle_click_action, right_click_action, - mouse_wheel_action); + retval = gwd_settings_titlebar_actions_changed (storage->settings, double_click_action, + middle_click_action, right_click_action, + mouse_wheel_action); g_free (double_click_action); g_free (middle_click_action); diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-storage.h compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-storage.h --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-storage.h 2016-05-17 02:52:35.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-storage.h 2016-05-25 14:20:26.000000000 +0000 @@ -60,41 +60,41 @@ GWD, SETTINGS_STORAGE, GObject) GWDSettingsStorage * -gwd_settings_storage_new (GWDSettingsWritable *writable, - gboolean connect); +gwd_settings_storage_new (GWDSettings *settings, + gboolean connect); gboolean -gwd_settings_storage_update_use_tooltips (GWDSettingsStorage *storage); +gwd_settings_storage_update_use_tooltips (GWDSettingsStorage *storage); gboolean -gwd_settings_storage_update_blur (GWDSettingsStorage *storage); +gwd_settings_storage_update_blur (GWDSettingsStorage *storage); gboolean -gwd_settings_storage_update_metacity_theme (GWDSettingsStorage *storage); +gwd_settings_storage_update_metacity_theme (GWDSettingsStorage *storage); gboolean -gwd_settings_storage_update_opacity (GWDSettingsStorage *storage); +gwd_settings_storage_update_opacity (GWDSettingsStorage *storage); gboolean -gwd_settings_storage_update_button_layout (GWDSettingsStorage *storage); +gwd_settings_storage_update_button_layout (GWDSettingsStorage *storage); gboolean -gwd_settings_storage_update_font (GWDSettingsStorage *storage); +gwd_settings_storage_update_font (GWDSettingsStorage *storage); gboolean gwd_settings_storage_update_titlebar_actions (GWDSettingsStorage *storage); GSettings * -gwd_get_org_compiz_gwd_settings (GWDSettingsStorage *storage); +gwd_get_org_compiz_gwd_settings (GWDSettingsStorage *storage); GSettings * -gwd_get_org_gnome_desktop_wm_preferences_settings (GWDSettingsStorage *storage); +gwd_get_org_gnome_desktop_wm_preferences_settings (GWDSettingsStorage *storage); GSettings * -gwd_get_org_gnome_metacity_settings (GWDSettingsStorage *storage); +gwd_get_org_gnome_metacity_settings (GWDSettingsStorage *storage); GSettings * -gwd_get_org_mate_marco_general_settings (GWDSettingsStorage *storage); +gwd_get_org_mate_marco_general_settings (GWDSettingsStorage *storage); G_END_DECLS diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-writable-interface.c compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-writable-interface.c --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-writable-interface.c 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-writable-interface.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,137 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Authored By: Sam Spilsbury - */ -#include "gwd-settings-writable-interface.h" - -static void gwd_settings_writable_interface_default_init (GWDSettingsWritableInterface *settings_interface); - -G_DEFINE_INTERFACE (GWDSettingsWritable, gwd_settings_writable_interface, G_TYPE_OBJECT); - -static void gwd_settings_writable_interface_default_init (GWDSettingsWritableInterface *settings_interface) -{ -} - -void -gwd_settings_writable_freeze_updates (GWDSettingsWritable *settings) -{ - GWDSettingsWritableInterface *iface = GWD_SETTINGS_WRITABLE_GET_INTERFACE (settings); - (*iface->freeze_updates) (settings); -} - -void -gwd_settings_writable_thaw_updates (GWDSettingsWritable *settings) -{ - GWDSettingsWritableInterface *iface = GWD_SETTINGS_WRITABLE_GET_INTERFACE (settings); - (*iface->thaw_updates) (settings); -} - -gboolean -gwd_settings_writable_shadow_property_changed (GWDSettingsWritable *settings, - gdouble active_shadow_radius, - gdouble active_shadow_opacity, - gdouble active_shadow_offset_x, - gdouble active_shadow_offset_y, - const gchar *active_shadow_color, - gdouble inactive_shadow_radius, - gdouble inactive_shadow_opacity, - gdouble inactive_shadow_offset_x, - gdouble inactive_shadow_offset_y, - const gchar *inactive_shadow_color) -{ - GWDSettingsWritableInterface *iface = GWD_SETTINGS_WRITABLE_GET_INTERFACE (settings); - return (*iface->shadow_property_changed) (settings, - active_shadow_radius, - active_shadow_opacity, - active_shadow_offset_x, - active_shadow_offset_y, - active_shadow_color, - inactive_shadow_radius, - inactive_shadow_opacity, - inactive_shadow_offset_x, - inactive_shadow_offset_y, - inactive_shadow_color); -} - -gboolean -gwd_settings_writable_use_tooltips_changed (GWDSettingsWritable *settings, - gboolean use_tooltips) -{ - GWDSettingsWritableInterface *iface = GWD_SETTINGS_WRITABLE_GET_INTERFACE (settings); - return (*iface->use_tooltips_changed) (settings, use_tooltips); -} - -gboolean -gwd_settings_writable_blur_changed (GWDSettingsWritable *settings, - const gchar *blur_type) -{ - GWDSettingsWritableInterface *iface = GWD_SETTINGS_WRITABLE_GET_INTERFACE (settings); - return (*iface->blur_changed) (settings, blur_type); -} - -gboolean -gwd_settings_writable_metacity_theme_changed (GWDSettingsWritable *settings, - gboolean use_metacity_theme, - const gchar *metacity_theme) -{ - GWDSettingsWritableInterface *iface = GWD_SETTINGS_WRITABLE_GET_INTERFACE (settings); - return (*iface->metacity_theme_changed) (settings, use_metacity_theme, metacity_theme); -} - -gboolean -gwd_settings_writable_opacity_changed (GWDSettingsWritable *settings, - gdouble active_opacity, - gdouble inactive_opacity, - gboolean active_shade_opacity, - gboolean inactive_shade_opacity) -{ - GWDSettingsWritableInterface *iface = GWD_SETTINGS_WRITABLE_GET_INTERFACE (settings); - return (*iface->opacity_changed) (settings, active_opacity, inactive_opacity, active_shade_opacity, inactive_shade_opacity); -} - -gboolean -gwd_settings_writable_button_layout_changed (GWDSettingsWritable *settings, - const gchar *button_layout) -{ - GWDSettingsWritableInterface *iface = GWD_SETTINGS_WRITABLE_GET_INTERFACE (settings); - return (*iface->button_layout_changed) (settings, button_layout); -} - -gboolean -gwd_settings_writable_font_changed (GWDSettingsWritable *settings, - gboolean titlebar_uses_system_font, - const gchar *titlebar_font) -{ - GWDSettingsWritableInterface *iface = GWD_SETTINGS_WRITABLE_GET_INTERFACE (settings); - return (*iface->font_changed) (settings, titlebar_uses_system_font, titlebar_font); -} - -gboolean -gwd_settings_writable_titlebar_actions_changed (GWDSettingsWritable *settings, - const gchar *action_double_click_titlebar, - const gchar *action_middle_click_titlebar, - const gchar *action_right_click_titlebar, - const gchar *mouse_wheel_action) -{ - GWDSettingsWritableInterface *iface = GWD_SETTINGS_WRITABLE_GET_INTERFACE (settings); - return (*iface->titlebar_actions_changed) (settings, - action_double_click_titlebar, - action_middle_click_titlebar, - action_right_click_titlebar, - mouse_wheel_action); -} diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-writable-interface.h compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-writable-interface.h --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-writable-interface.h 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-writable-interface.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,138 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Authored By: Sam Spilsbury - */ -#ifndef _COMPIZ_GWD_SETTINGS_WRITABLE_INTERFACE_H -#define _COMPIZ_GWD_SETTINGS_WRITABLE_INTERFACE_H - -#include -#include - -G_BEGIN_DECLS - -#define GWD_SETTINGS_WRITABLE_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ - GWD_TYPE_WRITABLE_SETTINGS_INTERFACE, \ - GWDSettingsWritable)) -#define GWD_SETTINGS_WRITABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE (obj, \ - GWD_TYPE_WRITABLE_SETTINGS_INTERFACE, \ - GWDSettingsWritableInterface)) -#define GWD_TYPE_WRITABLE_SETTINGS_INTERFACE (gwd_settings_writable_interface_get_type ()) - -typedef struct _GWDSettingsWritableInterface GWDSettingsWritableInterface; - -struct _GWDSettingsWritableInterface -{ - GTypeInterface parent; - - void (*freeze_updates) (GWDSettingsWritable *settings); - void (*thaw_updates) (GWDSettingsWritable *settings); - gboolean (*shadow_property_changed) (GWDSettingsWritable *settings, - gdouble active_shadow_radius, - gdouble active_shadow_opacity, - gdouble active_shadow_offset_x, - gdouble active_shadow_offset_y, - const gchar *active_shadow_color, - gdouble inactive_shadow_radius, - gdouble inactive_shadow_opacity, - gdouble inactive_shadow_offset_x, - gdouble inactive_shadow_offset_y, - const gchar *inactive_shadow_color); - gboolean (*use_tooltips_changed) (GWDSettingsWritable *settings, - gboolean new_value); - gboolean (*blur_changed) (GWDSettingsWritable *settings, - const gchar *type); - gboolean (*metacity_theme_changed) (GWDSettingsWritable *settings, - gboolean use_metacity_theme, - const gchar *metacity_theme); - gboolean (*opacity_changed) (GWDSettingsWritable *settings, - gdouble active_opacity, - gdouble inactive_opacity, - gboolean active_shade_opacity, - gboolean inactive_shade_opacity); - gboolean (*button_layout_changed) (GWDSettingsWritable *settings, - const gchar *button_layout); - gboolean (*font_changed) (GWDSettingsWritable *settings, - gboolean titlebar_uses_system_font, - const gchar *titlebar_font); - gboolean (*titlebar_actions_changed) (GWDSettingsWritable *settings, - const gchar *action_double_click_titlebar, - const gchar *action_middle_click_titlebar, - const gchar *action_right_click_titlebar, - const gchar *mouse_wheel_action); -}; - -void -gwd_settings_writable_freeze_updates (GWDSettingsWritable *settings); - -void -gwd_settings_writable_thaw_updates (GWDSettingsWritable *settings); - -gboolean -gwd_settings_writable_shadow_property_changed (GWDSettingsWritable *settings, - gdouble active_shadow_radius, - gdouble active_shadow_opacity, - gdouble active_shadow_offset_x, - gdouble active_shadow_offset_y, - const gchar *active_shadow_color, - gdouble inactive_shadow_radius, - gdouble inactive_shadow_opacity, - gdouble inactive_shadow_offset_x, - gdouble inactive_shadow_offset_y, - const gchar *inactive_shadow_color); - -gboolean -gwd_settings_writable_use_tooltips_changed (GWDSettingsWritable *settings, - gboolean use_tooltips); - -gboolean -gwd_settings_writable_blur_changed (GWDSettingsWritable *settings, - const gchar *blur_type); - -gboolean -gwd_settings_writable_metacity_theme_changed (GWDSettingsWritable *settings, - gboolean use_metacity_theme, - const gchar *metacity_theme); - -gboolean -gwd_settings_writable_opacity_changed (GWDSettingsWritable *settings, - gdouble active_opacity, - gdouble inactive_opacity, - gboolean active_shade_opacity, - gboolean inactive_shade_opacity); - -gboolean -gwd_settings_writable_button_layout_changed (GWDSettingsWritable *settings, - const gchar *button_layout); - -gboolean -gwd_settings_writable_font_changed (GWDSettingsWritable *settings, - gboolean titlebar_uses_system_font, - const gchar *titlebar_font); - -gboolean -gwd_settings_writable_titlebar_actions_changed (GWDSettingsWritable *settings, - const gchar *action_double_click_titlebar, - const gchar *action_middle_click_titlebar, - const gchar *action_right_click_titlebar, - const gchar *mouse_wheel_action); - -GType gwd_settings_writable_interface_get_type (void); - -G_END_DECLS - -#endif diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-xproperty-storage.c compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-xproperty-storage.c --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-xproperty-storage.c 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-xproperty-storage.c 2016-05-25 14:20:26.000000000 +0000 @@ -22,24 +22,24 @@ #include #include "gtk-window-decorator.h" -#include "gwd-settings-writable-interface.h" +#include "gwd-settings.h" #include "gwd-settings-xproperty-storage.h" struct _GWDSettingsXPropertyStorage { - GObject parent; + GObject parent; - GWDSettingsWritable *writable; + GWDSettings *settings; - Display *xdpy; - Window root; + Display *xdpy; + Window root; }; enum { PROP_0, - PROP_WRITABLE_SETTINGS, + PROP_SETTINGS, LAST_PROP }; @@ -56,7 +56,7 @@ storage = GWD_SETTINGS_XPROPERTY_STORAGE (object); - g_clear_object (&storage->writable); + g_clear_object (&storage->settings); G_OBJECT_CLASS (gwd_settings_xproperty_storage_parent_class)->dispose (object); } @@ -72,9 +72,9 @@ storage = GWD_SETTINGS_XPROPERTY_STORAGE (object); switch (property_id) { - case PROP_WRITABLE_SETTINGS: - g_return_if_fail (!storage->writable); - storage->writable = g_value_dup_object (value); + case PROP_SETTINGS: + g_return_if_fail (!storage->settings); + storage->settings = g_value_dup_object (value); break; default: @@ -93,10 +93,9 @@ object_class->dispose = gwd_settings_xproperty_storage_dispose; object_class->set_property = gwd_settings_xproperty_storage_set_property; - storage_properties[PROP_WRITABLE_SETTINGS] = - g_param_spec_object ("writable-settings", "GWDSettingsWritable", - "An object that implements GWDSettingsWritable", - GWD_TYPE_WRITABLE_SETTINGS_INTERFACE, + storage_properties[PROP_SETTINGS] = + g_param_spec_object ("settings", "GWDSettings", "GWDSettings", + GWD_TYPE_SETTINGS, G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS); @@ -116,10 +115,10 @@ } GWDSettingsXPropertyStorage * -gwd_settings_xproperty_storage_new (GWDSettingsWritable *writable) +gwd_settings_xproperty_storage_new (GWDSettings *settings) { return g_object_new (GWD_TYPE_SETTINGS_XPROPERTY_STORAGE, - "writable-settings", writable, + "settings", settings, NULL); } @@ -201,15 +200,15 @@ } } - return gwd_settings_writable_shadow_property_changed (storage->writable, - (gdouble) MAX (0.0, MIN (aradius, 48.0)), - (gdouble) MAX (0.0, MIN (aopacity, 6.0)), - (gdouble) MAX (-16, MIN (ax_off, 16)), - (gdouble) MAX (-16, MIN (ay_off, 16)), - active_shadow_color, - (gdouble) MAX (0.0, MIN (iradius, 48.0)), - (gdouble) MAX (0.0, MIN (iopacity, 6.0)), - (gdouble) MAX (-16, MIN (ix_off, 16)), - (gdouble) MAX (-16, MIN (iy_off, 16)), - inactive_shadow_color); + return gwd_settings_shadow_property_changed (storage->settings, + (gdouble) MAX (0.0, MIN (aradius, 48.0)), + (gdouble) MAX (0.0, MIN (aopacity, 6.0)), + (gdouble) MAX (-16, MIN (ax_off, 16)), + (gdouble) MAX (-16, MIN (ay_off, 16)), + active_shadow_color, + (gdouble) MAX (0.0, MIN (iradius, 48.0)), + (gdouble) MAX (0.0, MIN (iopacity, 6.0)), + (gdouble) MAX (-16, MIN (ix_off, 16)), + (gdouble) MAX (-16, MIN (iy_off, 16)), + inactive_shadow_color); } diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-xproperty-storage.h compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-xproperty-storage.h --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-settings-xproperty-storage.h 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-settings-xproperty-storage.h 2016-05-25 14:20:26.000000000 +0000 @@ -22,6 +22,7 @@ #define GWD_SETTINGS_XPROPERTY_STORAGE_H #include +#include G_BEGIN_DECLS @@ -30,7 +31,7 @@ GWD, SETTINGS_XPROPERTY_STORAGE, GObject) GWDSettingsXPropertyStorage * -gwd_settings_xproperty_storage_new (GWDSettingsWritable *writable); +gwd_settings_xproperty_storage_new (GWDSettings *settings); gboolean gwd_settings_xproperty_storage_update_all (GWDSettingsXPropertyStorage *storage); diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-theme.c compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-theme.c --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-theme.c 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-theme.c 2016-05-25 14:20:18.000000000 +0000 @@ -0,0 +1,323 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */ + +/* + * Copyright (C) 2016 Alberts Muktupāvels + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "config.h" +#include "gwd-settings.h" +#include "gwd-theme.h" +#include "gwd-theme-cairo.h" + +#ifdef USE_METACITY +#include "gwd-theme-metacity.h" +#endif + +typedef struct +{ + GWDSettings *settings; +} GWDThemePrivate; + +enum +{ + PROP_0, + + PROP_SETTINGS, + + LAST_PROP +}; + +static GParamSpec *properties[LAST_PROP] = { NULL }; + +G_DEFINE_TYPE_WITH_PRIVATE (GWDTheme, gwd_theme, G_TYPE_OBJECT) + +static void +gwd_theme_dispose (GObject *object) +{ + GWDTheme *theme; + GWDThemePrivate *priv; + + theme = GWD_THEME (object); + priv = gwd_theme_get_instance_private (theme); + + g_clear_object (&priv->settings); + + G_OBJECT_CLASS (gwd_theme_parent_class)->dispose (object); +} + +static void +gwd_theme_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + GWDTheme *theme; + GWDThemePrivate *priv; + + theme = GWD_THEME (object); + priv = gwd_theme_get_instance_private (theme); + + switch (property_id) { + case PROP_SETTINGS: + g_value_set_object (value, priv->settings); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +gwd_theme_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GWDTheme *theme; + GWDThemePrivate *priv; + + theme = GWD_THEME (object); + priv = gwd_theme_get_instance_private (theme); + + switch (property_id) { + case PROP_SETTINGS: + priv->settings = g_value_dup_object (value); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +gwd_theme_real_get_shadow (GWDTheme *theme, + decor_frame_t *frame, + decor_shadow_options_t *options, + gboolean active) +{ + GWDThemePrivate *priv; + decor_shadow_options_t *shadow; + + priv = gwd_theme_get_instance_private (theme); + shadow = NULL; + + if (active) + g_object_get (priv->settings, "active-shadow", &shadow, NULL); + else + g_object_get (priv->settings, "inactive-shadow", &shadow, NULL); + + if (shadow) + memcpy (options, shadow, sizeof (decor_shadow_options_t)); +} + +static void +gwd_theme_real_draw_window_decoration (GWDTheme *theme, + decor_t *decor) +{ +} + +static gboolean +gwd_theme_real_calc_decoration_size (GWDTheme *theme, + decor_t *decor, + gint w, + gint h, + gint name_width, + gint *width, + gint *height) +{ + return FALSE; +} + +static void +gwd_theme_real_update_border_extents (GWDTheme *theme, + decor_frame_t *frame) +{ +} + +static void +gwd_theme_real_get_event_window_position (GWDTheme *theme, + decor_t *decor, + gint i, + gint j, + gint width, + gint height, + gint *x, + gint *y, + gint *w, + gint *h) +{ +} + +static gboolean +gwd_theme_real_get_button_position (GWDTheme *theme, + decor_t *decor, + gint i, + gint width, + gint height, + gint *x, + gint *y, + gint *w, + gint *h) +{ + return FALSE; +} + +static gfloat +gwd_theme_real_get_title_scale (GWDTheme *theme, + decor_frame_t *frame) +{ + return 1.0; +} + +static void +gwd_theme_class_init (GWDThemeClass *theme_class) +{ + GObjectClass *object_class; + + object_class = G_OBJECT_CLASS (theme_class); + + object_class->dispose = gwd_theme_dispose; + object_class->get_property = gwd_theme_get_property; + object_class->set_property = gwd_theme_set_property; + + theme_class->get_shadow = gwd_theme_real_get_shadow; + theme_class->draw_window_decoration = gwd_theme_real_draw_window_decoration; + theme_class->calc_decoration_size = gwd_theme_real_calc_decoration_size; + theme_class->update_border_extents = gwd_theme_real_update_border_extents; + theme_class->get_event_window_position = gwd_theme_real_get_event_window_position; + theme_class->get_button_position = gwd_theme_real_get_button_position; + theme_class->get_title_scale = gwd_theme_real_get_title_scale; + + properties[PROP_SETTINGS] = + g_param_spec_object ("settings", "GWDSettings", "GWDSettings", + GWD_TYPE_SETTINGS, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, LAST_PROP, properties); +} + +static void +gwd_theme_init (GWDTheme *theme) +{ +} + +GWDTheme * +gwd_theme_new (GWDThemeType type, + GWDSettings *settings) +{ + GType object_type; + + object_type = GWD_TYPE_THEME_CAIRO; + +#ifdef USE_METACITY + if (type == GWD_THEME_TYPE_METACITY) + object_type = GWD_TYPE_THEME_METACITY; +#endif + + return g_object_new (object_type, + "settings", settings, + NULL); +} + +GWDSettings * +gwd_theme_get_settings (GWDTheme *theme) +{ + GWDThemePrivate *priv; + + priv = gwd_theme_get_instance_private (theme); + + return priv->settings; +} + +void +gwd_theme_get_shadow (GWDTheme *theme, + decor_frame_t *frame, + decor_shadow_options_t *options, + gboolean active) +{ + GWD_THEME_GET_CLASS (theme)->get_shadow (theme, frame, options, active); +} + +void +gwd_theme_draw_window_decoration (GWDTheme *theme, + decor_t *decor) +{ + GWD_THEME_GET_CLASS (theme)->draw_window_decoration (theme, decor); +} + +gboolean +gwd_theme_calc_decoration_size (GWDTheme *theme, + decor_t *decor, + gint w, + gint h, + gint name_width, + gint *width, + gint *height) +{ + return GWD_THEME_GET_CLASS (theme)->calc_decoration_size (theme, decor, + w, h, name_width, + width, height); +} + +void +gwd_theme_update_border_extents (GWDTheme *theme, + decor_frame_t *frame) +{ + GWD_THEME_GET_CLASS (theme)->update_border_extents (theme, frame); +} + +void +gwd_theme_get_event_window_position (GWDTheme *theme, + decor_t *decor, + gint i, + gint j, + gint width, + gint height, + gint *x, + gint *y, + gint *w, + gint *h) +{ + GWD_THEME_GET_CLASS (theme)->get_event_window_position (theme, decor, i, j, + width, height, + x, y, w, h); +} + +gboolean +gwd_theme_get_button_position (GWDTheme *theme, + decor_t *decor, + gint i, + gint width, + gint height, + gint *x, + gint *y, + gint *w, + gint *h) +{ + return GWD_THEME_GET_CLASS (theme)->get_button_position (theme, decor, i, + width, height, + x, y, w, h); +} + +gfloat +gwd_theme_get_title_scale (GWDTheme *theme, + decor_frame_t *frame) +{ + return GWD_THEME_GET_CLASS (theme)->get_title_scale (theme, frame); +} diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-theme-cairo.c compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-theme-cairo.c --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-theme-cairo.c 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-theme-cairo.c 2016-05-25 14:20:10.000000000 +0000 @@ -0,0 +1,823 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */ + +/* + * Copyright (C) 2006 Novell, Inc. + * Copyright (C) 2010 Sam Spilsbury + * Copyright (C) 2011 Canonical Ltd. + * Copyright (C) 2016 Alberts Muktupāvels + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authors: + * Alberts Muktupāvels + * David Reveman + * Sam Spilsbury + */ + +#include "config.h" +#include "gtk-window-decorator.h" +#include "gwd-cairo-window-decoration-util.h" +#include "gwd-theme-cairo.h" + +#define STROKE_ALPHA 0.6f + +struct _GWDThemeCairo +{ + GObject parent; +}; + +G_DEFINE_TYPE (GWDThemeCairo, gwd_theme_cairo, GWD_TYPE_THEME) + +static void +button_state_offsets (gdouble x, + gdouble y, + guint state, + gdouble *return_x, + gdouble *return_y) +{ + static gdouble off[] = { 0.0, 0.0, 0.0, 0.5 }; + + *return_x = x + off[state]; + *return_y = y + off[state]; +} + +static void +button_state_paint (cairo_t *cr, + GtkStyleContext *context, + decor_color_t *color, + guint state) +{ + GdkRGBA fg; + +#define IN_STATE (PRESSED_EVENT_WINDOW | IN_EVENT_WINDOW) + + gtk_style_context_save (context); + gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL); + gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &fg); + gtk_style_context_restore (context); + + fg.alpha = STROKE_ALPHA; + + if ((state & IN_STATE) == IN_STATE) { + if (state & IN_EVENT_WINDOW) + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); + else + cairo_set_source_rgba (cr, color->r, color->g, color->b, 0.95); + + cairo_fill_preserve (cr); + + gdk_cairo_set_source_rgba (cr, &fg); + + cairo_set_line_width (cr, 1.0); + cairo_stroke (cr); + cairo_set_line_width (cr, 2.0); + } else { + gdk_cairo_set_source_rgba (cr, &fg); + cairo_stroke_preserve (cr); + + if (state & IN_EVENT_WINDOW) + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); + else + cairo_set_source_rgba (cr, color->r, color->g, color->b, 0.95); + + cairo_fill (cr); + } +} + +static void +draw_close_button (cairo_t *cr, + gdouble s) +{ + cairo_rel_move_to (cr, 0.0, s); + + cairo_rel_line_to (cr, s, -s); + cairo_rel_line_to (cr, s, s); + cairo_rel_line_to (cr, s, -s); + cairo_rel_line_to (cr, s, s); + + cairo_rel_line_to (cr, -s, s); + cairo_rel_line_to (cr, s, s); + cairo_rel_line_to (cr, -s, s); + cairo_rel_line_to (cr, -s, -s); + + cairo_rel_line_to (cr, -s, s); + cairo_rel_line_to (cr, -s, -s); + cairo_rel_line_to (cr, s, -s); + + cairo_close_path (cr); +} + +static void +draw_max_button (cairo_t *cr, + gdouble s) +{ + cairo_rel_line_to (cr, 12.0, 0.0); + cairo_rel_line_to (cr, 0.0, 12.0); + cairo_rel_line_to (cr, -12.0, 0.0); + + cairo_close_path (cr); + + cairo_rel_move_to (cr, 2.0, s); + + cairo_rel_line_to (cr, 12.0 - 4.0, 0.0); + cairo_rel_line_to (cr, 0.0, 12.0 - s - 2.0); + cairo_rel_line_to (cr, -(12.0 - 4.0), 0.0); + + cairo_close_path (cr); +} + +static void +draw_unmax_button (cairo_t *cr, + gdouble s) +{ + cairo_rel_move_to (cr, 1.0, 1.0); + + cairo_rel_line_to (cr, 10.0, 0.0); + cairo_rel_line_to (cr, 0.0, 10.0); + cairo_rel_line_to (cr, -10.0, 0.0); + + cairo_close_path (cr); + + cairo_rel_move_to (cr, 2.0, s); + + cairo_rel_line_to (cr, 10.0 - 4.0, 0.0); + cairo_rel_line_to (cr, 0.0, 10.0 - s - 2.0); + cairo_rel_line_to (cr, -(10.0 - 4.0), 0.0); + + cairo_close_path (cr); +} + +static void +draw_min_button (cairo_t *cr, + gdouble s) +{ + cairo_rel_move_to (cr, 0.0, 8.0); + + cairo_rel_line_to (cr, 12.0, 0.0); + cairo_rel_line_to (cr, 0.0, s); + cairo_rel_line_to (cr, -12.0, 0.0); + + cairo_close_path (cr); +} + +static void +calc_button_size (decor_t *decor) +{ + gint button_width = 0; + + if (decor->actions & WNCK_WINDOW_ACTION_CLOSE) + button_width += 17; + + if (decor->actions & (WNCK_WINDOW_ACTION_MAXIMIZE_HORIZONTALLY | + WNCK_WINDOW_ACTION_MAXIMIZE_VERTICALLY | + WNCK_WINDOW_ACTION_UNMAXIMIZE_HORIZONTALLY | + WNCK_WINDOW_ACTION_UNMAXIMIZE_VERTICALLY)) + button_width += 17; + + if (decor->actions & WNCK_WINDOW_ACTION_MINIMIZE) + button_width += 17; + + if (button_width) + ++button_width; + + decor->button_width = button_width; +} + +static gboolean +button_present (decor_t *decor, + gint i) +{ + switch (i) { + case BUTTON_MIN: + if (decor->actions & WNCK_WINDOW_ACTION_MINIMIZE) + return TRUE; + break; + + case BUTTON_MAX: + if (decor->actions & WNCK_WINDOW_ACTION_MAXIMIZE) + return TRUE; + break; + + case BUTTON_CLOSE: + if (decor->actions & WNCK_WINDOW_ACTION_CLOSE) + return TRUE; + break; + + case BUTTON_MENU: + case BUTTON_SHADE: + case BUTTON_ABOVE: + case BUTTON_STICK: + case BUTTON_UNSHADE: + case BUTTON_UNABOVE: + case BUTTON_UNSTICK: + break; + + default: + break; + } + + return FALSE; +} + +static void +gwd_theme_cairo_draw_window_decoration (GWDTheme *theme, + decor_t *decor) +{ + cairo_t *cr; + GtkStyleContext *context; + GdkRGBA bg, fg; + cairo_surface_t *surface; + decor_color_t color; + gdouble alpha; + gdouble x1, y1, x2, y2, x, y, h; + gint corners = SHADE_LEFT | SHADE_RIGHT | SHADE_TOP | SHADE_BOTTOM; + gint top; + gint button_x; + + if (!decor->surface) + return; + + context = gtk_widget_get_style_context (decor->frame->style_window_rgba); + + gtk_style_context_save (context); + gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL); + gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg); + gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &fg); + gtk_style_context_restore (context); + + if (decor->state & (WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY | + WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY)) + corners = 0; + + color.r = bg.red; + color.g = bg.green; + color.b = bg.blue; + + if (decor->buffer_surface) + surface = decor->buffer_surface; + else + surface = decor->surface; + + cr = cairo_create (surface); + + if (!cr) + return; + + cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); + + top = decor->frame->win_extents.top + decor->frame->titlebar_height; + + x1 = decor->context->left_space - decor->frame->win_extents.left; + y1 = decor->context->top_space - decor->frame->win_extents.top - decor->frame->titlebar_height; + x2 = decor->width - decor->context->right_space + decor->frame->win_extents.right; + y2 = decor->height - decor->context->bottom_space + decor->frame->win_extents.bottom; + + h = decor->height - decor->context->top_space - decor->context->bottom_space; + + cairo_set_line_width (cr, 1.0); + + if (!decor->frame_window) + draw_shadow_background (decor, cr, decor->shadow, decor->context); + + if (decor->active) { + decor_color_t *title_color = _title_color; + + alpha = decoration_alpha + 0.3; + + fill_rounded_rectangle (cr, + x1 + 0.5, + y1 + 0.5, + decor->frame->win_extents.left - 0.5, + top - 0.5, + 5.0, CORNER_TOPLEFT & corners, + &title_color[0], 1.0, &title_color[1], alpha, + SHADE_TOP | SHADE_LEFT); + + fill_rounded_rectangle (cr, + x1 + decor->frame->win_extents.left, + y1 + 0.5, + x2 - x1 - decor->frame->win_extents.left - + decor->frame->win_extents.right, + top - 0.5, + 5.0, 0, + &title_color[0], 1.0, &title_color[1], alpha, + SHADE_TOP); + + fill_rounded_rectangle (cr, + x2 - decor->frame->win_extents.right, + y1 + 0.5, + decor->frame->win_extents.right - 0.5, + top - 0.5, + 5.0, CORNER_TOPRIGHT & corners, + &title_color[0], 1.0, &title_color[1], alpha, + SHADE_TOP | SHADE_RIGHT); + } else { + alpha = decoration_alpha; + + fill_rounded_rectangle (cr, + x1 + 0.5, + y1 + 0.5, + decor->frame->win_extents.left - 0.5, + top - 0.5, + 5.0, CORNER_TOPLEFT & corners, + &color, 1.0, &color, alpha, + SHADE_TOP | SHADE_LEFT); + + fill_rounded_rectangle (cr, + x1 + decor->frame->win_extents.left, + y1 + 0.5, + x2 - x1 - decor->frame->win_extents.left - + decor->frame->win_extents.right, + top - 0.5, + 5.0, 0, + &color, 1.0, &color, alpha, + SHADE_TOP); + + fill_rounded_rectangle (cr, + x2 - decor->frame->win_extents.right, + y1 + 0.5, + decor->frame->win_extents.right - 0.5, + top - 0.5, + 5.0, CORNER_TOPRIGHT & corners, + &color, 1.0, &color, alpha, + SHADE_TOP | SHADE_RIGHT); + } + + fill_rounded_rectangle (cr, + x1 + 0.5, + y1 + top, + decor->frame->win_extents.left - 0.5, + h, + 5.0, 0, + &color, 1.0, &color, alpha, + SHADE_LEFT); + + fill_rounded_rectangle (cr, + x2 - decor->frame->win_extents.right, + y1 + top, + decor->frame->win_extents.right - 0.5, + h, + 5.0, 0, + &color, 1.0, &color, alpha, + SHADE_RIGHT); + + + fill_rounded_rectangle (cr, + x1 + 0.5, + y2 - decor->frame->win_extents.bottom, + decor->frame->win_extents.left - 0.5, + decor->frame->win_extents.bottom - 0.5, + 5.0, CORNER_BOTTOMLEFT & corners, + &color, 1.0, &color, alpha, + SHADE_BOTTOM | SHADE_LEFT); + + fill_rounded_rectangle (cr, + x1 + decor->frame->win_extents.left, + y2 - decor->frame->win_extents.bottom, + x2 - x1 - decor->frame->win_extents.left - + decor->frame->win_extents.right, + decor->frame->win_extents.bottom - 0.5, + 5.0, 0, + &color, 1.0, &color, alpha, + SHADE_BOTTOM); + + fill_rounded_rectangle (cr, + x2 - decor->frame->win_extents.right, + y2 - decor->frame->win_extents.bottom, + decor->frame->win_extents.right - 0.5, + decor->frame->win_extents.bottom - 0.5, + 5.0, CORNER_BOTTOMRIGHT & corners, + &color, 1.0, &color, alpha, + SHADE_BOTTOM | SHADE_RIGHT); + + cairo_rectangle (cr, + decor->context->left_space, + decor->context->top_space, + decor->width - decor->context->left_space - + decor->context->right_space, + h); + gdk_cairo_set_source_rgba (cr, &bg); + cairo_fill (cr); + + cairo_set_operator (cr, CAIRO_OPERATOR_OVER); + + if (decor->active) { + fg.alpha = 0.7; + gdk_cairo_set_source_rgba (cr, &fg); + + cairo_move_to (cr, x1 + 0.5, y1 + top - 0.5); + cairo_rel_line_to (cr, x2 - x1 - 1.0, 0.0); + + cairo_stroke (cr); + } + + rounded_rectangle (cr, + x1 + 0.5, y1 + 0.5, + x2 - x1 - 1.0, y2 - y1 - 1.0, + 5.0, + (CORNER_TOPLEFT | CORNER_TOPRIGHT | CORNER_BOTTOMLEFT | + CORNER_BOTTOMRIGHT) & corners); + + cairo_clip (cr); + + cairo_translate (cr, 1.0, 1.0); + + rounded_rectangle (cr, + x1 + 0.5, y1 + 0.5, + x2 - x1 - 1.0, y2 - y1 - 1.0, + 5.0, + (CORNER_TOPLEFT | CORNER_TOPRIGHT | CORNER_BOTTOMLEFT | + CORNER_BOTTOMRIGHT) & corners); + + cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.4); + + cairo_stroke (cr); + + cairo_translate (cr, -2.0, -2.0); + + rounded_rectangle (cr, + x1 + 0.5, y1 + 0.5, + x2 - x1 - 1.0, y2 - y1 - 1.0, + 5.0, + (CORNER_TOPLEFT | CORNER_TOPRIGHT | CORNER_BOTTOMLEFT | + CORNER_BOTTOMRIGHT) & corners); + + cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.1); + + cairo_stroke (cr); + + cairo_translate (cr, 1.0, 1.0); + + cairo_reset_clip (cr); + + rounded_rectangle (cr, + x1 + 0.5, y1 + 0.5, + x2 - x1 - 1.0, y2 - y1 - 1.0, + 5.0, + (CORNER_TOPLEFT | CORNER_TOPRIGHT | CORNER_BOTTOMLEFT | + CORNER_BOTTOMRIGHT) & corners); + + fg.alpha = alpha; + gdk_cairo_set_source_rgba (cr, &fg); + + cairo_stroke (cr); + + cairo_set_line_width (cr, 2.0); + + button_x = decor->width - decor->context->right_space - 13; + + if (decor->actions & WNCK_WINDOW_ACTION_CLOSE) { + button_state_offsets (button_x, + y1 - 3.0 + decor->frame->titlebar_height / 2, + decor->button_states[BUTTON_CLOSE], &x, &y); + + button_x -= 17; + + if (decor->active) { + cairo_move_to (cr, x, y); + draw_close_button (cr, 3.0); + button_state_paint (cr, context, &color, + decor->button_states[BUTTON_CLOSE]); + } else { + fg.alpha = alpha * 0.75; + gdk_cairo_set_source_rgba (cr, &fg); + + cairo_move_to (cr, x, y); + draw_close_button (cr, 3.0); + cairo_fill (cr); + } + } + + if (decor->actions & WNCK_WINDOW_ACTION_MAXIMIZE) { + button_state_offsets (button_x, + y1 - 3.0 + decor->frame->titlebar_height / 2, + decor->button_states[BUTTON_MAX], &x, &y); + + button_x -= 17; + + cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); + + if (decor->active) { + fg.alpha = STROKE_ALPHA; + gdk_cairo_set_source_rgba (cr, &fg); + + cairo_move_to (cr, x, y); + + if (decor->state & (WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY | + WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY)) + draw_unmax_button (cr, 4.0); + else + draw_max_button (cr, 4.0); + + button_state_paint (cr, context, &color, + decor->button_states[BUTTON_MAX]); + } else { + fg.alpha = alpha * 0.75; + gdk_cairo_set_source_rgba (cr, &fg); + + cairo_move_to (cr, x, y); + + if (decor->state & (WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY | + WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY)) + draw_unmax_button (cr, 4.0); + else + draw_max_button (cr, 4.0); + + cairo_fill (cr); + } + } + + if (decor->actions & WNCK_WINDOW_ACTION_MINIMIZE) { + button_state_offsets (button_x, + y1 - 3.0 + decor->frame->titlebar_height / 2, + decor->button_states[BUTTON_MIN], &x, &y); + + button_x -= 17; + + if (decor->active) { + fg.alpha = STROKE_ALPHA; + gdk_cairo_set_source_rgba (cr, &fg); + + cairo_move_to (cr, x, y); + draw_min_button (cr, 4.0); + button_state_paint (cr, context, &color, + decor->button_states[BUTTON_MIN]); + } else { + fg.alpha = alpha * 0.75; + gdk_cairo_set_source_rgba (cr, &fg); + + cairo_move_to (cr, x, y); + draw_min_button (cr, 4.0); + cairo_fill (cr); + } + } + + if (decor->layout) { + if (decor->active) { + cairo_move_to (cr, + decor->context->left_space + 21.0, + y1 + 2.0 + (decor->frame->titlebar_height - decor->frame->text_height) / 2.0); + + fg.alpha = STROKE_ALPHA; + gdk_cairo_set_source_rgba (cr, &fg); + + pango_cairo_layout_path (cr, decor->layout); + cairo_stroke (cr); + + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); + } else { + fg.alpha = alpha; + gdk_cairo_set_source_rgba (cr, &fg); + } + + cairo_move_to (cr, + decor->context->left_space + 21.0, + y1 + 2.0 + (decor->frame->titlebar_height - decor->frame->text_height) / 2.0); + + pango_cairo_show_layout (cr, decor->layout); + } + + if (decor->icon) { + cairo_translate (cr, + decor->context->left_space + 1, + y1 - 5.0 + decor->frame->titlebar_height / 2); + cairo_set_source (cr, decor->icon); + cairo_rectangle (cr, 0.0, 0.0, 16.0, 16.0); + cairo_clip (cr); + + if (decor->active) + cairo_paint (cr); + else + cairo_paint_with_alpha (cr, alpha); + } + + cairo_destroy (cr); + + copy_to_front_buffer (decor); + + if (decor->frame_window) { + GdkWindow *gdk_frame_window = gtk_widget_get_window (decor->decor_window); + GdkPixbuf *pixbuf = gdk_pixbuf_get_from_surface (decor->surface, 0, 0, + decor->width, decor->height); + + gtk_image_set_from_pixbuf (GTK_IMAGE (decor->decor_image), pixbuf); + g_object_unref (pixbuf); + + gtk_window_resize (GTK_WINDOW (decor->decor_window), decor->width, decor->height); + gdk_window_move (gdk_frame_window, 0, 0); + gdk_window_lower (gdk_frame_window); + } + + if (decor->prop_xid) { + decor_update_window_property (decor); + decor->prop_xid = 0; + } +} + +static gboolean +gwd_theme_cairo_calc_decoration_size (GWDTheme *theme, + decor_t *decor, + gint w, + gint h, + gint name_width, + gint *width, + gint *height) +{ + decor_layout_t layout; + gint top_width; + + if (!decor->decorated) + return FALSE; + + /* To avoid wasting texture memory, we only calculate the minimal + * required decoration size then clip and stretch the texture where + * appropriate + */ + + if (!decor->frame_window) { + calc_button_size (decor); + + if (w < ICON_SPACE + decor->button_width) + return FALSE; + + top_width = name_width + decor->button_width + ICON_SPACE; + if (w < top_width) + top_width = MAX (ICON_SPACE + decor->button_width, w); + + if (decor->active) + decor_get_default_layout (&decor->frame->window_context_active, top_width, 1, &layout); + else + decor_get_default_layout (&decor->frame->window_context_inactive, top_width, 1, &layout); + + if (!decor->context || memcmp (&layout, &decor->border_layout, sizeof (layout))) { + *width = layout.width; + *height = layout.height; + + decor->border_layout = layout; + if (decor->active) { + decor->context = &decor->frame->window_context_active; + decor->shadow = decor->frame->border_shadow_active; + } else { + decor->context = &decor->frame->window_context_inactive; + decor->shadow = decor->frame->border_shadow_inactive; + } + + return TRUE; + } + } else { + calc_button_size (decor); + + /* _default_win_extents + top height */ + + top_width = name_width + decor->button_width + ICON_SPACE; + if (w < top_width) + top_width = MAX (ICON_SPACE + decor->button_width, w); + + decor_get_default_layout (&decor->frame->window_context_no_shadow, + decor->client_width, decor->client_height, + &layout); + + *width = layout.width; + *height = layout.height; + + decor->border_layout = layout; + if (decor->active) { + decor->context = &decor->frame->window_context_active; + decor->shadow = decor->frame->border_shadow_active; + } else { + decor->context = &decor->frame->window_context_inactive; + decor->shadow = decor->frame->border_shadow_inactive; + } + + return TRUE; + } + + return FALSE; +} + +static void +gwd_theme_cairo_update_border_extents (GWDTheme *theme, + decor_frame_t *frame) +{ + frame = gwd_decor_frame_ref (frame); + + gwd_cairo_window_decoration_get_extents (&frame->win_extents, + &frame->max_win_extents); + + frame->titlebar_height = frame->max_titlebar_height = + (frame->text_height < 17) ? 17 : frame->text_height; + + gwd_decor_frame_unref (frame); +} + +static void +gwd_theme_cairo_get_event_window_position (GWDTheme *theme, + decor_t *decor, + gint i, + gint j, + gint width, + gint height, + gint *x, + gint *y, + gint *w, + gint *h) +{ + if (decor->frame_window) { + *x = pos[i][j].x + pos[i][j].xw * width + decor->frame->win_extents.left; + *y = pos[i][j].y + decor->frame->win_extents.top + + pos[i][j].yh * height + pos[i][j].yth * (decor->frame->titlebar_height - 17); + + if (i == 0 && (j == 0 || j == 2)) + *y -= decor->frame->titlebar_height; + } else { + *x = pos[i][j].x + pos[i][j].xw * width; + *y = pos[i][j].y + + pos[i][j].yh * height + pos[i][j].yth * (decor->frame->titlebar_height - 17); + } + + if ((decor->state & WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY) && (j == 0 || j == 2)) { + *w = 0; + } else { + *w = pos[i][j].w + pos[i][j].ww * width; + } + + if ((decor->state & WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY) && (i == 0 || i == 2)) { + *h = 0; + } else { + *h = pos[i][j].h + + pos[i][j].hh * height + pos[i][j].hth * (decor->frame->titlebar_height - 17); + } +} + +static gboolean +gwd_theme_cairo_get_button_position (GWDTheme *theme, + decor_t *decor, + gint i, + gint width, + gint height, + gint *x, + gint *y, + gint *w, + gint *h) +{ + if (i > BUTTON_MENU) + return FALSE; + + if (decor->frame_window) { + *x = bpos[i].x + bpos[i].xw * width + decor->frame->win_extents.left + 4; + *y = bpos[i].y + bpos[i].yh * height + bpos[i].yth * + (decor->frame->titlebar_height - 17) + decor->frame->win_extents.top + 2; + } else { + *x = bpos[i].x + bpos[i].xw * width; + *y = bpos[i].y + bpos[i].yh * height + bpos[i].yth * + (decor->frame->titlebar_height - 17); + } + + *w = bpos[i].w + bpos[i].ww * width; + *h = bpos[i].h + bpos[i].hh * height + bpos[i].hth + + (decor->frame->titlebar_height - 17); + + /* hack to position multiple buttons on the right */ + if (i != BUTTON_MENU) { + gint position = 0; + gint button = 0; + + while (button != i) { + if (button_present (decor, button)) + position++; + button++; + } + + *x -= 10 + 16 * position; + } + + return TRUE; +} + +static void +gwd_theme_cairo_class_init (GWDThemeCairoClass *cairo_class) +{ + GWDThemeClass *theme_class = GWD_THEME_CLASS (cairo_class); + + theme_class->draw_window_decoration = gwd_theme_cairo_draw_window_decoration; + theme_class->calc_decoration_size = gwd_theme_cairo_calc_decoration_size; + theme_class->update_border_extents = gwd_theme_cairo_update_border_extents; + theme_class->get_event_window_position = gwd_theme_cairo_get_event_window_position; + theme_class->get_button_position = gwd_theme_cairo_get_button_position; +} + +static void +gwd_theme_cairo_init (GWDThemeCairo *cairo) +{ +} diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-theme-cairo.h compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-theme-cairo.h --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-theme-cairo.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-theme-cairo.h 2016-05-25 14:19:20.000000000 +0000 @@ -0,0 +1,33 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */ + +/* + * Copyright (C) 2016 Alberts Muktupāvels + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GWD_THEME_CAIRO_H +#define GWD_THEME_CAIRO_H + +#include "gwd-theme.h" + +G_BEGIN_DECLS + +#define GWD_TYPE_THEME_CAIRO gwd_theme_cairo_get_type () +G_DECLARE_FINAL_TYPE (GWDThemeCairo, gwd_theme_cairo, + GWD, THEME_CAIRO, GWDTheme) + +G_END_DECLS + +#endif diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-theme.h compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-theme.h --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-theme.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-theme.h 2016-05-25 14:20:18.000000000 +0000 @@ -0,0 +1,148 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */ + +/* + * Copyright (C) 2016 Alberts Muktupāvels + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GWD_THEME_H +#define GWD_THEME_H + +#include +#include + +G_BEGIN_DECLS + +typedef struct _decor decor_t; +typedef struct _decor_frame decor_frame_t; +typedef struct _GWDSettings GWDSettings; + +#define GWD_TYPE_THEME gwd_theme_get_type () +G_DECLARE_DERIVABLE_TYPE (GWDTheme, gwd_theme, GWD, THEME, GObject) + +struct _GWDThemeClass +{ + GObjectClass parent_class; + + void (* get_shadow) (GWDTheme *theme, + decor_frame_t *frame, + decor_shadow_options_t *options, + gboolean active); + + void (* draw_window_decoration) (GWDTheme *theme, + decor_t *decor); + + gboolean (* calc_decoration_size) (GWDTheme *theme, + decor_t *decor, + gint w, + gint h, + gint name_width, + gint *width, + gint *height); + + void (* update_border_extents) (GWDTheme *theme, + decor_frame_t *frame); + + void (* get_event_window_position) (GWDTheme *theme, + decor_t *decor, + gint i, + gint j, + gint width, + gint height, + gint *x, + gint *y, + gint *w, + gint *h); + + gboolean (* get_button_position) (GWDTheme *theme, + decor_t *decor, + gint i, + gint width, + gint height, + gint *x, + gint *y, + gint *w, + gint *h); + + gfloat (* get_title_scale) (GWDTheme *theme, + decor_frame_t *frame); +}; + +typedef enum +{ + GWD_THEME_TYPE_CAIRO, + GWD_THEME_TYPE_METACITY +} GWDThemeType; + +GWDTheme * +gwd_theme_new (GWDThemeType type, + GWDSettings *settings); + +GWDSettings * +gwd_theme_get_settings (GWDTheme *theme); + +void +gwd_theme_get_shadow (GWDTheme *theme, + decor_frame_t *frame, + decor_shadow_options_t *options, + gboolean active); + +void +gwd_theme_draw_window_decoration (GWDTheme *theme, + decor_t *decor); + +gboolean +gwd_theme_calc_decoration_size (GWDTheme *theme, + decor_t *decor, + gint w, + gint h, + gint name_width, + gint *width, + gint *height); + +void +gwd_theme_update_border_extents (GWDTheme *theme, + decor_frame_t *frame); + +void +gwd_theme_get_event_window_position (GWDTheme *theme, + decor_t *decor, + gint i, + gint j, + gint width, + gint height, + gint *x, + gint *y, + gint *w, + gint *h); + +gboolean +gwd_theme_get_button_position (GWDTheme *theme, + decor_t *decor, + gint i, + gint width, + gint height, + gint *x, + gint *y, + gint *w, + gint *h); + +gfloat +gwd_theme_get_title_scale (GWDTheme *theme, + decor_frame_t *frame); + +G_END_DECLS + +#endif diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-theme-metacity.c compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-theme-metacity.c --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-theme-metacity.c 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-theme-metacity.c 2016-05-25 14:20:33.000000000 +0000 @@ -0,0 +1,1519 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */ + +/* + * Copyright (C) 2006 Novell, Inc. + * Copyright (C) 2010 Sam Spilsbury + * Copyright (C) 2011 Canonical Ltd. + * Copyright (C) 2016 Alberts Muktupāvels + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * Authors: + * Alberts Muktupāvels + * David Reveman + * Sam Spilsbury + */ + +#include "config.h" + +#include "gtk-window-decorator.h" +#include "gwd-settings.h" +#include "gwd-theme-metacity.h" + +struct _GWDThemeMetacity +{ + GObject parent; + + MetaTheme *theme; + + MetaButtonLayout button_layout; +}; + +G_DEFINE_TYPE (GWDThemeMetacity, gwd_theme_metacity, GWD_TYPE_THEME) + +static void +initialize_button_layout (MetaButtonLayout *layout) +{ + gint i; + + for (i = 0; i < MAX_BUTTONS_PER_CORNER; ++i) { + layout->left_buttons[i] = META_BUTTON_FUNCTION_LAST; + layout->right_buttons[i] = META_BUTTON_FUNCTION_LAST; + layout->left_buttons_has_spacer[i] = FALSE; + layout->right_buttons_has_spacer[i] = FALSE; + } +} + +static MetaButtonFunction +meta_button_function_from_string (const char *str) +{ + if (strcmp (str, "menu") == 0) + return META_BUTTON_FUNCTION_MENU; + else if (strcmp (str, "appmenu") == 0) + return META_BUTTON_FUNCTION_APPMENU; + else if (strcmp (str, "minimize") == 0) + return META_BUTTON_FUNCTION_MINIMIZE; + else if (strcmp (str, "maximize") == 0) + return META_BUTTON_FUNCTION_MAXIMIZE; + else if (strcmp (str, "close") == 0) + return META_BUTTON_FUNCTION_CLOSE; + else if (strcmp (str, "shade") == 0) + return META_BUTTON_FUNCTION_SHADE; + else if (strcmp (str, "above") == 0) + return META_BUTTON_FUNCTION_ABOVE; + else if (strcmp (str, "stick") == 0) + return META_BUTTON_FUNCTION_STICK; + else if (strcmp (str, "unshade") == 0) + return META_BUTTON_FUNCTION_UNSHADE; + else if (strcmp (str, "unabove") == 0) + return META_BUTTON_FUNCTION_UNABOVE; + else if (strcmp (str, "unstick") == 0) + return META_BUTTON_FUNCTION_UNSTICK; + else + return META_BUTTON_FUNCTION_LAST; +} + +static MetaButtonFunction +meta_button_opposite_function (MetaButtonFunction ofwhat) +{ + switch (ofwhat) { + case META_BUTTON_FUNCTION_SHADE: + return META_BUTTON_FUNCTION_UNSHADE; + case META_BUTTON_FUNCTION_UNSHADE: + return META_BUTTON_FUNCTION_SHADE; + + case META_BUTTON_FUNCTION_ABOVE: + return META_BUTTON_FUNCTION_UNABOVE; + case META_BUTTON_FUNCTION_UNABOVE: + return META_BUTTON_FUNCTION_ABOVE; + + case META_BUTTON_FUNCTION_STICK: + return META_BUTTON_FUNCTION_UNSTICK; + case META_BUTTON_FUNCTION_UNSTICK: + return META_BUTTON_FUNCTION_STICK; + + default: + return META_BUTTON_FUNCTION_LAST; + } +} + +static void +update_metacity_button_layout_cb (GWDSettings *settings, + const gchar *button_layout, + GWDThemeMetacity *metacity) +{ + MetaButtonLayout new_layout; + + initialize_button_layout (&new_layout); + + if (button_layout != NULL) { + gint i; + gchar **sides; + MetaButtonFunction f; + + sides = g_strsplit (button_layout, ":", 2); + + if (sides[0] != NULL) { + gchar **buttons; + gint b; + gboolean used[META_BUTTON_FUNCTION_LAST]; + + for (i = 0; i < META_BUTTON_FUNCTION_LAST; ++i) + used[i] = FALSE; + + buttons = g_strsplit (sides[0], ",", -1); + + i = b = 0; + while (buttons[b] != NULL) { + f = meta_button_function_from_string (buttons[b]); + + if (i > 0 && strcmp ("spacer", buttons[b]) == 0) { + new_layout.left_buttons_has_spacer[i - 1] = TRUE; + f = meta_button_opposite_function (f); + + if (f != META_BUTTON_FUNCTION_LAST) + new_layout.left_buttons_has_spacer[i - 2] = TRUE; + } else { + if (f != META_BUTTON_FUNCTION_LAST && !used[f]) { + used[f] = TRUE; + new_layout.left_buttons[i++] = f; + + f = meta_button_opposite_function (f); + + if (f != META_BUTTON_FUNCTION_LAST) + new_layout.left_buttons[i++] = f; + } else { + g_warning ("Ignoring unknown or already-used " + "button name \"%s\"", buttons[b]); + } + } + + ++b; + } + + new_layout.left_buttons[i] = META_BUTTON_FUNCTION_LAST; + + g_strfreev (buttons); + + if (sides[1] != NULL) { + for (i = 0; i < META_BUTTON_FUNCTION_LAST; ++i) + used[i] = FALSE; + + buttons = g_strsplit (sides[1], ",", -1); + + i = b = 0; + while (buttons[b] != NULL) { + f = meta_button_function_from_string (buttons[b]); + + if (i > 0 && strcmp ("spacer", buttons[b]) == 0) { + new_layout.right_buttons_has_spacer[i - 1] = TRUE; + f = meta_button_opposite_function (f); + + if (f != META_BUTTON_FUNCTION_LAST) + new_layout.right_buttons_has_spacer[i - 2] = TRUE; + } else { + if (f != META_BUTTON_FUNCTION_LAST && !used[f]) { + used[f] = TRUE; + new_layout.right_buttons[i++] = f; + + f = meta_button_opposite_function (f); + + if (f != META_BUTTON_FUNCTION_LAST) + new_layout.right_buttons[i++] = f; + } else { + g_warning ("Ignoring unknown or already-used " + "button name \"%s\"", buttons[b]); + } + } + + ++b; + } + + new_layout.right_buttons[i] = META_BUTTON_FUNCTION_LAST; + + g_strfreev (buttons); + } + } + + g_strfreev (sides); + + /* Invert the button layout for RTL languages */ + if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) { + MetaButtonLayout rtl_layout; + gint j; + + initialize_button_layout (&rtl_layout); + + i = 0; + while (new_layout.left_buttons[i] != META_BUTTON_FUNCTION_LAST) + ++i; + + for (j = 0; j < i; ++j) { + rtl_layout.right_buttons[j] = new_layout.left_buttons[i - j - 1]; + + if (j == 0) + rtl_layout.right_buttons_has_spacer[i - 1] = new_layout.left_buttons_has_spacer[i - j - 1]; + else + rtl_layout.right_buttons_has_spacer[j - 1] = new_layout.left_buttons_has_spacer[i - j - 1]; + } + + i = 0; + while (new_layout.right_buttons[i] != META_BUTTON_FUNCTION_LAST) + ++i; + + for (j = 0; j < i; ++j) { + rtl_layout.left_buttons[j] = new_layout.right_buttons[i - j - 1]; + + if (j == 0) + rtl_layout.left_buttons_has_spacer[i - 1] = new_layout.right_buttons_has_spacer[i - j - 1]; + else + rtl_layout.left_buttons_has_spacer[j - 1] = new_layout.right_buttons_has_spacer[i - j - 1]; + } + + new_layout = rtl_layout; + } + } else { + gint i; + + new_layout.left_buttons[0] = META_BUTTON_FUNCTION_MENU; + + for (i = 1; i < MAX_BUTTONS_PER_CORNER; ++i) + new_layout.left_buttons[i] = META_BUTTON_FUNCTION_LAST; + + new_layout.right_buttons[0] = META_BUTTON_FUNCTION_MINIMIZE; + new_layout.right_buttons[1] = META_BUTTON_FUNCTION_MAXIMIZE; + new_layout.right_buttons[2] = META_BUTTON_FUNCTION_CLOSE; + + for (i = 3; i < MAX_BUTTONS_PER_CORNER; ++i) + new_layout.right_buttons[i] = META_BUTTON_FUNCTION_LAST; + } + + metacity->button_layout = new_layout; +} + +static MetaButtonType +meta_function_to_type (MetaButtonFunction function) +{ + switch (function) { + case META_BUTTON_FUNCTION_MENU: + return META_BUTTON_TYPE_MENU; + case META_BUTTON_FUNCTION_MINIMIZE: + return META_BUTTON_TYPE_MINIMIZE; + case META_BUTTON_FUNCTION_MAXIMIZE: + return META_BUTTON_TYPE_MAXIMIZE; + case META_BUTTON_FUNCTION_CLOSE: + return META_BUTTON_TYPE_CLOSE; + case META_BUTTON_FUNCTION_SHADE: + return META_BUTTON_TYPE_SHADE; + case META_BUTTON_FUNCTION_ABOVE: + return META_BUTTON_TYPE_ABOVE; + case META_BUTTON_FUNCTION_STICK: + return META_BUTTON_TYPE_STICK; + case META_BUTTON_FUNCTION_UNSHADE: + return META_BUTTON_TYPE_UNSHADE; + case META_BUTTON_FUNCTION_UNABOVE: + return META_BUTTON_TYPE_UNABOVE; + case META_BUTTON_FUNCTION_UNSTICK: + return META_BUTTON_TYPE_UNSTICK; + default: + break; + } + + return META_BUTTON_TYPE_LAST; +} + +static MetaButtonState +meta_button_state (gint state) +{ + if (state & IN_EVENT_WINDOW) { + if (state & PRESSED_EVENT_WINDOW) + return META_BUTTON_STATE_PRESSED; + + return META_BUTTON_STATE_PRELIGHT; + } + + return META_BUTTON_STATE_NORMAL; +} + +static MetaButtonState +meta_button_state_for_button_type (GWDThemeMetacity *metacity, + decor_t *decor, + MetaButtonType type) +{ + switch (type) { + case META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND: + type = meta_function_to_type (metacity->button_layout.left_buttons[0]); + break; + case META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND: + type = meta_function_to_type (metacity->button_layout.left_buttons[1]); + break; + case META_BUTTON_TYPE_LEFT_RIGHT_BACKGROUND: + type = meta_function_to_type (metacity->button_layout.left_buttons[2]); + break; + case META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND: + type = meta_function_to_type (metacity->button_layout.right_buttons[0]); + break; + case META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND: + type = meta_function_to_type (metacity->button_layout.right_buttons[1]); + break; + case META_BUTTON_TYPE_RIGHT_RIGHT_BACKGROUND: + type = meta_function_to_type (metacity->button_layout.right_buttons[2]); + default: + break; + } + + switch (type) { + case META_BUTTON_TYPE_CLOSE: + return meta_button_state (decor->button_states[BUTTON_CLOSE]); + case META_BUTTON_TYPE_MAXIMIZE: + return meta_button_state (decor->button_states[BUTTON_MAX]); + case META_BUTTON_TYPE_MINIMIZE: + return meta_button_state (decor->button_states[BUTTON_MIN]); + case META_BUTTON_TYPE_MENU: + return meta_button_state (decor->button_states[BUTTON_MENU]); + case META_BUTTON_TYPE_SHADE: + return meta_button_state (decor->button_states[BUTTON_SHADE]); + case META_BUTTON_TYPE_ABOVE: + return meta_button_state (decor->button_states[BUTTON_ABOVE]); + case META_BUTTON_TYPE_STICK: + return meta_button_state (decor->button_states[BUTTON_STICK]); + case META_BUTTON_TYPE_UNSHADE: + return meta_button_state (decor->button_states[BUTTON_UNSHADE]); + case META_BUTTON_TYPE_UNABOVE: + return meta_button_state (decor->button_states[BUTTON_UNABOVE]); + case META_BUTTON_TYPE_UNSTICK: + return meta_button_state (decor->button_states[BUTTON_UNSTICK]); + default: + break; + } + + return META_BUTTON_STATE_NORMAL; +} + +static gint +radius_to_width (gint radius, + gint i) +{ + gfloat r1 = sqrt (radius) + radius; + gfloat r2 = r1 * r1 - (r1 - (i + 0.5)) * (r1 - (i + 0.5)); + + return floor (0.5f + r1 - sqrt (r2)); +} + +static void +get_corner_radius (const MetaFrameGeometry *fgeom, + gint *top_left_radius, + gint *top_right_radius, + gint *bottom_left_radius, + gint *bottom_right_radius) +{ + *top_left_radius = fgeom->top_left_corner_rounded_radius; + *top_right_radius = fgeom->top_right_corner_rounded_radius; + *bottom_left_radius = fgeom->bottom_left_corner_rounded_radius; + *bottom_right_radius = fgeom->bottom_right_corner_rounded_radius; +} + +static Region +get_top_border_region (const MetaFrameGeometry *fgeom, + gint width) +{ + Region corners_xregion; + Region border_xregion; + XRectangle xrect; + gint top_left_radius; + gint top_right_radius; + gint bottom_left_radius; + gint bottom_right_radius; + gint w; + gint i; + gint height; + + corners_xregion = XCreateRegion (); + + get_corner_radius (fgeom, &top_left_radius, &top_right_radius, + &bottom_left_radius, &bottom_right_radius); + + width = width - fgeom->borders.invisible.left - fgeom->borders.invisible.right; + height = fgeom->borders.visible.top; + + if (top_left_radius) { + for (i = 0; i < top_left_radius; ++i) { + w = radius_to_width (top_left_radius, i); + + xrect.x = 0; + xrect.y = i; + xrect.width = w; + xrect.height = 1; + + XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion); + } + } + + if (top_right_radius) { + for (i = 0; i < top_right_radius; ++i) { + w = radius_to_width (top_right_radius, i); + + xrect.x = width - w; + xrect.y = i; + xrect.width = w; + xrect.height = 1; + + XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion); + } + } + + border_xregion = XCreateRegion (); + + xrect.x = 0; + xrect.y = 0; + xrect.width = width; + xrect.height = height; + + XUnionRectWithRegion (&xrect, border_xregion, border_xregion); + + XSubtractRegion (border_xregion, corners_xregion, border_xregion); + XDestroyRegion (corners_xregion); + + return border_xregion; +} + +static Region +get_bottom_border_region (const MetaFrameGeometry *fgeom, + gint width) +{ + Region corners_xregion; + Region border_xregion; + XRectangle xrect; + gint top_left_radius; + gint top_right_radius; + gint bottom_left_radius; + gint bottom_right_radius; + gint w; + gint i; + gint height; + + corners_xregion = XCreateRegion (); + + get_corner_radius (fgeom, &top_left_radius, &top_right_radius, + &bottom_left_radius, &bottom_right_radius); + + width = width - fgeom->borders.invisible.left - fgeom->borders.invisible.right; + height = fgeom->borders.visible.bottom; + + if (bottom_left_radius) { + for (i = 0; i < bottom_left_radius; ++i) { + w = radius_to_width (bottom_left_radius, i); + + xrect.x = 0; + xrect.y = height - i - 1; + xrect.width = w; + xrect.height = 1; + + XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion); + } + } + + if (bottom_right_radius) { + for (i = 0; i < bottom_right_radius; ++i) { + w = radius_to_width (bottom_right_radius, i); + + xrect.x = width - w; + xrect.y = height - i - 1; + xrect.width = w; + xrect.height = 1; + + XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion); + } + } + + border_xregion = XCreateRegion (); + + xrect.x = 0; + xrect.y = 0; + xrect.width = width; + xrect.height = height; + + XUnionRectWithRegion (&xrect, border_xregion, border_xregion); + + XSubtractRegion (border_xregion, corners_xregion, border_xregion); + XDestroyRegion (corners_xregion); + + return border_xregion; +} + +static Region +get_left_border_region (const MetaFrameGeometry *fgeom, + gint height) +{ + Region border_xregion; + XRectangle xrect; + + border_xregion = XCreateRegion (); + + xrect.x = 0; + xrect.y = 0; + xrect.width = fgeom->borders.visible.left; + xrect.height = height - fgeom->borders.total.top - fgeom->borders.total.bottom; + + XUnionRectWithRegion (&xrect, border_xregion, border_xregion); + + return border_xregion; +} + +static Region +get_right_border_region (const MetaFrameGeometry *fgeom, + gint height) +{ + Region border_xregion; + XRectangle xrect; + + border_xregion = XCreateRegion (); + + xrect.x = 0; + xrect.y = 0; + xrect.width = fgeom->borders.visible.right; + xrect.height = height - fgeom->borders.total.top - fgeom->borders.total.bottom; + + XUnionRectWithRegion (&xrect, border_xregion, border_xregion); + + return border_xregion; +} + +static void +decor_update_meta_window_property (decor_t *d, + MetaTheme *theme, + MetaFrameFlags flags, + MetaFrameType type, + Region top, + Region bottom, + Region left, + Region right) +{ + long *data; + GdkDisplay *display; + Display *xdisplay; + gint nQuad; + decor_extents_t win_extents; + decor_extents_t frame_win_extents; + decor_extents_t max_win_extents; + decor_extents_t frame_max_win_extents; + decor_quad_t quads[N_QUADS_MAX]; + unsigned int nOffset; + unsigned int frame_type; + unsigned int frame_state; + unsigned int frame_actions; + gint w; + gint lh; + gint rh; + gint top_stretch_offset; + gint bottom_stretch_offset; + gint left_stretch_offset; + gint right_stretch_offset; + + display = gdk_display_get_default (); + xdisplay = gdk_x11_display_get_xdisplay (display); + + nOffset = 1; + + frame_type = populate_frame_type (d); + frame_state = populate_frame_state (d); + frame_actions = populate_frame_actions (d); + + win_extents = frame_win_extents = d->frame->win_extents; + max_win_extents = frame_max_win_extents = d->frame->max_win_extents; + + /* Add the invisible grab area padding, but only for + * pixmap type decorations */ + if (!d->frame_window) { + GdkScreen *screen; + MetaStyleInfo *style_info; + MetaFrameBorders borders; + + screen = gtk_widget_get_screen (d->frame->style_window_rgba); + style_info = meta_theme_create_style_info (screen, d->gtk_theme_variant); + + meta_theme_get_frame_borders (theme, style_info, type, + d->frame->text_height, + flags, &borders); + + if (flags & META_FRAME_ALLOWS_HORIZONTAL_RESIZE) { + frame_win_extents.left += borders.invisible.left; + frame_win_extents.right += borders.invisible.right; + frame_max_win_extents.left += borders.invisible.left; + frame_max_win_extents.right += borders.invisible.right; + } + + if (flags & META_FRAME_ALLOWS_VERTICAL_RESIZE) { + frame_win_extents.bottom += borders.invisible.bottom; + frame_win_extents.top += borders.invisible.top; + frame_max_win_extents.bottom += borders.invisible.bottom; + frame_max_win_extents.top += borders.invisible.top; + } + + meta_style_info_unref (style_info); + } + + w = d->border_layout.top.x2 - d->border_layout.top.x1 - + d->context->left_space - d->context->right_space; + + if (d->border_layout.rotation) + lh = d->border_layout.left.x2 - d->border_layout.left.x1; + else + lh = d->border_layout.left.y2 - d->border_layout.left.y1; + + if (d->border_layout.rotation) + rh = d->border_layout.right.x2 - d->border_layout.right.x1; + else + rh = d->border_layout.right.y2 - d->border_layout.right.y1; + + left_stretch_offset = lh / 2; + right_stretch_offset = rh / 2; + top_stretch_offset = w - d->button_width - 1; + bottom_stretch_offset = (d->border_layout.bottom.x2 - d->border_layout.bottom.x1 - + d->context->left_space - d->context->right_space) / 2; + + nQuad = decor_set_lXrXtXbX_window_quads (quads, d->context, &d->border_layout, + left_stretch_offset, right_stretch_offset, + top_stretch_offset, bottom_stretch_offset); + + win_extents.top += d->frame->titlebar_height; + frame_win_extents.top += d->frame->titlebar_height; + max_win_extents.top += d->frame->max_titlebar_height; + frame_max_win_extents.top += d->frame->max_titlebar_height; + + if (d->frame_window) { + data = decor_alloc_property (nOffset, WINDOW_DECORATION_TYPE_WINDOW); + decor_gen_window_property (data, nOffset - 1, &win_extents, &max_win_extents, + 20, 20, frame_type, frame_state, frame_actions); + } else { + data = decor_alloc_property (nOffset, WINDOW_DECORATION_TYPE_PIXMAP); + decor_quads_to_property (data, nOffset - 1, cairo_xlib_surface_get_drawable (d->surface), + &frame_win_extents, &win_extents, + &frame_max_win_extents, &max_win_extents, + ICON_SPACE + d->button_width, + 0, quads, nQuad, frame_type, frame_state, frame_actions); + } + + gdk_error_trap_push (); + + XChangeProperty (xdisplay, d->prop_xid, win_decor_atom, XA_INTEGER, + 32, PropModeReplace, (guchar *) data, + PROP_HEADER_SIZE + BASE_PROP_SIZE + QUAD_PROP_SIZE * N_QUADS_MAX); + gdk_display_sync (display); + + gdk_error_trap_pop_ignored (); + + free (data); + + decor_update_blur_property (d, w, lh, + top, top_stretch_offset, + bottom, bottom_stretch_offset, + left, left_stretch_offset, + right, right_stretch_offset); +} + +static void +get_decoration_geometry (GWDThemeMetacity *metacity, + decor_t *decor, + MetaFrameFlags *flags, + MetaFrameGeometry *fgeom, + MetaFrameType frame_type) +{ + GdkScreen *screen; + MetaStyleInfo *style_info; + gint client_width; + gint client_height; + + if (!(frame_type < META_FRAME_TYPE_LAST)) + frame_type = META_FRAME_TYPE_NORMAL; + + *flags = 0; + + if (decor->actions & WNCK_WINDOW_ACTION_CLOSE) + *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_DELETE; + + if (decor->actions & WNCK_WINDOW_ACTION_MINIMIZE) + *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_MINIMIZE; + + if (decor->actions & WNCK_WINDOW_ACTION_MAXIMIZE) + *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_MAXIMIZE; + + *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_MENU; + + if (decor->actions & WNCK_WINDOW_ACTION_RESIZE) { + if (!(decor->state & WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY)) + *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_VERTICAL_RESIZE; + + if (!(decor->state & WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY)) + *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_HORIZONTAL_RESIZE; + } + + if (decor->actions & WNCK_WINDOW_ACTION_MOVE) + *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_MOVE; + + if (decor->actions & WNCK_WINDOW_ACTION_MAXIMIZE) + *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_MAXIMIZE; + + if (decor->actions & WNCK_WINDOW_ACTION_SHADE) + *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_SHADE; + + if (decor->active) + *flags |= (MetaFrameFlags ) META_FRAME_HAS_FOCUS; + + if ((decor->state & META_MAXIMIZED) == META_MAXIMIZED) + *flags |= (MetaFrameFlags ) META_FRAME_MAXIMIZED; + + if (decor->state & WNCK_WINDOW_STATE_STICKY) + *flags |= (MetaFrameFlags ) META_FRAME_STUCK; + + if (decor->state & WNCK_WINDOW_STATE_FULLSCREEN) + *flags |= (MetaFrameFlags ) META_FRAME_FULLSCREEN; + + if (decor->state & WNCK_WINDOW_STATE_SHADED) + *flags |= (MetaFrameFlags ) META_FRAME_SHADED; + + if (decor->state & WNCK_WINDOW_STATE_ABOVE) + *flags |= (MetaFrameFlags ) META_FRAME_ABOVE; + + client_width = decor->border_layout.top.x2 - decor->border_layout.top.x1; + client_width -= decor->context->right_space + decor->context->left_space; + + if (decor->border_layout.rotation) + client_height = decor->border_layout.left.x2 - decor->border_layout.left.x1; + else + client_height = decor->border_layout.left.y2 - decor->border_layout.left.y1; + + screen = gtk_widget_get_screen (decor->frame->style_window_rgba); + style_info = meta_theme_create_style_info (screen, decor->gtk_theme_variant); + + meta_theme_calc_geometry (metacity->theme, style_info, frame_type, + decor->frame->text_height, *flags, client_width, + client_height, &metacity->button_layout, fgeom); + + meta_style_info_unref (style_info); +} + +static void +calc_button_size (GWDTheme *theme, + decor_t *decor) +{ + MetaFrameType frame_type; + MetaFrameFlags flags; + MetaFrameGeometry fgeom; + gint i, min_x, x, y, w, h, width; + + if (!decor->context) { + decor->button_width = 0; + return; + } + + frame_type = meta_frame_type_from_string (decor->frame->type); + if (!(frame_type < META_FRAME_TYPE_LAST)) + frame_type = META_FRAME_TYPE_NORMAL; + + get_decoration_geometry (GWD_THEME_METACITY (theme), decor, &flags, + &fgeom, frame_type); + + width = decor->border_layout.top.x2 - decor->border_layout.top.x1 - + decor->context->left_space - decor->context->right_space + + fgeom.borders.total.left + fgeom.borders.total.right; + + min_x = width; + + for (i = 0; i < 3; ++i) { + static guint button_actions[3] = { + WNCK_WINDOW_ACTION_CLOSE, + WNCK_WINDOW_ACTION_MAXIMIZE, + WNCK_WINDOW_ACTION_MINIMIZE + }; + + if (decor->actions & button_actions[i]) { + if (gwd_theme_get_button_position (theme, decor, i, width, 256, + &x, &y, &w, &h)) { + if (x > width / 2 && x < min_x) + min_x = x; + } + } + } + + decor->button_width = width - min_x; +} + +static gboolean +button_present (GWDThemeMetacity *metacity, + MetaButtonFunction function) +{ + int i; + + for (i = 0; i < MAX_BUTTONS_PER_CORNER; ++i) + if (metacity->button_layout.left_buttons[i] == function) + return TRUE; + + for (i = 0; i < MAX_BUTTONS_PER_CORNER; ++i) + if (metacity->button_layout.right_buttons[i] == function) + return TRUE; + + return FALSE; +} + +static MetaButtonFunction +button_to_meta_button_function (gint i) +{ + switch (i) { + case BUTTON_MENU: + return META_BUTTON_FUNCTION_MENU; + case BUTTON_MIN: + return META_BUTTON_FUNCTION_MINIMIZE; + case BUTTON_MAX: + return META_BUTTON_FUNCTION_MAXIMIZE; + case BUTTON_CLOSE: + return META_BUTTON_FUNCTION_CLOSE; + case BUTTON_SHADE: + return META_BUTTON_FUNCTION_SHADE; + case BUTTON_ABOVE: + return META_BUTTON_FUNCTION_ABOVE; + case BUTTON_STICK: + return META_BUTTON_FUNCTION_STICK; + case BUTTON_UNSHADE: + return META_BUTTON_FUNCTION_UNSHADE; + case BUTTON_UNABOVE: + return META_BUTTON_FUNCTION_UNABOVE; + case BUTTON_UNSTICK: + return META_BUTTON_FUNCTION_UNSTICK; + default: + break; + } + + return META_BUTTON_FUNCTION_LAST; +} + +static void +gwd_theme_metacity_constructed (GObject *object) +{ + GWDTheme *theme = GWD_THEME (object); + GWDThemeMetacity *metacity = GWD_THEME_METACITY (object); + GWDSettings *settings; + const gchar *button_layout; + + G_OBJECT_CLASS (gwd_theme_metacity_parent_class)->constructed (object); + + settings = gwd_theme_get_settings (theme); + button_layout = gwd_settings_get_metacity_button_layout (settings); + + g_signal_connect (settings, "update-metacity-button-layout", + G_CALLBACK (update_metacity_button_layout_cb), metacity); + + update_metacity_button_layout_cb (settings, button_layout, metacity); +} + +static GObject * +gwd_theme_metacity_constructor (GType type, + guint n_properties, + GObjectConstructParam *properties) +{ + GObject *object; + GWDThemeMetacity *metacity; + + object = G_OBJECT_CLASS (gwd_theme_metacity_parent_class)->constructor (type, n_properties, properties); + metacity = GWD_THEME_METACITY (object); + + /* Always valid and current MetaTheme! On theme change new GWDThemeMetacity + * object will be created and old one destroyed. If Metacity theme is not + * valid (gwd_metacity_window_decoration_update_meta_theme returns FALSE) + * then GWDThemeCairo will be created. + */ + metacity->theme = meta_theme_get_current (); + + return object; +} + +static void +gwd_theme_metacity_draw_window_decoration (GWDTheme *theme, + decor_t *decor) +{ + GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme); + GWDSettings *settings = gwd_theme_get_settings (gwd_theme); + GdkDisplay *display; + GdkScreen *screen; + Display *xdisplay; + cairo_surface_t *surface; + Picture src; + MetaButtonState button_states [META_BUTTON_TYPE_LAST]; + MetaFrameGeometry fgeom; + MetaFrameFlags flags; + MetaFrameType frame_type; + MetaStyleInfo *style_info; + GtkStyleContext *context; + cairo_t *cr; + gint i; + Region top_region; + Region bottom_region; + Region left_region; + Region right_region; + gdouble meta_active_opacity; + gdouble meta_inactive_opacity; + gboolean meta_active_shade_opacity; + gboolean meta_inactive_shade_opacity; + double alpha; + gboolean shade_alpha; + MetaFrameStyle *frame_style; + GtkWidget *style_window; + GdkRGBA bg_rgba; + + if (!decor->surface || !decor->picture) + return; + + display = gdk_display_get_default (); + xdisplay = gdk_x11_display_get_xdisplay (display); + + top_region = NULL; + bottom_region = NULL; + left_region = NULL; + right_region = NULL; + + g_object_get (settings, "metacity-active-opacity", &meta_active_opacity, NULL); + g_object_get (settings, "metacity-inactive-opacity", &meta_inactive_opacity, NULL); + g_object_get (settings, "metacity-active-shade-opacity", &meta_active_shade_opacity, NULL); + g_object_get (settings, "metacity-inactive-shade-opacity", &meta_inactive_shade_opacity, NULL); + + alpha = (decor->active) ? meta_active_opacity : meta_inactive_opacity; + shade_alpha = (decor->active) ? meta_active_shade_opacity : meta_inactive_shade_opacity; + + if (decoration_alpha == 1.0) + alpha = 1.0; + + if (cairo_xlib_surface_get_depth (decor->surface) == 32) + style_window = decor->frame->style_window_rgba; + else + style_window = decor->frame->style_window_rgb; + + context = gtk_widget_get_style_context (style_window); + + cr = cairo_create (decor->buffer_surface ? decor->buffer_surface : decor->surface); + + cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); + + frame_type = meta_frame_type_from_string (decor->frame->type); + + if (frame_type == META_FRAME_TYPE_LAST) + frame_type = META_FRAME_TYPE_NORMAL; + + get_decoration_geometry (metacity, decor, &flags, &fgeom, frame_type); + + if ((decor->prop_xid || !decor->buffer_surface) && !decor->frame_window) + draw_shadow_background (decor, cr, decor->shadow, decor->context); + + for (i = 0; i < META_BUTTON_TYPE_LAST; ++i) + button_states[i] = meta_button_state_for_button_type (metacity, decor, i); + + frame_style = meta_theme_get_frame_style (metacity->theme, frame_type, flags); + + gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg_rgba); + bg_rgba.alpha = 1.0; + + if (frame_style->window_background_color) { + meta_color_spec_render (frame_style->window_background_color, + context, &bg_rgba); + + bg_rgba.alpha = frame_style->window_background_alpha / 255.0; + } + + /* Draw something that will be almost invisible to user. This is hacky way + * to fix invisible decorations. */ + cairo_set_source_rgba (cr, 0, 0, 0, 0.01); + cairo_rectangle (cr, 0, 0, 1, 1); + cairo_fill (cr); + /* ------------ */ + + cairo_destroy (cr); + + if (decor->frame_window) + surface = create_surface (fgeom.width, fgeom.height, decor->frame->style_window_rgb); + else + surface = create_surface (fgeom.width, fgeom.height, decor->frame->style_window_rgba); + + cr = cairo_create (surface); + gdk_cairo_set_source_rgba (cr, &bg_rgba); + cairo_set_operator (cr, CAIRO_OPERATOR_OVER); + + src = XRenderCreatePicture (xdisplay, cairo_xlib_surface_get_drawable (surface), + get_format_for_surface (decor, surface), 0, NULL); + + screen = gtk_widget_get_screen (decor->frame->style_window_rgba); + style_info = meta_theme_create_style_info (screen, decor->gtk_theme_variant); + + cairo_paint (cr); + meta_theme_draw_frame (metacity->theme, style_info, cr, frame_type, flags, + fgeom.width - fgeom.borders.total.left - fgeom.borders.total.right, + fgeom.height - fgeom.borders.total.top - fgeom.borders.total.bottom, + decor->layout, decor->frame->text_height, &metacity->button_layout, + button_states, decor->icon_pixbuf, NULL); + + meta_style_info_unref (style_info); + + if (fgeom.borders.visible.top) { + top_region = get_top_border_region (&fgeom, fgeom.width); + + decor_blend_border_picture (xdisplay, decor->context, src, + fgeom.borders.invisible.left, + fgeom.borders.invisible.top, + decor->picture, &decor->border_layout, + BORDER_TOP, top_region, + alpha * 0xffff, shade_alpha, 0); + } + + if (fgeom.borders.visible.bottom) { + bottom_region = get_bottom_border_region (&fgeom, fgeom.width); + + decor_blend_border_picture (xdisplay, decor->context, src, + fgeom.borders.invisible.left, + fgeom.height - fgeom.borders.total.bottom, + decor->picture, &decor->border_layout, + BORDER_BOTTOM, bottom_region, + alpha * 0xffff, shade_alpha, 0); + } + + if (fgeom.borders.visible.left) { + left_region = get_left_border_region (&fgeom, fgeom.height); + + decor_blend_border_picture (xdisplay, decor->context, src, + fgeom.borders.invisible.left, + fgeom.borders.total.top, + decor->picture, &decor->border_layout, + BORDER_LEFT, left_region, + alpha * 0xffff, shade_alpha, 0); + } + + if (fgeom.borders.visible.right) { + right_region = get_right_border_region (&fgeom, fgeom.height); + + decor_blend_border_picture (xdisplay, decor->context, src, + fgeom.width - fgeom.borders.total.right, + fgeom.borders.total.top, + decor->picture, &decor->border_layout, + BORDER_RIGHT, right_region, + alpha * 0xffff, shade_alpha, 0); + } + + cairo_destroy (cr); + cairo_surface_destroy (surface); + XRenderFreePicture (xdisplay, src); + + copy_to_front_buffer (decor); + + if (decor->frame_window) { + GdkWindow *gdk_frame_window; + GdkPixbuf *pixbuf; + + gdk_frame_window = gtk_widget_get_window (decor->decor_window); + + pixbuf = gdk_pixbuf_get_from_surface (decor->surface, 0, 0, decor->width, decor->height); + gtk_image_set_from_pixbuf (GTK_IMAGE (decor->decor_image), pixbuf); + g_object_unref (pixbuf); + + gdk_window_move_resize (gdk_frame_window, + decor->context->left_corner_space - 1, + decor->context->top_corner_space - 1, + decor->width, + decor->height); + + gdk_window_lower (gdk_frame_window); + } + + if (decor->prop_xid) { + /* translate from frame to client window space */ + if (top_region) + XOffsetRegion (top_region, -fgeom.borders.total.left, -fgeom.borders.total.top); + if (bottom_region) + XOffsetRegion (bottom_region, -fgeom.borders.total.left, 0); + if (left_region) + XOffsetRegion (left_region, -fgeom.borders.total.left, 0); + + decor_update_meta_window_property (decor, metacity->theme, flags, + frame_type, + top_region, bottom_region, + left_region, right_region); + + decor->prop_xid = 0; + } + + if (top_region) + XDestroyRegion (top_region); + if (bottom_region) + XDestroyRegion (bottom_region); + if (left_region) + XDestroyRegion (left_region); + if (right_region) + XDestroyRegion (right_region); +} + +static gboolean +gwd_theme_metacity_calc_decoration_size (GWDTheme *theme, + decor_t *decor, + gint w, + gint h, + gint name_width, + gint *width, + gint *height) +{ + decor_layout_t layout; + decor_context_t *context; + decor_shadow_t *shadow; + + if (!decor->decorated) + return FALSE; + + if ((decor->state & META_MAXIMIZED) == META_MAXIMIZED) { + if (!decor->frame_window) { + if (decor->active) { + context = &decor->frame->max_window_context_active; + shadow = decor->frame->max_border_shadow_active; + } else { + context = &decor->frame->max_window_context_inactive; + shadow = decor->frame->max_border_shadow_inactive; + } + } else { + context = &decor->frame->max_window_context_no_shadow; + shadow = decor->frame->max_border_no_shadow; + } + } else { + if (!decor->frame_window) { + if (decor->active) { + context = &decor->frame->window_context_active; + shadow = decor->frame->border_shadow_active; + } else { + context = &decor->frame->window_context_inactive; + shadow = decor->frame->border_shadow_inactive; + } + } else { + context = &decor->frame->window_context_no_shadow; + shadow = decor->frame->border_no_shadow; + } + } + + if (!decor->frame_window) { + decor_get_best_layout (context, w, h, &layout); + + if (context != decor->context || + memcmp (&layout, &decor->border_layout, sizeof (layout))) { + *width = layout.width; + *height = layout.height; + + decor->border_layout = layout; + decor->context = context; + decor->shadow = shadow; + + calc_button_size (theme, decor); + + return TRUE; + } + } else { + if ((decor->state & META_MAXIMIZED) == META_MAXIMIZED) + decor_get_default_layout (context, decor->client_width, + decor->client_height - decor->frame->titlebar_height, + &layout); + else + decor_get_default_layout (context, decor->client_width, + decor->client_height, &layout); + + *width = layout.width; + *height = layout.height; + + decor->border_layout = layout; + decor->shadow = shadow; + decor->context = context; + + calc_button_size (theme, decor); + + return TRUE; + } + + return FALSE; +} + +static void +gwd_theme_metacity_update_border_extents (GWDTheme *theme, + decor_frame_t *frame) +{ + GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme); + GdkScreen *screen = gtk_widget_get_screen (frame->style_window_rgba); + MetaStyleInfo *style_info = meta_theme_create_style_info (screen, NULL); + MetaFrameType frame_type; + MetaFrameBorders borders; + + gwd_decor_frame_ref (frame); + + frame_type = meta_frame_type_from_string (frame->type); + if (!(frame_type < META_FRAME_TYPE_LAST)) + frame_type = META_FRAME_TYPE_NORMAL; + + meta_theme_get_frame_borders (metacity->theme, style_info, frame_type, + frame->text_height, 0, &borders); + + frame->win_extents.top = frame->win_extents.top; + frame->win_extents.bottom = borders.visible.bottom; + frame->win_extents.left = borders.visible.left; + frame->win_extents.right = borders.visible.right; + + frame->titlebar_height = borders.visible.top - frame->win_extents.top; + + meta_theme_get_frame_borders (metacity->theme, style_info, frame_type, + frame->text_height, META_FRAME_MAXIMIZED, + &borders); + + frame->max_win_extents.top = frame->win_extents.top; + frame->max_win_extents.bottom = borders.visible.bottom; + frame->max_win_extents.left = borders.visible.left; + frame->max_win_extents.right = borders.visible.right; + + frame->max_titlebar_height = borders.visible.top - frame->max_win_extents.top; + + meta_style_info_unref (style_info); + + gwd_decor_frame_unref (frame); +} + +static void +gwd_theme_metacity_get_event_window_position (GWDTheme *theme, + decor_t *decor, + gint i, + gint j, + gint width, + gint height, + gint *x, + gint *y, + gint *w, + gint *h) +{ + GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme); + MetaFrameGeometry fgeom; + MetaFrameFlags flags; + + get_decoration_geometry (metacity, decor, &flags, &fgeom, + meta_frame_type_from_string (decor->frame->type)); + + width += fgeom.borders.total.right + fgeom.borders.total.left; + height += fgeom.borders.total.top + fgeom.borders.total.bottom; + +#define TOP_RESIZE_HEIGHT 2 +#define RESIZE_EXTENDS 15 + + switch (i) { + case 2: /* bottom */ + switch (j) { + case 2: /* bottom right */ + *x = width - fgeom.borders.total.right - RESIZE_EXTENDS; + *y = height - fgeom.borders.total.bottom - RESIZE_EXTENDS; + + if (decor->frame_window) { + *x += decor->frame->win_extents.left + 2; + *y += decor->frame->win_extents.top + 2; + } + + *w = fgeom.borders.total.right + RESIZE_EXTENDS; + *h = fgeom.borders.total.bottom + RESIZE_EXTENDS; + break; + case 1: /* bottom */ + *x = fgeom.borders.total.left + RESIZE_EXTENDS; + *y = height - fgeom.borders.total.bottom; + + if (decor->frame_window) + *y += decor->frame->win_extents.top + 2; + + *w = width - fgeom.borders.total.left - fgeom.borders.total.right - (2 * RESIZE_EXTENDS); + *h = fgeom.borders.total.bottom; + break; + case 0: /* bottom left */ + default: + *x = 0; + *y = height - fgeom.borders.total.bottom - RESIZE_EXTENDS; + + if (decor->frame_window) { + *x += decor->frame->win_extents.left + 4; + *y += decor->frame->win_extents.bottom + 2; + } + + *w = fgeom.borders.total.left + RESIZE_EXTENDS; + *h = fgeom.borders.total.bottom + RESIZE_EXTENDS; + break; + } + break; + case 1: /* middle */ + switch (j) { + case 2: /* right */ + *x = width - fgeom.borders.total.right; + *y = fgeom.borders.total.top + RESIZE_EXTENDS; + + if (decor->frame_window) + *x += decor->frame->win_extents.left + 2; + + *w = fgeom.borders.total.right; + *h = height - fgeom.borders.total.top - fgeom.borders.total.bottom - (2 * RESIZE_EXTENDS); + break; + case 1: /* middle */ + *x = fgeom.borders.total.left; + *y = fgeom.title_rect.y + TOP_RESIZE_HEIGHT; + *w = width - fgeom.borders.total.left - fgeom.borders.total.right; + *h = height - fgeom.borders.total.top - fgeom.borders.total.bottom; + break; + case 0: /* left */ + default: + *x = 0; + *y = fgeom.borders.total.top + RESIZE_EXTENDS; + + if (decor->frame_window) + *x += decor->frame->win_extents.left + 4; + + *w = fgeom.borders.total.left; + *h = height - fgeom.borders.total.top - fgeom.borders.total.bottom - (2 * RESIZE_EXTENDS); + break; + } + break; + case 0: /* top */ + default: + switch (j) { + case 2: /* top right */ + *x = width - fgeom.borders.total.right - RESIZE_EXTENDS; + *y = 0; + + if (decor->frame_window) { + *x += decor->frame->win_extents.left + 2; + *y += decor->frame->win_extents.top + 2 - fgeom.title_rect.height; + } + + *w = fgeom.borders.total.right + RESIZE_EXTENDS; + *h = fgeom.borders.total.top + RESIZE_EXTENDS; + break; + case 1: /* top */ + *x = fgeom.borders.total.left + RESIZE_EXTENDS; + *y = 0; + + if (decor->frame_window) + *y += decor->frame->win_extents.top + 2; + + *w = width - fgeom.borders.total.left - fgeom.borders.total.right - (2 * RESIZE_EXTENDS); + *h = fgeom.borders.total.top - fgeom.title_rect.height; + break; + case 0: /* top left */ + default: + *x = 0; + *y = 0; + + if (decor->frame_window) { + *x += decor->frame->win_extents.left + 4; + *y += decor->frame->win_extents.top + 2 - fgeom.title_rect.height; + } + + *w = fgeom.borders.total.left + RESIZE_EXTENDS; + *h = fgeom.borders.total.top + RESIZE_EXTENDS; + break; + } + break; + } + + if (!(flags & META_FRAME_ALLOWS_VERTICAL_RESIZE)) { + /* turn off top and bottom event windows */ + if (i == 0 || i == 2) + *w = *h = 0; + } + + if (!(flags & META_FRAME_ALLOWS_HORIZONTAL_RESIZE)) { + /* turn off left and right event windows */ + if (j == 0 || j == 2) + *w = *h = 0; + } + +#undef TOP_RESIZE_HEIGHT +#undef RESIZE_EXTENDS +} + +static gboolean +gwd_theme_metacity_get_button_position (GWDTheme *theme, + decor_t *decor, + gint i, + gint width, + gint height, + gint *x, + gint *y, + gint *w, + gint *h) +{ + GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme); + MetaFrameGeometry fgeom; + MetaFrameType frame_type; + MetaFrameFlags flags; + MetaButtonFunction button_function; + MetaButtonSpace *space; + + if (!decor->context) { + /* undecorated windows implicitly have no buttons */ + return FALSE; + } + + frame_type = meta_frame_type_from_string (decor->frame->type); + if (!(frame_type < META_FRAME_TYPE_LAST)) + frame_type = META_FRAME_TYPE_NORMAL; + + get_decoration_geometry (metacity, decor, &flags, &fgeom, frame_type); + + button_function = button_to_meta_button_function (i); + if (!button_present (metacity, button_function)) + return FALSE; + + switch (i) { + case BUTTON_MENU: + space = &fgeom.menu_rect; + break; + case BUTTON_MIN: + space = &fgeom.min_rect; + break; + case BUTTON_MAX: + space = &fgeom.max_rect; + break; + case BUTTON_CLOSE: + space = &fgeom.close_rect; + break; + case BUTTON_SHADE: + space = &fgeom.shade_rect; + break; + case BUTTON_ABOVE: + space = &fgeom.above_rect; + break; + case BUTTON_STICK: + space = &fgeom.stick_rect; + break; + case BUTTON_UNSHADE: + space = &fgeom.unshade_rect; + break; + case BUTTON_UNABOVE: + space = &fgeom.unabove_rect; + break; + case BUTTON_UNSTICK: + space = &fgeom.unstick_rect; + break; + default: + return FALSE; + } + + if (!space->clickable.width && !space->clickable.height) + return FALSE; + + *x = space->clickable.x; + *y = space->clickable.y; + *w = space->clickable.width; + *h = space->clickable.height; + + if (decor->frame_window) { + *x += decor->frame->win_extents.left + 4; + *y += decor->frame->win_extents.top + 2; + } + + return TRUE; +} + +static gfloat +gwd_theme_metacity_get_title_scale (GWDTheme *theme, + decor_frame_t *frame) +{ + GWDThemeMetacity *metacity = GWD_THEME_METACITY (theme); + MetaFrameType type = meta_frame_type_from_string (frame->type); + MetaFrameFlags flags = 0xc33; /* FIXME */ + + if (type == META_FRAME_TYPE_LAST) + return 1.0f; + + return meta_theme_get_title_scale (metacity->theme, type, flags); +} + +static void +gwd_theme_metacity_class_init (GWDThemeMetacityClass *metacity_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (metacity_class); + GWDThemeClass *theme_class = GWD_THEME_CLASS (metacity_class); + + object_class->constructed = gwd_theme_metacity_constructed; + object_class->constructor = gwd_theme_metacity_constructor; + + theme_class->draw_window_decoration = gwd_theme_metacity_draw_window_decoration; + theme_class->calc_decoration_size = gwd_theme_metacity_calc_decoration_size; + theme_class->update_border_extents = gwd_theme_metacity_update_border_extents; + theme_class->get_event_window_position = gwd_theme_metacity_get_event_window_position; + theme_class->get_button_position = gwd_theme_metacity_get_button_position; + theme_class->get_title_scale = gwd_theme_metacity_get_title_scale; +} + +static void +gwd_theme_metacity_init (GWDThemeMetacity *metacity) +{ +} diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-theme-metacity.h compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-theme-metacity.h --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/gwd-theme-metacity.h 1970-01-01 00:00:00.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/gwd-theme-metacity.h 2016-05-25 14:20:18.000000000 +0000 @@ -0,0 +1,35 @@ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4 -*- */ + +/* + * Copyright (C) 2016 Alberts Muktupāvels + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GWD_THEME_METACITY_H +#define GWD_THEME_METACITY_H + +#include + +#include "gwd-theme.h" + +G_BEGIN_DECLS + +#define GWD_TYPE_THEME_METACITY gwd_theme_metacity_get_type () +G_DECLARE_FINAL_TYPE (GWDThemeMetacity, gwd_theme_metacity, + GWD, THEME_METACITY, GWDTheme) + +G_END_DECLS + +#endif diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/metacity.c compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/metacity.c --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/metacity.c 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/metacity.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,1553 +0,0 @@ -/* - * Copyright © 2006 Novell, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: David Reveman - * - * 2D Mode: Copyright © 2010 Sam Spilsbury - * Frames Management: Copright © 2011 Canonical Ltd. - * Authored By: Sam Spilsbury - */ - -#include "gtk-window-decorator.h" - -#ifdef USE_METACITY - -MetaButtonLayout meta_button_layout; - -static gboolean -meta_button_present (MetaButtonLayout *button_layout, - MetaButtonFunction function) -{ - int i; - - for (i = 0; i < MAX_BUTTONS_PER_CORNER; ++i) - if (button_layout->left_buttons[i] == function) - return TRUE; - - for (i = 0; i < MAX_BUTTONS_PER_CORNER; ++i) - if (button_layout->right_buttons[i] == function) - return TRUE; - - return FALSE; -} - -static void -decor_update_meta_window_property (decor_t *d, - MetaTheme *theme, - MetaFrameFlags flags, - MetaFrameType type, - Region top, - Region bottom, - Region left, - Region right) -{ - long *data; - GdkDisplay *display; - Display *xdisplay; - gint nQuad; - decor_extents_t win_extents; - decor_extents_t frame_win_extents; - decor_extents_t max_win_extents; - decor_extents_t frame_max_win_extents; - decor_quad_t quads[N_QUADS_MAX]; - unsigned int nOffset; - unsigned int frame_type; - unsigned int frame_state; - unsigned int frame_actions; - gint w; - gint lh; - gint rh; - gint top_stretch_offset; - gint bottom_stretch_offset; - gint left_stretch_offset; - gint right_stretch_offset; - - display = gdk_display_get_default (); - xdisplay = gdk_x11_display_get_xdisplay (display); - - nOffset = 1; - - frame_type = populate_frame_type (d); - frame_state = populate_frame_state (d); - frame_actions = populate_frame_actions (d); - - win_extents = frame_win_extents = d->frame->win_extents; - max_win_extents = frame_max_win_extents = d->frame->max_win_extents; - - /* Add the invisible grab area padding, but only for - * pixmap type decorations */ - if (!d->frame_window) - { - GdkScreen *screen; - MetaStyleInfo *style_info; - MetaFrameBorders borders; - - screen = gtk_widget_get_screen (d->frame->style_window_rgba); - style_info = meta_theme_create_style_info (screen, d->gtk_theme_variant); - - meta_theme_get_frame_borders (theme, style_info, type, - d->frame->text_height, - flags, &borders); - - if (flags & META_FRAME_ALLOWS_HORIZONTAL_RESIZE) - { - frame_win_extents.left += borders.invisible.left; - frame_win_extents.right += borders.invisible.right; - frame_max_win_extents.left += borders.invisible.left; - frame_max_win_extents.right += borders.invisible.right; - } - - if (flags & META_FRAME_ALLOWS_VERTICAL_RESIZE) - { - frame_win_extents.bottom += borders.invisible.bottom; - frame_win_extents.top += borders.invisible.top; - frame_max_win_extents.bottom += borders.invisible.bottom; - frame_max_win_extents.top += borders.invisible.top; - } - - meta_style_info_unref (style_info); - } - - w = d->border_layout.top.x2 - d->border_layout.top.x1 - - d->context->left_space - d->context->right_space; - - if (d->border_layout.rotation) - lh = d->border_layout.left.x2 - d->border_layout.left.x1; - else - lh = d->border_layout.left.y2 - d->border_layout.left.y1; - - if (d->border_layout.rotation) - rh = d->border_layout.right.x2 - d->border_layout.right.x1; - else - rh = d->border_layout.right.y2 - d->border_layout.right.y1; - - left_stretch_offset = lh / 2; - right_stretch_offset = rh / 2; - top_stretch_offset = w - d->button_width - 1; - bottom_stretch_offset = (d->border_layout.bottom.x2 - d->border_layout.bottom.x1 - - d->context->left_space - d->context->right_space) / 2; - - nQuad = decor_set_lXrXtXbX_window_quads (quads, d->context, &d->border_layout, - left_stretch_offset, right_stretch_offset, - top_stretch_offset, bottom_stretch_offset); - - win_extents.top += d->frame->titlebar_height; - frame_win_extents.top += d->frame->titlebar_height; - max_win_extents.top += d->frame->max_titlebar_height; - frame_max_win_extents.top += d->frame->max_titlebar_height; - - if (d->frame_window) - { - data = decor_alloc_property (nOffset, WINDOW_DECORATION_TYPE_WINDOW); - decor_gen_window_property (data, nOffset - 1, &win_extents, &max_win_extents, - 20, 20, frame_type, frame_state, frame_actions); - } - else - { - data = decor_alloc_property (nOffset, WINDOW_DECORATION_TYPE_PIXMAP); - decor_quads_to_property (data, nOffset - 1, cairo_xlib_surface_get_drawable (d->surface), - &frame_win_extents, &win_extents, - &frame_max_win_extents, &max_win_extents, - ICON_SPACE + d->button_width, - 0, quads, nQuad, frame_type, frame_state, frame_actions); - } - - gdk_error_trap_push (); - - XChangeProperty (xdisplay, d->prop_xid, win_decor_atom, XA_INTEGER, - 32, PropModeReplace, (guchar *) data, - PROP_HEADER_SIZE + BASE_PROP_SIZE + QUAD_PROP_SIZE * N_QUADS_MAX); - gdk_display_sync (display); - - gdk_error_trap_pop_ignored (); - - free (data); - - decor_update_blur_property (d, w, lh, - top, top_stretch_offset, - bottom, bottom_stretch_offset, - left, left_stretch_offset, - right, right_stretch_offset); -} - -static void -meta_get_corner_radius (const MetaFrameGeometry *fgeom, - int *top_left_radius, - int *top_right_radius, - int *bottom_left_radius, - int *bottom_right_radius) -{ - *top_left_radius = fgeom->top_left_corner_rounded_radius; - *top_right_radius = fgeom->top_right_corner_rounded_radius; - *bottom_left_radius = fgeom->bottom_left_corner_rounded_radius; - *bottom_right_radius = fgeom->bottom_right_corner_rounded_radius; -} - -static int -radius_to_width (int radius, - int i) -{ - float r1 = sqrt (radius) + radius; - float r2 = r1 * r1 - (r1 - (i + 0.5)) * (r1 - (i + 0.5)); - - return floor (0.5f + r1 - sqrt (r2)); -} - -static Region -meta_get_top_border_region (const MetaFrameGeometry *fgeom, - int width) -{ - Region corners_xregion; - Region border_xregion; - XRectangle xrect; - int top_left_radius; - int top_right_radius; - int bottom_left_radius; - int bottom_right_radius; - int w; - int i; - int height; - - corners_xregion = XCreateRegion (); - - meta_get_corner_radius (fgeom, &top_left_radius, &top_right_radius, - &bottom_left_radius, &bottom_right_radius); - - width = width - fgeom->borders.invisible.left - fgeom->borders.invisible.right; - height = fgeom->borders.visible.top; - - if (top_left_radius) - { - for (i = 0; i < top_left_radius; ++i) - { - w = radius_to_width (top_left_radius, i); - - xrect.x = 0; - xrect.y = i; - xrect.width = w; - xrect.height = 1; - - XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion); - } - } - - if (top_right_radius) - { - for (i = 0; i < top_right_radius; ++i) - { - w = radius_to_width (top_right_radius, i); - - xrect.x = width - w; - xrect.y = i; - xrect.width = w; - xrect.height = 1; - - XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion); - } - } - - border_xregion = XCreateRegion (); - - xrect.x = 0; - xrect.y = 0; - xrect.width = width; - xrect.height = height; - - XUnionRectWithRegion (&xrect, border_xregion, border_xregion); - - XSubtractRegion (border_xregion, corners_xregion, border_xregion); - - XDestroyRegion (corners_xregion); - - return border_xregion; -} - -static Region -meta_get_bottom_border_region (const MetaFrameGeometry *fgeom, - int width) -{ - Region corners_xregion; - Region border_xregion; - XRectangle xrect; - int top_left_radius; - int top_right_radius; - int bottom_left_radius; - int bottom_right_radius; - int w; - int i; - int height; - - corners_xregion = XCreateRegion (); - - meta_get_corner_radius (fgeom, &top_left_radius, &top_right_radius, - &bottom_left_radius, &bottom_right_radius); - - width = width - fgeom->borders.invisible.left - fgeom->borders.invisible.right; - height = fgeom->borders.visible.bottom; - - if (bottom_left_radius) - { - for (i = 0; i < bottom_left_radius; ++i) - { - w = radius_to_width (bottom_left_radius, i); - - xrect.x = 0; - xrect.y = height - i - 1; - xrect.width = w; - xrect.height = 1; - - XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion); - } - } - - if (bottom_right_radius) - { - for (i = 0; i < bottom_right_radius; ++i) - { - w = radius_to_width (bottom_right_radius, i); - - xrect.x = width - w; - xrect.y = height - i - 1; - xrect.width = w; - xrect.height = 1; - - XUnionRectWithRegion (&xrect, corners_xregion, corners_xregion); - } - } - - border_xregion = XCreateRegion (); - - xrect.x = 0; - xrect.y = 0; - xrect.width = width; - xrect.height = height; - - XUnionRectWithRegion (&xrect, border_xregion, border_xregion); - - XSubtractRegion (border_xregion, corners_xregion, border_xregion); - - XDestroyRegion (corners_xregion); - - return border_xregion; -} - -static Region -meta_get_left_border_region (const MetaFrameGeometry *fgeom, - int height) -{ - Region border_xregion; - XRectangle xrect; - - border_xregion = XCreateRegion (); - - xrect.x = 0; - xrect.y = 0; - xrect.width = fgeom->borders.visible.left; - xrect.height = height - fgeom->borders.total.top - fgeom->borders.total.bottom; - - XUnionRectWithRegion (&xrect, border_xregion, border_xregion); - - return border_xregion; -} - -static Region -meta_get_right_border_region (const MetaFrameGeometry *fgeom, - int height) -{ - Region border_xregion; - XRectangle xrect; - - border_xregion = XCreateRegion (); - - xrect.x = 0; - xrect.y = 0; - xrect.width = fgeom->borders.visible.right; - xrect.height = height - fgeom->borders.total.top - fgeom->borders.total.bottom; - - XUnionRectWithRegion (&xrect, border_xregion, border_xregion); - - return border_xregion; -} - -static MetaButtonState -meta_button_state (int state) -{ - if (state & IN_EVENT_WINDOW) - { - if (state & PRESSED_EVENT_WINDOW) - return META_BUTTON_STATE_PRESSED; - - return META_BUTTON_STATE_PRELIGHT; - } - - return META_BUTTON_STATE_NORMAL; -} - -static MetaButtonType -meta_function_to_type (MetaButtonFunction function) -{ - switch (function) - { - case META_BUTTON_FUNCTION_MENU: - return META_BUTTON_TYPE_MENU; - case META_BUTTON_FUNCTION_MINIMIZE: - return META_BUTTON_TYPE_MINIMIZE; - case META_BUTTON_FUNCTION_MAXIMIZE: - return META_BUTTON_TYPE_MAXIMIZE; - case META_BUTTON_FUNCTION_CLOSE: - return META_BUTTON_TYPE_CLOSE; - case META_BUTTON_FUNCTION_SHADE: - return META_BUTTON_TYPE_SHADE; - case META_BUTTON_FUNCTION_ABOVE: - return META_BUTTON_TYPE_ABOVE; - case META_BUTTON_FUNCTION_STICK: - return META_BUTTON_TYPE_STICK; - case META_BUTTON_FUNCTION_UNSHADE: - return META_BUTTON_TYPE_UNSHADE; - case META_BUTTON_FUNCTION_UNABOVE: - return META_BUTTON_TYPE_UNABOVE; - case META_BUTTON_FUNCTION_UNSTICK: - return META_BUTTON_TYPE_UNSTICK; - default: - break; - } - - return META_BUTTON_TYPE_LAST; -} - -static MetaButtonState -meta_button_state_for_button_type (decor_t *d, - MetaButtonType type) -{ - switch (type) - { - case META_BUTTON_TYPE_LEFT_LEFT_BACKGROUND: - type = meta_function_to_type (meta_button_layout.left_buttons[0]); - break; - case META_BUTTON_TYPE_LEFT_MIDDLE_BACKGROUND: - type = meta_function_to_type (meta_button_layout.left_buttons[1]); - break; - case META_BUTTON_TYPE_LEFT_RIGHT_BACKGROUND: - type = meta_function_to_type (meta_button_layout.left_buttons[2]); - break; - case META_BUTTON_TYPE_RIGHT_LEFT_BACKGROUND: - type = meta_function_to_type (meta_button_layout.right_buttons[0]); - break; - case META_BUTTON_TYPE_RIGHT_MIDDLE_BACKGROUND: - type = meta_function_to_type (meta_button_layout.right_buttons[1]); - break; - case META_BUTTON_TYPE_RIGHT_RIGHT_BACKGROUND: - type = meta_function_to_type (meta_button_layout.right_buttons[2]); - default: - break; - } - - switch (type) - { - case META_BUTTON_TYPE_CLOSE: - return meta_button_state (d->button_states[BUTTON_CLOSE]); - case META_BUTTON_TYPE_MAXIMIZE: - return meta_button_state (d->button_states[BUTTON_MAX]); - case META_BUTTON_TYPE_MINIMIZE: - return meta_button_state (d->button_states[BUTTON_MIN]); - case META_BUTTON_TYPE_MENU: - return meta_button_state (d->button_states[BUTTON_MENU]); - case META_BUTTON_TYPE_SHADE: - return meta_button_state (d->button_states[BUTTON_SHADE]); - case META_BUTTON_TYPE_ABOVE: - return meta_button_state (d->button_states[BUTTON_ABOVE]); - case META_BUTTON_TYPE_STICK: - return meta_button_state (d->button_states[BUTTON_STICK]); - case META_BUTTON_TYPE_UNSHADE: - return meta_button_state (d->button_states[BUTTON_UNSHADE]); - case META_BUTTON_TYPE_UNABOVE: - return meta_button_state (d->button_states[BUTTON_UNABOVE]); - case META_BUTTON_TYPE_UNSTICK: - return meta_button_state (d->button_states[BUTTON_UNSTICK]); - default: - break; - } - - return META_BUTTON_STATE_NORMAL; -} - -static void -meta_get_decoration_geometry (decor_t *d, - MetaTheme *theme, - MetaFrameFlags *flags, - MetaFrameGeometry *fgeom, - MetaButtonLayout *button_layout, - MetaFrameType frame_type) -{ - GdkScreen *screen; - MetaStyleInfo *style_info; - gint client_width; - gint client_height; - - if (!(frame_type < META_FRAME_TYPE_LAST)) - frame_type = META_FRAME_TYPE_NORMAL; - - if (meta_button_layout_set) - { - *button_layout = meta_button_layout; - } - else - { - gint i; - - button_layout->left_buttons[0] = META_BUTTON_FUNCTION_MENU; - - for (i = 1; i < MAX_BUTTONS_PER_CORNER; ++i) - button_layout->left_buttons[i] = META_BUTTON_FUNCTION_LAST; - - button_layout->right_buttons[0] = META_BUTTON_FUNCTION_MINIMIZE; - button_layout->right_buttons[1] = META_BUTTON_FUNCTION_MAXIMIZE; - button_layout->right_buttons[2] = META_BUTTON_FUNCTION_CLOSE; - - for (i = 3; i < MAX_BUTTONS_PER_CORNER; ++i) - button_layout->right_buttons[i] = META_BUTTON_FUNCTION_LAST; - } - - *flags = 0; - - if (d->actions & WNCK_WINDOW_ACTION_CLOSE) - *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_DELETE; - - if (d->actions & WNCK_WINDOW_ACTION_MINIMIZE) - *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_MINIMIZE; - - if (d->actions & WNCK_WINDOW_ACTION_MAXIMIZE) - *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_MAXIMIZE; - - *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_MENU; - - if (d->actions & WNCK_WINDOW_ACTION_RESIZE) - { - if (!(d->state & WNCK_WINDOW_STATE_MAXIMIZED_VERTICALLY)) - *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_VERTICAL_RESIZE; - if (!(d->state & WNCK_WINDOW_STATE_MAXIMIZED_HORIZONTALLY)) - *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_HORIZONTAL_RESIZE; - } - - if (d->actions & WNCK_WINDOW_ACTION_MOVE) - *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_MOVE; - - if (d->actions & WNCK_WINDOW_ACTION_MAXIMIZE) - *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_MAXIMIZE; - - if (d->actions & WNCK_WINDOW_ACTION_SHADE) - *flags |= (MetaFrameFlags ) META_FRAME_ALLOWS_SHADE; - - if (d->active) - *flags |= (MetaFrameFlags ) META_FRAME_HAS_FOCUS; - - if ((d->state & META_MAXIMIZED) == META_MAXIMIZED) - *flags |= (MetaFrameFlags ) META_FRAME_MAXIMIZED; - - if (d->state & WNCK_WINDOW_STATE_STICKY) - *flags |= (MetaFrameFlags ) META_FRAME_STUCK; - - if (d->state & WNCK_WINDOW_STATE_FULLSCREEN) - *flags |= (MetaFrameFlags ) META_FRAME_FULLSCREEN; - - if (d->state & WNCK_WINDOW_STATE_SHADED) - *flags |= (MetaFrameFlags ) META_FRAME_SHADED; - - if (d->state & WNCK_WINDOW_STATE_ABOVE) - *flags |= (MetaFrameFlags ) META_FRAME_ABOVE; - - client_width = d->border_layout.top.x2 - d->border_layout.top.x1; - client_width -= d->context->right_space + d->context->left_space; - - if (d->border_layout.rotation) - client_height = d->border_layout.left.x2 - d->border_layout.left.x1; - else - client_height = d->border_layout.left.y2 - d->border_layout.left.y1; - - screen = gtk_widget_get_screen (d->frame->style_window_rgba); - style_info = meta_theme_create_style_info (screen, d->gtk_theme_variant); - - meta_theme_calc_geometry (theme, style_info, frame_type, d->frame->text_height, - *flags, client_width, client_height, - button_layout, fgeom); - - meta_style_info_unref (style_info); -} - -void -meta_draw_window_decoration (decor_t *d) -{ - GdkDisplay *display; - GdkScreen *screen; - Display *xdisplay; - cairo_surface_t *surface; - Picture src; - MetaButtonState button_states [META_BUTTON_TYPE_LAST]; - MetaButtonLayout button_layout; - MetaFrameGeometry fgeom; - MetaFrameFlags flags; - MetaFrameType frame_type; - MetaTheme *theme; - MetaStyleInfo *style_info; - GtkStyleContext *context; - cairo_t *cr; - gint i; - Region top_region; - Region bottom_region; - Region left_region; - Region right_region; - gdouble meta_active_opacity; - gdouble meta_inactive_opacity; - gboolean meta_active_shade_opacity; - gboolean meta_inactive_shade_opacity; - double alpha; - gboolean shade_alpha; - MetaFrameStyle *frame_style; - GtkWidget *style_window; - GdkRGBA bg_rgba; - - if (!d->surface || !d->picture) - return; - - display = gdk_display_get_default (); - xdisplay = gdk_x11_display_get_xdisplay (display); - - top_region = NULL; - bottom_region = NULL; - left_region = NULL; - right_region = NULL; - - g_object_get (settings, "metacity-active-opacity", &meta_active_opacity, NULL); - g_object_get (settings, "metacity-inactive-opacity", &meta_inactive_opacity, NULL); - g_object_get (settings, "metacity-active-shade-opacity", &meta_active_shade_opacity, NULL); - g_object_get (settings, "metacity-inactive-shade-opacity", &meta_inactive_shade_opacity, NULL); - - alpha = (d->active) ? meta_active_opacity : meta_inactive_opacity; - shade_alpha = (d->active) ? meta_active_shade_opacity : meta_inactive_shade_opacity; - - if (decoration_alpha == 1.0) - alpha = 1.0; - - if (cairo_xlib_surface_get_depth (d->surface) == 32) - style_window = d->frame->style_window_rgba; - else - style_window = d->frame->style_window_rgb; - - context = gtk_widget_get_style_context (style_window); - - cr = cairo_create (d->buffer_surface ? d->buffer_surface : d->surface); - - cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); - - theme = meta_theme_get_current (); - - frame_type = meta_frame_type_from_string (d->frame->type); - - if (frame_type == META_FRAME_TYPE_LAST) - frame_type = META_FRAME_TYPE_NORMAL; - - meta_get_decoration_geometry (d, theme, &flags, &fgeom, &button_layout, - frame_type); - - if ((d->prop_xid || !d->buffer_surface) && !d->frame_window) - draw_shadow_background (d, cr, d->shadow, d->context); - - for (i = 0; i < META_BUTTON_TYPE_LAST; ++i) - button_states[i] = meta_button_state_for_button_type (d, i); - - frame_style = meta_theme_get_frame_style (theme, frame_type, flags); - - gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg_rgba); - bg_rgba.alpha = 1.0; - - if (frame_style->window_background_color) - { - meta_color_spec_render (frame_style->window_background_color, - context, &bg_rgba); - - bg_rgba.alpha = frame_style->window_background_alpha / 255.0; - } - - /* Draw something that will be almost invisible to user. This is hacky way - * to fix invisible decorations. */ - cairo_set_source_rgba (cr, 0, 0, 0, 0.01); - cairo_rectangle (cr, 0, 0, 1, 1); - cairo_fill (cr); - /* ------------ */ - - cairo_destroy (cr); - - if (d->frame_window) - surface = create_surface (fgeom.width, fgeom.height, d->frame->style_window_rgb); - else - surface = create_surface (fgeom.width, fgeom.height, d->frame->style_window_rgba); - - cr = cairo_create (surface); - gdk_cairo_set_source_rgba (cr, &bg_rgba); - cairo_set_operator (cr, CAIRO_OPERATOR_OVER); - - src = XRenderCreatePicture (xdisplay, cairo_xlib_surface_get_drawable (surface), - get_format_for_surface (d, surface), 0, NULL); - - screen = gtk_widget_get_screen (d->frame->style_window_rgba); - style_info = meta_theme_create_style_info (screen, d->gtk_theme_variant); - - cairo_paint (cr); - meta_theme_draw_frame (theme, style_info, cr, frame_type, flags, - fgeom.width - fgeom.borders.total.left - fgeom.borders.total.right, - fgeom.height - fgeom.borders.total.top - fgeom.borders.total.bottom, - d->layout, d->frame->text_height, &button_layout, - button_states, d->icon_pixbuf, NULL); - - meta_style_info_unref (style_info); - - if (fgeom.borders.visible.top) - { - top_region = meta_get_top_border_region (&fgeom, fgeom.width); - - decor_blend_border_picture (xdisplay, d->context, src, - fgeom.borders.invisible.left, - fgeom.borders.invisible.top, - d->picture, &d->border_layout, - BORDER_TOP, top_region, - alpha * 0xffff, shade_alpha, 0); - } - - if (fgeom.borders.visible.bottom) - { - bottom_region = meta_get_bottom_border_region (&fgeom, fgeom.width); - - decor_blend_border_picture (xdisplay, d->context, src, - fgeom.borders.invisible.left, - fgeom.height - fgeom.borders.total.bottom, - d->picture, &d->border_layout, - BORDER_BOTTOM, bottom_region, - alpha * 0xffff, shade_alpha, 0); - } - - if (fgeom.borders.visible.left) - { - left_region = meta_get_left_border_region (&fgeom, fgeom.height); - - decor_blend_border_picture (xdisplay, d->context, src, - fgeom.borders.invisible.left, - fgeom.borders.total.top, - d->picture, &d->border_layout, - BORDER_LEFT, left_region, - alpha * 0xffff, shade_alpha, 0); - } - - if (fgeom.borders.visible.right) - { - right_region = meta_get_right_border_region (&fgeom, fgeom.height); - - decor_blend_border_picture (xdisplay, d->context, src, - fgeom.width - fgeom.borders.total.right, - fgeom.borders.total.top, - d->picture, &d->border_layout, - BORDER_RIGHT, right_region, - alpha * 0xffff, shade_alpha, 0); - } - - cairo_destroy (cr); - cairo_surface_destroy (surface); - XRenderFreePicture (xdisplay, src); - - copy_to_front_buffer (d); - - if (d->frame_window) - { - GdkWindow *gdk_frame_window; - GdkPixbuf *pixbuf; - - gdk_frame_window = gtk_widget_get_window (d->decor_window); - - pixbuf = gdk_pixbuf_get_from_surface (d->surface, 0, 0, d->width, d->height); - gtk_image_set_from_pixbuf (GTK_IMAGE (d->decor_image), pixbuf); - g_object_unref (pixbuf); - - gdk_window_move_resize (gdk_frame_window, - d->context->left_corner_space - 1, - d->context->top_corner_space - 1, - d->width, - d->height); - - gdk_window_lower (gdk_frame_window); - } - - if (d->prop_xid) - { - /* translate from frame to client window space */ - if (top_region) - XOffsetRegion (top_region, -fgeom.borders.total.left, -fgeom.borders.total.top); - if (bottom_region) - XOffsetRegion (bottom_region, -fgeom.borders.total.left, 0); - if (left_region) - XOffsetRegion (left_region, -fgeom.borders.total.left, 0); - - decor_update_meta_window_property (d, theme, flags, frame_type, - top_region, bottom_region, - left_region, right_region); - - d->prop_xid = 0; - } - - if (top_region) - XDestroyRegion (top_region); - if (bottom_region) - XDestroyRegion (bottom_region); - if (left_region) - XDestroyRegion (left_region); - if (right_region) - XDestroyRegion (right_region); -} - -static void -meta_calc_button_size (decor_t *d) -{ - MetaTheme *theme; - MetaFrameType frame_type; - MetaFrameFlags flags; - MetaFrameGeometry fgeom; - MetaButtonLayout button_layout; - gint i, min_x, x, y, w, h, width; - - if (!d->context) - { - d->button_width = 0; - return; - } - - theme = meta_theme_get_current (); - - frame_type = meta_frame_type_from_string (d->frame->type); - if (!(frame_type < META_FRAME_TYPE_LAST)) - frame_type = META_FRAME_TYPE_NORMAL; - - meta_get_decoration_geometry (d, theme, &flags, &fgeom, &button_layout, - frame_type); - - width = d->border_layout.top.x2 - d->border_layout.top.x1 - - d->context->left_space - d->context->right_space + - fgeom.borders.total.left + fgeom.borders.total.right; - - min_x = width; - - for (i = 0; i < 3; ++i) - { - static guint button_actions[3] = { - WNCK_WINDOW_ACTION_CLOSE, - WNCK_WINDOW_ACTION_MAXIMIZE, - WNCK_WINDOW_ACTION_MINIMIZE - }; - - if (d->actions & button_actions[i]) - { - if (meta_get_button_position (d, i, width, 256, &x, &y, &w, &h)) - { - if (x > width / 2 && x < min_x) - min_x = x; - } - } - } - - d->button_width = width - min_x; -} - -static MetaButtonFunction -button_to_meta_button_function (gint i) -{ - switch (i) - { - case BUTTON_MENU: - return META_BUTTON_FUNCTION_MENU; - case BUTTON_MIN: - return META_BUTTON_FUNCTION_MINIMIZE; - case BUTTON_MAX: - return META_BUTTON_FUNCTION_MAXIMIZE; - case BUTTON_CLOSE: - return META_BUTTON_FUNCTION_CLOSE; - case BUTTON_SHADE: - return META_BUTTON_FUNCTION_SHADE; - case BUTTON_ABOVE: - return META_BUTTON_FUNCTION_ABOVE; - case BUTTON_STICK: - return META_BUTTON_FUNCTION_STICK; - case BUTTON_UNSHADE: - return META_BUTTON_FUNCTION_UNSHADE; - case BUTTON_UNABOVE: - return META_BUTTON_FUNCTION_UNABOVE; - case BUTTON_UNSTICK: - return META_BUTTON_FUNCTION_UNSTICK; - default: - break; - } - - return META_BUTTON_FUNCTION_LAST; -} - -gboolean -meta_get_button_position (decor_t *d, - gint i, - gint width, - gint height, - gint *x, - gint *y, - gint *w, - gint *h) -{ - MetaButtonLayout button_layout; - MetaFrameGeometry fgeom; - MetaFrameType frame_type; - MetaFrameFlags flags; - MetaTheme *theme; - MetaButtonFunction button_function; - MetaButtonSpace *space; - - if (!d->context) - { - /* undecorated windows implicitly have no buttons */ - return FALSE; - } - - theme = meta_theme_get_current (); - - frame_type = meta_frame_type_from_string (d->frame->type); - if (!(frame_type < META_FRAME_TYPE_LAST)) - frame_type = META_FRAME_TYPE_NORMAL; - - meta_get_decoration_geometry (d, theme, &flags, &fgeom, &button_layout, - frame_type); - - button_function = button_to_meta_button_function (i); - if (!meta_button_present (&button_layout, button_function)) - return FALSE; - - switch (i) - { - case BUTTON_MENU: - space = &fgeom.menu_rect; - break; - case BUTTON_MIN: - space = &fgeom.min_rect; - break; - case BUTTON_MAX: - space = &fgeom.max_rect; - break; - case BUTTON_CLOSE: - space = &fgeom.close_rect; - break; - case BUTTON_SHADE: - space = &fgeom.shade_rect; - break; - case BUTTON_ABOVE: - space = &fgeom.above_rect; - break; - case BUTTON_STICK: - space = &fgeom.stick_rect; - break; - case BUTTON_UNSHADE: - space = &fgeom.unshade_rect; - break; - case BUTTON_UNABOVE: - space = &fgeom.unabove_rect; - break; - case BUTTON_UNSTICK: - space = &fgeom.unstick_rect; - break; - default: - return FALSE; - } - - if (!space->clickable.width && !space->clickable.height) - return FALSE; - - *x = space->clickable.x; - *y = space->clickable.y; - *w = space->clickable.width; - *h = space->clickable.height; - - if (d->frame_window) - { - *x += d->frame->win_extents.left + 4; - *y += d->frame->win_extents.top + 2; - } - - return TRUE; -} - -gfloat -meta_get_title_scale (decor_frame_t *frame) -{ - MetaTheme *theme; - MetaFrameType type; - MetaFrameFlags flags; - - theme = meta_theme_get_current (); - type = meta_frame_type_from_string (frame->type); - flags = 0xc33; /* fixme */ - - if (type == META_FRAME_TYPE_LAST) - return 1.0f; - - gfloat scale = meta_theme_get_title_scale (theme, type, flags); - - return scale; -} - -gboolean -meta_calc_decoration_size (decor_t *d, - gint w, - gint h, - gint name_width, - gint *width, - gint *height) -{ - decor_layout_t layout; - decor_context_t *context; - decor_shadow_t *shadow; - - if (!d->decorated) - return FALSE; - - if ((d->state & META_MAXIMIZED) == META_MAXIMIZED) - { - if (!d->frame_window) - { - if (d->active) - { - context = &d->frame->max_window_context_active; - shadow = d->frame->max_border_shadow_active; - } - else - { - context = &d->frame->max_window_context_inactive; - shadow = d->frame->max_border_shadow_inactive; - } - } - else - { - context = &d->frame->max_window_context_no_shadow; - shadow = d->frame->max_border_no_shadow; - } - } - else - { - if (!d->frame_window) - { - if (d->active) - { - context = &d->frame->window_context_active; - shadow = d->frame->border_shadow_active; - } - else - { - context = &d->frame->window_context_inactive; - shadow = d->frame->border_shadow_inactive; - } - } - else - { - context = &d->frame->window_context_no_shadow; - shadow = d->frame->border_no_shadow; - } - } - - if (!d->frame_window) - { - decor_get_best_layout (context, w, h, &layout); - - if (context != d->context || memcmp (&layout, &d->border_layout, sizeof (layout))) - { - *width = layout.width; - *height = layout.height; - - d->border_layout = layout; - d->context = context; - d->shadow = shadow; - - meta_calc_button_size (d); - - return TRUE; - } - } - else - { - if ((d->state & META_MAXIMIZED) == META_MAXIMIZED) - decor_get_default_layout (context, d->client_width, - d->client_height - d->frame->titlebar_height, - &layout); - else - decor_get_default_layout (context, d->client_width, - d->client_height, &layout); - - *width = layout.width; - *height = layout.height; - - d->border_layout = layout; - d->shadow = shadow; - d->context = context; - - meta_calc_button_size (d); - - return TRUE; - } - - return FALSE; -} - -#define TOP_RESIZE_HEIGHT 2 -#define RESIZE_EXTENDS 15 - -void -meta_get_event_window_position (decor_t *d, - gint i, - gint j, - gint width, - gint height, - gint *x, - gint *y, - gint *w, - gint *h) -{ - MetaButtonLayout button_layout; - MetaFrameGeometry fgeom; - MetaFrameFlags flags; - MetaTheme *theme; - - theme = meta_theme_get_current (); - - meta_get_decoration_geometry (d, theme, &flags, &fgeom, &button_layout, - meta_frame_type_from_string (d->frame->type)); - - width += fgeom.borders.total.right + fgeom.borders.total.left; - height += fgeom.borders.total.top + fgeom.borders.total.bottom; - - switch (i) - { - case 2: /* bottom */ - switch (j) - { - case 2: /* bottom right */ - *x = width - fgeom.borders.total.right - RESIZE_EXTENDS; - *y = height - fgeom.borders.total.bottom - RESIZE_EXTENDS; - - if (d->frame_window) - { - *x += d->frame->win_extents.left + 2; - *y += d->frame->win_extents.top + 2; - } - - *w = fgeom.borders.total.right + RESIZE_EXTENDS; - *h = fgeom.borders.total.bottom + RESIZE_EXTENDS; - break; - case 1: /* bottom */ - *x = fgeom.borders.total.left + RESIZE_EXTENDS; - *y = height - fgeom.borders.total.bottom; - - if (d->frame_window) - *y += d->frame->win_extents.top + 2; - - *w = width - fgeom.borders.total.left - fgeom.borders.total.right - (2 * RESIZE_EXTENDS); - *h = fgeom.borders.total.bottom; - break; - case 0: /* bottom left */ - default: - *x = 0; - *y = height - fgeom.borders.total.bottom - RESIZE_EXTENDS; - - if (d->frame_window) - { - *x += d->frame->win_extents.left + 4; - *y += d->frame->win_extents.bottom + 2; - } - - *w = fgeom.borders.total.left + RESIZE_EXTENDS; - *h = fgeom.borders.total.bottom + RESIZE_EXTENDS; - break; - } - break; - case 1: /* middle */ - switch (j) - { - case 2: /* right */ - *x = width - fgeom.borders.total.right; - *y = fgeom.borders.total.top + RESIZE_EXTENDS; - - if (d->frame_window) - *x += d->frame->win_extents.left + 2; - - *w = fgeom.borders.total.right; - *h = height - fgeom.borders.total.top - fgeom.borders.total.bottom - (2 * RESIZE_EXTENDS); - break; - case 1: /* middle */ - *x = fgeom.borders.total.left; - *y = fgeom.title_rect.y + TOP_RESIZE_HEIGHT; - *w = width - fgeom.borders.total.left - fgeom.borders.total.right; - *h = height - fgeom.top_titlebar_edge - fgeom.borders.total.bottom; - break; - case 0: /* left */ - default: - *x = 0; - *y = fgeom.borders.total.top + RESIZE_EXTENDS; - - if (d->frame_window) - *x += d->frame->win_extents.left + 4; - - *w = fgeom.borders.total.left; - *h = height - fgeom.borders.total.top - fgeom.borders.total.bottom - (2 * RESIZE_EXTENDS); - break; - } - break; - case 0: /* top */ - default: - switch (j) - { - case 2: /* top right */ - *x = width - fgeom.borders.total.right - RESIZE_EXTENDS; - *y = 0; - - if (d->frame_window) - { - *x += d->frame->win_extents.left + 2; - *y += d->frame->win_extents.top + 2 - fgeom.title_rect.height; - } - - *w = fgeom.borders.total.right + RESIZE_EXTENDS; - *h = fgeom.borders.total.top + RESIZE_EXTENDS; - break; - case 1: /* top */ - *x = fgeom.borders.total.left + RESIZE_EXTENDS; - *y = 0; - - if (d->frame_window) - *y += d->frame->win_extents.top + 2; - - *w = width - fgeom.borders.total.left - fgeom.borders.total.right - (2 * RESIZE_EXTENDS); - *h = fgeom.borders.total.top - fgeom.title_rect.height; - break; - case 0: /* top left */ - default: - *x = 0; - *y = 0; - - if (d->frame_window) - { - *x += d->frame->win_extents.left + 4; - *y += d->frame->win_extents.top + 2 - fgeom.title_rect.height; - } - - *w = fgeom.borders.total.left + RESIZE_EXTENDS; - *h = fgeom.borders.total.top + RESIZE_EXTENDS; - break; - } - break; - } - - if (!(flags & META_FRAME_ALLOWS_VERTICAL_RESIZE)) - { - /* turn off top and bottom event windows */ - if (i == 0 || i == 2) - *w = *h = 0; - } - - if (!(flags & META_FRAME_ALLOWS_HORIZONTAL_RESIZE)) - { - /* turn off left and right event windows */ - if (j == 0 || j == 2) - *w = *h = 0; - } -} - -static MetaButtonFunction -meta_button_function_from_string (const char *str) -{ - if (strcmp (str, "menu") == 0) - return META_BUTTON_FUNCTION_MENU; - else if (strcmp (str, "appmenu") == 0) - return META_BUTTON_FUNCTION_APPMENU; - else if (strcmp (str, "minimize") == 0) - return META_BUTTON_FUNCTION_MINIMIZE; - else if (strcmp (str, "maximize") == 0) - return META_BUTTON_FUNCTION_MAXIMIZE; - else if (strcmp (str, "close") == 0) - return META_BUTTON_FUNCTION_CLOSE; - else if (strcmp (str, "shade") == 0) - return META_BUTTON_FUNCTION_SHADE; - else if (strcmp (str, "above") == 0) - return META_BUTTON_FUNCTION_ABOVE; - else if (strcmp (str, "stick") == 0) - return META_BUTTON_FUNCTION_STICK; - else if (strcmp (str, "unshade") == 0) - return META_BUTTON_FUNCTION_UNSHADE; - else if (strcmp (str, "unabove") == 0) - return META_BUTTON_FUNCTION_UNABOVE; - else if (strcmp (str, "unstick") == 0) - return META_BUTTON_FUNCTION_UNSTICK; - else - return META_BUTTON_FUNCTION_LAST; -} - -static MetaButtonFunction -meta_button_opposite_function (MetaButtonFunction ofwhat) -{ - switch (ofwhat) - { - case META_BUTTON_FUNCTION_SHADE: - return META_BUTTON_FUNCTION_UNSHADE; - case META_BUTTON_FUNCTION_UNSHADE: - return META_BUTTON_FUNCTION_SHADE; - - case META_BUTTON_FUNCTION_ABOVE: - return META_BUTTON_FUNCTION_UNABOVE; - case META_BUTTON_FUNCTION_UNABOVE: - return META_BUTTON_FUNCTION_ABOVE; - - case META_BUTTON_FUNCTION_STICK: - return META_BUTTON_FUNCTION_UNSTICK; - case META_BUTTON_FUNCTION_UNSTICK: - return META_BUTTON_FUNCTION_STICK; - - default: - return META_BUTTON_FUNCTION_LAST; - } -} - -static void -meta_initialize_button_layout (MetaButtonLayout *layout) -{ - int i; - - for (i = 0; i < MAX_BUTTONS_PER_CORNER; ++i) - { - layout->left_buttons[i] = META_BUTTON_FUNCTION_LAST; - layout->right_buttons[i] = META_BUTTON_FUNCTION_LAST; - layout->left_buttons_has_spacer[i] = FALSE; - layout->right_buttons_has_spacer[i] = FALSE; - } -} - -void -meta_update_button_layout (const char *value) -{ - MetaButtonLayout new_layout; - MetaButtonFunction f; - char **sides; - int i; - - meta_initialize_button_layout (&new_layout); - - sides = g_strsplit (value, ":", 2); - - if (sides[0] != NULL) - { - char **buttons; - int b; - gboolean used[META_BUTTON_FUNCTION_LAST]; - - for (i = 0; i < META_BUTTON_FUNCTION_LAST; ++i) - used[i] = FALSE; - - buttons = g_strsplit (sides[0], ",", -1); - - i = b = 0; - while (buttons[b] != NULL) - { - f = meta_button_function_from_string (buttons[b]); - if (i > 0 && strcmp ("spacer", buttons[b]) == 0) - { - new_layout.left_buttons_has_spacer[i - 1] = TRUE; - f = meta_button_opposite_function (f); - - if (f != META_BUTTON_FUNCTION_LAST) - new_layout.left_buttons_has_spacer[i - 2] = TRUE; - } - else - { - if (f != META_BUTTON_FUNCTION_LAST && !used[f]) - { - used[f] = TRUE; - new_layout.left_buttons[i++] = f; - - f = meta_button_opposite_function (f); - - if (f != META_BUTTON_FUNCTION_LAST) - new_layout.left_buttons[i++] = f; - - } - else - { - fprintf (stderr, "%s: Ignoring unknown or already-used " - "button name \"%s\"\n", program_name, buttons[b]); - } - } - ++b; - } - - new_layout.left_buttons[i] = META_BUTTON_FUNCTION_LAST; - - g_strfreev (buttons); - - if (sides[1] != NULL) - { - for (i = 0; i < META_BUTTON_FUNCTION_LAST; ++i) - used[i] = FALSE; - - buttons = g_strsplit (sides[1], ",", -1); - - i = b = 0; - while (buttons[b] != NULL) - { - f = meta_button_function_from_string (buttons[b]); - if (i > 0 && strcmp ("spacer", buttons[b]) == 0) - { - new_layout.right_buttons_has_spacer[i - 1] = TRUE; - f = meta_button_opposite_function (f); - if (f != META_BUTTON_FUNCTION_LAST) - new_layout.right_buttons_has_spacer[i - 2] = TRUE; - } - else - { - if (f != META_BUTTON_FUNCTION_LAST && !used[f]) - { - used[f] = TRUE; - new_layout.right_buttons[i++] = f; - - f = meta_button_opposite_function (f); - - if (f != META_BUTTON_FUNCTION_LAST) - new_layout.right_buttons[i++] = f; - } - else - { - fprintf (stderr, "%s: Ignoring unknown or " - "already-used button name \"%s\"\n", - program_name, buttons[b]); - } - } - ++b; - } - - new_layout.right_buttons[i] = META_BUTTON_FUNCTION_LAST; - - g_strfreev (buttons); - } - } - - g_strfreev (sides); - - /* Invert the button layout for RTL languages */ - if (gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL) - { - MetaButtonLayout rtl_layout; - int j; - - meta_initialize_button_layout (&rtl_layout); - - i = 0; - while (new_layout.left_buttons[i] != META_BUTTON_FUNCTION_LAST) - ++i; - - for (j = 0; j < i; ++j) - { - rtl_layout.right_buttons[j] = new_layout.left_buttons[i - j - 1]; - if (j == 0) - rtl_layout.right_buttons_has_spacer[i - 1] = new_layout.left_buttons_has_spacer[i - j - 1]; - else - rtl_layout.right_buttons_has_spacer[j - 1] = new_layout.left_buttons_has_spacer[i - j - 1]; - } - - i = 0; - while (new_layout.right_buttons[i] != META_BUTTON_FUNCTION_LAST) - ++i; - - for (j = 0; j < i; ++j) - { - rtl_layout.left_buttons[j] = new_layout.right_buttons[i - j - 1]; - if (j == 0) - rtl_layout.left_buttons_has_spacer[i - 1] = new_layout.right_buttons_has_spacer[i - j - 1]; - else - rtl_layout.left_buttons_has_spacer[j - 1] = new_layout.right_buttons_has_spacer[i - j - 1]; - } - - new_layout = rtl_layout; - } - - meta_button_layout = new_layout; -} - -void -meta_update_border_extents (decor_frame_t *frame) -{ - MetaTheme *theme; - GdkScreen *screen; - MetaStyleInfo *style_info; - MetaFrameBorders borders; - MetaFrameType frame_type; - gint top_height; - gint bottom_height; - gint left_width; - gint right_width; - - gwd_decor_frame_ref (frame); - - frame_type = meta_frame_type_from_string (frame->type); - if (!(frame_type < META_FRAME_TYPE_LAST)) - frame_type = META_FRAME_TYPE_NORMAL; - - theme = meta_theme_get_current (); - - screen = gtk_widget_get_screen (frame->style_window_rgba); - style_info = meta_theme_create_style_info (screen, NULL); - - meta_theme_get_frame_borders (theme, style_info, frame_type, frame->text_height, - 0, &borders); - - top_height = borders.visible.top; - bottom_height = borders.visible.bottom; - left_width = borders.visible.left; - right_width = borders.visible.right; - - frame->win_extents.top = frame->win_extents.top; - frame->win_extents.bottom = bottom_height; - frame->win_extents.left = left_width; - frame->win_extents.right = right_width; - - frame->titlebar_height = top_height - frame->win_extents.top; - - meta_theme_get_frame_borders (theme, style_info, frame_type, frame->text_height, - META_FRAME_MAXIMIZED, &borders); - - top_height = borders.visible.top; - bottom_height = borders.visible.bottom; - left_width = borders.visible.left; - right_width = borders.visible.right; - - frame->max_win_extents.top = frame->win_extents.top; - frame->max_win_extents.bottom = bottom_height; - frame->max_win_extents.left = left_width; - frame->max_win_extents.right = right_width; - - frame->max_titlebar_height = top_height - frame->max_win_extents.top; - - meta_style_info_unref (style_info); - - gwd_decor_frame_unref (frame); -} - -#endif diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/settings.c compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/settings.c --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/settings.c 2016-05-17 02:52:35.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/settings.c 2016-05-25 14:20:26.000000000 +0000 @@ -20,19 +20,17 @@ */ #include "gtk-window-decorator.h" -#include "gwd-settings-writable-interface.h" #include "gwd-settings-storage.h" #include "gwd-settings-xproperty-storage.h" GWDSettingsStorage *storage = NULL; GWDSettingsXPropertyStorage *xprop_storage = NULL; -gboolean -init_settings (GWDSettingsWritable *writable, - WnckScreen *screen) +void +init_settings (GWDSettings *settings) { - storage = gwd_settings_storage_new (writable, TRUE); - xprop_storage = gwd_settings_xproperty_storage_new (writable); + storage = gwd_settings_storage_new (settings, TRUE); + xprop_storage = gwd_settings_xproperty_storage_new (settings); gwd_settings_storage_update_metacity_theme (storage); gwd_settings_storage_update_opacity (storage); @@ -43,8 +41,6 @@ gwd_settings_storage_update_use_tooltips (storage); gwd_process_decor_shadow_property_update (); - - return TRUE; } void diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/CMakeLists.txt compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/tests/CMakeLists.txt --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/CMakeLists.txt 2016-05-17 02:52:35.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/tests/CMakeLists.txt 2016-05-25 14:20:26.000000000 +0000 @@ -18,37 +18,14 @@ link_directories (${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/..) - add_library (gtk_window_decorator_mock_settings STATIC - ${CMAKE_CURRENT_SOURCE_DIR}/compiz_gwd_mock_settings.cpp) - - target_link_libraries (gtk_window_decorator_mock_settings - gtk_window_decorator_settings_interface) - - add_library (gtk_window_decorator_mock_settings_writable STATIC - ${CMAKE_CURRENT_SOURCE_DIR}/compiz_gwd_mock_settings_writable.cpp) - - target_link_libraries (gtk_window_decorator_mock_settings_writable - gtk_window_decorator_settings_writable_interface) - - add_library (gtk_window_decorator_mock_settings_notified STATIC - ${CMAKE_CURRENT_SOURCE_DIR}/compiz_gwd_mock_settings_notified.cpp) - - target_link_libraries (gtk_window_decorator_mock_settings_notified - gtk_window_decorator_settings_notified_interface) - add_executable (compiz_test_gwd_settings ${CMAKE_CURRENT_SOURCE_DIR}/test_gwd_settings.cpp) set (COMPIZ_TEST_GWD_SETTINGS_ADDITIONAL_LIBRARIES - gtk_window_decorator_settings - gtk_window_decorator_mock_settings - gtk_window_decorator_mock_settings_writable - gtk_window_decorator_mock_settings_notified) + gtk_window_decorator_settings) set (COMPIZ_TEST_GWD_SETTINGS_COVERAGE_TARGETS - gtk_window_decorator_settings - gtk_window_decorator_settings_interface - gtk_window_decorator_settings_notified_interface) + gtk_window_decorator_settings) set (_desktop_gschema_name org.gnome.desktop.wm.preferences) set (_desktop_gschema_filename ${_desktop_gschema_name}.gschema.xml) diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/compiz_gwd_mock_settings.cpp compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/tests/compiz_gwd_mock_settings.cpp --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/compiz_gwd_mock_settings.cpp 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/tests/compiz_gwd_mock_settings.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,199 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Authored By: Sam Spilsbury - */ -#include -#include - -#include - -#include "gwd-settings-interface.h" -#include "compiz_gwd_mock_settings.h" - -#define GWD_MOCK_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GWD_TYPE_MOCK_SETTINGS, GWDMockSettings)); -#define GWD_MOCK_SETTINGS_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), GWD_TYPE_MOCK_SETTINGS, GWDMockSettingsClass)); -#define GWD_IS_MOCK_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GWD_TYPE_MOCK_SETTINGS)); -#define GWD_IS_MOCK_SETTINGS_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), GWD_TYPE_MOCK_SETTINGS)); -#define GWD_MOCK_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GWD_TYPE_MOCK_SETTINGS, GWDMockSettingsClass)); - -typedef struct _GWDMockSettings -{ - GObject parent; -} GWDMockSettings; - -typedef struct _GWDMockSettingsClass -{ - GObjectClass parent_class; -} GWDMockSettingsClass; - -static void gwd_mock_settings_interface_init (GWDSettingsInterface *interface); - -G_DEFINE_TYPE_WITH_CODE (GWDMockSettings, gwd_mock_settings, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (GWD_TYPE_SETTINGS_INTERFACE, - gwd_mock_settings_interface_init)) - -#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GWD_TYPE_MOCK_SETTINGS, GWDMockSettingsPrivate)) - -typedef struct _GWDMockSettingsPrivate -{ - GWDMockSettingsGMockInterface *mock; -} GWDMockSettingsPrivate; - -static void gwd_mock_settings_interface_init (GWDSettingsInterface *interface) -{ -} - -static void gwd_mock_settings_dispose (GObject *object) -{ - GWDMockSettingsGMockInterface *settingsGMock = GET_PRIVATE (object)->mock; - G_OBJECT_CLASS (gwd_mock_settings_parent_class)->dispose (object); - settingsGMock->dispose (); -} - -static void gwd_mock_settings_finalize (GObject *object) -{ - GWDMockSettingsGMockInterface *settingsGMock = GET_PRIVATE (object)->mock; - G_OBJECT_CLASS (gwd_mock_settings_parent_class)->finalize (object); - settingsGMock->finalize (); -} - -static void gwd_mock_settings_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - GWDMockSettingsPrivate *priv = GET_PRIVATE (object); - - switch (property_id) - { - case GWD_MOCK_SETTINGS_PROPERTY_GMOCK_INTERFACE: - if (!priv->mock) - priv->mock = reinterpret_cast (g_value_get_pointer (value)); - break; - case GWD_MOCK_SETTINGS_PROPERTY_BLUR_CHANGED: - case GWD_MOCK_SETTINGS_PROPERTY_ACTIVE_OPACITY: - case GWD_MOCK_SETTINGS_PROPERTY_ACTIVE_SHADE_OPACITY: - case GWD_MOCK_SETTINGS_PROPERTY_INACTIVE_OPACITY: - case GWD_MOCK_SETTINGS_PROPERTY_INACTIVE_SHADE_OPACITY: - case GWD_MOCK_SETTINGS_PROPERTY_METACITY_THEME: - break; - default: - g_assert_not_reached (); - break; - } -} - -static void gwd_mock_settings_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - GWDMockSettingsGMockInterface *settingsGMock = GET_PRIVATE (object)->mock; - settingsGMock->getProperty (property_id, value, pspec); -} - -static void gwd_mock_settings_class_init (GWDMockSettingsClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (klass, sizeof (GWDMockSettingsPrivate)); - - object_class->dispose = gwd_mock_settings_dispose; - object_class->finalize = gwd_mock_settings_finalize; - object_class->get_property = gwd_mock_settings_get_property; - object_class->set_property = gwd_mock_settings_set_property; - - g_object_class_override_property (object_class, - GWD_MOCK_SETTINGS_PROPERTY_ACTIVE_SHADOW, - "active-shadow"); - g_object_class_override_property (object_class, - GWD_MOCK_SETTINGS_PROPERTY_INACTIVE_SHADOW, - "inactive-shadow"); - g_object_class_override_property (object_class, - GWD_MOCK_SETTINGS_PROPERTY_USE_TOOLTIPS, - "use-tooltips"); - g_object_class_override_property (object_class, - GWD_MOCK_SETTINGS_PROPERTY_BLUR_CHANGED, - "blur"); - g_object_class_override_property (object_class, - GWD_MOCK_SETTINGS_PROPERTY_METACITY_THEME, - "metacity-theme"); - g_object_class_override_property (object_class, - GWD_MOCK_SETTINGS_PROPERTY_ACTIVE_OPACITY, - "metacity-active-opacity"); - g_object_class_override_property (object_class, - GWD_MOCK_SETTINGS_PROPERTY_INACTIVE_OPACITY, - "metacity-inactive-opacity"); - g_object_class_override_property (object_class, - GWD_MOCK_SETTINGS_PROPERTY_ACTIVE_SHADE_OPACITY, - "metacity-active-shade-opacity"); - g_object_class_override_property (object_class, - GWD_MOCK_SETTINGS_PROPERTY_INACTIVE_SHADE_OPACITY, - "metacity-inactive-shade-opacity"); - g_object_class_override_property (object_class, - GWD_MOCK_SETTINGS_PROPERTY_BUTTON_LAYOUT, - "metacity-button-layout"); - g_object_class_override_property (object_class, - GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_ACTION_DOUBLE_CLICK, - "titlebar-double-click-action"); - g_object_class_override_property (object_class, - GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_ACTION_MIDDLE_CLICK, - "titlebar-middle-click-action"); - g_object_class_override_property (object_class, - GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_ACTION_RIGHT_CLICK, - "titlebar-right-click-action"); - g_object_class_override_property (object_class, - GWD_MOCK_SETTINGS_PROPERTY_MOUSE_WHEEL_ACTION, - "mouse-wheel-action"); - g_object_class_override_property (object_class, - GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_FONT, - "titlebar-font"); - g_object_class_install_property (object_class, - GWD_MOCK_SETTINGS_PROPERTY_GMOCK_INTERFACE, - g_param_spec_pointer ("gmock-interface", - "Google Mock Interface", - "Google Mock Interface", - static_cast (G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY))); -} - -static void gwd_mock_settings_init (GWDMockSettings *self) -{ -} - -GWDSettings * -gwd_mock_settings_new (GWDMockSettingsGMockInterface *gmock) -{ - GValue gmock_interface_v = G_VALUE_INIT; - - g_value_init (&gmock_interface_v, G_TYPE_POINTER); - - g_value_set_pointer (&gmock_interface_v, reinterpret_cast (gmock)); - - GParameter param[1] = - { - { "gmock-interface", gmock_interface_v } - }; - - GWDSettings *settings = GWD_SETTINGS_INTERFACE (g_object_newv (GWD_TYPE_MOCK_SETTINGS, 1, param)); - - g_value_unset (&gmock_interface_v); - - return settings; -} - - diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/compiz_gwd_mock_settings.h compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/tests/compiz_gwd_mock_settings.h --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/compiz_gwd_mock_settings.h 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/tests/compiz_gwd_mock_settings.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,86 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef _COMPIZ_GWD_MOCK_SETTINGS_H -#define _COMPIZ_GWD_MOCK_SETTINGS_H - -#include -#include - -#include - -class GWDMockSettingsGMockInterface; - -typedef struct _GWDSettings GWDSettingsImpl; - -G_BEGIN_DECLS - -#define GWD_TYPE_MOCK_SETTINGS (gwd_mock_settings_get_type ()) -GType gwd_mock_settings_get_type (); - -GWDSettings * -gwd_mock_settings_new (GWDMockSettingsGMockInterface *); - -enum -{ - GWD_MOCK_SETTINGS_PROPERTY_ACTIVE_SHADOW = 1, - GWD_MOCK_SETTINGS_PROPERTY_INACTIVE_SHADOW = 2, - GWD_MOCK_SETTINGS_PROPERTY_USE_TOOLTIPS = 3, - GWD_MOCK_SETTINGS_PROPERTY_DRAGGABLE_BORDER_WIDTH = 4, - GWD_MOCK_SETTINGS_PROPERTY_ATTACH_MODAL_DIALOGS = 5, - GWD_MOCK_SETTINGS_PROPERTY_BLUR_CHANGED = 6, - GWD_MOCK_SETTINGS_PROPERTY_METACITY_THEME = 7, - GWD_MOCK_SETTINGS_PROPERTY_ACTIVE_OPACITY = 8, - GWD_MOCK_SETTINGS_PROPERTY_INACTIVE_OPACITY = 9, - GWD_MOCK_SETTINGS_PROPERTY_ACTIVE_SHADE_OPACITY = 10, - GWD_MOCK_SETTINGS_PROPERTY_INACTIVE_SHADE_OPACITY = 11, - GWD_MOCK_SETTINGS_PROPERTY_BUTTON_LAYOUT = 12, - GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_ACTION_DOUBLE_CLICK = 13, - GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_ACTION_MIDDLE_CLICK = 14, - GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_ACTION_RIGHT_CLICK = 15, - GWD_MOCK_SETTINGS_PROPERTY_MOUSE_WHEEL_ACTION = 16, - GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_FONT = 17, - GWD_MOCK_SETTINGS_PROPERTY_GMOCK_INTERFACE = 18 -}; - -G_END_DECLS - -class GWDMockSettingsGMockInterface -{ - public: - - virtual ~GWDMockSettingsGMockInterface () {} - - virtual void getProperty (guint property_id, - GValue *property_value, - GParamSpec *pspec) = 0; - virtual void dispose () = 0; - virtual void finalize () = 0; -}; - -class GWDMockSettingsGMock : - public GWDMockSettingsGMockInterface -{ - public: - - MOCK_METHOD3 (getProperty, void (guint, GValue *, GParamSpec *)); - MOCK_METHOD0 (dispose, void ()); - MOCK_METHOD0 (finalize, void ()); -}; - -#endif diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/compiz_gwd_mock_settings_notified.cpp compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/tests/compiz_gwd_mock_settings_notified.cpp --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/compiz_gwd_mock_settings_notified.cpp 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/tests/compiz_gwd_mock_settings_notified.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,192 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Authored By: Sam Spilsbury - */ -#include -#include - -#include - -#include "gwd-settings-notified-interface.h" -#include "compiz_gwd_mock_settings_notified.h" - -#define GWD_MOCK_SETTINGS_NOTIFIED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GWD_TYPE_MOCK_SETTINGS_NOTIFIED, GWDMockSettingsNotified)); -#define GWD_MOCK_SETTINGS_NOTIFIED_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), GWD_TYPE_MOCK_SETTINGS_NOTIFIED, GWDMockSettingsNotifiedClass)); -#define GWD_IS_MOCK_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GWD_TYPE_MOCK_SETTINGS_NOTIFIED)); -#define GWD_IS_MOCK_SETTINGS_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), GWD_TYPE_MOCK_SETTINGS_NOTIFIED)); -#define GWD_MOCK_SETTINGS_NOTIFIED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GWD_TYPE_MOCK_SETTINGS_NOTIFIED, GWDMockSettingsNotifiedClass)); - -typedef struct _GWDMockSettingsNotified -{ - GObject parent; -} GWDMockSettingsNotified; - -typedef struct _GWDMockSettingsNotifiedClass -{ - GObjectClass parent_class; -} GWDMockSettingsNotifiedClass; - -static void gwd_mock_settings_notified_interface_init (GWDSettingsNotifiedInterface *interface); - -G_DEFINE_TYPE_WITH_CODE (GWDMockSettingsNotified, gwd_mock_settings_notified, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (GWD_TYPE_SETTINGS_NOTIFIED_INTERFACE, - gwd_mock_settings_notified_interface_init)) - -#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GWD_TYPE_MOCK_SETTINGS_NOTIFIED, GWDMockSettingsNotifiedPrivate)) - -enum -{ - GWD_MOCK_SETTINGS_NOTIFIED_PROPERTY_GMOCK_INTERFACE = 1 -}; - -typedef struct _GWDMockSettingsNotifiedPrivate -{ - GWDMockSettingsNotifiedGMockInterface *mock; -} GWDMockSettingsNotifiedPrivate; - -gboolean -gwd_mock_settings_notified_update_decorations (GWDSettingsNotified *notified) -{ - GWDMockSettingsNotifiedGMockInterface *notifiedGMock = GET_PRIVATE (notified)->mock; - return notifiedGMock->updateDecorations (); -} - -gboolean -gwd_mock_settings_notified_update_frames (GWDSettingsNotified *notified) -{ - GWDMockSettingsNotifiedGMockInterface *notifiedGMock = GET_PRIVATE (notified)->mock; - return notifiedGMock->updateFrames (); -} - -gboolean -gwd_mock_settings_notified_update_metacity_theme (GWDSettingsNotified *notified) -{ - GWDMockSettingsNotifiedGMockInterface *notifiedGMock = GET_PRIVATE (notified)->mock; - return notifiedGMock->updateMetacityTheme (); -} - -gboolean -gwd_mock_settings_notified_update_metacity_button_layout (GWDSettingsNotified *notified) -{ - GWDMockSettingsNotifiedGMockInterface *notifiedGMock = GET_PRIVATE (notified)->mock; - return notifiedGMock->updateMetacityButtonLayout (); -} -static void gwd_mock_settings_notified_interface_init (GWDSettingsNotifiedInterface *interface) -{ - interface->update_decorations = gwd_mock_settings_notified_update_decorations; - interface->update_frames = gwd_mock_settings_notified_update_frames; - interface->update_metacity_theme = gwd_mock_settings_notified_update_metacity_theme; - interface->update_metacity_button_layout = gwd_mock_settings_notified_update_metacity_button_layout; -} - -static GObject * gwd_mock_settings_notified_constructor (GType type, - guint n_construction_properties, - GObjectConstructParam *construction_properties) -{ - GObject *object = G_OBJECT_CLASS (gwd_mock_settings_notified_parent_class)->constructor (type, n_construction_properties, construction_properties); - GWDMockSettingsNotifiedPrivate *priv = GET_PRIVATE (object); - guint i = 0; - - for (; i < n_construction_properties; ++i) - { - if (g_strcmp0 (construction_properties[i].pspec->name, "gmock-interface") == 0) - { - priv->mock = reinterpret_cast (g_value_get_pointer (construction_properties[i].value)); - } - else - g_assert_not_reached (); - } - - return object; -} - -static void gwd_mock_settings_notified_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - GWDMockSettingsNotifiedPrivate *priv = GET_PRIVATE (object); - - switch (property_id) - { - case GWD_MOCK_SETTINGS_NOTIFIED_PROPERTY_GMOCK_INTERFACE: - if (!priv->mock) - priv->mock = reinterpret_cast (g_value_get_pointer (value)); - break; - default: - g_assert_not_reached (); - } -} - -static void gwd_mock_settings_notified_dispose (GObject *object) -{ - GWDMockSettingsNotifiedGMockInterface *settingsGMock = GET_PRIVATE (object)->mock; - G_OBJECT_CLASS (gwd_mock_settings_notified_parent_class)->dispose (object); - settingsGMock->dispose (); -} - -static void gwd_mock_settings_notified_finalize (GObject *object) -{ - GWDMockSettingsNotifiedGMockInterface *settingsGMock = GET_PRIVATE (object)->mock; - G_OBJECT_CLASS (gwd_mock_settings_notified_parent_class)->finalize (object); - settingsGMock->finalize (); -} - -static void gwd_mock_settings_notified_class_init (GWDMockSettingsNotifiedClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (klass, sizeof (GWDMockSettingsNotifiedPrivate)); - - object_class->dispose = gwd_mock_settings_notified_dispose; - object_class->finalize = gwd_mock_settings_notified_finalize; - object_class->constructor = gwd_mock_settings_notified_constructor; - object_class->set_property = gwd_mock_settings_notified_set_property; - - g_object_class_install_property (object_class, - GWD_MOCK_SETTINGS_NOTIFIED_PROPERTY_GMOCK_INTERFACE, - g_param_spec_pointer ("gmock-interface", - "Google Mock Interface", - "Google Mock Interface", - static_cast (G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY))); -} - -void gwd_mock_settings_notified_init (GWDMockSettingsNotified *self) -{ -} - -GWDSettingsNotified * -gwd_mock_settings_notified_new (GWDMockSettingsNotifiedGMockInterface *gmock) -{ - GValue gmock_interface_v = G_VALUE_INIT; - - g_value_init (&gmock_interface_v, G_TYPE_POINTER); - - g_value_set_pointer (&gmock_interface_v, reinterpret_cast (gmock)); - - GParameter param[1] = - { - { "gmock-interface", gmock_interface_v } - }; - - GWDSettingsNotified *writable = GWD_SETTINGS_NOTIFIED_INTERFACE (g_object_newv (GWD_TYPE_MOCK_SETTINGS_NOTIFIED, 1, param)); - - g_value_unset (&gmock_interface_v); - - return writable; -} diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/compiz_gwd_mock_settings_notified.h compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/tests/compiz_gwd_mock_settings_notified.h --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/compiz_gwd_mock_settings_notified.h 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/tests/compiz_gwd_mock_settings_notified.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,71 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Authored By: Sam Spilsbury - */ -#ifndef _COMPIZ_GWD_MOCK_SETTINGS_NOTIFIED_H -#define _COMPIZ_GWD_MOCK_SETTINGS_NOTIFIED_H - -#include -#include - -#include - -typedef struct _GWDSettingsNotified GWDSettingsNotified; - -class GWDMockSettingsNotifiedGMockInterface; - -G_BEGIN_DECLS - -#define GWD_TYPE_MOCK_SETTINGS_NOTIFIED (gwd_mock_settings_notified_get_type ()) -GType gwd_mock_settings_notified_get_type (); - -GWDSettingsNotified * -gwd_mock_settings_notified_new (GWDMockSettingsNotifiedGMockInterface *); - -G_END_DECLS - -class GWDMockSettingsNotifiedGMockInterface -{ - public: - - virtual ~GWDMockSettingsNotifiedGMockInterface () {} - - virtual gboolean updateDecorations () = 0; - virtual gboolean updateFrames () = 0; - virtual gboolean updateMetacityTheme () = 0; - virtual gboolean updateMetacityButtonLayout () = 0; - - virtual void dispose () = 0; - virtual void finalize () = 0; -}; - -class GWDMockSettingsNotifiedGMock : - public GWDMockSettingsNotifiedGMockInterface -{ - public: - - MOCK_METHOD0 (updateDecorations, gboolean ()); - MOCK_METHOD0 (updateFrames, gboolean ()); - MOCK_METHOD0 (updateMetacityTheme, gboolean ()); - MOCK_METHOD0 (updateMetacityButtonLayout, gboolean ()); - - MOCK_METHOD0 (dispose, void ()); - MOCK_METHOD0 (finalize, void ()); -}; - -#endif diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/compiz_gwd_mock_settings_writable.cpp compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/tests/compiz_gwd_mock_settings_writable.cpp --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/compiz_gwd_mock_settings_writable.cpp 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/tests/compiz_gwd_mock_settings_writable.cpp 1970-01-01 00:00:00.000000000 +0000 @@ -1,278 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Authored By: Sam Spilsbury - */ -#include -#include - -#include - -#include "gwd-settings-writable-interface.h" -#include "compiz_gwd_mock_settings_writable.h" - -#define GWD_MOCK_SETTINGS_WRITABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GWD_TYPE_MOCK_SETTINGS_WRITABLE, GWDMockSettingsWritable)); -#define GWD_MOCK_SETTINGS_WRITABLE_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), GWD_TYPE_MOCK_SETTINGS_WRITABLE, GWDMockSettingsWritableClass)); -#define GWD_IS_MOCK_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GWD_TYPE_MOCK_SETTINGS_WRITABLE)); -#define GWD_IS_MOCK_SETTINGS_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), GWD_TYPE_MOCK_SETTINGS_WRITABLE)); -#define GWD_MOCK_SETTINGS_WRITABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GWD_TYPE_MOCK_SETTINGS_WRITABLE, GWDMockSettingsWritableClass)); - -typedef struct _GWDMockSettingsWritable -{ - GObject parent; -} GWDMockSettingsWritable; - -typedef struct _GWDMockSettingsWritableClass -{ - GObjectClass parent_class; -} GWDMockSettingsWritableClass; - -static void gwd_mock_settings_writable_interface_init (GWDSettingsWritableInterface *interface); - -G_DEFINE_TYPE_WITH_CODE (GWDMockSettingsWritable, gwd_mock_settings_writable, G_TYPE_OBJECT, - G_IMPLEMENT_INTERFACE (GWD_TYPE_WRITABLE_SETTINGS_INTERFACE, - gwd_mock_settings_writable_interface_init)) - -#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GWD_TYPE_MOCK_SETTINGS_WRITABLE, GWDMockSettingsWritablePrivate)) - -enum -{ - GWD_MOCK_SETTINGS_WRITABLE_PROPERTY_GMOCK_INTERFACE = 1 -}; - -typedef struct _GWDMockSettingsWritablePrivate -{ - GWDMockSettingsWritableGMockInterface *mock; -} GWDMockSettingsWritablePrivate; - -void -gwd_mock_settings_writable_freeze_updates (GWDSettingsWritable *settings) -{ - GWDMockSettingsWritableGMockInterface *gmockSettingsWritable = GET_PRIVATE (settings)->mock; - return gmockSettingsWritable->freezeUpdates (); -} - -void -gwd_mock_settings_writable_thaw_updates (GWDSettingsWritable *settings) -{ - GWDMockSettingsWritableGMockInterface *gmockSettingsWritable = GET_PRIVATE (settings)->mock; - return gmockSettingsWritable->thawUpdates (); -} - -gboolean -gwd_mock_settings_writable_shadow_property_changed (GWDSettingsWritable *settings, - gdouble active_shadow_radius, - gdouble active_shadow_opacity, - gdouble active_shadow_offset_x, - gdouble active_shadow_offset_y, - const gchar *active_shadow_color, - gdouble inactive_shadow_radius, - gdouble inactive_shadow_opacity, - gdouble inactive_shadow_offset_x, - gdouble inactive_shadow_offset_y, - const gchar *inactive_shadow_color) -{ - GWDMockSettingsWritableGMockInterface *gmockSettingsWritable = GET_PRIVATE (settings)->mock; - return gmockSettingsWritable->shadowPropertyChanged (active_shadow_radius, - active_shadow_opacity, - active_shadow_offset_x, - active_shadow_offset_y, - active_shadow_color, - inactive_shadow_radius, - inactive_shadow_opacity, - inactive_shadow_offset_x, - inactive_shadow_offset_y, - inactive_shadow_color); -} - -gboolean -gwd_mock_settings_writable_use_tooltips_changed (GWDSettingsWritable *settings, - gboolean use_tooltips) -{ - GWDMockSettingsWritableGMockInterface *gmockSettingsWritable = GET_PRIVATE (settings)->mock; - return gmockSettingsWritable->useTooltipsChanged (use_tooltips); -} - -gboolean -gwd_mock_settings_writable_blur_changed (GWDSettingsWritable *settings, - const gchar *blur_type) -{ - GWDMockSettingsWritableGMockInterface *gmockSettingsWritable = GET_PRIVATE (settings)->mock; - return gmockSettingsWritable->blurChanged (blur_type); -} - -gboolean -gwd_mock_settings_writable_metacity_theme_changed (GWDSettingsWritable *settings, - gboolean use_metacity_theme, - const gchar *metacity_theme) -{ - GWDMockSettingsWritableGMockInterface *gmockSettingsWritable = GET_PRIVATE (settings)->mock; - return gmockSettingsWritable->metacityThemeChanged (use_metacity_theme, metacity_theme); -} - -gboolean -gwd_mock_settings_writable_opacity_changed (GWDSettingsWritable *settings, - gdouble inactive_opacity, - gdouble active_opacity, - gboolean inactive_shade_opacity, - gboolean active_shade_opacity) -{ - GWDMockSettingsWritableGMockInterface *gmockSettingsWritable = GET_PRIVATE (settings)->mock; - return gmockSettingsWritable->opacityChanged (inactive_opacity, active_opacity, inactive_shade_opacity, active_shade_opacity); -} - -gboolean -gwd_mock_settings_writable_button_layout_changed (GWDSettingsWritable *settings, - const gchar *button_layout) -{ - GWDMockSettingsWritableGMockInterface *gmockSettingsWritable = GET_PRIVATE (settings)->mock; - return gmockSettingsWritable->buttonLayoutChanged (button_layout); -} - -gboolean -gwd_mock_settings_writable_font_changed (GWDSettingsWritable *settings, - gboolean titlebar_uses_system_font, - const gchar *titlebar_font) -{ - GWDMockSettingsWritableGMockInterface *gmockSettingsWritable = GET_PRIVATE (settings)->mock; - return gmockSettingsWritable->fontChanged (titlebar_uses_system_font, titlebar_font); -} - -gboolean -gwd_mock_settings_writable_titlebar_actions_changed (GWDSettingsWritable *settings, - const gchar *action_double_click_titlebar, - const gchar *action_middle_click_titlebar, - const gchar *action_right_click_titlebar, - const gchar *mouse_wheel_action) -{ - GWDMockSettingsWritableGMockInterface *gmockSettingsWritable = GET_PRIVATE (settings)->mock; - return gmockSettingsWritable->titlebarActionsChanged (action_double_click_titlebar, - action_middle_click_titlebar, - action_right_click_titlebar, - mouse_wheel_action); -} - -static void gwd_mock_settings_writable_interface_init (GWDSettingsWritableInterface *interface) -{ - interface->shadow_property_changed = gwd_mock_settings_writable_shadow_property_changed; - interface->use_tooltips_changed = gwd_mock_settings_writable_use_tooltips_changed; - interface->blur_changed = gwd_mock_settings_writable_blur_changed; - interface->metacity_theme_changed = gwd_mock_settings_writable_metacity_theme_changed; - interface->opacity_changed = gwd_mock_settings_writable_opacity_changed; - interface->button_layout_changed = gwd_mock_settings_writable_button_layout_changed; - interface->font_changed = gwd_mock_settings_writable_font_changed; - interface->titlebar_actions_changed = gwd_mock_settings_writable_titlebar_actions_changed; - interface->freeze_updates = gwd_mock_settings_writable_freeze_updates; - interface->thaw_updates = gwd_mock_settings_writable_thaw_updates; -} - -static GObject * gwd_mock_settings_writable_constructor (GType type, - guint n_construction_properties, - GObjectConstructParam *construction_properties) -{ - GObject *object = G_OBJECT_CLASS (gwd_mock_settings_writable_parent_class)->constructor (type, n_construction_properties, construction_properties); - GWDMockSettingsWritablePrivate *priv = GET_PRIVATE (object); - guint i = 0; - - for (; i < n_construction_properties; ++i) - { - if (g_strcmp0 (construction_properties[i].pspec->name, "gmock-interface") == 0) - { - priv->mock = reinterpret_cast (g_value_get_pointer (construction_properties[i].value)); - } - else - g_assert_not_reached (); - } - - return object; -} - -static void gwd_mock_settings_writable_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - GWDMockSettingsWritablePrivate *priv = GET_PRIVATE (object); - - switch (property_id) - { - case GWD_MOCK_SETTINGS_WRITABLE_PROPERTY_GMOCK_INTERFACE: - if (!priv->mock) - priv->mock = reinterpret_cast (g_value_get_pointer (value)); - break; - default: - g_assert_not_reached (); - } -} - -static void gwd_mock_settings_writable_dispose (GObject *object) -{ - GWDMockSettingsWritableGMockInterface *settingsGMock = GET_PRIVATE (object)->mock; - G_OBJECT_CLASS (gwd_mock_settings_writable_parent_class)->dispose (object); - settingsGMock->dispose (); -} - -static void gwd_mock_settings_writable_finalize (GObject *object) -{ - GWDMockSettingsWritableGMockInterface *settingsGMock = GET_PRIVATE (object)->mock; - G_OBJECT_CLASS (gwd_mock_settings_writable_parent_class)->finalize (object); - settingsGMock->finalize (); -} - -static void gwd_mock_settings_writable_class_init (GWDMockSettingsWritableClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - g_type_class_add_private (klass, sizeof (GWDMockSettingsWritablePrivate)); - - object_class->dispose = gwd_mock_settings_writable_dispose; - object_class->finalize = gwd_mock_settings_writable_finalize; - object_class->constructor = gwd_mock_settings_writable_constructor; - object_class->set_property = gwd_mock_settings_writable_set_property; - - g_object_class_install_property (object_class, - GWD_MOCK_SETTINGS_WRITABLE_PROPERTY_GMOCK_INTERFACE, - g_param_spec_pointer ("gmock-interface", - "Google Mock Interface", - "Google Mock Interface", - static_cast (G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY))); -} - -void gwd_mock_settings_writable_init (GWDMockSettingsWritable *self) -{ -} - -GWDSettingsWritable * -gwd_mock_settings_writable_new (GWDMockSettingsWritableGMockInterface *gmock) -{ - GValue gmock_interface_v = G_VALUE_INIT; - - g_value_init (&gmock_interface_v, G_TYPE_POINTER); - - g_value_set_pointer (&gmock_interface_v, reinterpret_cast (gmock)); - - GParameter param[1] = - { - { "gmock-interface", gmock_interface_v } - }; - - GWDSettingsWritable *writable = GWD_SETTINGS_WRITABLE_INTERFACE (g_object_newv (GWD_TYPE_MOCK_SETTINGS_WRITABLE, 1, param)); - - g_value_unset (&gmock_interface_v); - - return writable; -} diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/compiz_gwd_mock_settings_writable.h compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/tests/compiz_gwd_mock_settings_writable.h --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/compiz_gwd_mock_settings_writable.h 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/tests/compiz_gwd_mock_settings_writable.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,104 +0,0 @@ -/* - * Copyright © 2012 Canonical Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * Authored By: Sam Spilsbury - */ -#ifndef _COMPIZ_GWD_MOCK_SETTINGS_WRITABLE_H -#define _COMPIZ_GWD_MOCK_SETTINGS_WRITABLE_H - -#include -#include - -#include - -typedef struct _GWDSettingsWritable GWDSettingsWritable; - -class GWDMockSettingsWritableGMockInterface; - -G_BEGIN_DECLS - -#define GWD_TYPE_MOCK_SETTINGS_WRITABLE (gwd_mock_settings_writable_get_type ()) -GType gwd_mock_settings_writable_get_type (); - -GWDSettingsWritable * -gwd_mock_settings_writable_new (GWDMockSettingsWritableGMockInterface *); - -G_END_DECLS - -class GWDMockSettingsWritableGMockInterface -{ - public: - - virtual ~GWDMockSettingsWritableGMockInterface () {} - - virtual void freezeUpdates() = 0; - virtual void thawUpdates () = 0; - virtual gboolean shadowPropertyChanged (gdouble active_shadow_radius, - gdouble active_shadow_opacity, - gdouble active_shadow_offset_x, - gdouble active_shadow_offset_y, - const gchar *active_shadow_color, - gdouble inactive_shadow_radius, - gdouble inactive_shadow_opacity, - gdouble inactive_shadow_offset_x, - gdouble inactive_shadow_offset_y, - const gchar *inactive_shadow_color) = 0; - virtual gboolean useTooltipsChanged (gboolean newValue) = 0; - virtual gboolean blurChanged (const gchar *type) = 0; - virtual gboolean metacityThemeChanged (gboolean useMetacityTheme, const gchar *metacityTheme) = 0; - virtual gboolean opacityChanged (gdouble inactiveOpacity, - gdouble activeOpacity, - gboolean inactiveShadeOpacity, - gboolean activeShadeOpacity) = 0; - virtual gboolean buttonLayoutChanged (const gchar *buttonLayout) = 0; - virtual gboolean fontChanged (gboolean useSystemFont, - const gchar *titlebarFont) = 0; - virtual gboolean titlebarActionsChanged (const gchar *doubleClickAction, - const gchar *middleClickAction, - const gchar *rightClickAction, - const gchar *mouseWheelAction) = 0; - - - virtual void dispose () = 0; - virtual void finalize () = 0; -}; - -class GWDMockSettingsWritableGMock : - public GWDMockSettingsWritableGMockInterface -{ - public: - - MOCK_METHOD0 (freezeUpdates, void ()); - MOCK_METHOD0 (thawUpdates, void ()); - MOCK_METHOD10 (shadowPropertyChanged, gboolean (gdouble, gdouble, gdouble, gdouble, const gchar *, - gdouble, gdouble, gdouble, gdouble, const gchar *)); - MOCK_METHOD1 (useTooltipsChanged, gboolean (gboolean)); - MOCK_METHOD1 (blurChanged, gboolean (const gchar *)); - MOCK_METHOD2 (metacityThemeChanged, gboolean (gboolean, const gchar *)); - MOCK_METHOD4 (opacityChanged, gboolean (gdouble, gdouble, gboolean, gboolean)); - MOCK_METHOD1 (buttonLayoutChanged, gboolean (const gchar *)); - MOCK_METHOD2 (fontChanged, gboolean (gboolean, const gchar *)); - MOCK_METHOD4 (titlebarActionsChanged, gboolean (const gchar *, - const gchar *, - const gchar *, - const gchar *)); - - MOCK_METHOD0 (dispose, void ()); - MOCK_METHOD0 (finalize, void ()); -}; - -#endif diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/test_gwd_settings.cpp compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/tests/test_gwd_settings.cpp --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/tests/test_gwd_settings.cpp 2016-05-17 02:52:35.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/tests/test_gwd_settings.cpp 2016-05-25 14:20:26.000000000 +0000 @@ -41,18 +41,11 @@ #include "compiz_gwd_tests.h" -#include "gwd-settings-interface.h" #include "gwd-settings.h" #include "gwd-settings-storage.h" -#include "gwd-settings-writable-interface.h" -#include "gwd-settings-notified-interface.h" #include "decoration.h" -#include "compiz_gwd_mock_settings.h" -#include "compiz_gwd_mock_settings_writable.h" -#include "compiz_gwd_mock_settings_notified.h" - using ::testing::TestWithParam; using ::testing::Eq; using ::testing::Return; @@ -249,32 +242,13 @@ CompizGLibGSliceOffEnv env; }; -class GWDMockSettingsWritableTest : - public GWDSettingsTestCommon -{ -}; - namespace { - void gwd_settings_storage_unref (GWDSettingsStorage *storage) - { - g_object_unref (G_OBJECT (storage)); - } - - void gwd_settings_writable_unref (GWDSettingsWritable *writable) - { - g_object_unref (G_OBJECT (writable)); - } - - void gwd_settings_unref (GWDSettingsImpl *settings) + void gwd_settings_unref (GWDSettings *settings) { g_object_unref (G_OBJECT (settings)); } - void gwd_settings_notified_do_nothing (GWDSettingsNotified *notified) - { - } - class AutoUnsetGValue { public: @@ -305,299 +279,88 @@ }; } -TEST_F(GWDMockSettingsWritableTest, TestMock) -{ - GWDMockSettingsWritableGMock writableGMock; - boost::shared_ptr writableMock (gwd_mock_settings_writable_new (&writableGMock), - boost::bind (gwd_settings_writable_unref, _1)); - - - EXPECT_CALL (writableGMock, freezeUpdates ()); - EXPECT_CALL (writableGMock, thawUpdates ()); - EXPECT_CALL (writableGMock, shadowPropertyChanged (testing_values::ACTIVE_SHADOW_RADIUS_VALUE, - testing_values::ACTIVE_SHADOW_OPACITY_VALUE, - testing_values::ACTIVE_SHADOW_OFFSET_X_VALUE, - testing_values::ACTIVE_SHADOW_OFFSET_Y_VALUE, - Eq (testing_values::ACTIVE_SHADOW_COLOR_STR_VALUE), - testing_values::INACTIVE_SHADOW_RADIUS_VALUE, - testing_values::INACTIVE_SHADOW_OPACITY_VALUE, - testing_values::INACTIVE_SHADOW_OFFSET_X_VALUE, - testing_values::INACTIVE_SHADOW_OFFSET_Y_VALUE, - Eq (testing_values::INACTIVE_SHADOW_COLOR_STR_VALUE))).WillOnce (Return (TRUE)); - EXPECT_CALL (writableGMock, useTooltipsChanged (testing_values::USE_TOOLTIPS_VALUE)).WillOnce (Return (TRUE)); - EXPECT_CALL (writableGMock, blurChanged (Eq (testing_values::BLUR_TYPE_TITLEBAR_VALUE))).WillOnce (Return (TRUE)); - EXPECT_CALL (writableGMock, metacityThemeChanged (TRUE, Eq (testing_values::METACITY_THEME_VALUE))).WillOnce (Return (TRUE)); - EXPECT_CALL (writableGMock, opacityChanged (testing_values::ACTIVE_OPACITY_VALUE, - testing_values::INACTIVE_OPACITY_VALUE, - testing_values::ACTIVE_SHADE_OPACITY_VALUE, - testing_values::INACTIVE_SHADE_OPACITY_VALUE)).WillOnce (Return (TRUE)); - EXPECT_CALL (writableGMock, buttonLayoutChanged (Eq (testing_values::BUTTON_LAYOUT_VALUE))).WillOnce (Return (TRUE)); - EXPECT_CALL (writableGMock, fontChanged (testing_values::USE_SYSTEM_FONT_VALUE, - testing_values::TITLEBAR_FONT_VALUE.c_str ())).WillOnce (Return (TRUE)); - EXPECT_CALL (writableGMock, titlebarActionsChanged (Eq (testing_values::TITLEBAR_ACTION_MAX), - Eq (testing_values::TITLEBAR_ACTION_MENU), - Eq (testing_values::TITLEBAR_ACTION_LOWER), - Eq (testing_values::TITLEBAR_ACTION_SHADE))).WillOnce (Return (TRUE)); - - EXPECT_CALL (writableGMock, dispose ()); - EXPECT_CALL (writableGMock, finalize ()); - - gwd_settings_writable_freeze_updates (writableMock.get ()); - gwd_settings_writable_thaw_updates (writableMock.get ()); - - EXPECT_THAT (gwd_settings_writable_shadow_property_changed (writableMock.get (), - testing_values::ACTIVE_SHADOW_RADIUS_VALUE, - testing_values::ACTIVE_SHADOW_OPACITY_VALUE, - testing_values::ACTIVE_SHADOW_OFFSET_X_VALUE, - testing_values::ACTIVE_SHADOW_OFFSET_Y_VALUE, - testing_values::ACTIVE_SHADOW_COLOR_STR_VALUE.c_str (), - testing_values::INACTIVE_SHADOW_RADIUS_VALUE, - testing_values::INACTIVE_SHADOW_OPACITY_VALUE, - testing_values::INACTIVE_SHADOW_OFFSET_X_VALUE, - testing_values::INACTIVE_SHADOW_OFFSET_Y_VALUE, - testing_values::INACTIVE_SHADOW_COLOR_STR_VALUE.c_str ()), IsTrue ()); - EXPECT_THAT (gwd_settings_writable_use_tooltips_changed (writableMock.get (), testing_values::USE_TOOLTIPS_VALUE), IsTrue ()); - EXPECT_THAT (gwd_settings_writable_blur_changed (writableMock.get (), testing_values::BLUR_TYPE_TITLEBAR_VALUE.c_str ()), IsTrue ()); - EXPECT_THAT (gwd_settings_writable_metacity_theme_changed (writableMock.get (), - testing_values::USE_METACITY_THEME_VALUE, - testing_values::METACITY_THEME_VALUE.c_str ()), IsTrue ()); - EXPECT_THAT (gwd_settings_writable_opacity_changed (writableMock.get (), - testing_values::ACTIVE_OPACITY_VALUE, - testing_values::INACTIVE_OPACITY_VALUE, - testing_values::ACTIVE_SHADE_OPACITY_VALUE, - testing_values::INACTIVE_SHADE_OPACITY_VALUE), IsTrue ()); - EXPECT_THAT (gwd_settings_writable_button_layout_changed (writableMock.get (), - testing_values::BUTTON_LAYOUT_VALUE.c_str ()), IsTrue ()); - EXPECT_THAT (gwd_settings_writable_font_changed (writableMock.get (), - testing_values::USE_SYSTEM_FONT_VALUE, - testing_values::TITLEBAR_FONT_VALUE.c_str ()), IsTrue ()); - EXPECT_THAT (gwd_settings_writable_titlebar_actions_changed (writableMock.get (), - testing_values::TITLEBAR_ACTION_MAX.c_str (), - testing_values::TITLEBAR_ACTION_MENU.c_str (), - testing_values::TITLEBAR_ACTION_LOWER.c_str (), - testing_values::TITLEBAR_ACTION_SHADE.c_str ()), IsTrue ()); -} - -class GWDMockSettingsTest : - public GWDSettingsTestCommon -{ -}; - -TEST_F(GWDMockSettingsTest, TestMock) +class GWDMockSettingsNotifiedGMock { - GWDMockSettingsGMock settingsGMock; - boost::shared_ptr settingsMock (gwd_mock_settings_new (&settingsGMock), - boost::bind (gwd_settings_unref, _1)); - - AutoUnsetGValue pointerValue (G_TYPE_POINTER); - AutoUnsetGValue booleanValue (G_TYPE_BOOLEAN); - AutoUnsetGValue stringValue (G_TYPE_STRING); - AutoUnsetGValue integerValue (G_TYPE_INT); - AutoUnsetGValue doubleValue (G_TYPE_DOUBLE); - - GValue &pointerGValue = pointerValue; - GValue &booleanGValue = booleanValue; - GValue &stringGValue = stringValue; - GValue &integerGValue = integerValue; - GValue &doubleGValue = doubleValue; - - int POINTEE_VALUE = 1; - gpointer POINTER_VALUE = &POINTEE_VALUE; - const std::string STRING_VALUE ("test"); - const int INTEGER_VALUE = 2; - const gboolean BOOLEAN_VALUE = TRUE; - const gdouble DOUBLE_VALUE = 2.0; - - g_value_set_pointer (&pointerGValue, POINTER_VALUE); - g_value_set_boolean (&booleanGValue, BOOLEAN_VALUE); - g_value_set_string (&stringGValue, STRING_VALUE.c_str ()); - g_value_set_int (&integerGValue, INTEGER_VALUE); - g_value_set_double (&doubleGValue, DOUBLE_VALUE); - - EXPECT_CALL (settingsGMock, dispose ()); - EXPECT_CALL (settingsGMock, finalize ()); - - /* The order of evaluation of matchers in Google Mock appears to be undefined and - * the way GValueMatch is written makes it particularly unsafe when used with - * matchers of multiple types on the same function, since there's no guaruntee - * that the matchers will be traversed in any order. If a type is passed to - * any of the matchers that it doesn't know how to handle then it will - * call directly through to GValueCmp which will run into undefined behaviour - * in itself. - * - * In reality, the API for GValueMatch is probably a little bit broken in this - * sense, but just satisfying each expectation as soon as its set seems to do - * the job here - */ - - /* calling g_object_get_property actually resets - * the value so expecting 0x0 is correct */ - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_ACTIVE_SHADOW, - GValueMatch (0x0, g_value_get_pointer), - _)); - - g_object_get_property (G_OBJECT (settingsMock.get ()), - "active-shadow", - &pointerGValue); - - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_INACTIVE_SHADOW, - GValueMatch (0x0, g_value_get_pointer), - _)); - - g_object_get_property (G_OBJECT (settingsMock.get ()), - "inactive-shadow", - &pointerGValue); - - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_USE_TOOLTIPS, - GValueMatch (FALSE, g_value_get_boolean), - _)); - - g_object_get_property (G_OBJECT (settingsMock.get ()), - "use-tooltips", - &booleanGValue); - - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_BLUR_CHANGED, - GValueMatch (0, g_value_get_int), - _)); - - g_object_get_property (G_OBJECT (settingsMock.get ()), - "blur", - &integerGValue); - - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_METACITY_THEME, - GValueMatch (NULL, g_value_get_string), - _)); - - g_object_get_property (G_OBJECT (settingsMock.get ()), - "metacity-theme", - &stringGValue); - - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_ACTIVE_OPACITY, - GValueMatch (0.0, g_value_get_double), - _)); - - g_object_get_property (G_OBJECT (settingsMock.get ()), - "metacity-active-opacity", - &doubleGValue); - - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_INACTIVE_OPACITY, - GValueMatch (0.0, g_value_get_double), - _)); - - g_object_get_property (G_OBJECT (settingsMock.get ()), - "metacity-inactive-opacity", - &doubleGValue); - - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_ACTIVE_SHADE_OPACITY, - GValueMatch (FALSE, g_value_get_boolean), - _)); - - g_object_get_property (G_OBJECT (settingsMock.get ()), - "metacity-active-shade-opacity", - &booleanGValue); - - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_INACTIVE_SHADE_OPACITY, - GValueMatch (FALSE, g_value_get_boolean), - _)); - - g_object_get_property (G_OBJECT (settingsMock.get ()), - "metacity-inactive-shade-opacity", - &booleanGValue); - - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_BUTTON_LAYOUT, - GValueMatch (NULL, g_value_get_string), - _)); - - g_object_get_property (G_OBJECT (settingsMock.get ()), - "metacity-button-layout", - &stringGValue); - - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_ACTION_DOUBLE_CLICK, - GValueMatch (0, g_value_get_int), - _)); - - g_object_get_property (G_OBJECT (settingsMock.get ()), - "titlebar-double-click-action", - &integerGValue); - - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_ACTION_MIDDLE_CLICK, - GValueMatch (0, g_value_get_int), - _)); - - g_object_get_property (G_OBJECT (settingsMock.get ()), - "titlebar-middle-click-action", - &integerGValue); - - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_ACTION_RIGHT_CLICK, - GValueMatch (0, g_value_get_int), - _)); - - g_object_get_property (G_OBJECT (settingsMock.get ()), - "titlebar-right-click-action", - &integerGValue); - - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_MOUSE_WHEEL_ACTION, - GValueMatch (0, g_value_get_int), - _)); - - g_object_get_property (G_OBJECT (settingsMock.get ()), - "mouse-wheel-action", - &integerGValue); - - EXPECT_CALL (settingsGMock, getProperty (GWD_MOCK_SETTINGS_PROPERTY_TITLEBAR_FONT, - GValueMatch (NULL, g_value_get_string), - _)); + public: - g_object_get_property (G_OBJECT (settingsMock.get ()), - "titlebar-font", - &stringGValue); -} + GWDMockSettingsNotifiedGMock (boost::shared_ptr settings) + { + g_signal_connect (settings.get (), "update-decorations", + G_CALLBACK (GWDMockSettingsNotifiedGMock::updateDecorationsCb), this); + g_signal_connect (settings.get (), "update-frames", + G_CALLBACK (GWDMockSettingsNotifiedGMock::updateFramesCb), this); + g_signal_connect (settings.get (), "update-metacity-theme", + G_CALLBACK (GWDMockSettingsNotifiedGMock::updateMetacityThemeCb), this); + g_signal_connect (settings.get (), "update-metacity-button-layout", + G_CALLBACK (GWDMockSettingsNotifiedGMock::updateMetacityButtonLayoutCb), this); + } + + MOCK_METHOD0 (updateDecorations, void ()); + MOCK_METHOD0 (updateFrames, void ()); + MOCK_METHOD0 (updateMetacityTheme, void ()); + MOCK_METHOD0 (updateMetacityButtonLayout, void ()); -namespace -{ - void ExpectAllNotificationsOnce (boost::shared_ptr > &gmockNotified, - boost::shared_ptr &settings) - { - InSequence s; + private: - EXPECT_CALL (*gmockNotified, updateMetacityTheme ()).Times (1); - EXPECT_CALL (*gmockNotified, updateMetacityButtonLayout ()).Times (1); - EXPECT_CALL (*gmockNotified, updateFrames ()).Times (1); - EXPECT_CALL (*gmockNotified, updateDecorations ()).Times (1); + static void updateDecorationsCb (GWDSettings *settings, + GWDMockSettingsNotifiedGMock *gmock) + { + gmock->updateDecorations (); + } + + static void updateFramesCb (GWDSettings *settings, + GWDMockSettingsNotifiedGMock *gmock) + { + gmock->updateFrames (); + } + + static void updateMetacityThemeCb (GWDSettings *settings, + GWDMockSettingsNotifiedGMock *gmock) + { + gmock->updateMetacityTheme (); + } + + static void updateMetacityButtonLayoutCb (GWDSettings *settings, + const gchar *button_layout, + GWDMockSettingsNotifiedGMock *gmock) + { + gmock->updateMetacityButtonLayout (); + } - gwd_settings_writable_thaw_updates (GWD_SETTINGS_WRITABLE_INTERFACE (settings.get ())); - } -} +}; class GWDSettingsTest : public GWDSettingsTestCommon { public: - virtual void SetUp () - { - GWDSettingsTestCommon::SetUp (); - mGMockNotified.reset (new StrictMock ()); - mMockNotified.reset (gwd_mock_settings_notified_new (mGMockNotified.get ()), - boost::bind (gwd_settings_notified_do_nothing, _1)); - mSettings.reset (gwd_settings_impl_new (NULL, - NULL, - mMockNotified.get ()), - boost::bind (gwd_settings_unref, _1)); - ExpectAllNotificationsOnce (mGMockNotified, mSettings); - } + virtual void SetUp () + { + GWDSettingsTestCommon::SetUp (); - virtual void TearDown () - { - EXPECT_CALL (*mGMockNotified, dispose ()); - EXPECT_CALL (*mGMockNotified, finalize ()); - } + mSettings.reset (gwd_settings_new (BLUR_TYPE_UNSET, NULL), boost::bind (gwd_settings_unref, _1)); + mGMockNotified.reset (new StrictMock (mSettings)); + + ExpectAllNotificationsOnce (); + } protected: - boost::shared_ptr > mGMockNotified; - boost::shared_ptr mMockNotified; - boost::shared_ptr mSettings; + boost::shared_ptr > mGMockNotified; + boost::shared_ptr mSettings; + + private: + + void ExpectAllNotificationsOnce () + { + EXPECT_CALL (*mGMockNotified, updateMetacityTheme ()).Times (1); + EXPECT_CALL (*mGMockNotified, updateMetacityButtonLayout ()).Times (1); + EXPECT_CALL (*mGMockNotified, updateFrames ()).Times (1); + EXPECT_CALL (*mGMockNotified, updateDecorations ()).Times (1); + + gwd_settings_thaw_updates (mSettings.get ()); + } + }; TEST_F(GWDSettingsTest, TestGWDSettingsInstantiation) @@ -612,51 +375,51 @@ /* We're just using use_tooltips here as an example */ TEST_F(GWDSettingsTest, TestFreezeUpdatesNoUpdates) { - gwd_settings_writable_freeze_updates (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ())); - EXPECT_THAT (gwd_settings_writable_use_tooltips_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::USE_TOOLTIPS_VALUE), IsTrue ()); + gwd_settings_freeze_updates (mSettings.get ()); + EXPECT_THAT (gwd_settings_use_tooltips_changed (mSettings.get (), + testing_values::USE_TOOLTIPS_VALUE), IsTrue ()); } /* We're just using use_tooltips here as an example */ TEST_F(GWDSettingsTest, TestFreezeUpdatesNoUpdatesThawUpdatesAllUpdates) { - gwd_settings_writable_freeze_updates (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ())); - EXPECT_THAT (gwd_settings_writable_use_tooltips_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::USE_TOOLTIPS_VALUE), IsTrue ()); + gwd_settings_freeze_updates (mSettings.get ()); + EXPECT_THAT (gwd_settings_use_tooltips_changed (mSettings.get (), + testing_values::USE_TOOLTIPS_VALUE), IsTrue ()); EXPECT_CALL (*mGMockNotified, updateDecorations ()); - gwd_settings_writable_thaw_updates (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ())); + gwd_settings_thaw_updates (mSettings.get ()); } /* We're just using use_tooltips here as an example */ TEST_F(GWDSettingsTest, TestFreezeUpdatesNoUpdatesThawUpdatesAllUpdatesNoDupes) { - gwd_settings_writable_freeze_updates (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ())); - EXPECT_THAT (gwd_settings_writable_use_tooltips_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::USE_TOOLTIPS_VALUE), IsTrue ()); - EXPECT_THAT (gwd_settings_writable_use_tooltips_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - !testing_values::USE_TOOLTIPS_VALUE), IsTrue ()); - EXPECT_THAT (gwd_settings_writable_use_tooltips_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::USE_TOOLTIPS_VALUE), IsTrue ()); + gwd_settings_freeze_updates (mSettings.get ()); + EXPECT_THAT (gwd_settings_use_tooltips_changed (mSettings.get (), + testing_values::USE_TOOLTIPS_VALUE), IsTrue ()); + EXPECT_THAT (gwd_settings_use_tooltips_changed (mSettings.get (), + !testing_values::USE_TOOLTIPS_VALUE), IsTrue ()); + EXPECT_THAT (gwd_settings_use_tooltips_changed (mSettings.get (), + testing_values::USE_TOOLTIPS_VALUE), IsTrue ()); EXPECT_CALL (*mGMockNotified, updateDecorations ()).Times (1); - gwd_settings_writable_thaw_updates (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ())); + gwd_settings_thaw_updates (mSettings.get ()); } TEST_F(GWDSettingsTest, TestShadowPropertyChanged) { EXPECT_CALL (*mGMockNotified, updateDecorations ()); - EXPECT_THAT (gwd_settings_writable_shadow_property_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::ACTIVE_SHADOW_OPACITY_VALUE, - testing_values::ACTIVE_SHADOW_RADIUS_VALUE, - testing_values::ACTIVE_SHADOW_OFFSET_X_VALUE, - testing_values::ACTIVE_SHADOW_OFFSET_Y_VALUE, - testing_values::ACTIVE_SHADOW_COLOR_STR_VALUE.c_str (), - testing_values::INACTIVE_SHADOW_OPACITY_VALUE, - testing_values::INACTIVE_SHADOW_RADIUS_VALUE, - testing_values::INACTIVE_SHADOW_OFFSET_X_VALUE, - testing_values::INACTIVE_SHADOW_OFFSET_Y_VALUE, - testing_values::INACTIVE_SHADOW_COLOR_STR_VALUE.c_str ()), IsTrue ()); + EXPECT_THAT (gwd_settings_shadow_property_changed (mSettings.get (), + testing_values::ACTIVE_SHADOW_OPACITY_VALUE, + testing_values::ACTIVE_SHADOW_RADIUS_VALUE, + testing_values::ACTIVE_SHADOW_OFFSET_X_VALUE, + testing_values::ACTIVE_SHADOW_OFFSET_Y_VALUE, + testing_values::ACTIVE_SHADOW_COLOR_STR_VALUE.c_str (), + testing_values::INACTIVE_SHADOW_OPACITY_VALUE, + testing_values::INACTIVE_SHADOW_RADIUS_VALUE, + testing_values::INACTIVE_SHADOW_OFFSET_X_VALUE, + testing_values::INACTIVE_SHADOW_OFFSET_Y_VALUE, + testing_values::INACTIVE_SHADOW_COLOR_STR_VALUE.c_str ()), IsTrue ()); AutoUnsetGValue activeShadowValue (G_TYPE_POINTER); AutoUnsetGValue inactiveShadowValue (G_TYPE_POINTER); @@ -700,24 +463,24 @@ TEST_F(GWDSettingsTest, TestShadowPropertyChangedIsDefault) { - EXPECT_THAT (gwd_settings_writable_shadow_property_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - ACTIVE_SHADOW_RADIUS_DEFAULT, - ACTIVE_SHADOW_OPACITY_DEFAULT, - ACTIVE_SHADOW_OFFSET_X_DEFAULT, - ACTIVE_SHADOW_OFFSET_Y_DEFAULT, - ACTIVE_SHADOW_COLOR_DEFAULT, - INACTIVE_SHADOW_RADIUS_DEFAULT, - INACTIVE_SHADOW_OPACITY_DEFAULT, - INACTIVE_SHADOW_OFFSET_X_DEFAULT, - INACTIVE_SHADOW_OFFSET_Y_DEFAULT, - INACTIVE_SHADOW_COLOR_DEFAULT), IsFalse ()); + EXPECT_THAT (gwd_settings_shadow_property_changed (mSettings.get (), + ACTIVE_SHADOW_RADIUS_DEFAULT, + ACTIVE_SHADOW_OPACITY_DEFAULT, + ACTIVE_SHADOW_OFFSET_X_DEFAULT, + ACTIVE_SHADOW_OFFSET_Y_DEFAULT, + ACTIVE_SHADOW_COLOR_DEFAULT, + INACTIVE_SHADOW_RADIUS_DEFAULT, + INACTIVE_SHADOW_OPACITY_DEFAULT, + INACTIVE_SHADOW_OFFSET_X_DEFAULT, + INACTIVE_SHADOW_OFFSET_Y_DEFAULT, + INACTIVE_SHADOW_COLOR_DEFAULT), IsFalse ()); } TEST_F(GWDSettingsTest, TestUseTooltipsChanged) { EXPECT_CALL (*mGMockNotified, updateDecorations ()); - EXPECT_THAT (gwd_settings_writable_use_tooltips_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::USE_TOOLTIPS_VALUE), IsTrue ()); + EXPECT_THAT (gwd_settings_use_tooltips_changed (mSettings.get (), + testing_values::USE_TOOLTIPS_VALUE), IsTrue ()); AutoUnsetGValue useTooltipsValue (G_TYPE_BOOLEAN); GValue &useTooltipsGValue = useTooltipsValue; @@ -732,15 +495,15 @@ TEST_F(GWDSettingsTest, TestUseTooltipsChangedIsDefault) { - EXPECT_THAT (gwd_settings_writable_use_tooltips_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - USE_TOOLTIPS_DEFAULT), IsFalse ()); + EXPECT_THAT (gwd_settings_use_tooltips_changed (mSettings.get (), + USE_TOOLTIPS_DEFAULT), IsFalse ()); } TEST_F(GWDSettingsTest, TestBlurChangedTitlebar) { EXPECT_CALL (*mGMockNotified, updateDecorations ()); - EXPECT_THAT (gwd_settings_writable_blur_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::BLUR_TYPE_TITLEBAR_VALUE.c_str ()), IsTrue ()); + EXPECT_THAT (gwd_settings_blur_changed (mSettings.get (), + testing_values::BLUR_TYPE_TITLEBAR_VALUE.c_str ()), IsTrue ()); AutoUnsetGValue blurValue (G_TYPE_INT); GValue &blurGValue = blurValue; @@ -756,8 +519,8 @@ TEST_F(GWDSettingsTest, TestBlurChangedAll) { EXPECT_CALL (*mGMockNotified, updateDecorations ()); - EXPECT_THAT (gwd_settings_writable_blur_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::BLUR_TYPE_ALL_VALUE.c_str ()), IsTrue ()); + EXPECT_THAT (gwd_settings_blur_changed (mSettings.get (), + testing_values::BLUR_TYPE_ALL_VALUE.c_str ()), IsTrue ()); AutoUnsetGValue blurValue (G_TYPE_INT); GValue &blurGValue = blurValue; @@ -772,8 +535,8 @@ TEST_F(GWDSettingsTest, TestBlurChangedNone) { - EXPECT_THAT (gwd_settings_writable_blur_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::BLUR_TYPE_NONE_VALUE.c_str ()), IsFalse ()); + EXPECT_THAT (gwd_settings_blur_changed (mSettings.get (), + testing_values::BLUR_TYPE_NONE_VALUE.c_str ()), IsFalse ()); AutoUnsetGValue blurValue (G_TYPE_INT); GValue &blurGValue = blurValue; @@ -790,16 +553,11 @@ { gint blurType = testing_values::BLUR_TYPE_ALL_INT_VALUE; - /* We need to increment the reference count so that it doesn't - * go away when we create a new GWDSettingsImpl */ - g_object_ref (mMockNotified.get ()); - mSettings.reset (gwd_settings_impl_new (&blurType, - NULL, - mMockNotified.get ()), + mSettings.reset (gwd_settings_new (blurType, NULL), boost::bind (gwd_settings_unref, _1)); - EXPECT_THAT (gwd_settings_writable_blur_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::BLUR_TYPE_NONE_VALUE.c_str ()), IsFalse ()); + EXPECT_THAT (gwd_settings_blur_changed (mSettings.get (), + testing_values::BLUR_TYPE_NONE_VALUE.c_str ()), IsFalse ()); AutoUnsetGValue blurValue (G_TYPE_INT); GValue &blurGValue = blurValue; @@ -816,9 +574,9 @@ { EXPECT_CALL (*mGMockNotified, updateMetacityTheme ()); EXPECT_CALL (*mGMockNotified, updateDecorations ()); - EXPECT_THAT (gwd_settings_writable_metacity_theme_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::USE_METACITY_THEME_VALUE, - testing_values::METACITY_THEME_VALUE.c_str ()), IsTrue ()); + EXPECT_THAT (gwd_settings_metacity_theme_changed (mSettings.get (), + testing_values::USE_METACITY_THEME_VALUE, + testing_values::METACITY_THEME_VALUE.c_str ()), IsTrue ()); AutoUnsetGValue metacityThemeValue (G_TYPE_STRING); GValue &metacityThemeGValue = metacityThemeValue; @@ -835,9 +593,9 @@ { EXPECT_CALL (*mGMockNotified, updateMetacityTheme ()); EXPECT_CALL (*mGMockNotified, updateDecorations ()); - EXPECT_THAT (gwd_settings_writable_metacity_theme_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::NO_USE_METACITY_THEME_VALUE, - testing_values::METACITY_THEME_VALUE.c_str ()), IsTrue ()); + EXPECT_THAT (gwd_settings_metacity_theme_changed (mSettings.get (), + testing_values::NO_USE_METACITY_THEME_VALUE, + testing_values::METACITY_THEME_VALUE.c_str ()), IsTrue ()); AutoUnsetGValue metacityThemeValue (G_TYPE_STRING); GValue &metacityThemeGValue = metacityThemeValue; @@ -852,24 +610,21 @@ TEST_F(GWDSettingsTest, TestMetacityThemeChangedIsDefault) { - EXPECT_THAT (gwd_settings_writable_metacity_theme_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::USE_METACITY_THEME_VALUE, - METACITY_THEME_DEFAULT), IsFalse ()); + EXPECT_THAT (gwd_settings_metacity_theme_changed (mSettings.get (), + testing_values::USE_METACITY_THEME_VALUE, + METACITY_THEME_DEFAULT), IsFalse ()); } TEST_F(GWDSettingsTest, TestMetacityThemeSetCommandLine) { const gchar *metacityTheme = "Ambiance"; - g_object_ref (mMockNotified.get ()); - mSettings.reset (gwd_settings_impl_new (NULL, - &metacityTheme, - mMockNotified.get ()), + mSettings.reset (gwd_settings_new (BLUR_TYPE_UNSET, metacityTheme), boost::bind (gwd_settings_unref, _1)); - EXPECT_THAT (gwd_settings_writable_metacity_theme_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::USE_METACITY_THEME_VALUE, - testing_values::METACITY_THEME_VALUE.c_str ()), IsFalse ()); + EXPECT_THAT (gwd_settings_metacity_theme_changed (mSettings.get (), + testing_values::USE_METACITY_THEME_VALUE, + testing_values::METACITY_THEME_VALUE.c_str ()), IsFalse ()); AutoUnsetGValue metacityThemeValue (G_TYPE_STRING); GValue &metacityThemeGValue = metacityThemeValue; @@ -885,11 +640,11 @@ TEST_F(GWDSettingsTest, TestMetacityOpacityChanged) { EXPECT_CALL (*mGMockNotified, updateDecorations ()); - EXPECT_THAT (gwd_settings_writable_opacity_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::ACTIVE_OPACITY_VALUE, - testing_values::INACTIVE_OPACITY_VALUE, - testing_values::ACTIVE_SHADE_OPACITY_VALUE, - testing_values::INACTIVE_SHADE_OPACITY_VALUE), IsTrue ()); + EXPECT_THAT (gwd_settings_opacity_changed (mSettings.get (), + testing_values::ACTIVE_OPACITY_VALUE, + testing_values::INACTIVE_OPACITY_VALUE, + testing_values::ACTIVE_SHADE_OPACITY_VALUE, + testing_values::INACTIVE_SHADE_OPACITY_VALUE), IsTrue ()); AutoUnsetGValue metacityInactiveOpacityValue (G_TYPE_DOUBLE); AutoUnsetGValue metacityActiveOpacityValue (G_TYPE_DOUBLE); @@ -926,19 +681,19 @@ TEST_F(GWDSettingsTest, TestMetacityOpacityChangedIsDefault) { - EXPECT_THAT (gwd_settings_writable_opacity_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - METACITY_ACTIVE_OPACITY_DEFAULT, - METACITY_INACTIVE_OPACITY_DEFAULT, - METACITY_ACTIVE_SHADE_OPACITY_DEFAULT, - METACITY_INACTIVE_SHADE_OPACITY_DEFAULT), IsFalse ()); + EXPECT_THAT (gwd_settings_opacity_changed (mSettings.get (), + METACITY_ACTIVE_OPACITY_DEFAULT, + METACITY_INACTIVE_OPACITY_DEFAULT, + METACITY_ACTIVE_SHADE_OPACITY_DEFAULT, + METACITY_INACTIVE_SHADE_OPACITY_DEFAULT), IsFalse ()); } TEST_F(GWDSettingsTest, TestButtonLayoutChanged) { EXPECT_CALL (*mGMockNotified, updateMetacityButtonLayout ()); EXPECT_CALL (*mGMockNotified, updateDecorations ()); - EXPECT_THAT (gwd_settings_writable_button_layout_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::BUTTON_LAYOUT_VALUE.c_str ()), IsTrue ()); + EXPECT_THAT (gwd_settings_button_layout_changed (mSettings.get (), + testing_values::BUTTON_LAYOUT_VALUE.c_str ()), IsTrue ()); AutoUnsetGValue buttonLayoutValue (G_TYPE_STRING); GValue &buttonLayoutGValue = buttonLayoutValue; @@ -953,17 +708,17 @@ TEST_F(GWDSettingsTest, TestButtonLayoutChangedIsDefault) { - EXPECT_THAT (gwd_settings_writable_button_layout_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - METACITY_BUTTON_LAYOUT_DEFAULT), IsFalse ()); + EXPECT_THAT (gwd_settings_button_layout_changed (mSettings.get (), + METACITY_BUTTON_LAYOUT_DEFAULT), IsFalse ()); } TEST_F(GWDSettingsTest, TestTitlebarFontChanged) { EXPECT_CALL (*mGMockNotified, updateFrames ()); EXPECT_CALL (*mGMockNotified, updateDecorations ()); - EXPECT_THAT (gwd_settings_writable_font_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::NO_USE_SYSTEM_FONT_VALUE, - testing_values::TITLEBAR_FONT_VALUE.c_str ()), IsTrue ()); + EXPECT_THAT (gwd_settings_font_changed (mSettings.get (), + testing_values::NO_USE_SYSTEM_FONT_VALUE, + testing_values::TITLEBAR_FONT_VALUE.c_str ()), IsTrue ()); AutoUnsetGValue fontValue (G_TYPE_STRING); GValue &fontGValue = fontValue; @@ -980,9 +735,9 @@ { EXPECT_CALL (*mGMockNotified, updateFrames ()); EXPECT_CALL (*mGMockNotified, updateDecorations ()); - EXPECT_THAT (gwd_settings_writable_font_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::USE_SYSTEM_FONT_VALUE, - testing_values::TITLEBAR_FONT_VALUE.c_str ()), IsTrue ()); + EXPECT_THAT (gwd_settings_font_changed (mSettings.get (), + testing_values::USE_SYSTEM_FONT_VALUE, + testing_values::TITLEBAR_FONT_VALUE.c_str ()), IsTrue ()); AutoUnsetGValue fontValue (G_TYPE_STRING); GValue &fontGValue = fontValue; @@ -998,9 +753,9 @@ TEST_F(GWDSettingsTest, TestTitlebarFontChangedIsDefault) { - EXPECT_THAT (gwd_settings_writable_font_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - testing_values::NO_USE_SYSTEM_FONT_VALUE, - TITLEBAR_FONT_DEFAULT), IsFalse ()); + EXPECT_THAT (gwd_settings_font_changed (mSettings.get (), + testing_values::NO_USE_SYSTEM_FONT_VALUE, + TITLEBAR_FONT_DEFAULT), IsFalse ()); } namespace @@ -1043,37 +798,22 @@ virtual void SetUp () { GWDSettingsTestCommon::SetUp (); - mGMockNotified.reset (new GWDMockSettingsNotifiedGMock ()); - mMockNotified.reset (gwd_mock_settings_notified_new (mGMockNotified.get ()), - boost::bind (gwd_settings_notified_do_nothing, _1)); - mSettings.reset (gwd_settings_impl_new (NULL, - NULL, - mMockNotified.get ()), + mSettings.reset (gwd_settings_new (BLUR_TYPE_UNSET, NULL), boost::bind (gwd_settings_unref, _1)); } - virtual void TearDown () - { - EXPECT_CALL (*mGMockNotified, dispose ()); - EXPECT_CALL (*mGMockNotified, finalize ()); - - GWDSettingsTestCommon::TearDown (); - } - protected: - boost::shared_ptr mGMockNotified; - boost::shared_ptr mMockNotified; - boost::shared_ptr mSettings; + boost::shared_ptr mSettings; }; TEST_P(GWDSettingsTestClickActions, TestClickActionsAndMouseActions) { - gwd_settings_writable_titlebar_actions_changed (GWD_SETTINGS_WRITABLE_INTERFACE (mSettings.get ()), - GetParam ().titlebarAction ().c_str (), - GetParam ().titlebarAction ().c_str (), - GetParam ().titlebarAction ().c_str (), - GetParam ().mouseWheelAction ().c_str ()); + gwd_settings_titlebar_actions_changed (mSettings.get (), + GetParam ().titlebarAction ().c_str (), + GetParam ().titlebarAction ().c_str (), + GetParam ().titlebarAction ().c_str (), + GetParam ().mouseWheelAction ().c_str ()); AutoUnsetGValue doubleClickActionValue (G_TYPE_INT); AutoUnsetGValue middleClickActionValue (G_TYPE_INT); @@ -1136,293 +876,3 @@ testing_values::MOUSE_WHEEL_ACTION_SHADE, CLICK_ACTION_MENU, WHEEL_ACTION_SHADE))); - -class GWDSettingsStorageFactoryWrapperInterface -{ - public: - - typedef boost::shared_ptr Ptr; - virtual ~GWDSettingsStorageFactoryWrapperInterface () {} - - virtual void SetUp (GWDSettingsWritable *writable) = 0; - virtual GWDSettingsStorage * GetStorage () = 0; - virtual void SetUseTooltips (gboolean useTooltips) = 0; - virtual void SetBlur (const std::string &blurType) = 0; - virtual void SetOpacity (gdouble activeOpacity, - gdouble inactiveOpacity, - gboolean activeShadeOpacity, - gboolean inactiveShadeOpacity) = 0; - virtual void SetMetacityTheme (gboolean useMetacityTheme, - const std::string &metacityTheme) = 0; - virtual void SetButtonLayout (const std::string &buttonLayout) = 0; - virtual void SetFont (gboolean useSystemFont, const std::string &titlebarFont) = 0; - virtual void SetTitlebarActions (const std::string &doubleClickAction, - const std::string &middleClickAction, - const std::string &rightClickAction, - const std::string &mouseWheelAction) = 0; - virtual void TearDown () = 0; -}; - -class GWDSettingsTestStorageUpdates : - public GWDSettingsTestCommon, - public ::testing::WithParamInterface -{ - public: - - virtual void SetUp () - { - GWDSettingsTestCommon::SetUp (); - mSettingsMock.reset (new GWDMockSettingsWritableGMock ()); - mSettings.reset (gwd_mock_settings_writable_new (mSettingsMock.get ()), - boost::bind (gwd_settings_writable_unref, _1)); - - GetParam ()->SetUp (mSettings.get ()); - } - - virtual void TearDown () - { - EXPECT_CALL (*mSettingsMock, dispose ()); - EXPECT_CALL (*mSettingsMock, finalize ()); - - GetParam ()->TearDown (); - GWDSettingsTestCommon::TearDown (); - } - - protected: - - boost::shared_ptr mSettingsMock; - boost::shared_ptr mSettings; -}; - -ACTION_P (InvokeFunctor, p) { return p (); } - -TEST_P (GWDSettingsTestStorageUpdates, TestInstantiation) -{ -} - -TEST_P (GWDSettingsTestStorageUpdates, TestSetUseTooltips) -{ - GWDSettingsStorage *storage = GetParam ()->GetStorage (); - GetParam ()->SetUseTooltips (testing_values::USE_TOOLTIPS_VALUE); - - EXPECT_CALL (*mSettingsMock, useTooltipsChanged (testing_values::USE_TOOLTIPS_VALUE)); - - gwd_settings_storage_update_use_tooltips (storage); -} - -TEST_P (GWDSettingsTestStorageUpdates, TestSetBlur) -{ - GWDSettingsStorage *storage = GetParam ()->GetStorage (); - GetParam ()->SetBlur (testing_values::BLUR_TYPE_ALL_VALUE); - - EXPECT_CALL (*mSettingsMock, blurChanged (Eq (testing_values::BLUR_TYPE_ALL_VALUE))); - - gwd_settings_storage_update_blur (storage); -} - -TEST_P (GWDSettingsTestStorageUpdates, TestSetButtonLayout) -{ - GWDSettingsStorage *storage = GetParam ()->GetStorage (); - GetParam ()->SetButtonLayout (testing_values::BUTTON_LAYOUT_VALUE); - - EXPECT_CALL (*mSettingsMock, buttonLayoutChanged (Eq (testing_values::BUTTON_LAYOUT_VALUE))); - - gwd_settings_storage_update_button_layout (storage); -} - -TEST_P (GWDSettingsTestStorageUpdates, TestSetOpacity) -{ - GWDSettingsStorage *storage = GetParam ()->GetStorage (); - GetParam ()->SetOpacity (testing_values::ACTIVE_OPACITY_VALUE, - testing_values::INACTIVE_OPACITY_VALUE, - testing_values::ACTIVE_SHADE_OPACITY_VALUE, - testing_values::INACTIVE_SHADE_OPACITY_VALUE); - - EXPECT_CALL (*mSettingsMock, opacityChanged (testing_values::ACTIVE_OPACITY_VALUE, - testing_values::INACTIVE_OPACITY_VALUE, - testing_values::ACTIVE_SHADE_OPACITY_VALUE, - testing_values::INACTIVE_SHADE_OPACITY_VALUE)); - - gwd_settings_storage_update_opacity (storage); -} - -TEST_P (GWDSettingsTestStorageUpdates, TestSetMetacityTheme) -{ - GWDSettingsStorage *storage = GetParam ()->GetStorage (); - GetParam ()->SetMetacityTheme (testing_values::USE_METACITY_THEME_VALUE, - testing_values::METACITY_THEME_VALUE); - - EXPECT_CALL (*mSettingsMock, metacityThemeChanged (testing_values::USE_METACITY_THEME_VALUE, - Eq (testing_values::METACITY_THEME_VALUE))); - - gwd_settings_storage_update_metacity_theme (storage); -} - -TEST_P (GWDSettingsTestStorageUpdates, TestSetFont) -{ - GWDSettingsStorage *storage = GetParam ()->GetStorage (); - GetParam ()->SetFont (testing_values::USE_SYSTEM_FONT_VALUE, - testing_values::TITLEBAR_FONT_VALUE); - - EXPECT_CALL (*mSettingsMock, fontChanged (testing_values::USE_SYSTEM_FONT_VALUE, - Eq (testing_values::TITLEBAR_FONT_VALUE))); - - gwd_settings_storage_update_font (storage); -} - -TEST_P (GWDSettingsTestStorageUpdates, TestSetTitlebarActions) -{ - GWDSettingsStorage *storage = GetParam ()->GetStorage (); - GetParam ()->SetTitlebarActions (testing_values::TITLEBAR_ACTION_LOWER, - testing_values::TITLEBAR_ACTION_MAX, - testing_values::TITLEBAR_ACTION_MENU, - testing_values::TITLEBAR_ACTION_SHADE); - - EXPECT_CALL (*mSettingsMock, titlebarActionsChanged (Eq (testing_values::TITLEBAR_ACTION_LOWER), - Eq (testing_values::TITLEBAR_ACTION_MAX), - Eq (testing_values::TITLEBAR_ACTION_MENU), - Eq (testing_values::TITLEBAR_ACTION_SHADE))); - - gwd_settings_storage_update_titlebar_actions (storage); -} - -class GWDSettingsStorageGSettingsFactoryWrapper : - public GWDSettingsStorageFactoryWrapperInterface -{ - public: - - virtual void SetUp (GWDSettingsWritable *writable) - { - gsliceEnv.SetUpEnv (); - gsettingsEnv.SetUpEnv (MOCK_PATH); - - mStorage.reset (gwd_settings_storage_new (writable, FALSE), - boost::bind (gwd_settings_storage_unref, _1)); - - /* We do not need to keep a reference to these */ - mGWDSettings = gwd_get_org_compiz_gwd_settings (GetStorage ()); - mMetacitySettings = gwd_get_org_gnome_metacity_settings (GetStorage ()); - mDesktopSettings = gwd_get_org_gnome_desktop_wm_preferences_settings (GetStorage ()); - mMarcoSettings = gwd_get_org_mate_marco_general_settings (GetStorage ()); - } - - virtual GWDSettingsStorage * GetStorage () - { - return mStorage.get (); - } - - virtual void SetUseTooltips (gboolean useTooltips) - { - g_settings_set_boolean (mGWDSettings, ORG_COMPIZ_GWD_KEY_USE_TOOLTIPS, useTooltips); - } - - virtual void SetBlur (const std::string &blurType) - { - g_settings_set_string (mGWDSettings, ORG_COMPIZ_GWD_KEY_BLUR_TYPE, blurType.c_str ()); - } - - virtual void SetOpacity (gdouble activeOpacity, - gdouble inactiveOpacity, - gboolean activeShadeOpacity, - gboolean inactiveShadeOpacity) - { - g_settings_set_double (mGWDSettings, ORG_COMPIZ_GWD_KEY_METACITY_THEME_ACTIVE_OPACITY, activeOpacity); - g_settings_set_double (mGWDSettings, ORG_COMPIZ_GWD_KEY_METACITY_THEME_INACTIVE_OPACITY, inactiveOpacity); - g_settings_set_boolean (mGWDSettings, ORG_COMPIZ_GWD_KEY_METACITY_THEME_ACTIVE_SHADE_OPACITY, activeShadeOpacity); - g_settings_set_boolean (mGWDSettings, ORG_COMPIZ_GWD_KEY_METACITY_THEME_INACTIVE_SHADE_OPACITY, inactiveShadeOpacity); - } - - virtual void SetMetacityTheme (gboolean useMetacityTheme, - const std::string &metacityTheme) - { - g_settings_set_boolean (mGWDSettings, ORG_COMPIZ_GWD_KEY_USE_METACITY_THEME, useMetacityTheme); - g_settings_set_string (mDesktopSettings, ORG_GNOME_DESKTOP_WM_PREFERENCES_THEME, metacityTheme.c_str ()); - g_settings_set_string (mMarcoSettings, ORG_MATE_MARCO_GENERAL_THEME, metacityTheme.c_str ()); - } - - virtual void SetButtonLayout (const std::string &buttonLayout) - { - g_settings_set_string (mDesktopSettings, - ORG_GNOME_DESKTOP_WM_PREFERENCES_BUTTON_LAYOUT, - buttonLayout.c_str ()); - g_settings_set_string (mMarcoSettings, - ORG_MATE_MARCO_GENERAL_BUTTON_LAYOUT, - buttonLayout.c_str ()); - } - - virtual void SetFont (gboolean useSystemFont, const std::string &titlebarFont) - { - g_settings_set_boolean (mDesktopSettings, - ORG_GNOME_DESKTOP_WM_PREFERENCES_TITLEBAR_USES_SYSTEM_FONT, - useSystemFont); - g_settings_set_string (mDesktopSettings, - ORG_GNOME_DESKTOP_WM_PREFERENCES_TITLEBAR_FONT, - titlebarFont.c_str ()); - g_settings_set_boolean (mMarcoSettings, - ORG_MATE_MARCO_GENERAL_TITLEBAR_USES_SYSTEM_FONT, - useSystemFont); - g_settings_set_string (mMarcoSettings, - ORG_MATE_MARCO_GENERAL_TITLEBAR_FONT, - titlebarFont.c_str ()); - } - - virtual void SetTitlebarActions (const std::string &doubleClickAction, - const std::string &middleClickAction, - const std::string &rightClickAction, - const std::string &mouseWheelAction) - { - std::string translatedDC (doubleClickAction); - std::string translatedMC (middleClickAction); - std::string translatedRC (rightClickAction); - - boost::replace_all (translatedDC, "_", "-"); - boost::replace_all (translatedMC, "_", "-"); - boost::replace_all (translatedRC, "_", "-"); - - g_settings_set_string (mDesktopSettings, - ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_DOUBLE_CLICK_TITLEBAR, - translatedDC.c_str ()); - g_settings_set_string (mDesktopSettings, - ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_MIDDLE_CLICK_TITLEBAR, - translatedMC.c_str ()); - g_settings_set_string (mDesktopSettings, - ORG_GNOME_DESKTOP_WM_PREFERENCES_ACTION_RIGHT_CLICK_TITLEBAR, - translatedRC.c_str ()); - g_settings_set_string (mMarcoSettings, - ORG_MATE_MARCO_GENERAL_ACTION_DOUBLE_CLICK_TITLEBAR, - translatedDC.c_str ()); - g_settings_set_string (mMarcoSettings, - ORG_MATE_MARCO_GENERAL_ACTION_MIDDLE_CLICK_TITLEBAR, - translatedMC.c_str ()); - g_settings_set_string (mMarcoSettings, - ORG_MATE_MARCO_GENERAL_ACTION_RIGHT_CLICK_TITLEBAR, - translatedRC.c_str ()); - g_settings_set_string (mGWDSettings, - ORG_COMPIZ_GWD_KEY_MOUSE_WHEEL_ACTION, - mouseWheelAction.c_str ()); - } - - virtual void TearDown () - { - mStorage.reset (); - mGWDSettings = NULL; - mMetacitySettings = NULL; - mDesktopSettings = NULL; - mMarcoSettings = NULL; - gsettingsEnv.TearDownEnv (); - gsliceEnv.TearDownEnv (); - } - - private: - - GSettings *mGWDSettings; - GSettings *mMetacitySettings; - GSettings *mDesktopSettings; - GSettings *mMarcoSettings; - boost::shared_ptr mStorage; - CompizGLibGSliceOffEnv gsliceEnv; - CompizGLibGSettingsMemoryBackendTestingEnv gsettingsEnv; -}; - -INSTANTIATE_TEST_CASE_P (GSettingsStorageUpdates, GWDSettingsTestStorageUpdates, - ::testing::Values (boost::shared_ptr (new GWDSettingsStorageGSettingsFactoryWrapper ()))); diff -Nru compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/wnck.c compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/wnck.c --- compiz-0.9.12.2+16.10.20160517/gtk/window-decorator/wnck.c 2016-05-17 02:51:52.000000000 +0000 +++ compiz-0.9.12.2+16.10.20160525/gtk/window-decorator/wnck.c 2016-05-25 14:20:33.000000000 +0000 @@ -25,6 +25,12 @@ #include "gtk-window-decorator.h" +static void +draw_window_decoration (decor_t *decor) +{ + gwd_theme_draw_window_decoration (gwd_theme, decor); +} + const gchar * get_frame_type (WnckWindow *win) { @@ -169,7 +175,7 @@ { decor_frame_t *frame = (decor_frame_t *) value; - (*theme_update_border_extents) (frame); + gwd_theme_update_border_extents (gwd_theme, frame); } void @@ -183,6 +189,7 @@ gdkdisplay = gdk_display_get_default (); gdkscreen = gdk_display_get_default_screen (gdkdisplay); + GWDSettings *settings = gwd_theme_get_settings (gwd_theme); const gchar *titlebar_font = NULL; g_object_get (settings, "titlebar-font", &titlebar_font, NULL); @@ -207,16 +214,8 @@ { decor_t *d = g_object_get_data (G_OBJECT (windows->data), "decor"); - if (d->decorated) - { - -#ifdef USE_METACITY - if (d->draw == draw_window_decoration || - d->draw == meta_draw_window_decoration) - d->draw = theme_draw_window_decoration; -#endif - - } + if (d->decorated) + d->draw = draw_window_decoration; update_window_decoration (WNCK_WINDOW (windows->data)); windows = windows->next; @@ -813,7 +812,7 @@ &d->client_width, &d->client_height); - d->draw = theme_draw_window_decoration; + d->draw = draw_window_decoration; d->created = FALSE; d->surface = NULL;