summaryrefslogtreecommitdiffstats
path: root/kicker
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-12-23 17:29:08 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-12-23 17:29:08 -0600
commit0ef12d60c85f58af9052d83ce1945d71afe16cb4 (patch)
treea82f5c57d032227ed0a520f5771ec37f10779d28 /kicker
parent55c907ad0e031f2ceddb2693761b747395137ac0 (diff)
downloadtdebase-0ef12d60c85f58af9052d83ce1945d71afe16cb4.tar.gz
tdebase-0ef12d60c85f58af9052d83ce1945d71afe16cb4.zip
Add preliminary taskbar task state support
Diffstat (limited to 'kicker')
-rw-r--r--kicker/taskbar/taskbar.cpp24
-rw-r--r--kicker/taskbar/taskbar.h11
-rw-r--r--kicker/taskbar/taskbar.kcfg16
-rw-r--r--kicker/taskbar/taskcontainer.cpp118
-rw-r--r--kicker/taskbar/taskcontainer.h1
5 files changed, 158 insertions, 12 deletions
diff --git a/kicker/taskbar/taskbar.cpp b/kicker/taskbar/taskbar.cpp
index ac8753caa..dd66c22b2 100644
--- a/kicker/taskbar/taskbar.cpp
+++ b/kicker/taskbar/taskbar.cpp
@@ -53,12 +53,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
TaskBar::TaskBar( TQWidget *parent, const char *name )
: Panner( parent, name ),
m_showAllWindows(false),
+ m_cycleWheel(false),
m_currentScreen(-1),
m_showOnlyCurrentScreen(false),
m_sortByDesktop(false),
- m_cycleWheel(false),
m_showIcon(false),
m_showOnlyIconified(false),
+ m_showTaskStates(0),
m_textShadowEngine(0),
m_ignoreUpdates(false),
m_relayoutTimer(0, "TaskBar::m_relayoutTimer")
@@ -237,12 +238,14 @@ void TaskBar::configure()
bool wasCycleWheel = m_cycleWheel;
bool wasShowIcon = m_showIcon;
bool wasShowOnlyIconified = m_showOnlyIconified;
+ int wasShowTaskStates = m_showTaskStates;
m_showAllWindows = TaskBarSettings::showAllWindows();
m_sortByDesktop = m_showAllWindows && TaskBarSettings::sortByDesktop();
m_showIcon = TaskBarSettings::showIcon();
m_showOnlyIconified = TaskBarSettings::showOnlyIconified();
m_cycleWheel = TaskBarSettings::cycleWheel();
+ m_showTaskStates = TaskBarSettings::showTaskStates();
m_currentScreen = -1; // Show all screens or re-get our screen
m_showOnlyCurrentScreen = (TaskBarSettings::showCurrentScreenOnly() &&
@@ -266,7 +269,8 @@ void TaskBar::configure()
wasSortByDesktop != m_sortByDesktop ||
wasShowIcon != m_showIcon ||
wasCycleWheel != m_cycleWheel ||
- wasShowOnlyIconified != m_showOnlyIconified)
+ wasShowOnlyIconified != m_showOnlyIconified ||
+ wasShowTaskStates != m_showTaskStates)
{
// relevant settings changed, update our task containers
for (TaskContainer::Iterator it = containers.begin();
@@ -597,7 +601,8 @@ void TaskBar::windowChanged(Task::Ptr task)
if (!container ||
(!m_showAllWindows &&
!container->onCurrentDesktop() &&
- !container->isVisibleTo(this)))
+ !container->isVisibleTo(this)) ||
+ container->isHidden())
{
return;
}
@@ -927,7 +932,10 @@ int TaskBar::containerCount() const
if ((m_showAllWindows || (*it)->onCurrentDesktop()) &&
((showScreen() == -1) || ((*it)->isOnScreen())))
{
- i++;
+ if (!(*it)->isHidden())
+ {
+ i++;
+ }
}
}
@@ -945,7 +953,10 @@ int TaskBar::taskCount() const
if ((m_showAllWindows || (*it)->onCurrentDesktop()) &&
((showScreen() == -1) || ((*it)->isOnScreen())))
{
- i += (*it)->filteredTaskCount();
+ if (!(*it)->isHidden())
+ {
+ i += (*it)->filteredTaskCount();
+ }
}
}
@@ -1048,7 +1059,8 @@ TaskContainer::List TaskBar::filteredContainers()
TaskContainer* c = *it;
if ((m_showAllWindows || c->onCurrentDesktop()) &&
(!m_showOnlyIconified || c->isIconified()) &&
- ((showScreen() == -1) || c->isOnScreen()))
+ ((showScreen() == -1) || c->isOnScreen()) &&
+ (!c->isHidden()))
{
list.append(c);
c->show();
diff --git a/kicker/taskbar/taskbar.h b/kicker/taskbar/taskbar.h
index bb4167166..dc75fab9c 100644
--- a/kicker/taskbar/taskbar.h
+++ b/kicker/taskbar/taskbar.h
@@ -110,13 +110,14 @@ private:
bool blocklayout;
bool m_showAllWindows;
- bool m_cycleWheel;
+ bool m_cycleWheel;
// The screen to show, -1 for all screens
int m_currentScreen;
bool m_showOnlyCurrentScreen;
bool m_sortByDesktop;
bool m_showIcon;
bool m_showOnlyIconified;
+ int m_showTaskStates;
ArrowType arrowType;
TaskContainer::List containers;
TaskContainer::List m_hiddenContainers;
@@ -127,10 +128,10 @@ private:
bool isGrouping;
void reGroup();
KGlobalAccel* keys;
- KTextShadowEngine* m_textShadowEngine;
- TQTimer m_relayoutTimer;
- bool m_ignoreUpdates;
- TQImage m_blendGradient;
+ KTextShadowEngine* m_textShadowEngine;
+ bool m_ignoreUpdates;
+ TQTimer m_relayoutTimer;
+ TQImage m_blendGradient;
};
#endif
diff --git a/kicker/taskbar/taskbar.kcfg b/kicker/taskbar/taskbar.kcfg
index 0d11b4a60..1ac6dadbf 100644
--- a/kicker/taskbar/taskbar.kcfg
+++ b/kicker/taskbar/taskbar.kcfg
@@ -37,6 +37,22 @@
<label>Group similar tasks:</label>
<whatsthis>The taskbar can group similar windows into single buttons. When one of these window group buttons are clicked on a menu appears showing all the windows in that group. This can be especially useful with the <em>Show all windows</em> option.\n\nYou can set the taskbar to <strong>Never</strong> group windows, to <strong>Always</strong> group windows or to group windows only <strong>When the Taskbar is Full</strong>.\n\nBy default the taskbar groups windows when it is full.</whatsthis>
</entry>
+ <entry key="ShowTaskStates" type="Enum" >
+ <choices>
+ <choice name="ShowAll">
+ <label>Any</label>
+ </choice>
+ <choice name="ShowStopped">
+ <label>Only Stopped</label>
+ </choice>
+ <choice name="ShowRunning">
+ <label>Only Running</label>
+ </choice>
+ </choices>
+ <default>ShowAll</default>
+ <label>Show tasks with state:</label>
+ <whatsthis>The taskbar can show and/or hide tasks based on their current process state. Select <em>Any</em> to show all tasks regardless of current state.</whatsthis>
+ </entry>
<entry key="SortByDesktop" type="Bool" >
<default>true</default>
<label>Sort windows by desktop</label>
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
{
diff --git a/kicker/taskbar/taskcontainer.h b/kicker/taskbar/taskcontainer.h
index 8dfdf6d2d..766d37639 100644
--- a/kicker/taskbar/taskcontainer.h
+++ b/kicker/taskbar/taskcontainer.h
@@ -65,6 +65,7 @@ public:
bool onCurrentDesktop();
bool isIconified();
bool isOnScreen();
+ bool isHidden();
TQString id();
int desktop();