summaryrefslogtreecommitdiff
path: root/mate-panel
diff options
context:
space:
mode:
authorKonstantin Pugin <[email protected]>2014-06-20 00:04:13 +0700
committerKonstantin Pugin <[email protected]>2014-06-20 01:26:52 +0700
commita9d01e5afb6fd97d96f1b298e6e34d2dfa02f25c (patch)
tree4634f12585ec2259fb63b2743d16928c8b4dda86 /mate-panel
parentf327306271032e7b8ef716655f91c58513792cde (diff)
downloadmate-panel-a9d01e5afb6fd97d96f1b298e6e34d2dfa02f25c.tar.bz2
mate-panel-a9d01e5afb6fd97d96f1b298e6e34d2dfa02f25c.tar.xz
Fix RGBA issues for GTK3
Diffstat (limited to 'mate-panel')
-rw-r--r--mate-panel/mate-panel-applet-frame.c2
-rw-r--r--mate-panel/panel-background-monitor.c7
-rw-r--r--mate-panel/panel-background-monitor.h3
-rw-r--r--mate-panel/panel-background.c141
-rw-r--r--mate-panel/panel-background.h7
-rw-r--r--mate-panel/panel-menu-bar.c4
-rw-r--r--mate-panel/panel-separator.c11
-rw-r--r--mate-panel/panel-toplevel.c12
-rw-r--r--mate-panel/panel-widget.c4
9 files changed, 119 insertions, 72 deletions
diff --git a/mate-panel/mate-panel-applet-frame.c b/mate-panel/mate-panel-applet-frame.c
index bdabbc93..ba68c083 100644
--- a/mate-panel/mate-panel-applet-frame.c
+++ b/mate-panel/mate-panel-applet-frame.c
@@ -624,6 +624,7 @@ mate_panel_applet_frame_change_background (MatePanelAppletFrame *frame,
g_return_if_fail (PANEL_IS_WIDGET (parent));
+#if !GTK_CHECK_VERSION (3, 0, 0)
if (frame->priv->has_handle) {
PanelBackground *background;
@@ -631,6 +632,7 @@ mate_panel_applet_frame_change_background (MatePanelAppletFrame *frame,
panel_background_change_background_on_widget (background,
GTK_WIDGET (frame));
}
+#endif
MATE_PANEL_APPLET_FRAME_GET_CLASS (frame)->change_background (frame, type);
}
diff --git a/mate-panel/panel-background-monitor.c b/mate-panel/panel-background-monitor.c
index ce9737cf..2bd7fe15 100644
--- a/mate-panel/panel-background-monitor.c
+++ b/mate-panel/panel-background-monitor.c
@@ -84,6 +84,13 @@ static PanelBackgroundMonitor **global_background_monitors = NULL;
static guint signals [LAST_SIGNAL] = { 0 };
+#if GTK_CHECK_VERSION(3, 0, 0)
+gboolean gdk_window_check_composited_wm(GdkWindow* window)
+{
+ return gdk_screen_is_composited(gdk_window_get_screen(window));
+}
+#endif
+
static void
panel_background_monitor_finalize (GObject *object)
{
diff --git a/mate-panel/panel-background-monitor.h b/mate-panel/panel-background-monitor.h
index dadf910c..379e3313 100644
--- a/mate-panel/panel-background-monitor.h
+++ b/mate-panel/panel-background-monitor.h
@@ -49,6 +49,9 @@
typedef struct _PanelBackgroundMonitorClass PanelBackgroundMonitorClass;
typedef struct _PanelBackgroundMonitor PanelBackgroundMonitor;
+#if GTK_CHECK_VERSION(3, 0, 0)
+gboolean gdk_window_check_composited_wm (GdkWindow* window);
+#endif
GType panel_background_monitor_get_type (void);
PanelBackgroundMonitor *panel_background_monitor_get_for_screen (GdkScreen *screen);
GdkPixbuf *panel_background_monitor_get_region (PanelBackgroundMonitor *monitor,
diff --git a/mate-panel/panel-background.c b/mate-panel/panel-background.c
index bd5370c0..8765c2ea 100644
--- a/mate-panel/panel-background.c
+++ b/mate-panel/panel-background.c
@@ -96,6 +96,28 @@ set_pixbuf_background (PanelBackground *background)
#endif
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+void panel_background_apply_css (GtkWidget* widget)
+{
+ GtkStyleContext* context;
+ GtkCssProvider *provider;
+
+ context = gtk_widget_get_style_context (widget);
+ gtk_widget_reset_style(widget);
+ provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (provider,
+ ".-mate-custom-panel-background{\n"
+ " background-color: rgba (0, 0, 0, 0);\n"
+ " background-image: none;\n"
+ "}",
+ -1, NULL);
+ gtk_style_context_add_class (context, "-mate-custom-panel-background");
+ gtk_style_context_add_provider (context,
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+}
+#endif
+
static gboolean
panel_background_prepare (PanelBackground *background)
{
@@ -113,6 +135,8 @@ panel_background_prepare (PanelBackground *background)
effective_type = panel_background_effective_type (background);
+
+
switch (effective_type) {
case PANEL_BACK_NONE:
#if GTK_CHECK_VERSION (3, 0, 0)
@@ -155,7 +179,7 @@ panel_background_prepare (PanelBackground *background)
case PANEL_BACK_COLOR:
if (background->has_alpha &&
#if GTK_CHECK_VERSION (3, 0, 0)
- background->composited_pattern)
+ !gdk_window_check_composited_wm(background->window))
#else
background->composited_image)
#endif
@@ -187,6 +211,7 @@ panel_background_prepare (PanelBackground *background)
* make sure that all drawing has been completed before
* the applet looks at the pixmap. */
#if GTK_CHECK_VERSION (3, 0, 0)
+
gdk_display_sync (gdk_window_get_display (background->window));
#else
gdk_display_sync (gdk_drawable_get_display (background->window));
@@ -195,8 +220,10 @@ panel_background_prepare (PanelBackground *background)
gdk_window_get_user_data (GDK_WINDOW (background->window),
(gpointer) &widget);
- if (GTK_IS_WIDGET (widget))
- gtk_widget_queue_draw (widget);
+ if (GTK_IS_WIDGET (widget)) {
+ gtk_widget_set_app_paintable(widget,TRUE);
+ gtk_widget_queue_draw (widget);
+ }
background->prepared = TRUE;
@@ -223,6 +250,13 @@ free_composited_resources (PanelBackground *background)
#endif
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void _panel_background_transparency(GdkScreen* screen,PanelBackground* background)
+{
+ panel_background_composite(background);
+}
+#endif
+
static void
background_changed (PanelBackgroundMonitor *monitor,
PanelBackground *background)
@@ -263,7 +297,11 @@ get_desktop_pixbuf (PanelBackground *background)
background->monitor, "changed",
G_CALLBACK (background_changed), background);
}
-
+#if GTK_CHECK_VERSION (3, 0, 0)
+ g_signal_connect(gdk_window_get_screen(background->window), "composited-changed",
+ G_CALLBACK(_panel_background_transparency),
+ background);
+#endif
desktop = panel_background_monitor_get_region (
background->monitor,
background->region.x,
@@ -319,20 +357,23 @@ composite_image_onto_desktop (PanelBackground *background)
#endif
cr = cairo_create (surface);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if(!gdk_window_check_composited_wm(background->window)){
+#endif
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_paint (cr);
gdk_cairo_set_source_pixbuf (cr, background->desktop, 0, 0);
cairo_rectangle (cr, 0, 0, width, height);
cairo_fill (cr);
-
#if GTK_CHECK_VERSION (3, 0, 0)
- cairo_set_source (cr, background->transformed_pattern);
-#else
+ }
+#endif
+
gdk_cairo_set_source_pixbuf (cr, background->transformed_image, 0, 0);
pattern = cairo_get_source (cr);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
-#endif
+
cairo_rectangle (cr, 0, 0, width, height);
cairo_fill (cr);
@@ -382,9 +423,14 @@ composite_color_onto_desktop (PanelBackground *background)
}
cr = cairo_create (surface);
- gdk_cairo_set_source_pixbuf (cr, background->desktop, 0, 0);
- cairo_paint (cr);
-
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if(!gdk_window_check_composited_wm(background->window)){
+#endif
+ gdk_cairo_set_source_pixbuf (cr, background->desktop, 0, 0);
+ cairo_paint (cr);
+#if GTK_CHECK_VERSION(3, 0, 0)
+ }
+#endif
gdk_cairo_set_source_rgba (cr, &background->color);
cairo_paint (cr);
@@ -431,10 +477,7 @@ get_composited_pixbuf (PanelBackground *background)
break;
case PANEL_BACK_IMAGE:
retval = composite_image_onto_desktop (background);
-#if GTK_CHECK_VERSION (3, 0, 0)
- if (!retval && background->transformed_pattern);
- retval = cairo_pattern_reference (background->transformed_pattern);
-#else
+#if !GTK_CHECK_VERSION (3, 0, 0)
if (!retval)
retval = g_object_ref (background->transformed_image);
#endif
@@ -461,33 +504,27 @@ panel_background_composite (PanelBackground *background)
case PANEL_BACK_COLOR:
if (background->has_alpha)
#if GTK_CHECK_VERSION (3, 0, 0)
- background->composited_pattern =
- get_composited_pattern (background);
+ background->composited_pattern =
+ get_composited_pattern (background);
#else
background->composited_image =
get_composited_pixbuf (background);
#endif
break;
case PANEL_BACK_IMAGE:
+ if (background->transformed_image) {
#if GTK_CHECK_VERSION (3, 0, 0)
- if (background->transformed_pattern) {
- if (background->has_alpha)
- background->composited_pattern =
- get_composited_pattern (background);
- else
- background->composited_pattern =
- cairo_pattern_reference (background->transformed_pattern);
- }
+ background->composited_pattern =
+ get_composited_pattern (background);
#else
- if (background->transformed_image) {
if (background->has_alpha)
background->composited_image =
get_composited_pixbuf (background);
else
background->composited_image =
g_object_ref (background->transformed_image);
- }
#endif
+ }
break;
default:
g_assert_not_reached ();
@@ -511,28 +548,14 @@ free_transformed_resources (PanelBackground *background)
if (background->type != PANEL_BACK_IMAGE)
return;
-#if GTK_CHECK_VERSION (3, 0, 0)
- if (background->transformed_pattern)
- cairo_pattern_destroy (background->transformed_pattern);
- background->transformed_pattern = NULL;
-#else
if (background->transformed_image)
g_object_unref (background->transformed_image);
background->transformed_image = NULL;
-#endif
}
-#if GTK_CHECK_VERSION (3, 0, 0)
-static cairo_pattern_t *
-get_scaled_and_rotated_pattern (PanelBackground *background)
-#else
static GdkPixbuf *
get_scaled_and_rotated_pixbuf (PanelBackground *background)
-#endif
{
-#if GTK_CHECK_VERSION (3, 0, 0)
- cairo_pattern_t *pattern;
-#endif
GdkPixbuf *scaled;
GdkPixbuf *retval;
int orig_width, orig_height;
@@ -650,17 +673,7 @@ get_scaled_and_rotated_pixbuf (PanelBackground *background)
} else
retval = scaled;
-#if GTK_CHECK_VERSION (3, 0, 0)
- cairo_t *cr = gdk_cairo_create (background->window ? background->window : gdk_get_default_root_window());
- gdk_cairo_set_source_pixbuf (cr, retval, 0, 0);
- g_object_unref (retval);
- pattern = cairo_pattern_reference (cairo_get_source (cr));
- cairo_destroy (cr);
- cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
- return pattern;
-#else
return retval;
-#endif
}
static gboolean
@@ -672,13 +685,8 @@ panel_background_transform (PanelBackground *background)
free_transformed_resources (background);
if (background->type == PANEL_BACK_IMAGE)
-#if GTK_CHECK_VERSION (3, 0, 0)
- background->transformed_pattern =
- get_scaled_and_rotated_pattern (background);
-#else
background->transformed_image =
get_scaled_and_rotated_pixbuf (background);
-#endif
background->transformed = TRUE;
@@ -1017,11 +1025,11 @@ panel_background_set_default_style (PanelBackground *background,
background->default_pixmap = pixmap;
#endif
-
if (background->type == PANEL_BACK_NONE)
panel_background_prepare (background);
}
+
void
panel_background_realized (PanelBackground *background,
GdkWindow *window)
@@ -1048,7 +1056,12 @@ panel_background_realized (PanelBackground *background,
if (!background->gc)
background->gc = gdk_gc_new (window);
#endif
-
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GtkWidget* widget;
+ gdk_window_get_user_data (GDK_WINDOW (background->window),
+ (gpointer) &widget);
+ panel_background_apply_css(gtk_widget_get_toplevel(widget));
+#endif
panel_background_prepare (background);
}
@@ -1170,11 +1183,10 @@ panel_background_init (PanelBackground *background,
background->region.y = -1;
background->region.width = -1;
background->region.height = -1;
+ background->transformed_image = NULL;
#if GTK_CHECK_VERSION (3, 0, 0)
- background->transformed_pattern = NULL;
background->composited_pattern = NULL;
#else
- background->transformed_image = NULL;
background->composited_image = NULL;
#endif
@@ -1274,13 +1286,15 @@ panel_background_make_string (PanelBackground *background,
effective_type = panel_background_effective_type (background);
if (effective_type == PANEL_BACK_IMAGE ||
- (effective_type == PANEL_BACK_COLOR && background->has_alpha)) {
+ (effective_type == PANEL_BACK_COLOR && background->has_alpha
#if GTK_CHECK_VERSION (3, 0, 0)
+ && (!gdk_window_check_composited_wm(background->window)))) {
cairo_surface_t *surface;
if (!background->composited_pattern)
return NULL;
#else
+ )) {
GdkNativeWindow pixmap_xid;
if (!background->pixmap)
@@ -1526,15 +1540,12 @@ panel_background_change_background_on_widget (PanelBackground *background,
_panel_background_reset_widget_style_properties (widget);
return;
case PANEL_BACK_COLOR:
- if (!background->has_alpha) {
properties = _panel_background_get_widget_style_properties (widget, TRUE);
gtk_style_properties_set (properties, GTK_STATE_FLAG_NORMAL,
"background-color", &background->color,
"background-image", NULL,
NULL);
- break;
- }
- // Color with alpha, fallback to image
+ break;
case PANEL_BACK_IMAGE: {
cairo_pattern_t *pattern;
diff --git a/mate-panel/panel-background.h b/mate-panel/panel-background.h
index fead8648..6c36873b 100644
--- a/mate-panel/panel-background.h
+++ b/mate-panel/panel-background.h
@@ -54,11 +54,10 @@ struct _PanelBackground {
GtkOrientation orientation;
GdkRectangle region;
+ GdkPixbuf *transformed_image;
#if GTK_CHECK_VERSION (3, 0, 0)
- cairo_pattern_t *transformed_pattern;
cairo_pattern_t *composited_pattern;
#else
- GdkPixbuf *transformed_image;
GdkPixbuf *composited_image;
#endif
@@ -162,4 +161,8 @@ PanelBackgroundType
void panel_background_change_background_on_widget (PanelBackground *background,
GtkWidget *widget);
+#if GTK_CHECK_VERSION (3, 0, 0)
+void panel_background_apply_css(GtkWidget* widget);
+#endif
+
#endif /* __PANEL_BACKGROUND_H__ */
diff --git a/mate-panel/panel-menu-bar.c b/mate-panel/panel-menu-bar.c
index 9776fa1f..f05dc894 100644
--- a/mate-panel/panel-menu-bar.c
+++ b/mate-panel/panel-menu-bar.c
@@ -467,7 +467,11 @@ void panel_menu_bar_popup_menu(PanelMenuBar* menubar, guint32 activate_time)
void panel_menu_bar_change_background(PanelMenuBar* menubar)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ panel_background_apply_css(GTK_WIDGET(menubar));
+#else
panel_background_change_background_on_widget(&menubar->priv->panel->background, GTK_WIDGET(menubar));
+#endif
}
static void set_item_text_gravity(GtkWidget* item)
diff --git a/mate-panel/panel-separator.c b/mate-panel/panel-separator.c
index 7cb378fd..022797c6 100644
--- a/mate-panel/panel-separator.c
+++ b/mate-panel/panel-separator.c
@@ -50,23 +50,23 @@ panel_separator_paint (GtkWidget *widget,
#endif
{
PanelSeparator *separator;
- GdkWindow *window;
GtkStyle *style;
#if GTK_CHECK_VERSION (3, 0, 0)
int width;
int height;
#else
+ GdkWindow *window;
GtkAllocation allocation;
#endif
separator = PANEL_SEPARATOR (widget);
- window = gtk_widget_get_window (widget);
style = gtk_widget_get_style (widget);
#if GTK_CHECK_VERSION (3, 0, 0)
width = gtk_widget_get_allocated_width (widget);
height = gtk_widget_get_allocated_height (widget);
#else
+ window = gtk_widget_get_window (widget);
gtk_widget_get_allocation (widget, &allocation);
#endif
@@ -321,6 +321,9 @@ panel_separator_create (PanelToplevel *toplevel,
void
panel_separator_change_background (PanelSeparator *separator)
{
- panel_background_change_background_on_widget (&separator->priv->panel->background,
- GTK_WIDGET (separator));
+#if GTK_CHECK_VERSION (3, 0, 0)
+ panel_background_apply_css(GTK_WIDGET(separator));
+#else
+ panel_background_change_background_on_widget(&separator->priv->panel->background, GTK_WIDGET(separator));
+#endif
}
diff --git a/mate-panel/panel-toplevel.c b/mate-panel/panel-toplevel.c
index 0132d436..9f23d1e9 100644
--- a/mate-panel/panel-toplevel.c
+++ b/mate-panel/panel-toplevel.c
@@ -4940,6 +4940,18 @@ panel_toplevel_set_orientation (PanelToplevel *toplevel,
toplevel->priv->orientation = orientation;
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GtkStyleContext* context = gtk_widget_get_style_context (GTK_WIDGET (toplevel));
+ if (orientation & PANEL_HORIZONTAL_MASK) {
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+ gtk_style_context_remove_class (context, GTK_STYLE_CLASS_VERTICAL);
+ } else {
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_VERTICAL);
+ gtk_style_context_remove_class (context, GTK_STYLE_CLASS_HORIZONTAL);
+ }
+ gtk_widget_reset_style (GTK_WIDGET (toplevel));
+#endif
+
panel_toplevel_update_hide_buttons (toplevel);
panel_widget_set_orientation (
diff --git a/mate-panel/panel-widget.c b/mate-panel/panel-widget.c
index 15d22bdc..2f402da7 100644
--- a/mate-panel/panel-widget.c
+++ b/mate-panel/panel-widget.c
@@ -1662,6 +1662,8 @@ panel_widget_style_set (GtkWidget *widget, GtkStyle *previous_style)
#if GTK_CHECK_VERSION (3, 0, 0)
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
+ gtk_style_context_add_class(context,"gnome-panel-menu-bar");
+ gtk_style_context_add_class(context,"mate-panel-menu-bar");
gtk_style_context_get_background_color (context, state, &bg_color);
gtk_style_context_get (context, state, "background-image", &bg_image, NULL);
@@ -1749,11 +1751,11 @@ panel_widget_realize (GtkWidget *widget)
#if !GTK_CHECK_VERSION (3, 0, 0)
style = gtk_widget_get_style (widget);
state = gtk_widget_get_state (widget);
-#endif
/* For auto-hidden panels with a colored background, we need native
* windows to avoid some uglyness on unhide */
gdk_window_ensure_native (window);
+#endif
#if GTK_CHECK_VERSION (3, 0, 0)
panel_widget_set_background_default_style (widget);