Add preliminary taskbar task state support

pull/2/head
Timothy Pearson 11 years ago
parent 55c907ad0e
commit 0ef12d60c8

File diff suppressed because it is too large Load Diff

@ -118,6 +118,25 @@ TQStringList TaskbarConfig::i18nGroupModeList()
return i18nList;
}
// These are the strings that are actually stored in the config file.
const TQStringList& TaskbarConfig::showTaskStatesList()
{
static TQStringList list(
TQStringList() << I18N_NOOP("Any") << I18N_NOOP("Only Stopped")
<< I18N_NOOP("Only Running"));
return list;
}
// Get a translated version of the above string list.
TQStringList TaskbarConfig::i18nShowTaskStatesList()
{
TQStringList i18nList;
for( TQStringList::ConstIterator it = showTaskStatesList().begin(); it != showTaskStatesList().end(); ++it ) {
i18nList << i18n((*it).latin1());
}
return i18nList;
}
TaskbarConfig::TaskbarConfig(TQWidget *parent, const char* name, const TQStringList&)
: KCModule(TaskBarFactory::instance(), parent, name)
{
@ -151,6 +170,7 @@ TaskbarConfig::TaskbarConfig(TQWidget *parent, const char* name, const TQStringL
m_widget->kcfg_MiddleButtonAction->insertStringList(list);
m_widget->kcfg_RightButtonAction->insertStringList(list);
m_widget->kcfg_GroupTasks->insertStringList(i18nGroupModeList());
m_widget->kcfg_ShowTaskStates->insertStringList(i18nShowTaskStatesList());
connect(m_widget->kcfg_GroupTasks, TQT_SIGNAL(activated(int)),
this, TQT_SLOT(slotUpdateComboBox()));

@ -73,6 +73,8 @@ private:
static TQStringList i18nActionList();
static const TQStringList& groupModeList();
static TQStringList i18nGroupModeList();
static const TQStringList& showTaskStatesList();
static TQStringList i18nShowTaskStatesList();
TaskbarConfigUI *m_widget;
};

@ -107,13 +107,40 @@ By default the taskbar groups windows when it is full.</string>
</widget>
<widget class="TQLabel" row="7" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>groupTasksLabel</cstring>
<cstring>showTaskStatesLabel</cstring>
</property>
<property name="text">
<string>&amp;Group similar tasks:</string>
</property>
<property name="buddy" stdset="0">
<cstring>kcfg_GroupTasks</cstring>
<cstring>kcfg_ShowTaskStates</cstring>
</property>
</widget>
<widget class="TQComboBox" row="8" column="2">
<property name="name">
<cstring>kcfg_ShowTaskStates</cstring>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="whatsThis" stdset="0">
<string>The taskbar can show and/or hide tasks based on their current process state. Select &lt;em&gt;Any&lt;/em&gt; to show all tasks regardless of current state.</string>
</property>
</widget>
<widget class="TQLabel" row="8" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>groupTasksLabel</cstring>
</property>
<property name="text">
<string>&amp;Show tasks with state:</string>
</property>
<property name="buddy" stdset="0">
<cstring>kcfg_ShowTaskStates</cstring>
</property>
</widget>
<widget class="TQCheckBox" row="4" column="0" rowspan="1" colspan="3">
@ -161,12 +188,12 @@ By default this option is selected.</string>
By default, this option is selected and all windows are shown.</string>
</property>
</widget>
<widget class="TQComboBox" row="8" column="2">
<widget class="TQComboBox" row="9" column="2">
<property name="name">
<cstring>appearance</cstring>
</property>
</widget>
<widget class="TQLabel" row="8" column="0" rowspan="1" colspan="2">
<widget class="TQLabel" row="9" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>textLabel1</cstring>
</property>
@ -177,7 +204,7 @@ By default, this option is selected and all windows are shown.</string>
<cstring>appearance</cstring>
</property>
</widget>
<widget class="TQCheckBox" row="9" column="0" rowspan="1" colspan="2">
<widget class="TQCheckBox" row="10" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>kcfg_UseCustomColors</cstring>
</property>
@ -191,7 +218,7 @@ By default, this option is selected and all windows are shown.</string>
<bool>true</bool>
</property>
</widget>
<widget class="TQLayoutWidget" row="10" column="0" rowspan="1" colspan="3">
<widget class="TQLayoutWidget" row="11" column="0" rowspan="1" colspan="3">
<property name="name">
<cstring>layout9</cstring>
</property>
@ -199,23 +226,17 @@ By default, this option is selected and all windows are shown.</string>
<property name="name">
<cstring>unnamed</cstring>
</property>
<spacer row="1" column="2">
<widget class="TQLabel" row="0" column="0">
<property name="name">
<cstring>spacer11_2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
<cstring>inactiveTaskTextColorLabel</cstring>
</property>
<property name="sizeType">
<enum>Expanding</enum>
<property name="text">
<string>Inacti&amp;ve task text color:</string>
</property>
<property name="sizeHint">
<size>
<width>191</width>
<height>20</height>
</size>
<property name="buddy" stdset="0">
<cstring>kcfg_InactiveTaskTextColor</cstring>
</property>
</spacer>
</widget>
<widget class="KColorButton" row="0" column="1">
<property name="name">
<cstring>kcfg_InactiveTaskTextColor</cstring>
@ -241,26 +262,18 @@ By default, this option is selected and all windows are shown.</string>
</size>
</property>
</spacer>
<widget class="KColorButton" row="2" column="1">
<widget class="TQLabel" row="0" column="3">
<property name="name">
<cstring>kcfg_TaskBackgroundColor</cstring>
</property>
<property name="text">
<string></string>
</property>
</widget>
<widget class="TQLabel" row="2" column="0">
<property name="name">
<cstring>taskBackgroundColorLabel</cstring>
<cstring>activeTaskTextColorLabel</cstring>
</property>
<property name="text">
<string>&amp;Background color:</string>
<string>Active task te&amp;xt color:</string>
</property>
<property name="buddy" stdset="0">
<cstring>kcfg_TaskBackgroundColor</cstring>
<cstring>kcfg_ActiveTaskTextColor</cstring>
</property>
</widget>
<widget class="KColorButton" row="1" column="1">
<widget class="KColorButton" row="0" column="4">
<property name="name">
<cstring>kcfg_ActiveTaskTextColor</cstring>
</property>
@ -268,29 +281,43 @@ By default, this option is selected and all windows are shown.</string>
<string></string>
</property>
</widget>
<widget class="TQLabel" row="0" column="0">
<spacer row="0" column="5">
<property name="name">
<cstring>inactiveTaskTextColorLabel</cstring>
<cstring>spacer11_2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>191</width>
<height>20</height>
</size>
</property>
</spacer>
<widget class="TQLabel" row="0" column="6">
<property name="name">
<cstring>taskBackgroundColorLabel</cstring>
</property>
<property name="text">
<string>Inacti&amp;ve task text color:</string>
<string>&amp;Background color:</string>
</property>
<property name="buddy" stdset="0">
<cstring>kcfg_InactiveTaskTextColor</cstring>
<cstring>kcfg_TaskBackgroundColor</cstring>
</property>
</widget>
<widget class="TQLabel" row="1" column="0">
<widget class="KColorButton" row="0" column="7">
<property name="name">
<cstring>activeTaskTextColorLabel</cstring>
<cstring>kcfg_TaskBackgroundColor</cstring>
</property>
<property name="text">
<string>Active task te&amp;xt color:</string>
</property>
<property name="buddy" stdset="0">
<cstring>kcfg_ActiveTaskTextColor</cstring>
<string></string>
</property>
</widget>
<spacer row="2" column="2">
<spacer row="0" column="8">
<property name="name">
<cstring>spacer12</cstring>
</property>
@ -471,6 +498,7 @@ By default, this option is selected and all windows are shown.</string>
<tabstop>kcfg_ShowIcon</tabstop>
<tabstop>kcfg_ShowWindowListBtn</tabstop>
<tabstop>kcfg_GroupTasks</tabstop>
<tabstop>kcfg_ShowTaskStates</tabstop>
<tabstop>appearance</tabstop>
<tabstop>kcfg_UseCustomColors</tabstop>
<tabstop>kcfg_InactiveTaskTextColor</tabstop>

@ -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();

@ -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

@ -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>

@ -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
{

@ -65,6 +65,7 @@ public:
bool onCurrentDesktop();
bool isIconified();
bool isOnScreen();
bool isHidden();
TQString id();
int desktop();

@ -15,6 +15,7 @@ class KWinInterface : virtual public DCOPObject
virtual ASYNC killWindowId(unsigned long winId) = 0;
virtual ASYNC suspendWindowId(unsigned long winId) = 0;
virtual ASYNC resumeWindowId(unsigned long winId) = 0;
virtual bool isResumeableWindowID(unsigned long winId) = 0;
virtual void refresh() = 0;
virtual void doNotManage(TQString)= 0;
virtual void showWindowMenuAt(unsigned long winId, int x, int y)= 0;

@ -1974,6 +1974,37 @@ void Workspace::resumeWindowId( Window window_to_resume )
}
bool Workspace::isResumeableWindowID( Window window_to_check )
{
if( window_to_check == None )
return false;
Window window = window_to_check;
Client* client = NULL;
for(;;)
{
client = findClient( FrameIdMatchPredicate( window ));
if( client != NULL ) // found the client
break;
Window parent = NULL;
Window root = NULL;
Window* children = NULL;
unsigned int children_count;
XQueryTree( tqt_xdisplay(), window, &root, &parent, &children, &children_count );
if( children != NULL )
XFree( children );
if( window == root ) // we didn't find the client, probably an override-redirect window
break;
window = parent; // go up
if( window == NULL )
break;
}
if( client != NULL )
return client->isResumeable();
else
return false;
}
void Workspace::sendPingToWindow( Window window, Time timestamp )
{
rootInfo->sendPing( window, timestamp );

@ -96,9 +96,10 @@ class Workspace : public TQObject, public KWinInterface, public KDecorationDefin
/**
* @internal
*/
void killWindowId( Window window);
void suspendWindowId( Window window);
void resumeWindowId( Window window);
void killWindowId( Window window );
void suspendWindowId( Window window );
void resumeWindowId( Window window );
bool isResumeableWindowID( Window window );
void killWindow() { slotKillWindow(); }
void suspendWindow() { slotSuspendWindow(); }

Loading…
Cancel
Save