diff options
Diffstat (limited to 'src/qtraylabel.cpp')
-rw-r--r-- | src/qtraylabel.cpp | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/src/qtraylabel.cpp b/src/qtraylabel.cpp index a74ba48..13c020d 100644 --- a/src/qtraylabel.cpp +++ b/src/qtraylabel.cpp @@ -83,7 +83,7 @@ const char *TQTrayLabel::me(void) const { static char temp[100]; snprintf(temp, sizeof(temp), "(%s,PID=%i,WID=0x%x)", - mProgName[0].local8Bit().data(), mPid, (unsigned) mDockedWindow); + appName().local8Bit().data(), mPid, (unsigned) mDockedWindow); return temp; } @@ -98,8 +98,10 @@ 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] = TQFileInfo(pname[0]).absFilePath(); // convert to absolute + if (pname[0].at(0) != '/' && pname[0].find('/', 1) > 0) + { + mProgName.push_front(TQFileInfo(pname[0]).absFilePath()); // convert to absolute + } initialize(); } @@ -113,6 +115,18 @@ TQTrayLabel::~TQTrayLabel() map(); } +void TQTrayLabel::setAppName(const TQString &prog) +{ + if (mProgName.count() == 0) + { + mProgName.push_front(prog); + } + else + { + mProgName[0] = prog; + } +} + /* * Scans the windows in the desktop and checks if a window exists that we might * be interested in @@ -122,7 +136,7 @@ void TQTrayLabel::scanClients() Window r, parent, *children; unsigned nchildren = 0; Display *display = TQPaintDevice::x11AppDisplay(); - TQString ename = TQFileInfo(mProgName[0]).fileName(); // strip out the path + TQString ename = TQFileInfo(appName()).fileName(); // strip out the path XQueryTree(display, tqt_xrootwin(), &r, &parent, &children, &nchildren); TRACE("%s nchildren=%i", me(), nchildren); @@ -671,7 +685,10 @@ bool TQTrayLabel::x11EventFilter(XEvent *ev) if (event->window == mSysTray) { - if (event->type != DestroyNotify) return FALSE; // not interested in others + if (event->type != DestroyNotify) + { + return false; // not interested in others + } emit sysTrayDestroyed(); mSysTray = None; TRACE("%s SystemTray disappeared. Starting timer", me()); @@ -713,8 +730,10 @@ bool TQTrayLabel::x11EventFilter(XEvent *ev) Display *display = TQPaintDevice::x11AppDisplay(); Window w = XmuClientWindow(display, ((XMapEvent *) event)->window); if (!isNormalWindow(display, w)) return FALSE; - if (!analyzeWindow(display, w, mPid, - TQFileInfo(mProgName[0]).fileName().local8Bit())) return FALSE; + if (!analyzeWindow(display, w, mPid, TQFileInfo(appName()).fileName().local8Bit())) + { + return false; + } // All right. Lets dock this baby setDockedWindow(w); return true; @@ -772,8 +791,13 @@ void TQTrayLabel::propertyChangeEvent(Atom property) } // Session Management -void TQTrayLabel::saveState(TDEConfig *config) +bool TQTrayLabel::saveState(TDEConfig *config) { + if (appName().isEmpty()) + { + return false; + } + TRACE("%s saving state", me()); config->writeEntry("Application", mProgName.join(" ")); config->writeEntry("BalloonTimeout", mBalloonTimeout); @@ -781,6 +805,7 @@ void TQTrayLabel::saveState(TDEConfig *config) config->writeEntry("DockWhenMinimized", mDockWhenMinimized); config->writeEntry("SkipTaskbar", mSkippingTaskbar); config->writeEntry("Withdraw", mWithdrawn); + return true; } bool TQTrayLabel::restoreState(TDEConfig *config) |