diff options
author | Darrell Anderson <[email protected]> | 2012-12-26 13:35:30 -0600 |
---|---|---|
committer | Darrell Anderson <[email protected]> | 2012-12-26 13:35:30 -0600 |
commit | 4d3d2420430fb53000ceda25ae7498e49f6e94b2 (patch) | |
tree | f350afc9cba3f615fa3c982b73e57b2272fa8a47 /kicker/taskbar/taskcontainer.cpp | |
parent | f5c55ca4ce9587598ce81399c2196c876ec55942 (diff) | |
parent | 0ef12d60c85f58af9052d83ce1945d71afe16cb4 (diff) | |
download | tdebase-4d3d2420430fb53000ceda25ae7498e49f6e94b2.tar.gz tdebase-4d3d2420430fb53000ceda25ae7498e49f6e94b2.zip |
Merge branch 'master' of http://scm.trinitydesktop.org/scm/git/tdebase
Diffstat (limited to 'kicker/taskbar/taskcontainer.cpp')
-rw-r--r-- | kicker/taskbar/taskcontainer.cpp | 118 |
1 files changed, 117 insertions, 1 deletions
diff --git a/kicker/taskbar/taskcontainer.cpp b/kicker/taskbar/taskcontainer.cpp index ae50dc6cd..79aca98e8 100644 --- a/kicker/taskbar/taskcontainer.cpp +++ b/kicker/taskbar/taskcontainer.cpp @@ -34,6 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <tqstyle.h> #include <tqstylesheet.h> #include <tqtooltip.h> +#include <tqfile.h> #include <kapplication.h> #include <kdebug.h> @@ -43,6 +44,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <kiconloader.h> #include <kimageeffect.h> +#ifdef Q_WS_X11 +#include <X11/Xlib.h> +#include <netwm.h> +#include <fixx11h.h> +#endif + #include "global.h" #include "kickerSettings.h" #include "paneldrag.h" @@ -54,6 +61,57 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "taskcontainer.h" #include "taskcontainer.moc" +static Bool netwm_atoms_created = False; +static Atom net_wm_pid = 0; + +static const int netAtomCount = 1; +static void create_atoms(Display *d) { + static const char * const names[netAtomCount] = + { + "_NET_WM_PID" + }; + + Atom atoms[netAtomCount], *atomsp[netAtomCount] = + { + &net_wm_pid + }; + + assert( !netwm_atoms_created ); + + int i = netAtomCount; + while (i--) + atoms[i] = 0; + + XInternAtoms(d, (char **) names, netAtomCount, False, atoms); + + i = netAtomCount; + while (i--) + *atomsp[i] = atoms[i]; + + netwm_atoms_created = True; +} + +bool is_process_resumable(pid_t pid) { + TQFile procStatFile(TQString("/proc/%1/stat").arg(pid)); + if (procStatFile.open(IO_ReadOnly)) { + TQByteArray statRaw = procStatFile.readAll(); + procStatFile.close(); + TQString statString(statRaw); + TQStringList statFields = TQStringList::split(" ", statString, TRUE); + TQString tcomm = statFields[1]; + TQString state = statFields[2]; + if( state == "T" ) { + return true; + } + else { + return false; + } + } + else { + return false; + } +} + TaskContainer::TaskContainer(Task::Ptr task, TaskBar* bar, TQWidget *parent, const char *name) : TQToolButton(parent, name), @@ -117,6 +175,8 @@ TaskContainer::TaskContainer(Startup::Ptr startup, PixmapList& startupFrames, void TaskContainer::init() { + if (!netwm_atoms_created) create_atoms(TQPaintDevice::x11AppDisplay()); + setWFlags(TQt::WNoAutoErase); setBackgroundMode(NoBackground); animBg = TQPixmap(16, 16); @@ -432,6 +492,11 @@ bool TaskContainer::isEmpty() return (tasks.isEmpty() && !m_startup); } +bool TaskContainer::isHidden() +{ + return ((m_filteredTasks.count() < 1) && !m_startup); +} + TQString TaskContainer::id() { return sid; @@ -1477,7 +1542,58 @@ void TaskContainer::updateFilteredTaskList() if ((taskBar->showAllWindows() || t->isOnCurrentDesktop()) && (!TaskBarSettings::showOnlyIconified() || t->isIconified())) { - m_filteredTasks.append(t); + pid_t pid = 0; +#ifdef Q_WS_X11 + Atom type_ret; + int format_ret; + unsigned long nitems_ret = 0, unused = 0; + unsigned char *data_ret = 0; + if (XGetWindowProperty(TQPaintDevice::x11AppDisplay(), t->window(), net_wm_pid, 0l, 1l, + False, XA_CARDINAL, &type_ret, &format_ret, + &nitems_ret, &unused, &data_ret) == Success) { + if (type_ret == XA_CARDINAL && format_ret == 32 && nitems_ret == 1) { + pid = *((long *) data_ret); + } + if ( data_ret ) + XFree(data_ret); + } +#endif + if (pid < 0) { + m_filteredTasks.append(t); + } + else if (TaskBarSettings::showTaskStates() != TaskBarSettings::ShowAll) { + if (is_process_resumable(pid)) { + if (TaskBarSettings::showTaskStates() == TaskBarSettings::ShowAll) { + m_filteredTasks.append(t); + } + else if (TaskBarSettings::showTaskStates() == TaskBarSettings::ShowStopped) { + m_filteredTasks.append(t); + } + else if (TaskBarSettings::showTaskStates() == TaskBarSettings::ShowRunning) { + t->publishIconGeometry( TQRect()); + } + else { + m_filteredTasks.append(t); + } + } + else { + if (TaskBarSettings::showTaskStates() == TaskBarSettings::ShowAll) { + m_filteredTasks.append(t); + } + else if (TaskBarSettings::showTaskStates() == TaskBarSettings::ShowStopped) { + t->publishIconGeometry( TQRect()); + } + else if (TaskBarSettings::showTaskStates() == TaskBarSettings::ShowRunning) { + m_filteredTasks.append(t); + } + else { + m_filteredTasks.append(t); + } + } + } + else { + m_filteredTasks.append(t); + } } else { |