GTK+ 2.0 can't compile egg tray code
[wxWidgets.git] / src / gtk / taskbar.cpp
1 /////////////////////////////////////////////////////////////////////////
2 // File: taskbar.cpp
3 // Purpose: wxTaskBarIcon (src/unix/taskbarx11.cpp) helper for GTK2
4 // Author: Vaclav Slavik
5 // Modified by:
6 // Created: 2004/05/29
7 // RCS-ID: $Id$
8 // Copyright: (c) Vaclav Slavik, 2004
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////
11
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "taskbarpriv.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #include "wx/log.h"
20 #include "wx/frame.h"
21
22 #include <gdk/gdkx.h>
23 #include <gtk/gtkversion.h>
24
25 #if defined(__WXGTK20__) && GTK_CHECK_VERSION(2, 1, 0)
26
27 #include "wx/gtk/taskbarpriv.h"
28 #include "eggtrayicon.h"
29
30 wxTaskBarIconAreaBase::wxTaskBarIconAreaBase()
31 {
32 if (IsProtocolSupported())
33 {
34 m_widget = GTK_WIDGET(egg_tray_icon_new("systray icon"));
35 gtk_window_set_resizable(GTK_WINDOW(m_widget), false);
36
37 wxLogTrace(_T("systray"), _T("using freedesktop.org systray spec"));
38 }
39
40 wxTopLevelWindow::Create(
41 NULL, wxID_ANY, _T("systray icon"),
42 wxDefaultPosition, wxDefaultSize,
43 wxDEFAULT_FRAME_STYLE | wxFRAME_NO_TASKBAR | wxSIMPLE_BORDER |
44 wxFRAME_SHAPED,
45 wxEmptyString /*eggtray doesn't like setting wmclass*/);
46 }
47
48 bool wxTaskBarIconAreaBase::IsProtocolSupported()
49 {
50 static int s_supported = -1;
51 if (s_supported == -1)
52 {
53 Display *display = GDK_DISPLAY();
54 Screen *screen = DefaultScreenOfDisplay(display);
55
56 wxString name;
57 name.Printf(_T("_NET_SYSTEM_TRAY_S%d"), XScreenNumberOfScreen(screen));
58 Atom atom = XInternAtom(display, name.ToAscii(), False);
59
60 Window manager = XGetSelectionOwner(display, atom);
61
62 s_supported = (manager != None);
63 }
64
65 return (bool)s_supported;
66 }
67
68 #endif // __WXGTK20__