mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
theme: Remove support for painting layouts
We'll do this with a GtkLabel child instead. This means that the mask text shadows are currently broken -- we'll fix up things later to be better.
This commit is contained in:
parent
25815473e6
commit
11e1f687f9
@ -49,8 +49,6 @@ struct _MetaPreview
|
||||
MetaFrameType type;
|
||||
MetaFrameFlags flags;
|
||||
|
||||
PangoLayout *layout;
|
||||
|
||||
MetaFrameBorders borders;
|
||||
guint borders_cached : 1;
|
||||
|
||||
|
@ -127,10 +127,6 @@ ensure_info (MetaPreview *preview)
|
||||
|
||||
widget = GTK_WIDGET (preview);
|
||||
|
||||
if (preview->layout == NULL)
|
||||
preview->layout = gtk_widget_create_pango_layout (widget,
|
||||
preview->title);
|
||||
|
||||
if (!preview->borders_cached)
|
||||
{
|
||||
if (preview->theme)
|
||||
@ -184,7 +180,6 @@ meta_preview_draw (GtkWidget *widget,
|
||||
preview->flags,
|
||||
client_width,
|
||||
client_height,
|
||||
preview->layout,
|
||||
&preview->button_layout,
|
||||
button_states,
|
||||
meta_preview_get_mini_icon (),
|
||||
@ -293,12 +288,6 @@ meta_preview_size_allocate (GtkWidget *widget,
|
||||
static void
|
||||
clear_cache (MetaPreview *preview)
|
||||
{
|
||||
if (preview->layout)
|
||||
{
|
||||
g_object_unref (G_OBJECT (preview->layout));
|
||||
preview->layout = NULL;
|
||||
}
|
||||
|
||||
preview->borders_cached = FALSE;
|
||||
}
|
||||
|
||||
|
@ -1004,8 +1004,7 @@ GdkPixbuf* meta_theme_load_image (MetaTheme *theme,
|
||||
void meta_theme_render_background (GtkStyleContext *style,
|
||||
cairo_t *cr,
|
||||
MetaFrameFlags flags,
|
||||
const MetaFrameGeometry *fgeom,
|
||||
PangoLayout *title_layout);
|
||||
const MetaFrameGeometry *fgeom);
|
||||
|
||||
void meta_theme_draw_frame_with_style (MetaTheme *theme,
|
||||
GtkStyleContext *style_gtk,
|
||||
@ -1014,7 +1013,6 @@ void meta_theme_draw_frame_with_style (MetaTheme *theme,
|
||||
MetaFrameFlags flags,
|
||||
int client_width,
|
||||
int client_height,
|
||||
PangoLayout *title_layout,
|
||||
const MetaButtonLayout *button_layout,
|
||||
MetaButtonState button_states[META_BUTTON_TYPE_LAST],
|
||||
GdkPixbuf *mini_icon,
|
||||
|
@ -924,16 +924,6 @@ get_flags (GtkWidget *widget)
|
||||
META_FRAME_ALLOWS_MOVE;
|
||||
}
|
||||
|
||||
static PangoLayout*
|
||||
create_title_layout (GtkWidget *widget)
|
||||
{
|
||||
PangoLayout *layout;
|
||||
|
||||
layout = gtk_widget_create_pango_layout (widget, _("Window Title Goes Here"));
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
static void
|
||||
run_theme_benchmark (void)
|
||||
{
|
||||
@ -947,7 +937,6 @@ run_theme_benchmark (void)
|
||||
META_BUTTON_STATE_NORMAL,
|
||||
META_BUTTON_STATE_NORMAL
|
||||
};
|
||||
PangoLayout *layout;
|
||||
clock_t start;
|
||||
clock_t end;
|
||||
GTimer *timer;
|
||||
@ -968,8 +957,6 @@ run_theme_benchmark (void)
|
||||
get_flags (widget),
|
||||
&borders);
|
||||
|
||||
layout = create_title_layout (widget);
|
||||
|
||||
i = 0;
|
||||
while (i < MAX_BUTTONS_PER_CORNER)
|
||||
{
|
||||
@ -1012,7 +999,6 @@ run_theme_benchmark (void)
|
||||
META_FRAME_TYPE_NORMAL,
|
||||
get_flags (widget),
|
||||
client_width, client_height,
|
||||
layout,
|
||||
&button_layout,
|
||||
button_states,
|
||||
meta_preview_get_mini_icon (),
|
||||
@ -1039,7 +1025,6 @@ run_theme_benchmark (void)
|
||||
milliseconds_to_draw_frame);
|
||||
|
||||
g_timer_destroy (timer);
|
||||
g_object_unref (G_OBJECT (layout));
|
||||
gtk_widget_destroy (widget);
|
||||
|
||||
#undef ITERATIONS
|
||||
|
@ -4077,8 +4077,7 @@ void
|
||||
meta_theme_render_background (GtkStyleContext *style_gtk,
|
||||
cairo_t *cr,
|
||||
MetaFrameFlags flags,
|
||||
const MetaFrameGeometry *fgeom,
|
||||
PangoLayout *title_layout)
|
||||
const MetaFrameGeometry *fgeom)
|
||||
{
|
||||
GdkRectangle visible_rect;
|
||||
const MetaFrameBorders *borders;
|
||||
@ -4106,19 +4105,6 @@ meta_theme_render_background (GtkStyleContext *style_gtk,
|
||||
visible_rect.width,
|
||||
visible_rect.height);
|
||||
|
||||
if (title_layout != NULL)
|
||||
{
|
||||
PangoRectangle title_rect;
|
||||
|
||||
pango_layout_get_pixel_extents (title_layout,
|
||||
NULL, &title_rect);
|
||||
|
||||
gtk_render_layout (style_gtk, cr,
|
||||
borders->invisible.left + fgeom->width / 2.0 - title_rect.width / 2.0,
|
||||
borders->invisible.top + borders->visible.top / 2.0 - title_rect.height / 2.0,
|
||||
title_layout);
|
||||
}
|
||||
|
||||
gtk_style_context_restore (style_gtk);
|
||||
}
|
||||
|
||||
@ -4130,12 +4116,11 @@ meta_frame_style_draw_with_style (MetaFrameStyle *style,
|
||||
const MetaFrameGeometry *fgeom,
|
||||
int client_width,
|
||||
int client_height,
|
||||
PangoLayout *title_layout,
|
||||
MetaButtonState button_states[META_BUTTON_TYPE_LAST],
|
||||
GdkPixbuf *mini_icon,
|
||||
GdkPixbuf *icon)
|
||||
{
|
||||
meta_theme_render_background (style_gtk, cr, flags, fgeom, title_layout);
|
||||
meta_theme_render_background (style_gtk, cr, flags, fgeom);
|
||||
|
||||
#if 0
|
||||
int i, j;
|
||||
@ -4187,10 +4172,6 @@ meta_frame_style_draw_with_style (MetaFrameStyle *style,
|
||||
bottom_edge.width = visible_rect.width;
|
||||
bottom_edge.height = borders->visible.bottom;
|
||||
|
||||
if (title_layout)
|
||||
pango_layout_get_pixel_extents (title_layout,
|
||||
NULL, &logical_rect);
|
||||
|
||||
draw_info.mini_icon = mini_icon;
|
||||
draw_info.icon = icon;
|
||||
draw_info.title_layout = title_layout;
|
||||
@ -5017,7 +4998,6 @@ meta_theme_draw_frame_with_style (MetaTheme *theme,
|
||||
MetaFrameFlags flags,
|
||||
int client_width,
|
||||
int client_height,
|
||||
PangoLayout *title_layout,
|
||||
const MetaButtonLayout *button_layout,
|
||||
MetaButtonState button_states[META_BUTTON_TYPE_LAST],
|
||||
GdkPixbuf *mini_icon,
|
||||
@ -5049,7 +5029,6 @@ meta_theme_draw_frame_with_style (MetaTheme *theme,
|
||||
cr,
|
||||
&fgeom,
|
||||
client_width, client_height,
|
||||
title_layout,
|
||||
button_states,
|
||||
mini_icon, icon);
|
||||
}
|
||||
|
@ -383,8 +383,6 @@ meta_ui_get_frame_borders (MetaUI *ui,
|
||||
|
||||
g_return_if_fail (type < META_FRAME_TYPE_LAST);
|
||||
|
||||
meta_uiframe_ensure_layout (frame);
|
||||
|
||||
/* We can't get the full geometry, because that depends on
|
||||
* the client window size and probably we're being called
|
||||
* by the core move/resize code to decide on the client
|
||||
@ -413,7 +411,7 @@ meta_ui_render_background (MetaUI *ui,
|
||||
META_CORE_GET_END);
|
||||
|
||||
meta_uiframe_calc_geometry (frame, &fgeom);
|
||||
meta_theme_render_background (frame->tv->style_context, cr, flags, &fgeom, frame->layout);
|
||||
meta_theme_render_background (frame->tv->style_context, cr, flags, &fgeom);
|
||||
}
|
||||
|
||||
Window
|
||||
@ -506,9 +504,6 @@ meta_ui_create_frame_window (MetaUI *ui,
|
||||
/* Don't set event mask here, it's in frame.c */
|
||||
frame->window = g_object_ref (window);
|
||||
frame->xwindow = GDK_WINDOW_XID (window);
|
||||
frame->layout = NULL;
|
||||
frame->title = NULL;
|
||||
frame->shape_applied = FALSE;
|
||||
frame->prelit_control = META_FRAME_CONTROL_NONE;
|
||||
|
||||
/* Don't set the window background yet; we need frame->xwindow to be
|
||||
|
@ -59,17 +59,20 @@ meta_uiframe_finalize (GObject *obj)
|
||||
|
||||
if (frame->window)
|
||||
g_object_unref (frame->window);
|
||||
|
||||
if (frame->layout)
|
||||
g_object_unref (G_OBJECT (frame->layout));
|
||||
|
||||
if (frame->title)
|
||||
g_free (frame->title);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_uiframe_init (MetaUIFrame *frame)
|
||||
{
|
||||
GtkWidget *container, *label;
|
||||
|
||||
frame->container = container = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
frame->label = label = gtk_label_new ("");
|
||||
|
||||
gtk_container_add (GTK_CONTAINER (frame), container);
|
||||
gtk_container_add (GTK_CONTAINER (container), frame->label);
|
||||
|
||||
gtk_widget_show_all (GTK_WIDGET (container));
|
||||
}
|
||||
|
||||
/* In order to use a style with a window it has to be attached to that
|
||||
@ -92,30 +95,6 @@ meta_uiframe_attach_style (MetaUIFrame *frame)
|
||||
variant);
|
||||
}
|
||||
|
||||
void
|
||||
meta_uiframe_ensure_layout (MetaUIFrame *frame)
|
||||
{
|
||||
MetaFrameFlags flags;
|
||||
MetaFrameType type;
|
||||
|
||||
meta_core_get (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), frame->xwindow,
|
||||
META_CORE_GET_FRAME_FLAGS, &flags,
|
||||
META_CORE_GET_FRAME_TYPE, &type,
|
||||
META_CORE_GET_END);
|
||||
|
||||
if (frame->layout == NULL)
|
||||
{
|
||||
frame->layout = gtk_widget_create_pango_layout (GTK_WIDGET (frame), frame->title);
|
||||
|
||||
pango_layout_set_ellipsize (frame->layout, PANGO_ELLIPSIZE_END);
|
||||
pango_layout_set_auto_dir (frame->layout, FALSE);
|
||||
|
||||
/* Save some RAM */
|
||||
g_free (frame->title);
|
||||
frame->title = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
meta_uiframe_calc_geometry (MetaUIFrame *frame,
|
||||
MetaFrameGeometry *fgeom)
|
||||
@ -132,8 +111,6 @@ meta_uiframe_calc_geometry (MetaUIFrame *frame,
|
||||
META_CORE_GET_FRAME_TYPE, &type,
|
||||
META_CORE_GET_END);
|
||||
|
||||
meta_uiframe_ensure_layout (frame);
|
||||
|
||||
meta_prefs_get_button_layout (&button_layout);
|
||||
|
||||
meta_theme_calc_geometry (frame->tv->theme,
|
||||
@ -164,16 +141,7 @@ void
|
||||
meta_uiframe_set_title (MetaUIFrame *frame,
|
||||
const char *title)
|
||||
{
|
||||
g_free (frame->title);
|
||||
frame->title = g_strdup (title);
|
||||
|
||||
if (frame->layout)
|
||||
{
|
||||
g_object_unref (frame->layout);
|
||||
frame->layout = NULL;
|
||||
}
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (frame));
|
||||
gtk_label_set_text (GTK_LABEL (frame->label), title);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1052,8 +1020,6 @@ meta_uiframe_paint (MetaUIFrame *frame,
|
||||
META_CORE_GET_CLIENT_HEIGHT, &h,
|
||||
META_CORE_GET_END);
|
||||
|
||||
meta_uiframe_ensure_layout (frame);
|
||||
|
||||
meta_prefs_get_button_layout (&button_layout);
|
||||
|
||||
meta_theme_draw_frame_with_style (frame->tv->theme,
|
||||
@ -1062,7 +1028,6 @@ meta_uiframe_paint (MetaUIFrame *frame,
|
||||
type,
|
||||
flags,
|
||||
w, h,
|
||||
frame->layout,
|
||||
&button_layout,
|
||||
button_states,
|
||||
mini_icon, icon);
|
||||
|
@ -76,10 +76,10 @@ struct _MetaUIFrame
|
||||
Window xwindow;
|
||||
GdkWindow *window;
|
||||
MetaThemeVariant *tv;
|
||||
PangoLayout *layout;
|
||||
char *title; /* NULL once we have a layout */
|
||||
guint shape_applied : 1;
|
||||
MetaFrameControl prelit_control;
|
||||
|
||||
GtkWidget *label;
|
||||
GtkWidget *container;
|
||||
};
|
||||
|
||||
struct _MetaUIFrameClass
|
||||
@ -94,8 +94,6 @@ void meta_uiframe_set_title (MetaUIFrame *frame,
|
||||
|
||||
void meta_uiframe_attach_style (MetaUIFrame *frame);
|
||||
|
||||
void meta_uiframe_ensure_layout (MetaUIFrame *frame);
|
||||
|
||||
void meta_uiframe_calc_geometry (MetaUIFrame *frame,
|
||||
MetaFrameGeometry *fgeom);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user