Fix non-transparent color on panel; drop persistent usage on FbBg object.
authorAndriy Grytsenko <andrej@rep.kiev.ua>
Wed, 26 Nov 2014 21:26:45 +0000 (23:26 +0200)
committerAndriy Grytsenko <andrej@rep.kiev.ua>
Wed, 26 Nov 2014 21:26:45 +0000 (23:26 +0200)
We need FbBg object only once per background change so no need to keep it.

TODO
src/main.c
src/panel.c
src/private.h

diff --git a/TODO b/TODO
index beebdef..11c40d7 100644 (file)
--- a/TODO
+++ b/TODO
@@ -10,3 +10,4 @@
 * support rounded corners
 * support keywords in gtk-run
 * convert Task into GtkWidget and use it to emit signals for menus and buttons
+* make click-wait-release popdown popups similarly to as GtkMenuShell does
index 3fa781b..78aea00 100644 (file)
@@ -173,12 +173,7 @@ panel_event_filter(GdkXEvent *xevent, GdkEvent *event, gpointer not_used)
         {
             GSList* l;
             for( l = all_panels; l; l = l->next )
-            {
-                LXPanel* p = (LXPanel*)l->data;
-                if (p->priv->transparent) {
-                    fb_bg_notify_changed_bg(p->priv->bg);
-                }
-            }
+                _panel_queue_update_background((LXPanel*)l->data);
         }
         else if (at == a_NET_WORKAREA)
         {
index 36ba140..9a5c0e4 100644 (file)
@@ -55,7 +55,6 @@ static gulong monitors_handler = 0;
 static void panel_start_gui(LXPanel *p, config_setting_t *list);
 static void ah_start(LXPanel *p);
 static void ah_stop(LXPanel *p);
-static void on_root_bg_changed(FbBg *bg, LXPanel* p);
 static void _panel_update_background(LXPanel * p);
 
 enum
@@ -105,12 +104,6 @@ static void panel_stop_gui(LXPanel *self)
         /* just close the dialog, it will do all required cleanup */
         gtk_dialog_response(GTK_DIALOG(p->plugin_pref_dialog), GTK_RESPONSE_CLOSE);
 
-    if (p->bg != NULL)
-    {
-        g_signal_handlers_disconnect_by_func(G_OBJECT(p->bg), on_root_bg_changed, self);
-        g_object_unref(p->bg);
-        p->bg = NULL;
-    }
 
     if (p->initialized)
     {
@@ -275,16 +268,11 @@ static gboolean lxpanel_configure_event (GtkWidget *widget, GdkEventConfigure *e
 {
     Panel *p = LXPANEL(widget)->priv;
 
-    if (e->width == p->cw && e->height == p->ch && e->x == p->cx && e->y == p->cy)
-        goto ok;
     p->cw = e->width;
     p->ch = e->height;
     p->cx = e->x;
     p->cy = e->y;
 
-    if (p->transparent)
-        fb_bg_notify_changed_bg(p->bg);
-ok:
     return GTK_WIDGET_CLASS(lxpanel_parent_class)->configure_event(widget, e);
 }
 
@@ -607,12 +595,6 @@ void _panel_set_wm_strut(LXPanel *panel)
  ****************************************************/
 
 
-static void
-on_root_bg_changed(FbBg *bg, LXPanel* p)
-{
-    _panel_update_background( p );
-}
-
 void panel_determine_background_pixmap(Panel * panel, GtkWidget * widget, GdkWindow * window)
 {
     _panel_determine_background_pixmap(panel->topgwin, widget);
@@ -642,24 +624,17 @@ void _panel_determine_background_pixmap(LXPanel * panel, GtkWidget * widget)
             /* User specified background pixmap. */
             pixbuf = gdk_pixbuf_new_from_file(p->background_file, NULL);
         }
-        if (p->transparent || (pixbuf != NULL && gdk_pixbuf_get_has_alpha(pixbuf)))
+        if ((p->transparent && p->alpha != 255) || /* ignore it for opaque panel */
+            (pixbuf != NULL && gdk_pixbuf_get_has_alpha(pixbuf)))
         {
-            if (p->bg == NULL)
-            {
-                p->bg = fb_bg_get_for_display();
-                g_signal_connect(G_OBJECT(p->bg), "changed", G_CALLBACK(on_root_bg_changed), panel);
-            }
+            /* we don't need to keep it since we get it once */
+            FbBg *bg = fb_bg_get_for_display();
             /* Transparent.  Determine the appropriate value from the root pixmap. */
-            pixmap = fb_bg_get_xroot_pix_for_win(p->bg, widget);
+            pixmap = fb_bg_get_xroot_pix_for_win(bg, widget);
             gdk_cairo_set_source_pixmap(cr, pixmap, 0, 0);
             cairo_paint(cr);
             g_object_unref(pixmap);
-        }
-        else if (p->bg != NULL)
-        {
-            g_signal_handlers_disconnect_by_func(G_OBJECT(p->bg), on_root_bg_changed, panel);
-            g_object_unref(p->bg);
-            p->bg = NULL;
+            g_object_unref(bg);
         }
         if (pixbuf != NULL)
         {
@@ -676,6 +651,12 @@ void _panel_determine_background_pixmap(LXPanel * panel, GtkWidget * widget)
             y = 0;
             g_object_unref(pixbuf);
         }
+        if (p->transparent)
+        {
+            /* Color is set, fill the background */
+            gdk_cairo_set_source_color(cr, &p->gtintcolor);
+            cairo_paint_with_alpha(cr, (double)p->alpha/255);
+        }
         cairo_destroy(cr);
     }
 
@@ -697,12 +678,6 @@ void _panel_determine_background_pixmap(LXPanel * panel, GtkWidget * widget)
 not_paintable:
         gtk_widget_set_app_paintable(widget, FALSE);
         /* Free p->bg if it is not going to be used. */
-        if (p->bg != NULL)
-        {
-            g_signal_handlers_disconnect_by_func(G_OBJECT(p->bg), on_root_bg_changed, panel);
-            g_object_unref(p->bg);
-            p->bg = NULL;
-        }
     }
 }
 
index 4dd0551..331f1a5 100644 (file)
@@ -76,7 +76,7 @@ struct _Panel {
     GtkWidget *(*my_box_new) (gboolean, gint);
     GtkWidget *(*my_separator_new) ();
 
-    FbBg *bg;
+    FbBg *bg; /* unused since 0.8.0 */
     int alpha;
     guint32 tintcolor;
     guint32 fontcolor;