示例#1
0
文件: frames.c 项目: micove/compiz
decor_frame_t *
gwd_get_decor_frame (const gchar *frame_name)
{
    decor_frame_t *frame = g_hash_table_lookup (frames_table, frame_name);

    if (!frame)
    {
        /* Frame not found, look up frame type in the frame types
         * hash table and create a new one */

        decor_frame_type_info_t *info = g_hash_table_lookup (frame_info_table, frame_name);

        if (!info)
            g_critical ("Could not find frame info %s in frame type table", frame_name);

        frame = (*info->create_func) (frame_name);

        if (!frame)
            g_critical ("Could not allocate frame %s", frame_name);

        g_hash_table_insert (frames_table, frame->type, frame);

        gwd_decor_frame_ref (frame);

        decor_frame_refresh (frame);
    }
    else
        gwd_decor_frame_ref (frame);

    return frame;
}
示例#2
0
文件: decorator.c 项目: micove/compiz
void
frame_update_shadow (decor_frame_t	    *frame,
		     decor_shadow_info_t    *info,
		     decor_shadow_options_t *opt_active_shadow,
		     decor_shadow_options_t *opt_inactive_shadow)
{
    static decor_shadow_options_t no_shadow = {0.0, 0.0, {0, 0, 0}, 0, 0};
    gwd_decor_frame_ref (frame);

    info->active = TRUE;

    (*frame->update_shadow) (gdk_x11_get_default_xdisplay (),
			     gdk_x11_screen_get_xscreen (gdk_screen_get_default ()),
			     frame, &frame->border_shadow_active,
			     &frame->window_context_active,
			     &frame->max_border_shadow_active,
			     &frame->max_window_context_active,
			     info, opt_active_shadow, &no_shadow);

    info->active = FALSE;

    (*frame->update_shadow) (gdk_x11_get_default_xdisplay (),
                             gdk_x11_screen_get_xscreen (gdk_screen_get_default ()),
                             frame, &frame->border_shadow_inactive,
                             &frame->window_context_inactive,
                             &frame->max_border_shadow_inactive,
                             &frame->max_window_context_inactive,
                             info, opt_inactive_shadow, &no_shadow);

    gwd_decor_frame_unref (frame);
}
示例#3
0
/*
 * frame_update_titlebar_font
 *
 * Returns: void
 * Description: updates the titlebar font from the pango context, should
 * be called whenever the gtk style or font has changed
 */
void
frame_update_titlebar_font (decor_frame_t *frame)
{
    const PangoFontDescription *font_desc;
    PangoFontMetrics	       *metrics;
    PangoLanguage	       *lang;

    frame = gwd_decor_frame_ref (frame);

    font_desc = get_titlebar_font (frame);
    if (!font_desc)
    {
	GtkStyle *default_style;

	default_style = gtk_widget_get_default_style ();
	font_desc = default_style->font_desc;
    }

    pango_context_set_font_description (frame->pango_context, font_desc);

    lang    = pango_context_get_language (frame->pango_context);
    metrics = pango_context_get_metrics (frame->pango_context, font_desc, lang);

    frame->text_height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
				pango_font_metrics_get_descent (metrics));

    gwd_decor_frame_unref (frame);

    pango_font_metrics_unref (metrics);
}
示例#4
0
文件: decorator.c 项目: micove/compiz
void
update_frames_shadows (gpointer key,
		       gpointer value,
		       gpointer user_data)
{
    decor_frame_t	  *frame = (decor_frame_t *) value;
    tdtd_shadow_options_t  *opts;
    decor_shadow_options_t active_o, inactive_o;

    opts = malloc (sizeof (tdtd_shadow_options_t));

    if (!opts)
	return;

    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_decor_frame_ref (frame);

    decor_shadow_info_t *info = malloc (sizeof (decor_shadow_info_t));

    if (!info)
    {
	free (opts);
	return;
    }

    info->frame = frame;
    info->state = 0;

    frame_update_shadow (frame, info, opts->active_shadow, opts->inactive_shadow);

    gwd_decor_frame_unref (frame);

    free (info);
    info = NULL;

    free (opts);
    opts = NULL;

}
示例#5
0
文件: decorator.c 项目: micove/compiz
/*
 * frame_update_titlebar_font
 *
 * Returns: void
 * Description: updates the titlebar font from the pango context, should
 * be called whenever the gtk style or font has changed
 */
void
frame_update_titlebar_font (decor_frame_t *frame)
{
    const PangoFontDescription *font_desc;
    PangoFontDescription *free_font_desc;
    PangoFontMetrics *metrics;
    PangoLanguage *lang;

    free_font_desc = NULL;
    frame = gwd_decor_frame_ref (frame);

    font_desc = get_titlebar_font (frame);
    if (!font_desc)
    {
        GtkCssProvider *provider = gtk_css_provider_get_default ();
        GtkStyleContext *context = gtk_style_context_new ();
        GtkWidgetPath *path = gtk_widget_path_new ();

        gtk_widget_path_prepend_type (path, GTK_TYPE_WIDGET);
        gtk_style_context_set_path (context, path);
        gtk_widget_path_free (path);

        gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_FALLBACK);

        gtk_style_context_get (context, GTK_STATE_FLAG_NORMAL, "font", &free_font_desc, NULL);
        font_desc = (const PangoFontDescription *) free_font_desc;
    }

    pango_context_set_font_description (frame->pango_context, font_desc);

    lang    = pango_context_get_language (frame->pango_context);
    metrics = pango_context_get_metrics (frame->pango_context, font_desc, lang);

    frame->text_height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
				pango_font_metrics_get_descent (metrics));

    gwd_decor_frame_unref (frame);

    pango_font_metrics_unref (metrics);

    if (free_font_desc)
        pango_font_description_free (free_font_desc);
}
示例#6
0
文件: frames.c 项目: micove/compiz
void
decor_frame_refresh (decor_frame_t *frame)
{
    decor_shadow_options_t active_o, inactive_o;
    decor_shadow_info_t *info;
    const gchar *titlebar_font = NULL;

    gwd_decor_frame_ref (frame);

    update_style (frame->style_window_rgba);
    update_style (frame->style_window_rgb);

    g_object_get (settings, "titlebar-font", &titlebar_font, NULL);

    set_frame_scale (frame, titlebar_font);

    titlebar_font = NULL;

    frame_update_titlebar_font (frame);

    if (strcmp (frame->type, "switcher") != 0 &&
            strcmp (frame->type, "bare") != 0)
        (*theme_update_border_extents) (frame);

    (*theme_get_shadow) (frame, &active_o, TRUE);
    (*theme_get_shadow) (frame, &inactive_o, FALSE);

    info = malloc (sizeof (decor_shadow_info_t));

    if (!info)
        return;

    info->frame = frame;
    info->state = 0;

    frame_update_shadow (frame, info, &active_o, &inactive_o);

    gwd_decor_frame_unref (frame);

    free (info);
    info = NULL;
}
示例#7
0
文件: decorator.c 项目: micove/compiz
/*
 * draw_border_shape
 * Returns: void
 * Description: Draws a slight border around the decoration
 */
static void
draw_border_shape (Display	   *xdisplay,
		   Pixmap	   pixmap,
		   Picture	   picture,
		   int		   width,
		   int		   height,
		   decor_context_t *c,
		   void		   *closure)
{
    static XRenderColor white = { 0xffff, 0xffff, 0xffff, 0xffff };
    decor_t		d;
    decor_shadow_info_t *info = (decor_shadow_info_t *) closure;
    double		save_decoration_alpha;
    GdkScreen           *screen;

    memset (&d, 0, sizeof (d));

    if (info)
    {
	gwd_decor_frame_ref (info->frame);

	d.frame = info->frame;
	d.state = info->state;
	d.actions = info->active;
    }
    else
    {
	d.frame = gwd_get_decor_frame ("normal");
	d.state = 0;
	d.active = TRUE;
    }

    screen = gdk_screen_get_default ();

    d.surface = cairo_xlib_surface_create (GDK_SCREEN_XDISPLAY (screen),
                                           pixmap,
                                           GDK_VISUAL_XVISUAL (gdk_screen_get_rgba_visual (screen)),
                                           width,
                                           height);
    d.width   = width;
    d.height  = height;
    d.active  = TRUE;
    d.draw    = theme_draw_window_decoration;
    d.picture = picture;
    d.context = c;

    /* we use closure argument if maximized */
    if (info)
	d.state = info->state;
    else
	d.state = 0;

    decor_get_default_layout (c, 1, 1, &d.border_layout);

    /* create shadow from opaque decoration
     * FIXME: Should not modify settings value
     * like this */
    save_decoration_alpha = decoration_alpha;
    decoration_alpha = 1.0;

    (*d.draw) (&d);

    decoration_alpha = save_decoration_alpha;

    XRenderFillRectangle (xdisplay, PictOpSrc, picture, &white,
			  c->left_space,
			  c->top_space,
			  width - c->left_space - c->right_space,
			  height - c->top_space - c->bottom_space);

    if (!info)
	gwd_decor_frame_unref (d.frame);

    cairo_surface_destroy (d.surface);
}
示例#8
0
文件: metacity.c 项目: micove/compiz
void
meta_update_border_extents (decor_frame_t *frame)
{
    MetaTheme *theme = meta_theme_get_current ();
#ifdef HAVE_METACITY_3_14_0
    MetaFrameBorders borders;
#endif

    gwd_decor_frame_ref (frame);
    MetaFrameType frame_type = meta_frame_type_from_string (frame->type);
    gint          top_height, bottom_height, left_width, right_width;

    if (!(frame_type < META_FRAME_TYPE_LAST))
	frame_type = META_FRAME_TYPE_NORMAL;

#ifdef HAVE_METACITY_3_14_0
    meta_theme_get_frame_borders (theme,
				  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;
#else
    meta_theme_get_frame_borders (theme,
				  frame_type,
				  frame->text_height,
				  0,
				  &top_height,
				  &bottom_height,
				  &left_width,
				  &right_width);
#endif

    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;

#ifdef HAVE_METACITY_3_14_0
    meta_theme_get_frame_borders (theme,
				  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;
#else
    meta_theme_get_frame_borders (theme,
				  frame_type,
				  frame->text_height,
				  META_FRAME_MAXIMIZED,
				  &top_height,
				  &bottom_height,
				  &left_width,
				  &right_width);
#endif

    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;

    gwd_decor_frame_unref (frame);
}
示例#9
0
/*
 * draw_border_shape
 * Returns: void
 * Description: Draws a slight border around the decoration
 */
static void
draw_border_shape (Display	   *xdisplay,
		   Pixmap	   pixmap,
		   Picture	   picture,
		   int		   width,
		   int		   height,
		   decor_context_t *c,
		   void		   *closure)
{
    static XRenderColor white = { 0xffff, 0xffff, 0xffff, 0xffff };
    GdkColormap		*colormap;
    decor_t		d;
    decor_shadow_info_t *info = (decor_shadow_info_t *) closure;
    double		save_decoration_alpha;

    memset (&d, 0, sizeof (d));

    if (info)
    {
	gwd_decor_frame_ref (info->frame);

	d.frame = info->frame;
	d.state = info->state;
	d.actions = info->active;
    }
    else
    {
	d.frame = gwd_get_decor_frame ("normal");
	d.state = 0;
	d.active = TRUE;
    }

    d.pixmap  = gdk_pixmap_foreign_new_for_display (gdk_display_get_default (),
						    pixmap);
    d.width   = width;
    d.height  = height;
    d.active  = TRUE;
    d.draw    = theme_draw_window_decoration;
    d.picture = picture;
    d.context = c;

    /* we use closure argument if maximized */
    if (info)
	d.state = info->state;
    else
	d.state = 0;

    decor_get_default_layout (c, 1, 1, &d.border_layout);

    colormap = get_colormap_for_drawable (GDK_DRAWABLE (d.pixmap));
    gdk_drawable_set_colormap (d.pixmap, colormap);

    /* create shadow from opaque decoration
     * FIXME: Should not modify settings value
     * like this */
    save_decoration_alpha = decoration_alpha;
    decoration_alpha = 1.0;

    (*d.draw) (&d);

    decoration_alpha = save_decoration_alpha;

    XRenderFillRectangle (xdisplay, PictOpSrc, picture, &white,
			  c->left_space,
			  c->top_space,
			  width - c->left_space - c->right_space,
			  height - c->top_space - c->bottom_space);

    if (!info)
	gwd_decor_frame_unref (d.frame);

    g_object_unref (G_OBJECT (d.pixmap));
}