[mutter/wip/cb2eb3: 49/55] theme: Remove support for painting layouts
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/cb2eb3: 49/55] theme: Remove support for painting layouts
- Date: Wed, 1 Oct 2014 15:51:32 +0000 (UTC)
commit 11e1f687f9aab7caffab2bec7c6adb07699a8d49
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Sat May 5 00:24:55 2012 -0300
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.
src/meta/preview-widget.h | 2 -
src/ui/preview-widget.c | 11 ---------
src/ui/theme-private.h | 4 +--
src/ui/theme-viewer.c | 15 ------------
src/ui/theme.c | 25 +------------------
src/ui/ui.c | 7 +-----
src/ui/uiframe.c | 55 ++++++++------------------------------------
src/ui/uiframe.h | 8 ++----
8 files changed, 17 insertions(+), 110 deletions(-)
---
diff --git a/src/meta/preview-widget.h b/src/meta/preview-widget.h
index b3d2639..189379e 100644
--- a/src/meta/preview-widget.h
+++ b/src/meta/preview-widget.h
@@ -49,8 +49,6 @@ struct _MetaPreview
MetaFrameType type;
MetaFrameFlags flags;
- PangoLayout *layout;
-
MetaFrameBorders borders;
guint borders_cached : 1;
diff --git a/src/ui/preview-widget.c b/src/ui/preview-widget.c
index dad470e..5eee668 100644
--- a/src/ui/preview-widget.c
+++ b/src/ui/preview-widget.c
@@ -126,10 +126,6 @@ ensure_info (MetaPreview *preview)
GtkWidget *widget;
widget = GTK_WIDGET (preview);
-
- if (preview->layout == NULL)
- preview->layout = gtk_widget_create_pango_layout (widget,
- preview->title);
if (!preview->borders_cached)
{
@@ -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;
}
diff --git a/src/ui/theme-private.h b/src/ui/theme-private.h
index 7de8a00..48538b2 100644
--- a/src/ui/theme-private.h
+++ b/src/ui/theme-private.h
@@ -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,
diff --git a/src/ui/theme-viewer.c b/src/ui/theme-viewer.c
index c767cf2..4ad4461 100644
--- a/src/ui/theme-viewer.c
+++ b/src/ui/theme-viewer.c
@@ -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
diff --git a/src/ui/theme.c b/src/ui/theme.c
index 8b36eeb..532c75f 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -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);
}
diff --git a/src/ui/ui.c b/src/ui/ui.c
index 168761b..84237b0 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -382,8 +382,6 @@ meta_ui_get_frame_borders (MetaUI *ui,
META_CORE_GET_END);
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
@@ -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
diff --git a/src/ui/uiframe.c b/src/ui/uiframe.c
index 5b8bd5b..878f679 100644
--- a/src/ui/uiframe.c
+++ b/src/ui/uiframe.c
@@ -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
@@ -93,30 +96,6 @@ meta_uiframe_attach_style (MetaUIFrame *frame)
}
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);
diff --git a/src/ui/uiframe.h b/src/ui/uiframe.h
index f10f1f3..1d8e377 100644
--- a/src/ui/uiframe.h
+++ b/src/ui/uiframe.h
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]