[mutter] tile-preview: Remove non-composited case
- From: Florian MÃllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] tile-preview: Remove non-composited case
- Date: Tue, 17 Jan 2012 11:54:14 +0000 (UTC)
commit 44f362ad87a5f78bae967b08ff1e45aa336eb5d9
Author: Florian MÃllner <fmuellner gnome org>
Date: Mon Dec 12 20:14:44 2011 +0100
tile-preview: Remove non-composited case
The main reason for handling the non-composited case was to keep
code differences with metacity small, but the tiling patch[0] never
got merged. In mutter itself, the compositor is not optional, so
there's no good reason for keeping those untested code chunks around.
[0] https://bugzilla.gnome.org/show_bug.cgi?id=607694
https://bugzilla.gnome.org/show_bug.cgi?id=666039
src/core/screen.c | 4 +-
src/ui/tile-preview.c | 124 +++++++++++++++----------------------------------
src/ui/tile-preview.h | 3 +-
3 files changed, 39 insertions(+), 92 deletions(-)
---
diff --git a/src/core/screen.c b/src/core/screen.c
index 14d40b1..0c742b5 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -1925,7 +1925,6 @@ meta_screen_tile_preview_update_timeout (gpointer data)
{
MetaScreen *screen = data;
MetaWindow *window = screen->display->grab_window;
- gboolean composited = screen->display->compositor != NULL;
gboolean needs_preview = FALSE;
screen->tile_preview_timeout_id = 0;
@@ -1935,8 +1934,7 @@ meta_screen_tile_preview_update_timeout (gpointer data)
Window xwindow;
gulong create_serial;
- screen->tile_preview = meta_tile_preview_new (screen->number,
- composited);
+ screen->tile_preview = meta_tile_preview_new (screen->number);
xwindow = meta_tile_preview_get_xwindow (screen->tile_preview,
&create_serial);
meta_stack_tracker_record_add (screen->stack_tracker,
diff --git a/src/ui/tile-preview.c b/src/ui/tile-preview.c
index f09c62a..61a4385 100644
--- a/src/ui/tile-preview.c
+++ b/src/ui/tile-preview.c
@@ -39,8 +39,6 @@ struct _MetaTilePreview {
GdkRGBA *preview_color;
MetaRectangle tile_rect;
-
- gboolean has_alpha: 1;
};
static gboolean
@@ -52,30 +50,17 @@ meta_tile_preview_draw (GtkWidget *widget,
cairo_set_line_width (cr, 1.0);
- if (preview->has_alpha)
- {
- /* Fill the preview area with a transparent color */
- gdk_cairo_set_source_rgba (cr, preview->preview_color);
-
- cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
- cairo_paint (cr);
-
- /* Use the opaque color for the border */
- cairo_set_source_rgb (cr,
- preview->preview_color->red,
- preview->preview_color->green,
- preview->preview_color->blue);
- }
- else
- {
- cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
-
- cairo_rectangle (cr,
- OUTLINE_WIDTH - 0.5, OUTLINE_WIDTH - 0.5,
- preview->tile_rect.width - 2 * (OUTLINE_WIDTH - 1) - 1,
- preview->tile_rect.height - 2 * (OUTLINE_WIDTH - 1) - 1);
- cairo_stroke (cr);
- }
+ /* Fill the preview area with a transparent color */
+ gdk_cairo_set_source_rgba (cr, preview->preview_color);
+
+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+ cairo_paint (cr);
+
+ /* Use the opaque color for the border */
+ cairo_set_source_rgb (cr,
+ preview->preview_color->red,
+ preview->preview_color->green,
+ preview->preview_color->blue);
cairo_rectangle (cr,
0.5, 0.5,
@@ -87,11 +72,13 @@ meta_tile_preview_draw (GtkWidget *widget,
}
MetaTilePreview *
-meta_tile_preview_new (int screen_number,
- gboolean composited)
+meta_tile_preview_new (int screen_number)
{
MetaTilePreview *preview;
GdkScreen *screen;
+ GtkStyleContext *context;
+ GtkWidgetPath *path;
+ guchar selection_alpha = 0xFF;
screen = gdk_display_get_screen (gdk_display_get_default (), screen_number);
@@ -107,44 +94,34 @@ meta_tile_preview_new (int screen_number,
preview->tile_rect.x = preview->tile_rect.y = 0;
preview->tile_rect.width = preview->tile_rect.height = 0;
- preview->has_alpha = composited &&
- (gdk_screen_get_rgba_visual (screen) != NULL);
-
- if (preview->has_alpha)
- {
- GtkStyleContext *context;
- GtkWidgetPath *path;
- guchar selection_alpha = 0xFF;
+ gtk_widget_set_visual (preview->preview_window,
+ gdk_screen_get_rgba_visual (screen));
- gtk_widget_set_visual (preview->preview_window,
- gdk_screen_get_rgba_visual (screen));
+ path = gtk_widget_path_new ();
+ gtk_widget_path_append_type (path, GTK_TYPE_ICON_VIEW);
- path = gtk_widget_path_new ();
- gtk_widget_path_append_type (path, GTK_TYPE_ICON_VIEW);
+ context = gtk_style_context_new ();
+ gtk_style_context_set_path (context, path);
+ gtk_style_context_add_class (context,
+ GTK_STYLE_CLASS_RUBBERBAND);
- context = gtk_style_context_new ();
- gtk_style_context_set_path (context, path);
- gtk_style_context_add_class (context,
- GTK_STYLE_CLASS_RUBBERBAND);
+ gtk_widget_path_free (path);
- gtk_widget_path_free (path);
+ gtk_style_context_get (context, GTK_STATE_FLAG_SELECTED,
+ "background-color", &preview->preview_color,
+ NULL);
- gtk_style_context_get (context, GTK_STATE_FLAG_SELECTED,
- "background-color", &preview->preview_color,
- NULL);
-
- /* The background-color for the .rubberband class should probably
- * contain the correct alpha value - unfortunately, at least for now
- * it doesn't. Hopefully the following workaround can be removed
- * when GtkIconView gets ported to GtkStyleContext.
- */
- gtk_style_context_get_style (context,
- "selection-box-alpha", &selection_alpha,
- NULL);
- preview->preview_color->alpha = (double)selection_alpha / 0xFF;
+ /* The background-color for the .rubberband class should probably
+ * contain the correct alpha value - unfortunately, at least for now
+ * it doesn't. Hopefully the following workaround can be removed
+ * when GtkIconView gets ported to GtkStyleContext.
+ */
+ gtk_style_context_get_style (context,
+ "selection-box-alpha", &selection_alpha,
+ NULL);
+ preview->preview_color->alpha = (double)selection_alpha / 0xFF;
- g_object_unref (context);
- }
+ g_object_unref (context);
/* We make an assumption that XCreateWindow will be the first operation
* when calling gtk_widget_realize() (via gdk_window_new()), or that it
@@ -200,33 +177,6 @@ meta_tile_preview_show (MetaTilePreview *preview,
gdk_window_move_resize (window,
preview->tile_rect.x, preview->tile_rect.y,
preview->tile_rect.width, preview->tile_rect.height);
-
- if (!preview->has_alpha)
- {
- cairo_region_t *outer_region, *inner_region;
- GdkRectangle outer_rect, inner_rect;
- GdkRGBA black = { 0.0, 0.0, 0.0, 1.0 };
-
- gdk_window_set_background_rgba (window, &black);
-
- outer_rect.x = outer_rect.y = 0;
- outer_rect.width = preview->tile_rect.width;
- outer_rect.height = preview->tile_rect.height;
-
- inner_rect.x = OUTLINE_WIDTH;
- inner_rect.y = OUTLINE_WIDTH;
- inner_rect.width = outer_rect.width - 2 * OUTLINE_WIDTH;
- inner_rect.height = outer_rect.height - 2 * OUTLINE_WIDTH;
-
- outer_region = cairo_region_create_rectangle (&outer_rect);
- inner_region = cairo_region_create_rectangle (&inner_rect);
-
- cairo_region_subtract (outer_region, inner_region);
- cairo_region_destroy (inner_region);
-
- gdk_window_shape_combine_region (window, outer_region, 0, 0);
- cairo_region_destroy (outer_region);
- }
}
void
diff --git a/src/ui/tile-preview.h b/src/ui/tile-preview.h
index 740f41f..8152a60 100644
--- a/src/ui/tile-preview.h
+++ b/src/ui/tile-preview.h
@@ -27,8 +27,7 @@
typedef struct _MetaTilePreview MetaTilePreview;
-MetaTilePreview *meta_tile_preview_new (int screen_number,
- gboolean composited);
+MetaTilePreview *meta_tile_preview_new (int screen_number);
void meta_tile_preview_free (MetaTilePreview *preview);
void meta_tile_preview_show (MetaTilePreview *preview,
MetaRectangle *rect);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]