19
19
#include "PanelTray.h"
21
21
PanelTray::PanelTray ()
23
_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
26
_window = gtk_window_new (GTK_WINDOW_POPUP);
24
27
gtk_window_set_type_hint (GTK_WINDOW (_window), GDK_WINDOW_TYPE_HINT_DOCK);
25
28
gtk_window_set_keep_above (GTK_WINDOW (_window), TRUE);
26
29
gtk_window_set_skip_pager_hint (GTK_WINDOW (_window), TRUE);
27
30
gtk_window_set_skip_taskbar_hint (GTK_WINDOW (_window), TRUE);
28
gtk_window_resize (GTK_WINDOW (_window), 24, 24);
31
gtk_window_resize (GTK_WINDOW (_window), 1, 24);
29
32
gtk_window_move (GTK_WINDOW (_window), 200, 12);
30
33
gtk_widget_set_name (_window, "UnityPanelApplet");
31
34
gtk_widget_set_colormap (_window, gdk_screen_get_rgba_colormap (gdk_screen_get_default ()));
32
35
gtk_widget_realize (_window);
33
36
gdk_window_set_back_pixmap (_window->window, NULL, FALSE);
34
37
gtk_widget_set_app_paintable (_window, TRUE);
36
_tray = na_tray_new_for_screen (gdk_screen_get_default (),
37
GTK_ORIENTATION_HORIZONTAL,
38
(NaTrayFilterCallback)FilterTrayCallback,
41
gtk_container_add (GTK_CONTAINER (_window), GTK_WIDGET (_tray));
42
gtk_widget_show (GTK_WIDGET (_tray));
44
gtk_widget_show_all (_window);
38
g_signal_connect (_window, "expose-event", G_CALLBACK (PanelTray::OnTrayExpose), this);
40
if (!g_getenv ("UNITY_PANEL_TRAY_DISABLE"))
42
_tray = na_tray_new_for_screen (gdk_screen_get_default (),
43
GTK_ORIENTATION_HORIZONTAL,
44
(NaTrayFilterCallback)FilterTrayCallback,
46
g_signal_connect (na_tray_get_manager (_tray), "tray_icon_removed",
47
G_CALLBACK (PanelTray::OnTrayIconRemoved), this);
49
gtk_container_add (GTK_CONTAINER (_window), GTK_WIDGET (_tray));
50
gtk_widget_show (GTK_WIDGET (_tray));
52
gtk_widget_show_all (_window);
47
56
PanelTray::~PanelTray ()
53
PanelTray::FilterTrayCallback (NaTray *tray, NaTrayChild *child, PanelTray *self)
61
PanelTray::Draw (nux::GraphicsEngine& gfx_content, bool force_draw)
63
nux::Geometry geo = GetGeometry ();
65
if (geo.x != _last_x || geo.y != _last_y)
70
gtk_window_move (GTK_WINDOW (_window), geo.x, geo.y + 24);
61
77
return GDK_WINDOW_XWINDOW (_window->window);
83
SetMinMaxSize (_n_children * 24, 24);
84
ComputeChildLayout ();
90
PanelTray::FilterTrayCallback (NaTray *tray, NaTrayChild *icon, PanelTray *self)
92
char *res_name = NULL;
93
char *res_class = NULL;
95
na_tray_child_get_wm_class (icon, &res_name, &res_class);
96
if (na_tray_child_has_alpha (icon))
97
na_tray_child_set_composited (icon, TRUE);
99
g_debug ("TrayChild %s: %s %s", na_tray_child_get_title (icon), res_name, res_class);
106
g_idle_add ((GSourceFunc)IdleSync, self);
111
PanelTray::OnTrayIconRemoved (NaTrayManager *manager, NaTrayChild *child, PanelTray *self)
113
g_idle_add ((GSourceFunc)IdleSync, self);
118
PanelTray::IdleSync (PanelTray *self)
125
PanelTray::OnTrayExpose (GtkWidget *widget, GdkEventExpose *ev, PanelTray *tray)
127
cairo_t *cr = gdk_cairo_create (widget->window);
130
gtk_widget_get_allocation (widget, &alloc);
132
gdk_cairo_region (cr, ev->region);
135
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
138
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
139
cairo_set_source_rgba (cr, 0.0f, 0.0f, 0.0f, 0.0f);
140
cairo_rectangle (cr, 0, 0, alloc.width, alloc.height);
145
gtk_container_propagate_expose (GTK_CONTAINER (widget),
146
gtk_bin_get_child (GTK_BIN (widget)),
65
153
// We don't use these