Support for sticky items in TabBox list

This is needed for Plasma Active's home screen which should always
be the first element in the list.
icc-effect-5.14.5
Martin Gräßlin 2011-12-01 13:15:11 +01:00
parent 946038f3c0
commit f644c28180
10 changed files with 52 additions and 0 deletions

View File

@ -126,6 +126,9 @@ Atoms::Atoms()
atoms[n] = &kde_net_wm_tab_group;
names[n++] = (char*) "_KDE_NET_WM_TAB_GROUP";
atoms[n] = &kde_first_in_window_list;
names[n++] = (char*) "_KDE_FIRST_IN_WINDOWLIST";
assert(n <= max);
XInternAtoms(display(), names, n, false, atoms_return);

View File

@ -64,6 +64,7 @@ public:
Atom kde_net_wm_shadow;
Atom kde_net_wm_opaque_region;
Atom kde_net_wm_tab_group;
Atom kde_first_in_window_list;
};

View File

@ -127,6 +127,7 @@ Client::Client(Workspace* ws)
, demandAttentionKNotifyTimer(NULL)
, m_responsibleForDecoPixmap(false)
, paintRedirector(0)
, m_firstInTabBox(false)
, electricMaximizing(false)
, activitiesDefined(false)
, needsSessionInteract(false)
@ -2393,6 +2394,24 @@ QRect Client::decorationRect() const
}
}
void Client::updateFirstInTabBox()
{
// TODO: move into KWindowInfo
Atom type;
int format, status;
unsigned long nitems = 0;
unsigned long extra = 0;
unsigned char *data = 0;
status = XGetWindowProperty(display(), window(), atoms->kde_first_in_window_list, 0, 1, false, atoms->kde_first_in_window_list, &type, &format, &nitems, &extra, &data);
if (status == Success && format == 32 && nitems == 1) {
setFirstInTabBox(true);
} else {
setFirstInTabBox(false);
}
if (data)
XFree(data);
}
} // namespace
#include "client.moc"

View File

@ -426,6 +426,13 @@ public:
TabBox::TabBoxClientImpl* tabBoxClient() const {
return m_tabBoxClient;
}
bool isFirstInTabBox() const {
return m_firstInTabBox;
}
void setFirstInTabBox(bool enable) {
m_firstInTabBox = enable;
}
void updateFirstInTabBox();
//sets whether the client should be treated as a SessionInteract window
void setSessionInteract(bool needed);
@ -718,6 +725,7 @@ private:
bool m_responsibleForDecoPixmap;
PaintRedirector* paintRedirector;
TabBox::TabBoxClientImpl* m_tabBoxClient;
bool m_firstInTabBox;
bool electricMaximizing;
QuickTileMode electricMode;

View File

@ -857,6 +857,8 @@ void Client::propertyNotifyEvent(XPropertyEvent* e)
checkActivities();
else if (e->atom == atoms->kde_net_wm_block_compositing)
updateCompositeBlocking(true);
else if (e->atom == atoms->kde_first_in_window_list)
updateFirstInTabBox();
break;
}
}

View File

@ -142,6 +142,7 @@ bool Client::manage(Window w, bool isMapped)
original_skip_taskbar = skip_taskbar = (info->state() & NET::SkipTaskbar) != 0;
skip_pager = (info->state() & NET::SkipPager) != 0;
updateFirstInTabBox();
setupCompositing();

View File

@ -175,6 +175,7 @@ void ClientModel::createClientList(int desktop, bool partialReset)
start = m_clientList.first();
m_clientList.clear();
QList<TabBoxClient*> stickyClients;
switch(tabBox->config().clientSwitchingMode()) {
case TabBoxConfig::FocusChainSwitching: {
@ -190,6 +191,9 @@ void ClientModel::createClientList(int desktop, bool partialReset)
m_clientList.prepend(add);
} else
m_clientList += add;
if (add->isFirstInTabBox()) {
stickyClients << add;
}
}
c = tabBox->nextClientFocusChain(c);
@ -214,6 +218,9 @@ void ClientModel::createClientList(int desktop, bool partialReset)
m_clientList.prepend(add);
} else
m_clientList += add;
if (add->isFirstInTabBox()) {
stickyClients << add;
}
}
if (index >= stacking.size() - 1) {
c = NULL;
@ -227,6 +234,10 @@ void ClientModel::createClientList(int desktop, bool partialReset)
break;
}
}
foreach (TabBoxClient *c, stickyClients) {
m_clientList.removeAll(c);
m_clientList.prepend(c);
}
if (tabBox->config().isShowDesktop()) {
TabBoxClient* desktopClient = tabBox->desktopClient();
if (desktopClient)

View File

@ -297,6 +297,11 @@ void TabBoxClientImpl::close()
m_client->closeWindow();
}
bool TabBoxClientImpl::isFirstInTabBox() const
{
return m_client->isFirstInTabBox();
}
/*********************************************************
* TabBox
*********************************************************/

View File

@ -83,6 +83,7 @@ public:
virtual int height() const;
virtual bool isCloseable() const;
virtual void close();
virtual bool isFirstInTabBox() const;
Client* client() const {
return m_client;

View File

@ -401,6 +401,7 @@ public:
virtual int height() const = 0;
virtual bool isCloseable() const = 0;
virtual void close() = 0;
virtual bool isFirstInTabBox() const = 0;
};
/**