|
|
090c1a5 |
--- ekiga-2.0.3/lib/gui/gmtray/eggtrayicon.h.transparent 2006-09-30 00:33:32.000000000 -0400
|
|
|
090c1a5 |
+++ ekiga-2.0.3/lib/gui/gmtray/eggtrayicon.h 2006-09-30 00:33:49.000000000 -0400
|
|
|
090c1a5 |
@@ -22,7 +22,9 @@
|
|
|
090c1a5 |
#define __EGG_TRAY_ICON_H__
|
|
|
090c1a5 |
|
|
|
090c1a5 |
#include <gtk/gtkplug.h>
|
|
|
090c1a5 |
+#ifdef GDK_WINDOWING_X11
|
|
|
090c1a5 |
#include <gdk/gdkx.h>
|
|
|
090c1a5 |
+#endif
|
|
|
090c1a5 |
|
|
|
090c1a5 |
G_BEGIN_DECLS
|
|
|
090c1a5 |
|
|
|
090c1a5 |
@@ -42,10 +44,14 @@
|
|
|
090c1a5 |
|
|
|
090c1a5 |
guint stamp;
|
|
|
090c1a5 |
|
|
|
090c1a5 |
+#ifdef GDK_WINDOWING_X11
|
|
|
090c1a5 |
Atom selection_atom;
|
|
|
090c1a5 |
Atom manager_atom;
|
|
|
090c1a5 |
Atom system_tray_opcode_atom;
|
|
|
090c1a5 |
+ Atom orientation_atom;
|
|
|
090c1a5 |
Window manager_window;
|
|
|
090c1a5 |
+#endif
|
|
|
090c1a5 |
+ GtkOrientation orientation;
|
|
|
090c1a5 |
};
|
|
|
090c1a5 |
|
|
|
090c1a5 |
struct _EggTrayIconClass
|
|
|
090c1a5 |
@@ -55,10 +61,8 @@
|
|
|
090c1a5 |
|
|
|
090c1a5 |
GType egg_tray_icon_get_type (void);
|
|
|
090c1a5 |
|
|
|
090c1a5 |
-#if EGG_TRAY_ENABLE_MULTIHEAD
|
|
|
090c1a5 |
EggTrayIcon *egg_tray_icon_new_for_screen (GdkScreen *screen,
|
|
|
090c1a5 |
const gchar *name);
|
|
|
090c1a5 |
-#endif
|
|
|
090c1a5 |
|
|
|
090c1a5 |
EggTrayIcon *egg_tray_icon_new (const gchar *name);
|
|
|
090c1a5 |
|
|
|
090c1a5 |
@@ -69,7 +73,7 @@
|
|
|
090c1a5 |
void egg_tray_icon_cancel_message (EggTrayIcon *icon,
|
|
|
090c1a5 |
guint id);
|
|
|
090c1a5 |
|
|
|
090c1a5 |
-
|
|
|
090c1a5 |
+GtkOrientation egg_tray_icon_get_orientation (EggTrayIcon *icon);
|
|
|
090c1a5 |
|
|
|
090c1a5 |
G_END_DECLS
|
|
|
090c1a5 |
|
|
|
090c1a5 |
--- ekiga-2.0.3/lib/gui/gmtray/eggtrayicon.c.transparent 2006-09-30 00:33:26.000000000 -0400
|
|
|
090c1a5 |
+++ ekiga-2.0.3/lib/gui/gmtray/eggtrayicon.c 2006-09-30 00:34:05.000000000 -0400
|
|
|
090c1a5 |
@@ -18,22 +18,56 @@
|
|
|
090c1a5 |
* Boston, MA 02111-1307, USA.
|
|
|
090c1a5 |
*/
|
|
|
090c1a5 |
|
|
|
090c1a5 |
+#include <config.h>
|
|
|
090c1a5 |
#include <string.h>
|
|
|
090c1a5 |
-#ifndef WIN32
|
|
|
090c1a5 |
+#include <libintl.h>
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+#include "eggtrayicon.h"
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+#include <gdkconfig.h>
|
|
|
090c1a5 |
+#if defined (GDK_WINDOWING_X11)
|
|
|
090c1a5 |
#include <gdk/gdkx.h>
|
|
|
090c1a5 |
+#include <X11/Xatom.h>
|
|
|
090c1a5 |
+#elif defined (GDK_WINDOWING_WIN32)
|
|
|
090c1a5 |
+#include <gdk/gdkwin32.h>
|
|
|
090c1a5 |
#endif
|
|
|
090c1a5 |
-#include "eggtrayicon.h"
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+#define _(x) x
|
|
|
090c1a5 |
+#define N_(x) x
|
|
|
090c1a5 |
|
|
|
090c1a5 |
#define SYSTEM_TRAY_REQUEST_DOCK 0
|
|
|
090c1a5 |
#define SYSTEM_TRAY_BEGIN_MESSAGE 1
|
|
|
090c1a5 |
#define SYSTEM_TRAY_CANCEL_MESSAGE 2
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+#define SYSTEM_TRAY_ORIENTATION_HORZ 0
|
|
|
090c1a5 |
+#define SYSTEM_TRAY_ORIENTATION_VERT 1
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+enum {
|
|
|
090c1a5 |
+ PROP_0,
|
|
|
090c1a5 |
+ PROP_ORIENTATION
|
|
|
090c1a5 |
+};
|
|
|
090c1a5 |
|
|
|
090c1a5 |
static GtkPlugClass *parent_class = NULL;
|
|
|
090c1a5 |
|
|
|
090c1a5 |
static void egg_tray_icon_init (EggTrayIcon *icon);
|
|
|
090c1a5 |
static void egg_tray_icon_class_init (EggTrayIconClass *klass);
|
|
|
090c1a5 |
|
|
|
090c1a5 |
-static void egg_tray_icon_update_manager_window (EggTrayIcon *icon);
|
|
|
090c1a5 |
+static void egg_tray_icon_get_property (GObject *object,
|
|
|
090c1a5 |
+ guint prop_id,
|
|
|
090c1a5 |
+ GValue *value,
|
|
|
090c1a5 |
+ GParamSpec *pspec);
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+static void egg_tray_icon_realize (GtkWidget *widget);
|
|
|
090c1a5 |
+static void egg_tray_icon_unrealize (GtkWidget *widget);
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+static void egg_tray_icon_add (GtkContainer *container,
|
|
|
090c1a5 |
+ GtkWidget *widget);
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+#ifdef GDK_WINDOWING_X11
|
|
|
090c1a5 |
+static void egg_tray_icon_update_manager_window (EggTrayIcon *icon,
|
|
|
090c1a5 |
+ gboolean dock_if_realized);
|
|
|
090c1a5 |
+static void egg_tray_icon_manager_window_destroyed (EggTrayIcon *icon);
|
|
|
090c1a5 |
+#endif
|
|
|
090c1a5 |
|
|
|
090c1a5 |
GType
|
|
|
090c1a5 |
egg_tray_icon_get_type (void)
|
|
|
090c1a5 |
@@ -65,6 +99,7 @@
|
|
|
090c1a5 |
egg_tray_icon_init (EggTrayIcon *icon)
|
|
|
090c1a5 |
{
|
|
|
090c1a5 |
icon->stamp = 1;
|
|
|
090c1a5 |
+ icon->orientation = GTK_ORIENTATION_HORIZONTAL;
|
|
|
090c1a5 |
|
|
|
090c1a5 |
gtk_widget_add_events (GTK_WIDGET (icon), GDK_PROPERTY_CHANGE_MASK);
|
|
|
090c1a5 |
}
|
|
|
090c1a5 |
@@ -72,7 +107,108 @@
|
|
|
090c1a5 |
static void
|
|
|
090c1a5 |
egg_tray_icon_class_init (EggTrayIconClass *klass)
|
|
|
090c1a5 |
{
|
|
|
090c1a5 |
+ GObjectClass *gobject_class = (GObjectClass *)klass;
|
|
|
090c1a5 |
+ GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;
|
|
|
090c1a5 |
+ GtkContainerClass *container_class = (GtkContainerClass *)klass;
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
parent_class = g_type_class_peek_parent (klass);
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ gobject_class->get_property = egg_tray_icon_get_property;
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ widget_class->realize = egg_tray_icon_realize;
|
|
|
090c1a5 |
+ widget_class->unrealize = egg_tray_icon_unrealize;
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ container_class->add = egg_tray_icon_add;
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ g_object_class_install_property (gobject_class,
|
|
|
090c1a5 |
+ PROP_ORIENTATION,
|
|
|
090c1a5 |
+ g_param_spec_enum ("orientation",
|
|
|
090c1a5 |
+ _("Orientation"),
|
|
|
090c1a5 |
+ _("The orientation of the tray."),
|
|
|
090c1a5 |
+ GTK_TYPE_ORIENTATION,
|
|
|
090c1a5 |
+ GTK_ORIENTATION_HORIZONTAL,
|
|
|
090c1a5 |
+ G_PARAM_READABLE));
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+#if defined (GDK_WINDOWING_X11)
|
|
|
090c1a5 |
+ /* Nothing */
|
|
|
090c1a5 |
+#elif defined (GDK_WINDOWING_WIN32)
|
|
|
090c1a5 |
+ g_warning ("Port eggtrayicon to Win32");
|
|
|
090c1a5 |
+#else
|
|
|
090c1a5 |
+ g_warning ("Port eggtrayicon to this GTK+ backend");
|
|
|
090c1a5 |
+#endif
|
|
|
090c1a5 |
+}
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+static void
|
|
|
090c1a5 |
+egg_tray_icon_get_property (GObject *object,
|
|
|
090c1a5 |
+ guint prop_id,
|
|
|
090c1a5 |
+ GValue *value,
|
|
|
090c1a5 |
+ GParamSpec *pspec)
|
|
|
090c1a5 |
+{
|
|
|
090c1a5 |
+ EggTrayIcon *icon = EGG_TRAY_ICON (object);
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ switch (prop_id)
|
|
|
090c1a5 |
+ {
|
|
|
090c1a5 |
+ case PROP_ORIENTATION:
|
|
|
090c1a5 |
+ g_value_set_enum (value, icon->orientation);
|
|
|
090c1a5 |
+ break;
|
|
|
090c1a5 |
+ default:
|
|
|
090c1a5 |
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
090c1a5 |
+ break;
|
|
|
090c1a5 |
+ }
|
|
|
090c1a5 |
+}
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+#ifdef GDK_WINDOWING_X11
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+static void
|
|
|
090c1a5 |
+egg_tray_icon_get_orientation_property (EggTrayIcon *icon)
|
|
|
090c1a5 |
+{
|
|
|
090c1a5 |
+ Display *xdisplay;
|
|
|
090c1a5 |
+ Atom type;
|
|
|
090c1a5 |
+ int format;
|
|
|
090c1a5 |
+ union {
|
|
|
090c1a5 |
+ gulong *prop;
|
|
|
090c1a5 |
+ guchar *prop_ch;
|
|
|
090c1a5 |
+ } prop = { NULL };
|
|
|
090c1a5 |
+ gulong nitems;
|
|
|
090c1a5 |
+ gulong bytes_after;
|
|
|
090c1a5 |
+ int error, result;
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ g_assert (icon->manager_window != None);
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ gdk_error_trap_push ();
|
|
|
090c1a5 |
+ type = None;
|
|
|
090c1a5 |
+ result = XGetWindowProperty (xdisplay,
|
|
|
090c1a5 |
+ icon->manager_window,
|
|
|
090c1a5 |
+ icon->orientation_atom,
|
|
|
090c1a5 |
+ 0, G_MAXLONG, FALSE,
|
|
|
090c1a5 |
+ XA_CARDINAL,
|
|
|
090c1a5 |
+ &type, &format, &nitems,
|
|
|
090c1a5 |
+ &bytes_after, &(prop.prop_ch));
|
|
|
090c1a5 |
+ error = gdk_error_trap_pop ();
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ if (error || result != Success)
|
|
|
090c1a5 |
+ return;
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ if (type == XA_CARDINAL)
|
|
|
090c1a5 |
+ {
|
|
|
090c1a5 |
+ GtkOrientation orientation;
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ orientation = (prop.prop [0] == SYSTEM_TRAY_ORIENTATION_HORZ) ?
|
|
|
090c1a5 |
+ GTK_ORIENTATION_HORIZONTAL :
|
|
|
090c1a5 |
+ GTK_ORIENTATION_VERTICAL;
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ if (icon->orientation != orientation)
|
|
|
090c1a5 |
+ {
|
|
|
090c1a5 |
+ icon->orientation = orientation;
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ g_object_notify (G_OBJECT (icon), "orientation");
|
|
|
090c1a5 |
+ }
|
|
|
090c1a5 |
+ }
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ if (prop.prop)
|
|
|
090c1a5 |
+ XFree (prop.prop);
|
|
|
090c1a5 |
}
|
|
|
090c1a5 |
|
|
|
090c1a5 |
static GdkFilterReturn
|
|
|
090c1a5 |
@@ -85,19 +221,53 @@
|
|
|
090c1a5 |
xev->xclient.message_type == icon->manager_atom &&
|
|
|
090c1a5 |
xev->xclient.data.l[1] == icon->selection_atom)
|
|
|
090c1a5 |
{
|
|
|
090c1a5 |
- egg_tray_icon_update_manager_window (icon);
|
|
|
090c1a5 |
+ egg_tray_icon_update_manager_window (icon, TRUE);
|
|
|
090c1a5 |
}
|
|
|
090c1a5 |
else if (xev->xany.window == icon->manager_window)
|
|
|
090c1a5 |
{
|
|
|
090c1a5 |
+ if (xev->xany.type == PropertyNotify &&
|
|
|
090c1a5 |
+ xev->xproperty.atom == icon->orientation_atom)
|
|
|
090c1a5 |
+ {
|
|
|
090c1a5 |
+ egg_tray_icon_get_orientation_property (icon);
|
|
|
090c1a5 |
+ }
|
|
|
090c1a5 |
if (xev->xany.type == DestroyNotify)
|
|
|
090c1a5 |
{
|
|
|
090c1a5 |
- egg_tray_icon_update_manager_window (icon);
|
|
|
090c1a5 |
+ egg_tray_icon_manager_window_destroyed (icon);
|
|
|
090c1a5 |
}
|
|
|
090c1a5 |
}
|
|
|
090c1a5 |
-
|
|
|
090c1a5 |
return GDK_FILTER_CONTINUE;
|
|
|
090c1a5 |
}
|
|
|
090c1a5 |
|
|
|
090c1a5 |
+#endif
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+static void
|
|
|
090c1a5 |
+egg_tray_icon_unrealize (GtkWidget *widget)
|
|
|
090c1a5 |
+{
|
|
|
090c1a5 |
+#ifdef GDK_WINDOWING_X11
|
|
|
090c1a5 |
+ EggTrayIcon *icon = EGG_TRAY_ICON (widget);
|
|
|
090c1a5 |
+ GdkWindow *root_window;
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ if (icon->manager_window != None)
|
|
|
090c1a5 |
+ {
|
|
|
090c1a5 |
+ GdkWindow *gdkwin;
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (widget),
|
|
|
090c1a5 |
+ icon->manager_window);
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
|
|
|
090c1a5 |
+ }
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget));
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ gdk_window_remove_filter (root_window, egg_tray_icon_manager_filter, icon);
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ if (GTK_WIDGET_CLASS (parent_class)->unrealize)
|
|
|
090c1a5 |
+ (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
|
|
|
090c1a5 |
+#endif
|
|
|
090c1a5 |
+}
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+#ifdef GDK_WINDOWING_X11
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
static void
|
|
|
090c1a5 |
egg_tray_icon_send_manager_message (EggTrayIcon *icon,
|
|
|
090c1a5 |
long message,
|
|
|
090c1a5 |
@@ -119,11 +289,7 @@
|
|
|
090c1a5 |
ev.data.l[3] = data2;
|
|
|
090c1a5 |
ev.data.l[4] = data3;
|
|
|
090c1a5 |
|
|
|
090c1a5 |
-#if HAVE_GTK_MULTIHEAD
|
|
|
090c1a5 |
display = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
|
|
|
090c1a5 |
-#else
|
|
|
090c1a5 |
- display = gdk_display;
|
|
|
090c1a5 |
-#endif
|
|
|
090c1a5 |
|
|
|
090c1a5 |
gdk_error_trap_push ();
|
|
|
090c1a5 |
XSendEvent (display,
|
|
|
090c1a5 |
@@ -143,29 +309,15 @@
|
|
|
090c1a5 |
}
|
|
|
090c1a5 |
|
|
|
090c1a5 |
static void
|
|
|
090c1a5 |
-egg_tray_icon_update_manager_window (EggTrayIcon *icon)
|
|
|
090c1a5 |
+egg_tray_icon_update_manager_window (EggTrayIcon *icon,
|
|
|
090c1a5 |
+ gboolean dock_if_realized)
|
|
|
090c1a5 |
{
|
|
|
090c1a5 |
Display *xdisplay;
|
|
|
090c1a5 |
|
|
|
090c1a5 |
-#if HAVE_GTK_MULTIHEAD
|
|
|
090c1a5 |
- xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
|
|
|
090c1a5 |
-#else
|
|
|
090c1a5 |
- xdisplay = gdk_display;
|
|
|
090c1a5 |
-#endif
|
|
|
090c1a5 |
-
|
|
|
090c1a5 |
if (icon->manager_window != None)
|
|
|
090c1a5 |
- {
|
|
|
090c1a5 |
- GdkWindow *gdkwin;
|
|
|
090c1a5 |
+ return;
|
|
|
090c1a5 |
|
|
|
090c1a5 |
-#if HAVE_GTK_MULTIHEAD
|
|
|
090c1a5 |
- gdkwin = gdk_window_lookup_for_display (display,
|
|
|
090c1a5 |
- icon->manager_window);
|
|
|
090c1a5 |
-#else
|
|
|
090c1a5 |
- gdkwin = gdk_window_lookup (icon->manager_window);
|
|
|
090c1a5 |
-#endif
|
|
|
090c1a5 |
-
|
|
|
090c1a5 |
- gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
|
|
|
090c1a5 |
- }
|
|
|
090c1a5 |
+ xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
|
|
|
090c1a5 |
|
|
|
090c1a5 |
XGrabServer (xdisplay);
|
|
|
090c1a5 |
|
|
|
090c1a5 |
@@ -174,7 +326,7 @@
|
|
|
090c1a5 |
|
|
|
090c1a5 |
if (icon->manager_window != None)
|
|
|
090c1a5 |
XSelectInput (xdisplay,
|
|
|
090c1a5 |
- icon->manager_window, StructureNotifyMask);
|
|
|
090c1a5 |
+ icon->manager_window, StructureNotifyMask|PropertyChangeMask);
|
|
|
090c1a5 |
|
|
|
090c1a5 |
XUngrabServer (xdisplay);
|
|
|
090c1a5 |
XFlush (xdisplay);
|
|
|
090c1a5 |
@@ -183,87 +335,135 @@
|
|
|
090c1a5 |
{
|
|
|
090c1a5 |
GdkWindow *gdkwin;
|
|
|
090c1a5 |
|
|
|
090c1a5 |
-#if HAVE_GTK_MULTIHEAD
|
|
|
090c1a5 |
gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
|
|
|
090c1a5 |
icon->manager_window);
|
|
|
090c1a5 |
-#else
|
|
|
090c1a5 |
- gdkwin = gdk_window_lookup (icon->manager_window);
|
|
|
090c1a5 |
-#endif
|
|
|
090c1a5 |
|
|
|
090c1a5 |
gdk_window_add_filter (gdkwin, egg_tray_icon_manager_filter, icon);
|
|
|
090c1a5 |
|
|
|
090c1a5 |
- /* Send a request that we'd like to dock */
|
|
|
090c1a5 |
- egg_tray_icon_send_dock_request (icon);
|
|
|
090c1a5 |
+ if (dock_if_realized && GTK_WIDGET_REALIZED (icon))
|
|
|
090c1a5 |
+ egg_tray_icon_send_dock_request (icon);
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ egg_tray_icon_get_orientation_property (icon);
|
|
|
090c1a5 |
}
|
|
|
090c1a5 |
}
|
|
|
090c1a5 |
|
|
|
090c1a5 |
-EggTrayIcon *
|
|
|
090c1a5 |
-egg_tray_icon_new_for_xscreen (Screen *xscreen, const char *name)
|
|
|
090c1a5 |
+static void
|
|
|
090c1a5 |
+egg_tray_icon_manager_window_destroyed (EggTrayIcon *icon)
|
|
|
090c1a5 |
{
|
|
|
090c1a5 |
- EggTrayIcon *icon;
|
|
|
090c1a5 |
+ GdkWindow *gdkwin;
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ g_return_if_fail (icon->manager_window != None);
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
|
|
|
090c1a5 |
+ icon->manager_window);
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ icon->manager_window = None;
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ egg_tray_icon_update_manager_window (icon, TRUE);
|
|
|
090c1a5 |
+}
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+#endif
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+static gboolean
|
|
|
090c1a5 |
+transparent_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
|
|
|
090c1a5 |
+{
|
|
|
090c1a5 |
+ gdk_window_clear_area (widget->window, event->area.x, event->area.y,
|
|
|
090c1a5 |
+ event->area.width, event->area.height);
|
|
|
090c1a5 |
+ return FALSE;
|
|
|
090c1a5 |
+}
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+static void
|
|
|
090c1a5 |
+make_transparent_again (GtkWidget *widget, GtkStyle *previous_style,
|
|
|
090c1a5 |
+ gpointer user_data)
|
|
|
090c1a5 |
+{
|
|
|
090c1a5 |
+ gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
|
|
|
090c1a5 |
+}
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+static void
|
|
|
090c1a5 |
+make_transparent (GtkWidget *widget, gpointer user_data)
|
|
|
090c1a5 |
+{
|
|
|
090c1a5 |
+ if (GTK_WIDGET_NO_WINDOW (widget) || GTK_WIDGET_APP_PAINTABLE (widget))
|
|
|
090c1a5 |
+ return;
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ gtk_widget_set_app_paintable (widget, TRUE);
|
|
|
090c1a5 |
+ gtk_widget_set_double_buffered (widget, FALSE);
|
|
|
090c1a5 |
+ gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
|
|
|
090c1a5 |
+ g_signal_connect (widget, "expose_event",
|
|
|
090c1a5 |
+ G_CALLBACK (transparent_expose_event), NULL);
|
|
|
090c1a5 |
+ g_signal_connect_after (widget, "style_set",
|
|
|
090c1a5 |
+ G_CALLBACK (make_transparent_again), NULL);
|
|
|
090c1a5 |
+}
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+static void
|
|
|
090c1a5 |
+egg_tray_icon_realize (GtkWidget *widget)
|
|
|
090c1a5 |
+{
|
|
|
090c1a5 |
+#ifdef GDK_WINDOWING_X11
|
|
|
090c1a5 |
+ EggTrayIcon *icon = EGG_TRAY_ICON (widget);
|
|
|
090c1a5 |
+ GdkScreen *screen;
|
|
|
090c1a5 |
+ GdkDisplay *display;
|
|
|
090c1a5 |
+ Display *xdisplay;
|
|
|
090c1a5 |
char buffer[256];
|
|
|
090c1a5 |
GdkWindow *root_window;
|
|
|
090c1a5 |
|
|
|
090c1a5 |
- g_return_val_if_fail (xscreen != NULL, NULL);
|
|
|
090c1a5 |
-
|
|
|
090c1a5 |
- icon = g_object_new (EGG_TYPE_TRAY_ICON, NULL);
|
|
|
090c1a5 |
- gtk_window_set_title (GTK_WINDOW (icon), name);
|
|
|
090c1a5 |
+ if (GTK_WIDGET_CLASS (parent_class)->realize)
|
|
|
090c1a5 |
+ GTK_WIDGET_CLASS (parent_class)->realize (widget);
|
|
|
090c1a5 |
|
|
|
090c1a5 |
-#if HAVE_GTK_MULTIHEAD
|
|
|
090c1a5 |
- gtk_plug_construct_for_display (GTK_PLUG (icon),
|
|
|
090c1a5 |
- gdk_screen_get_display (screen), 0);
|
|
|
090c1a5 |
-#else
|
|
|
090c1a5 |
- gtk_plug_construct (GTK_PLUG (icon), 0);
|
|
|
090c1a5 |
-#endif
|
|
|
090c1a5 |
-
|
|
|
090c1a5 |
- gtk_widget_realize (GTK_WIDGET (icon));
|
|
|
090c1a5 |
+ make_transparent (widget, NULL);
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ screen = gtk_widget_get_screen (widget);
|
|
|
090c1a5 |
+ display = gdk_screen_get_display (screen);
|
|
|
090c1a5 |
+ xdisplay = gdk_x11_display_get_xdisplay (display);
|
|
|
090c1a5 |
|
|
|
090c1a5 |
/* Now see if there's a manager window around */
|
|
|
090c1a5 |
g_snprintf (buffer, sizeof (buffer),
|
|
|
090c1a5 |
"_NET_SYSTEM_TRAY_S%d",
|
|
|
090c1a5 |
- XScreenNumberOfScreen (xscreen));
|
|
|
090c1a5 |
-
|
|
|
090c1a5 |
- icon->selection_atom = XInternAtom (DisplayOfScreen (xscreen),
|
|
|
090c1a5 |
- buffer, False);
|
|
|
090c1a5 |
+ gdk_screen_get_number (screen));
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ icon->selection_atom = XInternAtom (xdisplay, buffer, False);
|
|
|
090c1a5 |
|
|
|
090c1a5 |
- icon->manager_atom = XInternAtom (DisplayOfScreen (xscreen),
|
|
|
090c1a5 |
- "MANAGER", False);
|
|
|
090c1a5 |
+ icon->manager_atom = XInternAtom (xdisplay, "MANAGER", False);
|
|
|
090c1a5 |
|
|
|
090c1a5 |
- icon->system_tray_opcode_atom = XInternAtom (DisplayOfScreen (xscreen),
|
|
|
090c1a5 |
- "_NET_SYSTEM_TRAY_OPCODE", False);
|
|
|
090c1a5 |
+ icon->system_tray_opcode_atom = XInternAtom (xdisplay,
|
|
|
090c1a5 |
+ "_NET_SYSTEM_TRAY_OPCODE",
|
|
|
090c1a5 |
+ False);
|
|
|
090c1a5 |
|
|
|
090c1a5 |
- egg_tray_icon_update_manager_window (icon);
|
|
|
090c1a5 |
+ icon->orientation_atom = XInternAtom (xdisplay,
|
|
|
090c1a5 |
+ "_NET_SYSTEM_TRAY_ORIENTATION",
|
|
|
090c1a5 |
+ False);
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ egg_tray_icon_update_manager_window (icon, FALSE);
|
|
|
090c1a5 |
+ egg_tray_icon_send_dock_request (icon);
|
|
|
090c1a5 |
|
|
|
090c1a5 |
-#if HAVE_GTK_MULTIHEAD
|
|
|
090c1a5 |
root_window = gdk_screen_get_root_window (screen);
|
|
|
090c1a5 |
-#else
|
|
|
090c1a5 |
- root_window = gdk_window_lookup (gdk_x11_get_default_root_xwindow ());
|
|
|
090c1a5 |
-#endif
|
|
|
090c1a5 |
|
|
|
090c1a5 |
/* Add a root window filter so that we get changes on MANAGER */
|
|
|
090c1a5 |
gdk_window_add_filter (root_window,
|
|
|
090c1a5 |
egg_tray_icon_manager_filter, icon);
|
|
|
090c1a5 |
-
|
|
|
090c1a5 |
- return icon;
|
|
|
090c1a5 |
+#endif
|
|
|
090c1a5 |
+}
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+static void
|
|
|
090c1a5 |
+egg_tray_icon_add (GtkContainer *container, GtkWidget *widget)
|
|
|
090c1a5 |
+{
|
|
|
090c1a5 |
+ g_signal_connect (widget, "realize",
|
|
|
090c1a5 |
+ G_CALLBACK (make_transparent), NULL);
|
|
|
090c1a5 |
+ GTK_CONTAINER_CLASS (parent_class)->add (container, widget);
|
|
|
090c1a5 |
}
|
|
|
090c1a5 |
|
|
|
090c1a5 |
-#if HAVE_GTK_MULTIHEAD
|
|
|
090c1a5 |
EggTrayIcon *
|
|
|
090c1a5 |
egg_tray_icon_new_for_screen (GdkScreen *screen, const char *name)
|
|
|
090c1a5 |
{
|
|
|
090c1a5 |
- EggTrayIcon *icon;
|
|
|
090c1a5 |
- char buffer[256];
|
|
|
090c1a5 |
-
|
|
|
090c1a5 |
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
|
|
|
090c1a5 |
|
|
|
090c1a5 |
- return egg_tray_icon_new_for_xscreen (GDK_SCREEN_XSCREEN (screen), name);
|
|
|
090c1a5 |
+ return g_object_new (EGG_TYPE_TRAY_ICON, "screen", screen, "title", name, NULL);
|
|
|
090c1a5 |
}
|
|
|
090c1a5 |
-#endif
|
|
|
090c1a5 |
|
|
|
090c1a5 |
EggTrayIcon*
|
|
|
090c1a5 |
egg_tray_icon_new (const gchar *name)
|
|
|
090c1a5 |
{
|
|
|
090c1a5 |
- return egg_tray_icon_new_for_xscreen (DefaultScreenOfDisplay (gdk_display), name);
|
|
|
090c1a5 |
+ return g_object_new (EGG_TYPE_TRAY_ICON, "title", name, NULL);
|
|
|
090c1a5 |
}
|
|
|
090c1a5 |
|
|
|
090c1a5 |
guint
|
|
|
090c1a5 |
@@ -278,17 +478,20 @@
|
|
|
090c1a5 |
g_return_val_if_fail (timeout >= 0, 0);
|
|
|
090c1a5 |
g_return_val_if_fail (message != NULL, 0);
|
|
|
090c1a5 |
|
|
|
090c1a5 |
+#ifdef GDK_WINDOWING_X11
|
|
|
090c1a5 |
if (icon->manager_window == None)
|
|
|
090c1a5 |
return 0;
|
|
|
090c1a5 |
+#endif
|
|
|
090c1a5 |
|
|
|
090c1a5 |
if (len < 0)
|
|
|
090c1a5 |
len = strlen (message);
|
|
|
090c1a5 |
|
|
|
090c1a5 |
stamp = icon->stamp++;
|
|
|
090c1a5 |
|
|
|
090c1a5 |
+#ifdef GDK_WINDOWING_X11
|
|
|
090c1a5 |
/* Get ready to send the message */
|
|
|
090c1a5 |
egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_BEGIN_MESSAGE,
|
|
|
090c1a5 |
- (Window)gtk_plug_get_id (GTK_PLUG (icon)),
|
|
|
090c1a5 |
+ icon->manager_window,
|
|
|
090c1a5 |
timeout, len, stamp);
|
|
|
090c1a5 |
|
|
|
090c1a5 |
/* Now to send the actual message */
|
|
|
090c1a5 |
@@ -298,14 +501,10 @@
|
|
|
090c1a5 |
XClientMessageEvent ev;
|
|
|
090c1a5 |
Display *xdisplay;
|
|
|
090c1a5 |
|
|
|
090c1a5 |
-#if HAVE_GTK_MULTIHEAD
|
|
|
090c1a5 |
xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
|
|
|
090c1a5 |
-#else
|
|
|
090c1a5 |
- xdisplay = gdk_display;
|
|
|
090c1a5 |
-#endif
|
|
|
090c1a5 |
|
|
|
090c1a5 |
ev.type = ClientMessage;
|
|
|
090c1a5 |
- ev.window = (Window)gtk_plug_get_id (GTK_PLUG (icon));
|
|
|
090c1a5 |
+ ev.window = icon->manager_window;
|
|
|
090c1a5 |
ev.format = 8;
|
|
|
090c1a5 |
ev.message_type = XInternAtom (xdisplay,
|
|
|
090c1a5 |
"_NET_SYSTEM_TRAY_MESSAGE_DATA", False);
|
|
|
090c1a5 |
@@ -326,6 +525,7 @@
|
|
|
090c1a5 |
XSync (xdisplay, False);
|
|
|
090c1a5 |
}
|
|
|
090c1a5 |
gdk_error_trap_pop ();
|
|
|
090c1a5 |
+#endif
|
|
|
090c1a5 |
|
|
|
090c1a5 |
return stamp;
|
|
|
090c1a5 |
}
|
|
|
090c1a5 |
@@ -336,8 +536,17 @@
|
|
|
090c1a5 |
{
|
|
|
090c1a5 |
g_return_if_fail (EGG_IS_TRAY_ICON (icon));
|
|
|
090c1a5 |
g_return_if_fail (id > 0);
|
|
|
090c1a5 |
-
|
|
|
090c1a5 |
+#ifdef GDK_WINDOWING_X11
|
|
|
090c1a5 |
egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_CANCEL_MESSAGE,
|
|
|
090c1a5 |
(Window)gtk_plug_get_id (GTK_PLUG (icon)),
|
|
|
090c1a5 |
id, 0, 0);
|
|
|
090c1a5 |
+#endif
|
|
|
090c1a5 |
+}
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+GtkOrientation
|
|
|
090c1a5 |
+egg_tray_icon_get_orientation (EggTrayIcon *icon)
|
|
|
090c1a5 |
+{
|
|
|
090c1a5 |
+ g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), GTK_ORIENTATION_HORIZONTAL);
|
|
|
090c1a5 |
+
|
|
|
090c1a5 |
+ return icon->orientation;
|
|
|
090c1a5 |
}
|