[gnome-panel] background: remove fake transparency
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] background: remove fake transparency
- Date: Thu, 6 Oct 2016 22:20:01 +0000 (UTC)
commit 78cfb7e3ca82d6118065f4b2490906242f9965ff
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Thu Oct 6 19:37:42 2016 +0300
background: remove fake transparency
gnome-panel/Makefile.am | 2 -
gnome-panel/panel-background-monitor.c | 388 --------------------------------
gnome-panel/panel-background-monitor.h | 58 -----
gnome-panel/panel-background.c | 124 ++---------
gnome-panel/panel-background.h | 5 -
5 files changed, 19 insertions(+), 558 deletions(-)
---
diff --git a/gnome-panel/Makefile.am b/gnome-panel/Makefile.am
index 68528f9..6debf16 100644
--- a/gnome-panel/Makefile.am
+++ b/gnome-panel/Makefile.am
@@ -33,7 +33,6 @@ panel_sources = \
panel-applet-frame.c \
panel-applets-manager.c \
panel-background.c \
- panel-background-monitor.c \
panel-stock-icons.c \
panel-action-button.c \
panel-image-menu-item.c \
@@ -81,7 +80,6 @@ panel_headers = \
panel-applet-frame.h \
panel-applets-manager.h \
panel-background.h \
- panel-background-monitor.h \
panel-stock-icons.h \
panel-action-button.h \
panel-image-menu-item.h \
diff --git a/gnome-panel/panel-background.c b/gnome-panel/panel-background.c
index 3ad300b..5b16f91 100644
--- a/gnome-panel/panel-background.c
+++ b/gnome-panel/panel-background.c
@@ -32,7 +32,6 @@
#include <libpanel-util/panel-glib.h>
-#include "panel-background-monitor.h"
#include "panel-schemas.h"
#include "panel-util.h"
@@ -118,70 +117,17 @@ free_composited_resources (PanelBackground *background)
background->composited_pattern = NULL;
}
-static void
-background_changed (PanelBackgroundMonitor *monitor,
- PanelBackground *background)
-{
- GdkPixbuf *tmp;
-
- tmp = background->desktop;
-
- background->desktop = panel_background_monitor_get_region (
- background->monitor,
- background->region.x,
- background->region.y,
- background->region.width,
- background->region.height);
-
- if (tmp)
- g_object_unref (tmp);
-
- panel_background_composite (background);
-}
-
-// FIXMEchpe make this a cairo_pattern_t*
-static GdkPixbuf *
-get_desktop_pixbuf (PanelBackground *background)
-{
- GdkPixbuf *desktop;
-
- if (!background->monitor) {
- background->monitor =
- panel_background_monitor_get_for_screen (
- gdk_window_get_screen (background->window));
-
- background->monitor_signal =
- g_signal_connect (
- background->monitor, "changed",
- G_CALLBACK (background_changed), background);
- }
-
- desktop = panel_background_monitor_get_region (
- background->monitor,
- background->region.x,
- background->region.y,
- background->region.width,
- background->region.height);
-
- return desktop;
-}
-
static cairo_pattern_t *
composite_image_onto_desktop (PanelBackground *background)
{
int width, height;
+ GdkScreen *screen;
cairo_t *cr;
cairo_surface_t *surface;
cairo_pattern_t *pattern;
- if (!background->desktop)
- background->desktop = get_desktop_pixbuf (background);
-
- if (!background->desktop)
- return NULL;
-
- width = gdk_pixbuf_get_width (background->desktop);
- height = gdk_pixbuf_get_height (background->desktop);
+ width = background->region.width;
+ height = background->region.height;
surface = gdk_window_create_similar_surface (background->window,
CAIRO_CONTENT_COLOR_ALPHA,
@@ -193,13 +139,12 @@ composite_image_onto_desktop (PanelBackground *background)
cr = cairo_create (surface);
- if (background->has_alpha) {
- cairo_set_source_rgb (cr, 1, 1, 1);
- cairo_paint (cr);
+ screen = gdk_screen_get_default ();
+ if (background->has_alpha && !gdk_screen_is_composited (screen)) {
+ GdkRGBA c = background->default_color;
- gdk_cairo_set_source_pixbuf (cr, background->desktop, 0, 0);
- cairo_rectangle (cr, 0, 0, width, height);
- cairo_fill (cr);
+ cairo_set_source_rgb (cr, c.red, c.green, c.blue);
+ cairo_paint (cr);
}
gdk_cairo_set_source_pixbuf (cr, background->transformed_image, 0, 0);
@@ -218,15 +163,11 @@ composite_image_onto_desktop (PanelBackground *background)
static cairo_pattern_t *
composite_color_onto_desktop (PanelBackground *background)
{
+ GdkScreen *screen;
cairo_surface_t *surface;
cairo_pattern_t *pattern;
cairo_t *cr;
- if (!background->desktop)
- background->desktop = get_desktop_pixbuf (background);
- if (!background->desktop)
- return NULL;
-
surface = gdk_window_create_similar_surface (background->window,
CAIRO_CONTENT_COLOR_ALPHA,
background->region.width,
@@ -237,11 +178,17 @@ composite_color_onto_desktop (PanelBackground *background)
}
cr = cairo_create (surface);
- gdk_cairo_set_source_pixbuf (cr, background->desktop, 0, 0);
- cairo_paint (cr);
- gdk_cairo_set_source_rgba (cr, &background->color);
- cairo_paint (cr);
+ screen = gdk_screen_get_default ();
+ if (!gdk_screen_is_composited (screen)) {
+ GdkRGBA c = background->color;
+
+ cairo_set_source_rgb (cr, c.red, c.green, c.blue);
+ cairo_paint (cr);
+ } else {
+ gdk_cairo_set_source_rgba (cr, &background->color);
+ cairo_paint (cr);
+ }
cairo_destroy (cr);
@@ -473,22 +420,6 @@ panel_background_transform (PanelBackground *background)
}
static void
-disconnect_background_monitor (PanelBackground *background)
-{
- if (background->monitor) {
- g_signal_handler_disconnect (
- background->monitor, background->monitor_signal);
- background->monitor_signal = -1;
- g_object_unref (background->monitor);
- }
- background->monitor = NULL;
-
- if (background->desktop)
- g_object_unref (background->desktop);
- background->desktop = NULL;
-}
-
-static void
panel_background_update_has_alpha (PanelBackground *background)
{
gboolean has_alpha = FALSE;
@@ -500,9 +431,6 @@ panel_background_update_has_alpha (PanelBackground *background)
has_alpha = gdk_pixbuf_get_has_alpha (background->loaded_image);
background->has_alpha = has_alpha;
-
- if (!has_alpha)
- disconnect_background_monitor (background);
}
static void
@@ -829,10 +757,6 @@ panel_background_change_region (PanelBackground *background,
background->orientation = orientation;
- if (background->desktop)
- g_object_unref (background->desktop);
- background->desktop = NULL;
-
if (need_to_retransform || ! background->transformed)
/* only retransform the background if we have in
fact changed size/orientation */
@@ -874,10 +798,6 @@ panel_background_init (PanelBackground *background,
background->transformed_image = NULL;
background->composited_pattern = NULL;
- background->monitor = NULL;
- background->desktop = NULL;
- background->monitor_signal = -1;
-
background->window = NULL;
background->default_pattern = NULL;
@@ -898,8 +818,6 @@ panel_background_init (PanelBackground *background,
void
panel_background_free (PanelBackground *background)
{
- disconnect_background_monitor (background);
-
free_transformed_resources (background);
if (background->settings)
@@ -914,10 +832,6 @@ panel_background_free (PanelBackground *background)
g_object_unref (background->loaded_image);
background->loaded_image = NULL;
- if (background->monitor)
- g_object_unref (background->monitor);
- background->monitor = NULL;
-
if (background->window)
g_object_unref (background->window);
background->window = NULL;
diff --git a/gnome-panel/panel-background.h b/gnome-panel/panel-background.h
index b09e73f..48f94d9 100644
--- a/gnome-panel/panel-background.h
+++ b/gnome-panel/panel-background.h
@@ -28,7 +28,6 @@
#include "panel-enums.h"
#include "panel-types.h"
-#include "panel-background-monitor.h"
typedef struct _PanelBackground PanelBackground;
@@ -53,10 +52,6 @@ struct _PanelBackground {
GdkPixbuf *transformed_image;
cairo_pattern_t *composited_pattern;
- PanelBackgroundMonitor *monitor;
- GdkPixbuf *desktop;
- gulong monitor_signal;
-
GdkWindow *window;
cairo_pattern_t *default_pattern;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]