1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* eggtrayicon.c
3  * Copyright (C) 2002 Anders Carlsson <andersca@gnu.org>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20 
21 /*
22 
23 Permission to use this file under wxWindows licence given by
24 copyright holder:
25 --------
26 From andersca@gnu.org Tue Dec  9 13:01:56 2003
27 Return-path: <andersca@gnu.org>
28 Envelope-to: vasek@localhost
29 Delivery-date: Tue, 09 Dec 2003 13:04:35 +0100
30 Received: from localhost
31 	([127.0.0.1] helo=amavis ident=amavis)
32 	by armitage with esmtp (Exim 3.35 #1)
33 	id 1ATgbS-0001Gs-00
34 	for vasek@localhost; Tue, 09 Dec 2003 13:04:35 +0100
35 Received: from armitage ([127.0.0.1])
36 	by amavis (armitage [127.0.0.1]) (amavisd-new, port 10024) with ESMTP
37 	id 04227-09 for <vasek@localhost>;
38 	Tue, 9 Dec 2003 13:04:11 +0100 (CET)
39 Received: from localhost ([127.0.0.1] ident=fetchmail)
40 	by armitage with esmtp (Exim 3.35 #1)
41 	id 1ATgb5-0001GY-00
42 	for vasek@localhost; Tue, 09 Dec 2003 13:04:11 +0100
43 Delivered-To: alias-email-slavikvaclav@seznam.cz
44 Received: from pop3.seznam.cz [212.80.76.45]
45 	by localhost with POP3 (fetchmail-5.9.11)
46 	for vasek@localhost (single-drop); Tue, 09 Dec 2003 13:04:11 +0100 (CET)
47 Received: (qmail 9861 invoked from network); 9 Dec 2003 12:02:17 -0000
48 Received: from unknown (HELO maxipes.logix.cz) (81.0.234.97)
49   by buster.go.seznam.cz with SMTP; 9 Dec 2003 12:02:17 -0000
50 Received: by maxipes.logix.cz (Postfix, from userid 604)
51 	id 37E6D29A51; Tue,  9 Dec 2003 13:02:16 +0100 (CET)
52 X-Original-To: vaclav.slavik@matfyz.cz
53 Received: from mail.csbnet.se (glutus.csbnet.se [193.11.248.2])
54 	by maxipes.logix.cz (Postfix) with ESMTP id 90D6A29A51
55 	for <vaclav.slavik@matfyz.cz>; Tue,  9 Dec 2003 13:02:15 +0100 (CET)
56 Received: by mail.csbnet.se (Postfix, from userid 8)
57 	id 7AA7F10A6D7; Tue,  9 Dec 2003 13:02:14 +0100 (CET)
58 Received: from carbon.csbnet.se (carbon.csbnet.se [193.11.248.180])
59 	by mail.csbnet.se (Postfix) with ESMTP id A190F10A71D
60 	for <vaclav.slavik@matfyz.cz>; Tue,  9 Dec 2003 13:01:56 +0100 (CET)
61 Subject: Re: eggtrayicon.{c,h} licensing
62 From: Anders Carlsson <andersca@gnu.org>
63 To: Vaclav Slavik <vaclav.slavik@matfyz.cz>
64 In-Reply-To: <200312091142.54542.vaclav.slavik@matfyz.cz>
65 References: <200312091142.54542.vaclav.slavik@matfyz.cz>
66 Content-Type: text/plain
67 Message-Id: <1070971316.30989.0.camel@carbon.csbnet.se>
68 Mime-Version: 1.0
69 X-Mailer: Ximian Evolution 1.5
70 Date: Tue, 09 Dec 2003 13:01:56 +0100
71 Content-Transfer-Encoding: 7bit
72 X-Scanned-By: CLAM (openantivirus DB) antivirus scanner at mail.csbnet.se
73 X-Virus-Scanned: by amavisd-new-20030616-p5 (Debian) at armitage
74 X-Spam-Status: No, hits=-4.9 tagged_above=-999.0 required=6.3 tests=BAYES_00
75 X-Spam-Level:
76 Status: R
77 X-Status: N
78 X-KMail-EncryptionState:
79 X-KMail-SignatureState:
80 
81 On tis, 2003-12-09 at 11:42 +0100, Vaclav Slavik wrote:
82 > Hi,
83 >
84 > I'm working on the wxWindows cross-platform GUI toolkit
85 > (http://www.wxwindows.org) which uses GTK+ and it would save me a lot
86 > of time if I could use your eggtrayicon code to implement tray icons
87 > on X11. Unfortunately I can't use it right now because it is not part
88 > of any library we could depend on (as we do depend on GTK+) and would
89 > have to be included in our sources and it is under the LGPL license.
90 > The problem is that wxWindows' license is more permissive (see
91 > http://www.opensource.org/licenses/wxwindows.php for details) and so
92 > I can't take your code and put it under wxWindows License. And I
93 > can't put code that can't be used under the terms of wxWindows
94 > License into wxWindows either. Do you think it would be possible to
95 > get permission to include eggtrayicon under wxWindows license?
96 >
97 > Thanks,
98 > Vaclav
99 >
100 
101 Sure, that's fine by me.
102 
103 Anders
104 --------
105 */
106 
107 
108 #include "wx/platform.h"
109 
110 #if wxUSE_TASKBARICON
111 
112 #define GLIB_DISABLE_DEPRECATION_WARNINGS
113 #include <gtk/gtk.h>
114 #if GTK_CHECK_VERSION(2, 1, 0)
115 
116 #include <string.h>
117 #include "eggtrayicon.h"
118 
119 #include <gdkconfig.h>
120 #if defined (GDK_WINDOWING_X11)
121 #include <gdk/gdkx.h>
122 #include <X11/Xatom.h>
123 #elif defined (GDK_WINDOWING_WIN32)
124 #include <gdk/gdkwin32.h>
125 #endif
126 
127 
128 #define SYSTEM_TRAY_REQUEST_DOCK    0
129 #define SYSTEM_TRAY_BEGIN_MESSAGE   1
130 #define SYSTEM_TRAY_CANCEL_MESSAGE  2
131 
132 #define SYSTEM_TRAY_ORIENTATION_HORZ 0
133 #define SYSTEM_TRAY_ORIENTATION_VERT 1
134 
135 enum {
136   PROP_0,
137   PROP_ORIENTATION
138 };
139 
140 static GtkPlugClass *parent_class = NULL;
141 
142 static void egg_tray_icon_init (EggTrayIcon *icon);
143 static void egg_tray_icon_class_init (EggTrayIconClass *klass);
144 
145 static void egg_tray_icon_get_property (GObject    *object,
146 					guint       prop_id,
147 					GValue     *value,
148 					GParamSpec *pspec);
149 
150 static void egg_tray_icon_realize   (GtkWidget *widget);
151 static void egg_tray_icon_unrealize (GtkWidget *widget);
152 
153 static void egg_tray_icon_add (GtkContainer *container,
154 			       GtkWidget    *widget);
155 
156 #ifdef GDK_WINDOWING_X11
157 static void egg_tray_icon_update_manager_window    (EggTrayIcon *icon,
158 						    gboolean     dock_if_realized);
159 static void egg_tray_icon_manager_window_destroyed (EggTrayIcon *icon);
160 #endif
161 
162 GType
egg_tray_icon_get_type(void)163 egg_tray_icon_get_type (void)
164 {
165   static GType our_type = 0;
166 
167   if (our_type == 0)
168     {
169       static const GTypeInfo our_info =
170       {
171 	sizeof (EggTrayIconClass),
172 	(GBaseInitFunc) NULL,
173 	(GBaseFinalizeFunc) NULL,
174 	(GClassInitFunc) egg_tray_icon_class_init,
175 	NULL, /* class_finalize */
176 	NULL, /* class_data */
177 	sizeof (EggTrayIcon),
178 	0,    /* n_preallocs */
179 	(GInstanceInitFunc) egg_tray_icon_init
180       };
181 
182       our_type = g_type_register_static (GTK_TYPE_PLUG, "EggTrayIcon", &our_info, 0);
183     }
184 
185   return our_type;
186 }
187 
188 static void
egg_tray_icon_init(EggTrayIcon * icon)189 egg_tray_icon_init (EggTrayIcon *icon)
190 {
191   icon->stamp = 1;
192   icon->orientation = GTK_ORIENTATION_HORIZONTAL;
193 
194   gtk_widget_add_events (GTK_WIDGET (icon), GDK_PROPERTY_CHANGE_MASK);
195 }
196 
197 static void
egg_tray_icon_class_init(EggTrayIconClass * klass)198 egg_tray_icon_class_init (EggTrayIconClass *klass)
199 {
200   GObjectClass *gobject_class = (GObjectClass *)klass;
201   GtkWidgetClass *widget_class = (GtkWidgetClass *)klass;
202   GtkContainerClass *container_class = (GtkContainerClass *)klass;
203 
204   parent_class = g_type_class_peek_parent (klass);
205 
206   gobject_class->get_property = egg_tray_icon_get_property;
207 
208   widget_class->realize   = egg_tray_icon_realize;
209   widget_class->unrealize = egg_tray_icon_unrealize;
210 
211   container_class->add = egg_tray_icon_add;
212 
213   g_object_class_install_property (gobject_class,
214 				   PROP_ORIENTATION,
215 				   g_param_spec_enum ("orientation",
216 						      "Orientation",
217 						      "The orientation of the tray.",
218 						      GTK_TYPE_ORIENTATION,
219 						      GTK_ORIENTATION_HORIZONTAL,
220 						      G_PARAM_READABLE));
221 }
222 
223 static void
egg_tray_icon_get_property(GObject * object,guint prop_id,GValue * value,GParamSpec * pspec)224 egg_tray_icon_get_property (GObject    *object,
225 			    guint       prop_id,
226 			    GValue     *value,
227 			    GParamSpec *pspec)
228 {
229   EggTrayIcon *icon = EGG_TRAY_ICON (object);
230 
231   switch (prop_id)
232     {
233     case PROP_ORIENTATION:
234       g_value_set_enum (value, icon->orientation);
235       break;
236     default:
237       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
238       break;
239     }
240 }
241 
242 #ifdef GDK_WINDOWING_X11
243 
244 static void
egg_tray_icon_get_orientation_property(EggTrayIcon * icon)245 egg_tray_icon_get_orientation_property (EggTrayIcon *icon)
246 {
247   Display *xdisplay;
248   Atom type;
249   int format;
250   union {
251 	gulong *prop;
252 	guchar *prop_ch;
253   } prop = { NULL };
254   gulong nitems;
255   gulong bytes_after;
256   int error, result;
257 
258   g_assert (icon->manager_window != None);
259 
260   xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
261 
262   gdk_error_trap_push ();
263   type = None;
264   result = XGetWindowProperty (xdisplay,
265 			       icon->manager_window,
266 			       icon->orientation_atom,
267 			       0, G_MAXLONG, FALSE,
268 			       XA_CARDINAL,
269 			       &type, &format, &nitems,
270 			       &bytes_after, &(prop.prop_ch));
271   error = gdk_error_trap_pop ();
272 
273   if (error || result != Success)
274     return;
275 
276   if (type == XA_CARDINAL)
277     {
278       GtkOrientation orientation;
279 
280       orientation = (prop.prop [0] == SYSTEM_TRAY_ORIENTATION_HORZ) ?
281 					GTK_ORIENTATION_HORIZONTAL :
282 					GTK_ORIENTATION_VERTICAL;
283 
284       if (icon->orientation != orientation)
285 	{
286 	  icon->orientation = orientation;
287 
288 	  g_object_notify (G_OBJECT (icon), "orientation");
289 	}
290     }
291 
292   if (prop.prop)
293     XFree (prop.prop);
294 }
295 
296 static GdkFilterReturn
egg_tray_icon_manager_filter(GdkXEvent * xevent,GdkEvent * event,gpointer user_data)297 egg_tray_icon_manager_filter (GdkXEvent *xevent, GdkEvent *event, gpointer user_data)
298 {
299   EggTrayIcon *icon = user_data;
300   XEvent *xev = (XEvent *)xevent;
301 
302   if (xev->xany.type == ClientMessage &&
303       xev->xclient.message_type == icon->manager_atom &&
304       xev->xclient.data.l[1] == icon->selection_atom)
305     {
306       egg_tray_icon_update_manager_window (icon, TRUE);
307     }
308   else if (xev->xany.window == icon->manager_window)
309     {
310       if (xev->xany.type == PropertyNotify &&
311 	  xev->xproperty.atom == icon->orientation_atom)
312 	{
313 	  egg_tray_icon_get_orientation_property (icon);
314 	}
315       if (xev->xany.type == DestroyNotify)
316 	{
317 	  egg_tray_icon_manager_window_destroyed (icon);
318 	}
319     }
320   return GDK_FILTER_CONTINUE;
321 }
322 
323 #endif
324 
325 static void
egg_tray_icon_unrealize(GtkWidget * widget)326 egg_tray_icon_unrealize (GtkWidget *widget)
327 {
328 #ifdef GDK_WINDOWING_X11
329   EggTrayIcon *icon = EGG_TRAY_ICON (widget);
330   GdkWindow *root_window;
331 
332   if (icon->manager_window != None)
333     {
334       GdkWindow *gdkwin;
335 
336       gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (widget),
337                                               icon->manager_window);
338 
339       gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
340     }
341 
342   root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget));
343 
344   gdk_window_remove_filter (root_window, egg_tray_icon_manager_filter, icon);
345 
346   if (GTK_WIDGET_CLASS (parent_class)->unrealize)
347     (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
348 #endif
349 }
350 
351 #ifdef GDK_WINDOWING_X11
352 
353 static void
egg_tray_icon_send_manager_message(EggTrayIcon * icon,long message,Window window,long data1,long data2,long data3)354 egg_tray_icon_send_manager_message (EggTrayIcon *icon,
355 				    long         message,
356 				    Window       window,
357 				    long         data1,
358 				    long         data2,
359 				    long         data3)
360 {
361   XClientMessageEvent ev;
362   Display *display;
363 
364   ev.type = ClientMessage;
365   ev.window = window;
366   ev.message_type = icon->system_tray_opcode_atom;
367   ev.format = 32;
368   ev.data.l[0] = gdk_x11_get_server_time (GTK_WIDGET (icon)->window);
369   ev.data.l[1] = message;
370   ev.data.l[2] = data1;
371   ev.data.l[3] = data2;
372   ev.data.l[4] = data3;
373 
374   display = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
375 
376   gdk_error_trap_push ();
377   XSendEvent (display,
378 	      icon->manager_window, False, NoEventMask, (XEvent *)&ev);
379   XSync (display, False);
380   gdk_error_trap_pop ();
381 }
382 
383 static void
egg_tray_icon_send_dock_request(EggTrayIcon * icon)384 egg_tray_icon_send_dock_request (EggTrayIcon *icon)
385 {
386   egg_tray_icon_send_manager_message (icon,
387 				      SYSTEM_TRAY_REQUEST_DOCK,
388 				      icon->manager_window,
389 				      gtk_plug_get_id (GTK_PLUG (icon)),
390 				      0, 0);
391 }
392 
393 static void
egg_tray_icon_update_manager_window(EggTrayIcon * icon,gboolean dock_if_realized)394 egg_tray_icon_update_manager_window (EggTrayIcon *icon,
395 				     gboolean     dock_if_realized)
396 {
397   Display *xdisplay;
398 
399   if (icon->manager_window != None)
400     return;
401 
402   xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
403 
404   XGrabServer (xdisplay);
405 
406   icon->manager_window = XGetSelectionOwner (xdisplay,
407 					     icon->selection_atom);
408 
409   if (icon->manager_window != None)
410     XSelectInput (xdisplay,
411 		  icon->manager_window, StructureNotifyMask|PropertyChangeMask);
412 
413   XUngrabServer (xdisplay);
414   XFlush (xdisplay);
415 
416   if (icon->manager_window != None)
417     {
418       GdkWindow *gdkwin;
419 
420       gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
421 					      icon->manager_window);
422 
423       gdk_window_add_filter (gdkwin, egg_tray_icon_manager_filter, icon);
424 
425       if (dock_if_realized && GTK_WIDGET_REALIZED (icon))
426 	egg_tray_icon_send_dock_request (icon);
427 
428       egg_tray_icon_get_orientation_property (icon);
429     }
430 }
431 
432 static void
egg_tray_icon_manager_window_destroyed(EggTrayIcon * icon)433 egg_tray_icon_manager_window_destroyed (EggTrayIcon *icon)
434 {
435   GdkWindow *gdkwin;
436 
437   g_return_if_fail (icon->manager_window != None);
438 
439   gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)),
440 					  icon->manager_window);
441 
442   gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon);
443 
444   icon->manager_window = None;
445 
446   egg_tray_icon_update_manager_window (icon, TRUE);
447 }
448 
449 #endif
450 
451 static gboolean
transparent_expose_event(GtkWidget * widget,GdkEventExpose * event,gpointer user_data)452 transparent_expose_event (GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
453 {
454   gdk_window_clear_area (widget->window, event->area.x, event->area.y,
455 			 event->area.width, event->area.height);
456   return FALSE;
457 }
458 
459 static void
make_transparent_again(GtkWidget * widget,GtkStyle * previous_style,gpointer user_data)460 make_transparent_again (GtkWidget *widget, GtkStyle *previous_style,
461 			gpointer user_data)
462 {
463   gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
464 }
465 
466 static void
make_transparent(GtkWidget * widget,gpointer user_data)467 make_transparent (GtkWidget *widget, gpointer user_data)
468 {
469   if (GTK_WIDGET_NO_WINDOW (widget) || GTK_WIDGET_APP_PAINTABLE (widget))
470     return;
471 
472   gtk_widget_set_app_paintable (widget, TRUE);
473   gtk_widget_set_double_buffered (widget, FALSE);
474   gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
475   g_signal_connect (widget, "expose_event",
476 		    G_CALLBACK (transparent_expose_event), NULL);
477   g_signal_connect_after (widget, "style_set",
478 			  G_CALLBACK (make_transparent_again), NULL);
479 }
480 
481 static void
egg_tray_icon_realize(GtkWidget * widget)482 egg_tray_icon_realize (GtkWidget *widget)
483 {
484 #ifdef GDK_WINDOWING_X11
485   EggTrayIcon *icon = EGG_TRAY_ICON (widget);
486   GdkScreen *screen;
487   GdkDisplay *display;
488   Display *xdisplay;
489   char buffer[256];
490   GdkWindow *root_window;
491 
492   if (GTK_WIDGET_CLASS (parent_class)->realize)
493     GTK_WIDGET_CLASS (parent_class)->realize (widget);
494 
495   make_transparent (widget, NULL);
496 
497   screen = gtk_widget_get_screen (widget);
498   display = gdk_screen_get_display (screen);
499   xdisplay = gdk_x11_display_get_xdisplay (display);
500 
501   /* Now see if there's a manager window around */
502   g_snprintf (buffer, sizeof (buffer),
503 	      "_NET_SYSTEM_TRAY_S%d",
504 	      gdk_screen_get_number (screen));
505 
506   icon->selection_atom = XInternAtom (xdisplay, buffer, False);
507 
508   icon->manager_atom = XInternAtom (xdisplay, "MANAGER", False);
509 
510   icon->system_tray_opcode_atom = XInternAtom (xdisplay,
511 						   "_NET_SYSTEM_TRAY_OPCODE",
512 						   False);
513 
514   icon->orientation_atom = XInternAtom (xdisplay,
515 					"_NET_SYSTEM_TRAY_ORIENTATION",
516 					False);
517 
518   egg_tray_icon_update_manager_window (icon, FALSE);
519   egg_tray_icon_send_dock_request (icon);
520 
521   root_window = gdk_screen_get_root_window (screen);
522 
523   /* Add a root window filter so that we get changes on MANAGER */
524   gdk_window_add_filter (root_window,
525 			 egg_tray_icon_manager_filter, icon);
526 #endif
527 }
528 
529 static void
egg_tray_icon_add(GtkContainer * container,GtkWidget * widget)530 egg_tray_icon_add (GtkContainer *container, GtkWidget *widget)
531 {
532   g_signal_connect (widget, "realize",
533 		    G_CALLBACK (make_transparent), NULL);
534   GTK_CONTAINER_CLASS (parent_class)->add (container, widget);
535 }
536 
537 EggTrayIcon *
egg_tray_icon_new_for_screen(GdkScreen * screen,const char * name)538 egg_tray_icon_new_for_screen (GdkScreen *screen, const char *name)
539 {
540   g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
541 
542   return g_object_new (EGG_TYPE_TRAY_ICON, "screen", screen, "title", name, NULL);
543 }
544 
545 EggTrayIcon*
egg_tray_icon_new(const gchar * name)546 egg_tray_icon_new (const gchar *name)
547 {
548   return g_object_new (EGG_TYPE_TRAY_ICON, "title", name, NULL);
549 }
550 
551 guint
egg_tray_icon_send_message(EggTrayIcon * icon,gint timeout,const gchar * message,gint len)552 egg_tray_icon_send_message (EggTrayIcon *icon,
553 			    gint         timeout,
554 			    const gchar *message,
555 			    gint         len)
556 {
557   guint stamp;
558 
559   g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), 0);
560   g_return_val_if_fail (timeout >= 0, 0);
561   g_return_val_if_fail (message != NULL, 0);
562 
563 #ifdef GDK_WINDOWING_X11
564   if (icon->manager_window == None)
565     return 0;
566 #endif
567 
568   if (len < 0)
569     len = strlen (message);
570 
571   stamp = icon->stamp++;
572 
573 #ifdef GDK_WINDOWING_X11
574   /* Get ready to send the message */
575   egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_BEGIN_MESSAGE,
576 				      icon->manager_window,
577 				      timeout, len, stamp);
578 
579   /* Now to send the actual message */
580   gdk_error_trap_push ();
581   while (len > 0)
582     {
583       XClientMessageEvent ev;
584       Display *xdisplay;
585 
586       xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon)));
587 
588       ev.type = ClientMessage;
589       ev.window = icon->manager_window;
590       ev.format = 8;
591       ev.message_type = XInternAtom (xdisplay,
592 				     "_NET_SYSTEM_TRAY_MESSAGE_DATA", False);
593       if (len > 20)
594 	{
595 	  memcpy (&ev.data, message, 20);
596 	  len -= 20;
597 	  message += 20;
598 	}
599       else
600 	{
601 	  memcpy (&ev.data, message, len);
602 	  len = 0;
603 	}
604 
605       XSendEvent (xdisplay,
606 		  icon->manager_window, False, StructureNotifyMask, (XEvent *)&ev);
607       XSync (xdisplay, False);
608     }
609   gdk_error_trap_pop ();
610 #endif
611 
612   return stamp;
613 }
614 
615 void
egg_tray_icon_cancel_message(EggTrayIcon * icon,guint id)616 egg_tray_icon_cancel_message (EggTrayIcon *icon,
617 			      guint        id)
618 {
619   g_return_if_fail (EGG_IS_TRAY_ICON (icon));
620   g_return_if_fail (id > 0);
621 #ifdef GDK_WINDOWING_X11
622   egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_CANCEL_MESSAGE,
623 				      (Window)gtk_plug_get_id (GTK_PLUG (icon)),
624 				      id, 0, 0);
625 #endif
626 }
627 
628 GtkOrientation
egg_tray_icon_get_orientation(EggTrayIcon * icon)629 egg_tray_icon_get_orientation (EggTrayIcon *icon)
630 {
631   g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), GTK_ORIENTATION_HORIZONTAL);
632 
633   return icon->orientation;
634 }
635 
636 
637 
638 
639 
640 #endif /* GTK_CHECK_VERSION(2, 1, 0) */
641 #endif /* wxUSE_TASKBARICON */
642