From 88fbf7e81a6ab317262bd97875a0296f59287586 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Thu, 26 Mar 2020 15:10:12 +0900 Subject: 1) Additional work on tq app -> tde app translation. 2) Make sure to exit app after restore if no app window can be grabbed 3) Save state only for known applications (app with empty name will not be saved and restored) Signed-off-by: Michele Calgaro --- src/qtraylabel.cpp | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) (limited to 'src/qtraylabel.cpp') 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) -- cgit v1.2.1