[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 425/473: Draw transparent background behind resizer widget.
noreply at xfce.org
noreply at xfce.org
Mon Feb 16 23:59:55 CET 2015
This is an automated email from the git hooks/post-receive script.
gottcode pushed a commit to branch master
in repository panel-plugins/xfce4-whiskermenu-plugin.
commit ca387dc5c091d51d00de2a0165d93ee6f14da161
Author: Graeme Gott <graeme at gottcode.org>
Date: Mon Dec 8 14:58:12 2014 -0500
Draw transparent background behind resizer widget.
---
panel-plugin/resizer-widget.cpp | 37 +++++++++++++++++++++++++++++++++++--
panel-plugin/resizer-widget.h | 2 ++
2 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/panel-plugin/resizer-widget.cpp b/panel-plugin/resizer-widget.cpp
index 83d8e3d..ed0417f 100644
--- a/panel-plugin/resizer-widget.cpp
+++ b/panel-plugin/resizer-widget.cpp
@@ -17,6 +17,7 @@
#include "resizer-widget.h"
+#include "settings.h"
#include "slot.h"
using namespace WhiskerMenu;
@@ -26,12 +27,12 @@ using namespace WhiskerMenu;
ResizerWidget::ResizerWidget(GtkWindow* window) :
m_window(window),
m_cursor(NULL),
- m_shape(3)
+ m_shape(3),
+ m_supports_alpha(false)
{
m_alignment = GTK_ALIGNMENT(gtk_alignment_new(1,0,0,0));
m_drawing = gtk_drawing_area_new();
- gtk_widget_set_app_paintable(m_drawing, true);
gtk_widget_set_size_request(m_drawing, 10, 10);
gtk_widget_add_events(m_drawing, GDK_BUTTON_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
gtk_container_add(GTK_CONTAINER(m_alignment), m_drawing);
@@ -40,6 +41,9 @@ ResizerWidget::ResizerWidget(GtkWindow* window) :
g_signal_connect_slot(m_drawing, "enter-notify-event", &ResizerWidget::on_enter_notify_event, this);
g_signal_connect_slot(m_drawing, "leave-notify-event", &ResizerWidget::on_leave_notify_event, this);
g_signal_connect_slot(m_drawing, "expose-event", &ResizerWidget::on_expose_event, this);
+ g_signal_connect_slot(m_window, "screen-changed", &ResizerWidget::on_screen_changed_event, this);
+ on_screen_changed_event(GTK_WIDGET(m_drawing), NULL);
+
set_corner(TopRight);
}
@@ -136,11 +140,40 @@ gboolean ResizerWidget::on_leave_notify_event(GtkWidget* widget, GdkEvent*)
//-----------------------------------------------------------------------------
+void ResizerWidget::on_screen_changed_event(GtkWidget* widget, GdkScreen*)
+{
+ GdkScreen* screen = gtk_widget_get_screen(widget);
+ GdkColormap* colormap = gdk_screen_get_rgba_colormap(screen);
+ if (!colormap)
+ {
+ colormap = gdk_screen_get_system_colormap(screen);
+ m_supports_alpha = false;
+ }
+ else
+ {
+ m_supports_alpha = true;
+ }
+ gtk_widget_set_colormap(widget, colormap);
+}
+
+//-----------------------------------------------------------------------------
+
gboolean ResizerWidget::on_expose_event(GtkWidget* widget, GdkEvent*)
{
cairo_t* cr = gdk_cairo_create(gtk_widget_get_window(widget));
GtkStyle* style = gtk_widget_get_style(widget);
+
+ // Draw semi-transparent background to match window
+ if (m_supports_alpha)
+ {
+ const GdkColor& color = style->bg[GTK_STATE_NORMAL];
+ cairo_set_source_rgba(cr, color.red / 65535.0, color.green / 65535.0, color.blue / 65535.0, wm_settings->menu_opacity / 100.0);
+ cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
+ cairo_paint(cr);
+ }
+
+ // Draw resize triangle
const GdkColor& color = style->text_aa[gtk_widget_get_state(widget)];
cairo_set_source_rgb(cr, color.red / 65535.0, color.green / 65535.0, color.blue / 65535.0);
diff --git a/panel-plugin/resizer-widget.h b/panel-plugin/resizer-widget.h
index 4422700..d281aba 100644
--- a/panel-plugin/resizer-widget.h
+++ b/panel-plugin/resizer-widget.h
@@ -49,6 +49,7 @@ private:
gboolean on_button_press_event(GtkWidget*, GdkEvent* event);
gboolean on_enter_notify_event(GtkWidget* widget, GdkEvent*);
gboolean on_leave_notify_event(GtkWidget* widget, GdkEvent*);
+ void on_screen_changed_event(GtkWidget* widget, GdkScreen* old_screen);
gboolean on_expose_event(GtkWidget* widget, GdkEvent*);
private:
@@ -58,6 +59,7 @@ private:
GdkCursor* m_cursor;
GdkWindowEdge m_edge;
std::vector<GdkPoint> m_shape;
+ bool m_supports_alpha;
};
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list