diff options
Diffstat (limited to 'src/qtraylabel.cpp')
-rw-r--r-- | src/qtraylabel.cpp | 206 |
1 files changed, 103 insertions, 103 deletions
diff --git a/src/qtraylabel.cpp b/src/qtraylabel.cpp index 2c528c1..0d790c9 100644 --- a/src/qtraylabel.cpp +++ b/src/qtraylabel.cpp @@ -19,16 +19,16 @@ // $Id: qtraylabel.cpp,v 1.31 2005/06/21 10:04:36 cs19713 Exp $ -// Include all Qt includes before X -#include <qstring.h> -#include <qevent.h> -#include <qpoint.h> -#include <qtooltip.h> -#include <qtimer.h> -#include <qimage.h> -#include <qpixmap.h> -#include <qfileinfo.h> -#include <qapplication.h> +// Include all TQt includes before X +#include <tqstring.h> +#include <tqevent.h> +#include <tqpoint.h> +#include <tqtooltip.h> +#include <tqtimer.h> +#include <tqimage.h> +#include <tqpixmap.h> +#include <tqfileinfo.h> +#include <tqapplication.h> #include "trace.h" #include "qtraylabel.h" @@ -46,7 +46,7 @@ #include "util.h" -void QTrayLabel::initialize(void) +void TQTrayLabel::initialize(void) { mDocked = false; mWithdrawn = true; @@ -55,30 +55,30 @@ void QTrayLabel::initialize(void) mDockWhenMinimized = true; mDesktop = 666; // setDockedWindow would set it a saner value - // Balloon's properties are set to match a Qt tool tip (see Qt source) - mBalloon = new QLabel(0, "balloon", WType_TopLevel | WStyle_StaysOnTop | + // Balloon's properties are set to match a TQt tool tip (see TQt source) + mBalloon = new TQLabel(0, "balloon", WType_TopLevel | WStyle_StaysOnTop | WStyle_Customize | WStyle_NoBorder | WStyle_Tool | WX11BypassWM); - mBalloon->setFont(QToolTip::font()); - mBalloon->setPalette(QToolTip::palette()); - mBalloon->setAlignment(Qt::AlignLeft | Qt::AlignTop); + mBalloon->setFont(TQToolTip::font()); + mBalloon->setPalette(TQToolTip::palette()); + mBalloon->setAlignment(TQt::AlignLeft | TQt::AlignTop); mBalloon->setAutoMask(FALSE); mBalloon->setAutoResize(true); - setAlignment(Qt::AlignCenter); + setAlignment(TQt::AlignCenter); setBackgroundMode(X11ParentRelative); connect(&mRealityMonitor, SIGNAL(timeout()), this, SLOT(realityCheck())); setDockedWindow(mDockedWindow); - sysTrayStatus(QPaintDevice::x11AppDisplay(), &mSysTray); + sysTrayStatus(TQPaintDevice::x11AppDisplay(), &mSysTray); // Subscribe to system tray window notifications if (mSysTray != None) - subscribe(QPaintDevice::x11AppDisplay(), mSysTray, + subscribe(TQPaintDevice::x11AppDisplay(), mSysTray, StructureNotifyMask, true); } // Describe ourselves in a few words -const char *QTrayLabel::me(void) const +const char *TQTrayLabel::me(void) const { static char temp[100]; snprintf(temp, sizeof(temp), "(%s,PID=%i,WID=0x%x)", @@ -86,23 +86,23 @@ const char *QTrayLabel::me(void) const return temp; } -QTrayLabel::QTrayLabel(Window w, QWidget* parent, const QString& text) - :QLabel(parent, text.utf8(), WStyle_Customize | WStyle_NoBorder | WStyle_Tool), +TQTrayLabel::TQTrayLabel(Window w, TQWidget* parent, const TQString& text) + :TQLabel(parent, text.utf8(), WStyle_Customize | WStyle_NoBorder | WStyle_Tool), mDockedWindow(w), mPid(0) { initialize(); } -QTrayLabel::QTrayLabel(const QStringList& pname, pid_t pid, QWidget* parent) - :QLabel(parent, "TrayLabel", WStyle_Customize | WStyle_NoBorder | WStyle_Tool), +TQTrayLabel::TQTrayLabel(const TQStringList& pname, pid_t pid, TQWidget* parent) + :TQLabel(parent, "TrayLabel", WStyle_Customize | WStyle_NoBorder | WStyle_Tool), mDockedWindow(None), mProgName(pname), mPid(pid) { if (pname[0].at(0) != '/' && pname[0].find('/', 1) > 0) - mProgName[0] = QFileInfo(pname[0]).absFilePath(); // convert to absolute + mProgName[0] = TQFileInfo(pname[0]).absFilePath(); // convert to absolute initialize(); } -QTrayLabel::~QTrayLabel() +TQTrayLabel::~TQTrayLabel() { TRACE("%s Goodbye", me()); if (mDockedWindow == None) return; @@ -116,14 +116,14 @@ QTrayLabel::~QTrayLabel() * Scans the windows in the desktop and checks if a window exists that we might * be interested in */ -void QTrayLabel::scanClients() +void TQTrayLabel::scanClients() { Window r, parent, *children; unsigned nchildren = 0; - Display *display = QPaintDevice::x11AppDisplay(); - QString ename = QFileInfo(mProgName[0]).fileName(); // strip out the path + Display *display = TQPaintDevice::x11AppDisplay(); + TQString ename = TQFileInfo(mProgName[0]).fileName(); // strip out the path - XQueryTree(display, qt_xrootwin(), &r, &parent, &children, &nchildren); + XQueryTree(display, tqt_xrootwin(), &r, &parent, &children, &nchildren); TRACE("%s nchildren=%i", me(), nchildren); for(unsigned i=0; i<nchildren; i++) { @@ -143,38 +143,38 @@ void QTrayLabel::scanClients() * Do a reality check :). Note that this timer runs only when required. Does 3 * things, * 1) If the system tray had disappeared, checks for arrival of new system tray - * 2) Check root window subscription since it is overwritten by Qt (see below) + * 2) Check root window subscription since it is overwritten by TQt (see below) * 3) Checks health of the process whose windows we are docking */ -void QTrayLabel::realityCheck(void) +void TQTrayLabel::realityCheck(void) { if (mSysTray == None) { // Check the system tray status if we were docked - if (sysTrayStatus(QPaintDevice::x11AppDisplay(), &mSysTray) + if (sysTrayStatus(TQPaintDevice::x11AppDisplay(), &mSysTray) != SysTrayPresent) return; // no luck TRACE("%s System tray present", me()); dock(); - subscribe(QPaintDevice::x11AppDisplay(), mSysTray, + subscribe(TQPaintDevice::x11AppDisplay(), mSysTray, StructureNotifyMask, true); mRealityMonitor.stop(); return; } /* - * I am not sure when, but Qt at some point in time overwrites our + * I am not sure when, but TQt at some point in time overwrites our * subscription (SubstructureNotifyMask) on the root window. So, we check * the status of root window subscription periodically. Now, from the time - * Qt overwrote our subscription to the time we discovered it, the + * TQt overwrote our subscription to the time we discovered it, the * window we are looking for could have been mapped and we would have never - * been informed (since Qt overrwrote the subscription). So we have to + * been informed (since TQt overrwrote the subscription). So we have to * scan existing client list and dock. I have never seen this happen * but I see it likely to happen during session restoration */ - Display *display = QPaintDevice::x11AppDisplay(); + Display *display = TQPaintDevice::x11AppDisplay(); XWindowAttributes attr; - XGetWindowAttributes(display, qt_xrootwin(), &attr); + XGetWindowAttributes(display, tqt_xrootwin(), &attr); if (!(attr.your_event_mask & SubstructureNotifyMask)) { @@ -197,12 +197,12 @@ void QTrayLabel::realityCheck(void) /* * Sends a message to the WM to show this window on all the desktops */ -void QTrayLabel::showOnAllDesktops(void) +void TQTrayLabel::showOnAllDesktops(void) { TRACE("Showing on all desktops"); - Display *d = QPaintDevice::x11AppDisplay(); + Display *d = TQPaintDevice::x11AppDisplay(); long l[5] = { -1, 0, 0, 0, 0 }; // -1 = all, 0 = Desktop1, 1 = Desktop2 ... - sendMessage(d, qt_xrootwin(), mDockedWindow, "_NET_WM_DESKTOP", 32, + sendMessage(d, tqt_xrootwin(), mDockedWindow, "_NET_WM_DESKTOP", 32, SubstructureNotifyMask | SubstructureRedirectMask, l, sizeof(l)); } @@ -218,7 +218,7 @@ const long SYSTEM_TRAY_CANCEL_MESSAGE = 2; * 2. KDE 3.x and above - _KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR * 3. Older KDE - KWM_DOCKWINDOW (Untested) */ -void QTrayLabel::dock(void) +void TQTrayLabel::dock(void) { TRACE("%s", me()); mDocked = true; @@ -231,7 +231,7 @@ void QTrayLabel::dock(void) return; } - Display *display = QPaintDevice::x11AppDisplay(); + Display *display = TQPaintDevice::x11AppDisplay(); Window wid = winId(); // 1. GNOME and NET WM Specification @@ -264,7 +264,7 @@ void QTrayLabel::dock(void) * working with with a delay of as little as 50ms. But since I * dont understand why this delay is required, I am justifiably paranoid */ - QTimer::singleShot(500, this, SLOT(show())); + TQTimer::singleShot(500, this, SLOT(show())); // let the world know emit docked(this); @@ -277,11 +277,11 @@ void QTrayLabel::dock(void) * be used. It works but the system tray does not fill the void that we left * in the tray. Looks like the system tray will resize only for DestroyEvents */ -void QTrayLabel::undock(void) +void TQTrayLabel::undock(void) { TRACE("%s stopping reality monitor", me()); mRealityMonitor.stop(); - XUnmapWindow(QPaintDevice::x11AppDisplay(), winId()); + XUnmapWindow(TQPaintDevice::x11AppDisplay(), winId()); emit undocked(this); emit undocked(); } @@ -289,13 +289,13 @@ void QTrayLabel::undock(void) /* * Maps the window from the same place it was withdrawn from */ -void QTrayLabel::map(void) +void TQTrayLabel::map(void) { TRACE("%s", me()); mWithdrawn = false; if (mDockedWindow == None) return; - Display *display = QPaintDevice::x11AppDisplay(); + Display *display = TQPaintDevice::x11AppDisplay(); if (mDesktop == -1) { @@ -306,7 +306,7 @@ void QTrayLabel::map(void) * the WM 200ms to do that. We will override that value to -1 (all * desktops) on showOnAllDesktops(). */ - QTimer::singleShot(200, this, SLOT(showOnAllDesktops())); + TQTimer::singleShot(200, this, SLOT(showOnAllDesktops())); } /* @@ -328,22 +328,22 @@ void QTrayLabel::map(void) XSetWMNormalHints(display, mDockedWindow, &mSizeHint); // make it the active window long l[5] = { None, CurrentTime, None, 0, 0 }; - sendMessage(display, qt_xrootwin(), mDockedWindow, "_NET_ACTIVE_WINDOW", 32, + sendMessage(display, tqt_xrootwin(), mDockedWindow, "_NET_ACTIVE_WINDOW", 32, SubstructureNotifyMask | SubstructureRedirectMask, l, sizeof(l)); // skipTaskbar modifies _NET_WM_STATE. Make sure we dont override WMs value - QTimer::singleShot(230, this, SLOT(skipTaskbar())); + TQTimer::singleShot(230, this, SLOT(skipTaskbar())); // disable docking when minized for some time (since we went to Iconic state) mDockWhenMinimized = !mDockWhenMinimized; - QTimer::singleShot(230, this, SLOT(toggleDockWhenMinimized())); + TQTimer::singleShot(230, this, SLOT(toggleDockWhenMinimized())); } -void QTrayLabel::withdraw(void) +void TQTrayLabel::withdraw(void) { TRACE("%s", me()); mWithdrawn = true; if (mDockedWindow == None) return; - Display *display = QPaintDevice::x11AppDisplay(); + Display *display = TQPaintDevice::x11AppDisplay(); int screen = DefaultScreen(display); long dummy; @@ -363,10 +363,10 @@ void QTrayLabel::withdraw(void) memset(&ev, 0, sizeof(ev)); ev.type = UnmapNotify; ev.display = display; - ev.event = qt_xrootwin(); + ev.event = tqt_xrootwin(); ev.window = mDockedWindow; ev.from_configure = false; - XSendEvent(display, qt_xrootwin(), False, + XSendEvent(display, tqt_xrootwin(), False, SubstructureRedirectMask|SubstructureNotifyMask, (XEvent *)&ev); XSync(display, False); } @@ -376,14 +376,14 @@ void QTrayLabel::withdraw(void) * have _NET_WM_STATE_SKIP_TASKBAR. NET_WM_STATE needs to be updated * carefully since it is a set of states. */ -void QTrayLabel::skipTaskbar(void) +void TQTrayLabel::skipTaskbar(void) { Atom __attribute__ ((unused)) type; int __attribute__ ((unused)) format; unsigned long __attribute__ ((unused)) left; Atom *data = NULL; unsigned long nitems = 0, num_states = 0; - Display *display = QPaintDevice::x11AppDisplay(); + Display *display = TQPaintDevice::x11AppDisplay(); TRACE("%s", me()); Atom _NET_WM_STATE = XInternAtom(display, "_NET_WM_STATE", True); @@ -428,7 +428,7 @@ void QTrayLabel::skipTaskbar(void) PropModeReplace, (unsigned char *) &old_states, nitems - 1); } -void QTrayLabel::setSkipTaskbar(bool skip) +void TQTrayLabel::setSkipTaskbar(bool skip) { TRACE("%s Skip=%i", me(), skip); mSkippingTaskbar = skip; @@ -439,13 +439,13 @@ void QTrayLabel::setSkipTaskbar(bool skip) * Closes a window by sending _NET_CLOSE_WINDOW. For reasons best unknown we * need to first map and then send the request. */ -void QTrayLabel::close(void) +void TQTrayLabel::close(void) { TRACE("%s", me()); - Display *display = QPaintDevice::x11AppDisplay(); + Display *display = TQPaintDevice::x11AppDisplay(); long l[5] = { 0, 0, 0, 0, 0 }; map(); - sendMessage(display, qt_xrootwin(), mDockedWindow, "_NET_CLOSE_WINDOW", 32, + sendMessage(display, tqt_xrootwin(), mDockedWindow, "_NET_CLOSE_WINDOW", 32, SubstructureNotifyMask | SubstructureRedirectMask, l, sizeof(l)); } @@ -453,10 +453,10 @@ void QTrayLabel::close(void) /* * Sets the tray icon. If the icon failed to load, we revert to application icon */ -void QTrayLabel::setTrayIcon(const QString& icon) +void TQTrayLabel::setTrayIcon(const TQString& icon) { mCustomIcon = icon; - if (QPixmap(mCustomIcon).isNull()) mCustomIcon = QString::null; + if (TQPixmap(mCustomIcon).isNull()) mCustomIcon = TQString::null; TRACE("%s mCustomIcon=%s", me(), mCustomIcon.latin1()); updateIcon(); } @@ -467,7 +467,7 @@ void QTrayLabel::setTrayIcon(const QString& icon) * B) Subscribe/Unsubscribe for root/w notifications as appropriate * C) And of course, dock the window and apply some settings */ -void QTrayLabel::setDockedWindow(Window w) +void TQTrayLabel::setDockedWindow(Window w) { TRACE("%s %s reality monitor", me(), mDockedWindow==None ? "Starting" : "Stopping"); @@ -479,7 +479,7 @@ void QTrayLabel::setDockedWindow(Window w) if (mDockedWindow == None) mRealityMonitor.start(500); else mRealityMonitor.stop(); - Display *d = QPaintDevice::x11AppDisplay(); + Display *d = TQPaintDevice::x11AppDisplay(); // Subscribe for window or root window events if (w == None) subscribe(d, None, SubstructureNotifyMask, true); @@ -503,7 +503,7 @@ void QTrayLabel::setDockedWindow(Window w) if (mWithdrawn) // show the window for sometime before docking - QTimer::singleShot(1000, this, SLOT(withdraw())); + TQTimer::singleShot(1000, this, SLOT(withdraw())); else map(); dock(); } @@ -512,12 +512,12 @@ void QTrayLabel::setDockedWindow(Window w) /* * Balloon text. Overload this if you dont like the way things are ballooned */ -void QTrayLabel::balloonText() +void TQTrayLabel::balloonText() { TRACE("%s BalloonText=%s ToolTipText=%s", me(), - mBalloon->text().latin1(), QToolTip::textFor(this).latin1()); + mBalloon->text().latin1(), TQToolTip::textFor(this).latin1()); - if (mBalloon->text() == QToolTip::textFor(this)) return; + if (mBalloon->text() == TQToolTip::textFor(this)) return; #if 0 // I_GOT_NETWM_BALLOONING_TO_WORK // if you can get NET WM ballooning to work let me know static int id = 1; @@ -538,28 +538,28 @@ void QTrayLabel::balloonText() data += 20; } #else - // Manually do ballooning. See the Qt ToolTip code - QString oldText = mBalloon->text(); - mBalloon->setText(QToolTip::textFor(this)); + // Manually do ballooning. See the TQt ToolTip code + TQString oldText = mBalloon->text(); + mBalloon->setText(TQToolTip::textFor(this)); if (oldText.isEmpty()) return; // dont tool tip the first time - QPoint p = mapToGlobal(QPoint(0, -1 - mBalloon->height())); - if (p.x() + mBalloon->width() > QApplication::desktop()->width()) + TQPoint p = mapToGlobal(TQPoint(0, -1 - mBalloon->height())); + if (p.x() + mBalloon->width() > TQApplication::desktop()->width()) p.setX(p.x() + width() - mBalloon->width()); if (p.y() < 0) p.setY(height() + 1); mBalloon->move(p); mBalloon->show(); - QTimer::singleShot(mBalloonTimeout, mBalloon, SLOT(hide())); + TQTimer::singleShot(mBalloonTimeout, mBalloon, SLOT(hide())); #endif } /* * Update the title in the menu. Balloon the title change if necessary */ -void QTrayLabel::handleTitleChange(void) +void TQTrayLabel::handleTitleChange(void) { - Display *display = QPaintDevice::x11AppDisplay(); + Display *display = TQPaintDevice::x11AppDisplay(); char *window_name = NULL; XFetchName(display, mDockedWindow, &window_name); @@ -570,8 +570,8 @@ void QTrayLabel::handleTitleChange(void) XClassHint ch; if (XGetClassHint(display, mDockedWindow, &ch)) { - if (ch.res_class) mClass = QString(ch.res_class); - else if (ch.res_name) mClass = QString(ch.res_name); + if (ch.res_class) mClass = TQString(ch.res_class); + else if (ch.res_name) mClass = TQString(ch.res_name); if (ch.res_class) XFree(ch.res_class); if (ch.res_name) XFree(ch.res_name); @@ -585,24 +585,24 @@ void QTrayLabel::handleTitleChange(void) * Overload this if you want a tool tip format that is different from the one * below i.e "Title [Class]". */ -void QTrayLabel::updateTitle() +void TQTrayLabel::updateTitle() { TRACE("%s", me()); - QString text = mTitle + " [" + mClass + "]"; - QToolTip::remove(this); - QToolTip::add(this, text); + TQString text = mTitle + " [" + mClass + "]"; + TQToolTip::remove(this); + TQToolTip::add(this, text); if (mBalloonTimeout) balloonText(); } -void QTrayLabel::handleIconChange(void) +void TQTrayLabel::handleIconChange(void) { char **window_icon = NULL; TRACE("%s", me()); if (mDockedWindow == None) return; - Display *display = QPaintDevice::x11AppDisplay(); + Display *display = TQPaintDevice::x11AppDisplay(); XWMHints *wm_hints = XGetWMHints(display, mDockedWindow); if (wm_hints != NULL) { @@ -618,12 +618,12 @@ void QTrayLabel::handleIconChange(void) wm_hints->icon_mask, NULL); XFree(wm_hints); } - QImage image; + TQImage image; if (!window_icon) { image = KGlobal::iconLoader()->loadIcon("question", KIcon::NoGroup, KIcon::SizeMedium); } - else image = QPixmap((const char **) window_icon).convertToImage(); + else image = TQPixmap((const char **) window_icon).convertToImage(); if (window_icon) XpmFree(window_icon); mAppIcon = image.smoothScale(24, 24); // why? setMinimumSize(mAppIcon.size()); @@ -635,19 +635,19 @@ void QTrayLabel::handleIconChange(void) /* * Overload this to possibly do operations on the pixmap before it is set */ -void QTrayLabel::updateIcon() +void TQTrayLabel::updateIcon() { TRACE("%s", me()); setPixmap(mCustomIcon.isEmpty() ? mAppIcon : mCustomIcon); erase(); - QPaintEvent pe(rect()); + TQPaintEvent pe(rect()); paintEvent(&pe); } /* * Mouse activity on our label. RightClick = Menu. LeftClick = Toggle Map */ -void QTrayLabel::mouseReleaseEvent(QMouseEvent * ev) +void TQTrayLabel::mouseReleaseEvent(TQMouseEvent * ev) { emit clicked(ev->button(), ev->globalPos()); } @@ -655,7 +655,7 @@ void QTrayLabel::mouseReleaseEvent(QMouseEvent * ev) /* * Track drag event */ -void QTrayLabel::dragEnterEvent(QDragEnterEvent *ev) +void TQTrayLabel::dragEnterEvent(TQDragEnterEvent *ev) { ev->accept(); map(); @@ -664,7 +664,7 @@ void QTrayLabel::dragEnterEvent(QDragEnterEvent *ev) /* * Event dispatcher */ -bool QTrayLabel::x11EventFilter(XEvent *ev) +bool TQTrayLabel::x11EventFilter(XEvent *ev) { XAnyEvent *event = (XAnyEvent *)ev; @@ -709,32 +709,32 @@ bool QTrayLabel::x11EventFilter(XEvent *ev) TRACE("%s Will analyze window 0x%x", me(), (int)((XMapEvent *)event)->window); // Check if this window is the soulmate we are looking for - Display *display = QPaintDevice::x11AppDisplay(); + Display *display = TQPaintDevice::x11AppDisplay(); Window w = XmuClientWindow(display, ((XMapEvent *) event)->window); if (!isNormalWindow(display, w)) return FALSE; if (!analyzeWindow(display, w, mPid, - QFileInfo(mProgName[0]).fileName().latin1())) return FALSE; + TQFileInfo(mProgName[0]).fileName().latin1())) return FALSE; // All right. Lets dock this baby setDockedWindow(w); return true; } -void QTrayLabel::minimizeEvent(void) +void TQTrayLabel::minimizeEvent(void) { TRACE("minimizeEvent"); if (mDockWhenMinimized) withdraw(); } -void QTrayLabel::destroyEvent(void) +void TQTrayLabel::destroyEvent(void) { TRACE("%s destroyEvent", me()); setDockedWindow(None); if (!mPid) undock(); } -void QTrayLabel::propertyChangeEvent(Atom property) +void TQTrayLabel::propertyChangeEvent(Atom property) { - Display *display = QPaintDevice::x11AppDisplay(); + Display *display = TQPaintDevice::x11AppDisplay(); static Atom WM_NAME = XInternAtom(display, "WM_NAME", True); static Atom WM_ICON = XInternAtom(display, "WM_ICON", True); static Atom WM_STATE = XInternAtom(display, "WM_STATE", True); @@ -771,7 +771,7 @@ void QTrayLabel::propertyChangeEvent(Atom property) } // Session Management -bool QTrayLabel::saveState(QSettings &settings) +bool TQTrayLabel::saveState(TQSettings &settings) { TRACE("%s saving state", me()); settings.writeEntry("/Application", mProgName.join(" ")); @@ -783,7 +783,7 @@ bool QTrayLabel::saveState(QSettings &settings) return true; } -bool QTrayLabel::restoreState(QSettings &settings) +bool TQTrayLabel::restoreState(TQSettings &settings) { TRACE("%s restoring state", me()); mCustomIcon = settings.readEntry("/CustomIcon"); @@ -802,7 +802,7 @@ bool QTrayLabel::restoreState(QSettings &settings) * the application really shows itself up before we do a scan (the reason * why we have 2s */ - if (!mPid) QTimer::singleShot(2000, this, SLOT(scanClients())); + if (!mPid) TQTimer::singleShot(2000, this, SLOT(scanClients())); return true; } |