From 0ef12d60c85f58af9052d83ce1945d71afe16cb4 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 23 Dec 2012 17:29:08 -0600 Subject: Add preliminary taskbar task state support --- kcontrol/kicker/menutab.ui | 1298 +++++++++++++++++++------------------- kcontrol/taskbar/kcmtaskbar.cpp | 20 + kcontrol/taskbar/kcmtaskbar.h | 2 + kcontrol/taskbar/kcmtaskbarui.ui | 114 ++-- kicker/taskbar/taskbar.cpp | 24 +- kicker/taskbar/taskbar.h | 11 +- kicker/taskbar/taskbar.kcfg | 16 + kicker/taskbar/taskcontainer.cpp | 118 +++- kicker/taskbar/taskcontainer.h | 1 + twin/KWinInterface.h | 1 + twin/workspace.cpp | 31 + twin/workspace.h | 7 +- 12 files changed, 939 insertions(+), 704 deletions(-) diff --git a/kcontrol/kicker/menutab.ui b/kcontrol/kicker/menutab.ui index 73130771b..49c2502b6 100644 --- a/kcontrol/kicker/menutab.ui +++ b/kcontrol/kicker/menutab.ui @@ -1,694 +1,656 @@ -MenuTabBase - - - MenuTabBase - - - - 0 - 0 - 923 - 649 - - - - - unnamed - - - 0 - - - - layout5 - - - - unnamed - - - - textLabel1 - - - Start menu style: - - - comboMenuStyle - - - - - - Kickoff - - - - - Trinity Classic - - - - m_comboMenuStyle - - - - - spacer4 - - - Horizontal - - - Expanding - - - - 40 - 20 - - - - - - - - m_kmenuGroup - - - TDE Menu - - - - unnamed - - - - layout7 - - - - unnamed - - - - m_openOnHover - - - Open menu on mouse hover - - - - - kcfg_MenuEntryFormat - - - 0 - - - Menu item format: - - - true - - - Here you can choose how menu entries are shown. - - - - unnamed - - - - m_formatSimple - - - &Name only - - - When this option is selected, items in the TDE Menu will appear with the application's name next to the icon. - - - - - m_formatNameDesc - - - Name - &Description - - - true - - - When this option is selected, items in the TDE Menu will appear with the application's name and a brief description next to the icon. - - - - - m_formatDescOnly - - - D&escription only - - - When this option is selected, items in the TDE Menu will appear with the application's brief description next to the icon. - - - - - m_formDescName - - - NoFocus - - - Des&cription (Name) - - - When this option is selected, items in the TDE Menu will appear with a brief description and the application's name in brackets next to the icon. - - - - - - - kcfg_UseSidePixmap - - - Show side ima&ge - - - true - - - <qt>When this option is selected an image will appear down the left-hand side of the TDE Menu. The image will be tinted according to your color settings. - - <p><b>Tip</b>: You can customize the image that appears in the TDE Menu by putting an image file called kside.png and a tileable image file called kside_tile.png in $TDEHOME/share/apps/kicker/pics.</qt> - - - - - spacer8 - - - Vertical - - - MinimumExpanding - - - - 20 - 0 - - - - - - kcfg_ShowKMenuText - - - Display text in TDE Menu button - - - true - - - <qt>When this option is selected the text below will be shown in the TDE Menu button. - - - - - unnamed - - - 0 - - - - kcfg_KMenuText - - - 35 - - - - - TextLabel1_3_3_2 - - - - 4 - 1 - 0 - 0 - - - - TDE Menu button icon: - - - - - btnCustomKMenuIcon - - - - 0 - 0 - 0 - 0 - - - - - 26 - 26 - - - - - 26 - 26 - - - - false - - - - - - - - TextLabel1_3_3_2 - - - - 4 - 1 - 0 - 0 - - - - Text: - - - - - TextLabel1_3_3_2 - - - - 4 - 1 - 0 - 0 - - - - Font: - - - - - kcfg_ButtonFont - - - - - spacer6 - - - Vertical - - - Expanding - - - - 20 - 20 - - - - - - - spacer8 - - - Vertical - - - MinimumExpanding - - - - 20 - 0 - - - - - - - m_editKMenuButton - - - Edit &TDE Menu - - - Start the editor for the TDE Menu. Here you can add, edit, remove and hide applications. - - - - - - - - Optional Menus - - - true - - - true - - - - m_subMenus - - - - 7 - 7 - 0 - 1 - - - - - 0 - 0 - - - - true - - - This is a list of the dynamic menus that can be displayed in the TDE menu in addition to the normal applications. Use the checkboxes to add or remove menus. - - - - - + MenuTabBase + + + MenuTabBase + + + + 0 + 0 + 923 + 649 + + + unnamed 0 - - + + + + layout5 + + - m_browserGroup + unnamed - - QuickBrowser Menus + + + textLabel1 - - - unnamed + + TDE menu style: + + + comboMenuStyle + + + + + + Kickoff + + + + + Trinity Classic - + + + m_comboMenuStyle + + + + + spacer4 + + + Horizontal + + + Expanding + + + + 40 + 20 + + + + + + + + m_kmenuGroup + + + TDE Menu + + + + unnamed + + - Layout3 + layout7 - + unnamed - - - m_maxQuickBrowserItemsLabel - - - Ma&ximum number of entries: - - - kcfg_MaxEntries2 - - - When browsing directories that contain a lot of files, the QuickBrowser can sometimes hide your whole desktop. Here you can limit the number of entries shown at a time in the QuickBrowser. This is particularly useful for low screen resolutions. - + + + kcfg_MenuEntryFormat + + + 0 + + + Menu item format: + + + true + + + Here you can choose how menu entries are shown. + + + + unnamed + + + + m_formatSimple + + + &Name only + + + When this option is selected, items in the TDE Menu will appear with the application's name next to the icon. + + + + + m_formatNameDesc + + + Name - &Description + + + true + + + When this option is selected, items in the TDE Menu will appear with the application's name and a brief description next to the icon. + + + + + m_formatDescOnly + + + D&escription only + + + When this option is selected, items in the TDE Menu will appear with the application's brief description next to the icon. + + + + + m_formDescName + + + NoFocus + + + Des&cription (Name) + + + When this option is selected, items in the TDE Menu will appear with a brief description and the application's name in brackets next to the icon. + + + - - - kcfg_MaxEntries2 - - - 30 - - - 10 - - - 100 + + + m_editKMenuButton + + + Edit &TDE Menu + + + Start the editor for the TDE Menu. Here you can add, edit, remove and hide applications. + + + + + Spacer10 + + + Vertical + + + Expanding + + + + 20 + 0 + + + + + + + + + Optional Menus - - When browsing directories that contain a lot of files, the QuickBrowser can sometimes hide your whole desktop. Here you can limit the number of entries shown at a time in the QuickBrowser. This is particularly useful for low screen resolutions. + + true - - - - - - kcfg_ShowHiddenFiles - - - Show hidden fi&les - - + true - - - If this option is enabled, hidden files (i.e. files beginning with a dot) will be shown in the QuickBrowser menus. - - - + + - Spacer7 + m_subMenus - - Horizontal + + + 7 + 7 + 0 + 1 + - - Expanding - - + - 20 + 0 0 - - - - - - m_recentGroup - - - Recent Documents Menu - - + + true + + + This is a list of the dynamic menus that can be displayed in the TDE menu in addition to the normal applications. Use the checkboxes to add or remove menus. + + + - unnamed + Layout5 - - - Layout3 - - + + + + m_openOnHover + + + Open menu on mouse hover + + + + + kcfg_UseSidePixmap + + + Show side ima&ge + + + true + + + <qt>When this option is selected an image will appear down the left-hand side of the TDE Menu. The image will be tinted according to your color settings. + + <p><b>Tip</b>: You can customize the image that appears in the TDE Menu by putting an image file called kside.png and a tileable image file called kside_tile.png in $TDEHOME/share/apps/kicker/pics.</qt> + + + + + kcfg_ShowKMenuText + + + Display text in menu button + + + true + + + <qt>When this option is selected the text below will be shown in the TDE Menu button. + + + unnamed - + + 0 + + - m_maxRecentDocumentsItemsLabel + kcfg_KMenuText + + + 35 + + + + + TextLabel1_3_3_2 + + + + 4 + 1 + 0 + 0 + - Ma&ximum number of entries: + Menu button icon: - - kcfg_MaxEntries2 + + + + btnCustomKMenuIcon - - This sets the maximum number of recently accessed documents stored for fast retrieval. + + + 0 + 0 + 0 + 0 + + + + + 26 + 26 + + + + + 26 + 26 + + + + false + + + - + - maxrecentdocs + TextLabel1_3_3_2 - - 10 + + + 4 + 1 + 0 + 0 + - - 0 + + Text: - - 100 + + + + TextLabel1_3_3_2 - - This sets the maximum number of recently accessed documents stored for fast retrieval. + + + 4 + 1 + 0 + 0 + + + + Font: - - - - - Spacer7 - - - Horizontal - - - Expanding - - - - 20 - 0 - - - - + + + kcfg_ButtonFont + + + + + spacer6 + + + Vertical + + + Expanding + + + + 20 + 20 + + + + + + + spacer8 + + + Vertical + + + MinimumExpanding + + + + 20 + 0 + + + + + + - - - m_pRecentOrderGroup - - - QuickStart Menu Items - - - + + unnamed - - + + + 0 + + - Layout4 + m_browserGroup + + + QuickBrowser Menus - + unnamed - + - TextLabel2 - - - Maxim&um number of entries: - - - kcfg_NumVisibleEntries - - - This option allows you to define the maximum number of applications that should be displayed in the QuickStart menu area. + Layout3 + + + unnamed + + + + m_maxQuickBrowserItemsLabel + + + Ma&ximum number of entries: + + + kcfg_MaxEntries2 + + + When browsing directories that contain a lot of files, the QuickBrowser can sometimes hide your whole desktop. Here you can limit the number of entries shown at a time in the QuickBrowser. This is particularly useful for low screen resolutions. + + + + + kcfg_MaxEntries2 + + + 30 + + + 10 + + + 100 + + + When browsing directories that contain a lot of files, the QuickBrowser can sometimes hide your whole desktop. Here you can limit the number of entries shown at a time in the QuickBrowser. This is particularly useful for low screen resolutions. + + + - + - kcfg_NumVisibleEntries + kcfg_ShowHiddenFiles - - 5 - - - 0 + + Show hidden fi&les - - 20 + + true - This option allows you to define how many applications should be displayed at most in the QuickStart menu area. + If this option is enabled, hidden files (i.e. files beginning with a dot) will be shown in the QuickBrowser menus. - - - - - kcfg_RecentVsOften - - - Show the &applications most recently used - - - true - - - When this option is selected the QuickStart menu area will be filled with the applications you have used most recently. - - - - - m_showFrequent - - - Show the applications most fre&quently used - - - When this option is selected the QuickStart menu area will be filled with the applications you use most frequently. - - - + + + Spacer7 + + + Horizontal + + + Expanding + + + + 20 + 0 + + + + + + - Spacer8 - - - Horizontal + m_recentGroup - - Expanding - - - - 20 - 0 - + + Recent Documents Menu - - - - + + + unnamed + + + + Layout3 + + + + unnamed + + + + m_maxRecentDocumentsItemsLabel + + + Ma&ximum number of entries: + + + kcfg_MaxEntries2 + + + This sets the maximum number of recently accessed documents stored for fast retrieval. + + + + + maxrecentdocs + + + 10 + + + 0 + + + 100 + + + This sets the maximum number of recently accessed documents stored for fast retrieval. + + + + + + + Spacer7 + + + Horizontal + + + Expanding + + + + 20 + 0 + + + + + + - m_pSearchGroup + m_pRecentOrderGroup - TDE Menu Search + QuickStart Menu Items - - + + unnamed - - + + + + Layout4 + + + + unnamed + + + + TextLabel2 + + + Maxim&um number of entries: + + + kcfg_NumVisibleEntries + + + This option allows you to define the maximum number of applications that should be displayed in the QuickStart menu area. + + + + + kcfg_NumVisibleEntries + + + 5 + + + 0 + + + 20 + + + This option allows you to define how many applications should be displayed at most in the QuickStart menu area. + + + + + - kcfg_UseSearchBar + kcfg_RecentVsOften - Show search field in TDE Menu + Show the &applications most recently used true - <qt>When this option is selected a text-based search field will appear in the TDE Menu.</qt> + When this option is selected the QuickStart menu area will be filled with the applications you have used most recently. + + + + + m_showFrequent + + + Show the applications most fre&quently used + + + When this option is selected the QuickStart menu area will be filled with the applications you use most frequently. - - + + Spacer8 @@ -700,40 +662,84 @@ - 20 - 0 + 20 + 0 - - - - - - - - - - m_formatSimple - m_formatNameDesc - m_formDescName - kcfg_UseSidePixmap - m_editKMenuButton - m_subMenus - kcfg_ShowHiddenFiles - kcfg_MaxEntries2 - kcfg_RecentVsOften - m_showFrequent - kcfg_NumVisibleEntries - - - klistview.h - knuminput.h - kdialog.h - - - - - klistview.h - knuminput.h - + + + + + + m_pSearchGroup + + + TDE Menu Search + + + + unnamed + + + + kcfg_UseSearchBar + + + Show search field in TDE Menu + + + true + + + <qt>When this option is selected a text-based search field will appear in the TDE Menu.</qt> + + + + + Spacer8 + + + Horizontal + + + Expanding + + + + 20 + 0 + + + + + + + + + + + + m_formatSimple + m_formatNameDesc + m_formDescName + kcfg_UseSidePixmap + m_editKMenuButton + m_subMenus + kcfg_ShowHiddenFiles + kcfg_MaxEntries2 + kcfg_RecentVsOften + m_showFrequent + kcfg_NumVisibleEntries + + + klistview.h + knuminput.h + kdialog.h + + + + + klistview.h + knuminput.h + diff --git a/kcontrol/taskbar/kcmtaskbar.cpp b/kcontrol/taskbar/kcmtaskbar.cpp index 22ec10b14..cd1c67a1d 100644 --- a/kcontrol/taskbar/kcmtaskbar.cpp +++ b/kcontrol/taskbar/kcmtaskbar.cpp @@ -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())); diff --git a/kcontrol/taskbar/kcmtaskbar.h b/kcontrol/taskbar/kcmtaskbar.h index 877f26daf..d41f5e6f0 100644 --- a/kcontrol/taskbar/kcmtaskbar.h +++ b/kcontrol/taskbar/kcmtaskbar.h @@ -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; }; diff --git a/kcontrol/taskbar/kcmtaskbarui.ui b/kcontrol/taskbar/kcmtaskbarui.ui index 632f0c109..dd0aadb9d 100644 --- a/kcontrol/taskbar/kcmtaskbarui.ui +++ b/kcontrol/taskbar/kcmtaskbarui.ui @@ -107,13 +107,40 @@ By default the taskbar groups windows when it is full. - groupTasksLabel + showTaskStatesLabel &Group similar tasks: - kcfg_GroupTasks + kcfg_ShowTaskStates + + + + + kcfg_ShowTaskStates + + + + 7 + 0 + 0 + 0 + + + + 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. + + + + + groupTasksLabel + + + &Show tasks with state: + + + kcfg_ShowTaskStates @@ -161,12 +188,12 @@ By default this option is selected. By default, this option is selected and all windows are shown. - + appearance - + textLabel1 @@ -177,7 +204,7 @@ By default, this option is selected and all windows are shown. appearance - + kcfg_UseCustomColors @@ -191,7 +218,7 @@ By default, this option is selected and all windows are shown. true - + layout9 @@ -199,23 +226,17 @@ By default, this option is selected and all windows are shown. unnamed - + - spacer11_2 - - - Horizontal + inactiveTaskTextColorLabel - - Expanding + + Inacti&ve task text color: - - - 191 - 20 - + + kcfg_InactiveTaskTextColor - + kcfg_InactiveTaskTextColor @@ -241,26 +262,18 @@ By default, this option is selected and all windows are shown. - + - kcfg_TaskBackgroundColor - - - - - - - - taskBackgroundColorLabel + activeTaskTextColorLabel - &Background color: + Active task te&xt color: - kcfg_TaskBackgroundColor + kcfg_ActiveTaskTextColor - + kcfg_ActiveTaskTextColor @@ -268,29 +281,43 @@ By default, this option is selected and all windows are shown. - + - inactiveTaskTextColorLabel + spacer11_2 + + + Horizontal + + + Expanding + + + + 191 + 20 + + + + + + taskBackgroundColorLabel - Inacti&ve task text color: + &Background color: - kcfg_InactiveTaskTextColor + kcfg_TaskBackgroundColor - + - activeTaskTextColorLabel + kcfg_TaskBackgroundColor - Active task te&xt color: - - - kcfg_ActiveTaskTextColor + - + spacer12 @@ -471,6 +498,7 @@ By default, this option is selected and all windows are shown. kcfg_ShowIcon kcfg_ShowWindowListBtn kcfg_GroupTasks + kcfg_ShowTaskStates appearance kcfg_UseCustomColors kcfg_InactiveTaskTextColor 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 @@ 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 Show all windows option.\n\nYou can set the taskbar to Never group windows, to Always group windows or to group windows only When the Taskbar is Full.\n\nBy default the taskbar groups windows when it is full. + + + + + + + + + + + + + ShowAll + + The taskbar can show and/or hide tasks based on their current process state. Select Any to show all tasks regardless of current state. + true 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 #include #include +#include #include #include @@ -43,6 +44,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include +#ifdef Q_WS_X11 +#include +#include +#include +#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(); diff --git a/twin/KWinInterface.h b/twin/KWinInterface.h index 445e42fe9..dbc132888 100644 --- a/twin/KWinInterface.h +++ b/twin/KWinInterface.h @@ -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; diff --git a/twin/workspace.cpp b/twin/workspace.cpp index 643395e88..cc109918c 100644 --- a/twin/workspace.cpp +++ b/twin/workspace.cpp @@ -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 ); diff --git a/twin/workspace.h b/twin/workspace.h index f1f7dc97e..0f019cbbf 100644 --- a/twin/workspace.h +++ b/twin/workspace.h @@ -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(); } -- cgit v1.2.1