summaryrefslogtreecommitdiffstats
path: root/src/qtraylabel.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2020-03-26 15:10:12 +0900
committerMichele Calgaro <[email protected]>2020-03-26 15:10:12 +0900
commit88fbf7e81a6ab317262bd97875a0296f59287586 (patch)
tree0effe4e64f5cdf3c0aa42e8ca8096cca8b6ddc89 /src/qtraylabel.cpp
parent5c2a45303ead893a78c69ddbef21d5acedf654ff (diff)
downloadtdedocker-88fbf7e81a6ab317262bd97875a0296f59287586.tar.gz
tdedocker-88fbf7e81a6ab317262bd97875a0296f59287586.zip
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 <[email protected]>
Diffstat (limited to 'src/qtraylabel.cpp')
-rw-r--r--src/qtraylabel.cpp41
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)