From 98c89bcfd08be2fde7ccfc4fc417c4dd633b75e5 Mon Sep 17 00:00:00 2001 From: Anton Kreuzkamp Date: Mon, 7 Nov 2011 20:52:21 +0100 Subject: [PATCH] Make the window-tabbing group of a window public via an XProperty. --- atoms.cpp | 3 +++ atoms.h | 1 + client.cpp | 8 ++++++++ client.h | 5 ----- manage.cpp | 4 ++-- workspace.cpp | 15 +++++++++++++++ workspace.h | 5 ----- 7 files changed, 29 insertions(+), 12 deletions(-) diff --git a/atoms.cpp b/atoms.cpp index a0a1e082f2..1fd237d18b 100644 --- a/atoms.cpp +++ b/atoms.cpp @@ -123,6 +123,9 @@ Atoms::Atoms() atoms[n] = &kde_net_wm_opaque_region; names[n++] = (char*) "_KDE_NET_WM_OPAQUE_REGION"; + atoms[n] = &kde_net_wm_tab_group; + names[n++] = (char*) "_KDE_NET_WM_TAB_GROUP"; + assert(n <= max); XInternAtoms(display(), names, n, false, atoms_return); diff --git a/atoms.h b/atoms.h index bd80adc8b4..1f9085a265 100644 --- a/atoms.h +++ b/atoms.h @@ -63,6 +63,7 @@ public: Atom kde_net_wm_block_compositing; Atom kde_net_wm_shadow; Atom kde_net_wm_opaque_region; + Atom kde_net_wm_tab_group; }; diff --git a/client.cpp b/client.cpp index 9c232cd537..d6446107e7 100644 --- a/client.cpp +++ b/client.cpp @@ -1834,6 +1834,14 @@ QString Client::caption(bool full) const return full ? cap_normal + cap_suffix : cap_normal; } +void Client::setClientGroup(ClientGroup* group) +{ + client_group = group; + unsigned long data[1] = {(unsigned long)workspace()->indexOfClientGroup(group)}; + XChangeProperty(display(), window(), atoms->kde_net_wm_tab_group, atoms->kde_net_wm_tab_group, 32, + PropModeReplace, (unsigned char*)(data), 1); +} + void Client::dontMoveResize() { buttonDown = false; diff --git a/client.h b/client.h index 1b914aaea1..d484f2f78c 100644 --- a/client.h +++ b/client.h @@ -818,11 +818,6 @@ inline Group* Client::group() return in_group; } -inline void Client::setClientGroup(ClientGroup* group) -{ - client_group = group; -} - inline ClientGroup* Client::clientGroup() const { return client_group; diff --git a/manage.cpp b/manage.cpp index 586c3edb54..ebf3a54954 100644 --- a/manage.cpp +++ b/manage.cpp @@ -319,7 +319,7 @@ bool Client::manage(Window w, bool isMapped) // Create client group if the window will have a decoration bool dontKeepInArea = false; if (!noBorder()) { - client_group = NULL; + setClientGroup(NULL); // Automatically add to previous groups on session restore if (session && session->clientGroupClient && session->clientGroupClient != this && session->clientGroupClient->clientGroup()) session->clientGroupClient->clientGroup()->add(this, -1, true); @@ -349,7 +349,7 @@ bool Client::manage(Window w, bool isMapped) } } if (!client_group) - client_group = new ClientGroup(this); + setClientGroup(new ClientGroup(this)); } updateDecoration(false); // Also gravitates diff --git a/workspace.cpp b/workspace.cpp index 70b2df889c..6a8e2df2ea 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -2098,6 +2098,21 @@ void Workspace::moveItemToClientGroup(ClientGroup* oldGroup, int oldIndex, group->add(c, index, true); } +void Workspace::removeClientGroup(ClientGroup* group) +{ + int index = clientGroups.indexOf(group); + if (index == -1) { + return; + } + + clientGroups.removeAt(index); + for (; index < clientGroups.size(); index++) { + foreach (Client *c, clientGroups.at(index)->clients()) { + c->setClientGroup(c->clientGroup()); + } + } +} + // To accept "mainwindow#1" to "mainwindow#2" static QByteArray truncatedWindowRole(QByteArray a) { diff --git a/workspace.h b/workspace.h index e4db7e7617..4d7fda5ce2 100644 --- a/workspace.h +++ b/workspace.h @@ -1225,11 +1225,6 @@ inline void Workspace::addClientGroup(ClientGroup* group) clientGroups.append(group); } -inline void Workspace::removeClientGroup(ClientGroup* group) -{ - clientGroups.removeAll(group); -} - } // namespace #endif