19 #include "systemtray.h" 23 #include <kiconloader.h> 24 #include <tdelocale.h> 25 #include <twinmodule.h> 26 #include <tdemessagebox.h> 30 #include <tqpopupmenu.h> 31 #include <tqdragobject.h> 33 #include <tqstringlist.h> 38 Systemtray::Systemtray(TQWidget* parent)
39 : TQWidget(parent,0,0)
41 setBackgroundOrigin(ParentOrigin);
42 setBackgroundMode(FixedPixmap);
43 m_Wins.setAutoDelete(
true);
47 Systemtray::~Systemtray()
52 int Systemtray::getTraySize() {
54 return (
int) twin_module->systemTrayWindows().size();
57 void Systemtray::updateBackgroundPixmap (
const TQPixmap & pixmap) {
59 setPaletteBackgroundPixmap (pixmap);
60 for (emb = m_Wins.first(); emb != 0L; emb = m_Wins.next()) {
64 TQPixmap bug = TQPixmap(emb->size());
65 bitBlt(&bug, 0, 0, const_cast<TQPixmap*>(&pixmap), emb->parentWidget()->x()+emb->x(), emb->parentWidget()->y()+emb->y(), emb->width(), emb->height(),TQt::CopyROP,
false);
66 emb->setPaletteBackgroundPixmap (bug);
70 TQPoint topPoint = mapToGlobal(TQPoint(0,0));
71 Window hack = XCreateSimpleWindow(tqt_xdisplay(), winId(), 0,0, width(), height(), 0, 0, 0);
72 XRaiseWindow(tqt_xdisplay(), hack);
73 XMapWindow(tqt_xdisplay(), hack);
74 XUnmapWindow(tqt_xdisplay(), hack);
75 XDestroyWindow(tqt_xdisplay(), hack);
78 void Systemtray::initSystray(
void )
80 bool existing =
false;
82 Display *display = tqt_xdisplay();
83 no_of_systray_windows = 0;
85 twin_module =
new KWinModule();
86 systemTrayWindows = twin_module->systemTrayWindows();
87 TQValueList<WId>::ConstIterator end(systemTrayWindows.end());
88 for (TQValueList<WId>::ConstIterator it = systemTrayWindows.begin(); it!=end; ++it)
90 no_of_systray_windows++;
93 emb =
new QXEmbed(
this);
94 emb->setBackgroundMode(FixedPixmap);
96 emb->setAutoDelete(
false);
98 connect(emb, TQ_SIGNAL(embeddedWindowDestroyed()), TQ_SLOT(updateTrayWindows()));
110 connect(twin_module, TQ_SIGNAL(systemTrayWindowAdded(WId)), TQ_SLOT(systemTrayWindowAdded(WId)));
111 connect(twin_module, TQ_SIGNAL(systemTrayWindowRemoved(WId)), TQ_SLOT(systemTrayWindowRemoved(WId)));
114 screenstr.setNum(tqt_xscreen());
115 TQCString trayatom =
"_NET_SYSTEM_TRAY_S" + screenstr;
117 net_system_tray_selection = XInternAtom( display, trayatom,
false );
118 net_system_tray_opcode = XInternAtom( display,
"_NET_SYSTEM_TRAY_OPCODE",
false );
121 XSetSelectionOwner( display,
122 net_system_tray_selection,
126 WId root = tqt_xrootwin();
128 if (XGetSelectionOwner(display, net_system_tray_selection) == winId())
130 XClientMessageEvent xev;
132 xev.type = ClientMessage;
135 xev.message_type = XInternAtom(display,
"MANAGER",
false);
138 xev.data.l[0] = CurrentTime;
139 xev.data.l[1] = net_system_tray_selection;
140 xev.data.l[2] = winId();
144 XSendEvent( display, root,
false, StructureNotifyMask, (XEvent *)&xev );
148 void Systemtray::updateTrayWindows(
void )
152 emb = m_Wins.first();
153 while ((emb = m_Wins.current()) != 0L)
155 WId wid = emb->embeddedWinId();
156 if ((wid == 0) || !twin_module->systemTrayWindows().contains(wid) )
163 void Systemtray::layoutSystray()
172 int aa = width() / 24;
181 for (emb = m_Wins.first(); emb != 0L; emb = m_Wins.next()) {
197 void Systemtray::systemTrayWindowAdded( WId w )
201 no_of_systray_windows++;
204 emb =
new QXEmbed(
this);
206 emb->setAutoDelete(
false);
208 emb->setBackgroundMode(FixedPixmap);
209 connect(emb, TQ_SIGNAL(embeddedWindowDestroyed()), TQ_SLOT(updateTrayWindows()));
219 void Systemtray::systemTrayWindowRemoved(WId)
221 no_of_systray_windows--;
226 int Systemtray::getCurrentWindowCount()
228 return no_of_systray_windows;
231 #include "systemtray.moc"