2009-11-15 03:24:04 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2009 Jorge Mata <matamax123@gmail.com>
|
|
|
|
Copyright (C) 2009 Lucas Murray <lmurray@undefinedfire.com>
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
#ifndef KWIN_CLIENTGROUP_H
|
|
|
|
#define KWIN_CLIENTGROUP_H
|
|
|
|
|
2010-09-21 14:31:40 +00:00
|
|
|
#include <QObject>
|
|
|
|
|
2009-11-15 03:24:04 +00:00
|
|
|
#include "kdecoration.h"
|
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
class Client;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class represents a group of clients for use in window tabbing. All
|
|
|
|
* clients in the group share the same geometry and state information; I.e if
|
|
|
|
* one client changes then all others should also be changed.
|
|
|
|
*
|
|
|
|
* Workspace::clientGroups is a list of all currently-existing client groups.
|
|
|
|
*
|
|
|
|
* A group MUST contain at least one client and MUST NOT contain multiple
|
|
|
|
* copies of the same client. A client MUST NOT be in two groups at the same
|
|
|
|
* time. All decorated clients SHOULD be in a group, even if it's a group of
|
|
|
|
* one client.
|
2011-01-30 14:34:42 +00:00
|
|
|
*
|
2010-09-21 14:31:40 +00:00
|
|
|
* rohanp: Had to convert this object to a QObject to make it easier for adding
|
|
|
|
* scripting interface to ClientGroup.
|
2009-11-15 03:24:04 +00:00
|
|
|
*
|
|
|
|
* If a group contains multiple clients then only one will ever be mapped at
|
|
|
|
* any given time.
|
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
class ClientGroup : public QObject
|
|
|
|
{
|
2010-09-21 14:31:40 +00:00
|
|
|
Q_OBJECT
|
2012-01-01 13:31:11 +00:00
|
|
|
/**
|
|
|
|
* Currently visible client in this group.
|
|
|
|
**/
|
|
|
|
Q_PROPERTY(KWin::Client* visible READ visible WRITE setVisible NOTIFY visibleChanged)
|
|
|
|
/**
|
|
|
|
* Combined minimum size of all clients in the group.
|
|
|
|
**/
|
|
|
|
Q_PROPERTY(QSize minSize READ minSize NOTIFY minSizeChanged)
|
|
|
|
/**
|
|
|
|
* Combined maximum size of all clients in the group.
|
|
|
|
**/
|
|
|
|
Q_PROPERTY(QSize maxSize READ maxSize NOTIFY maxSizeChanged)
|
|
|
|
/**
|
|
|
|
* The index of the visible Client in this group.
|
|
|
|
**/
|
|
|
|
Q_PROPERTY(int visibleClientIndex READ indexOfVisibleClient NOTIFY visibleChanged)
|
2012-01-01 14:01:54 +00:00
|
|
|
/**
|
|
|
|
* The Clients in this group.
|
|
|
|
**/
|
|
|
|
Q_PROPERTY(QList<KWin::Client*> clients READ clients)
|
2011-01-30 14:34:42 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Creates a new group containing \p c.
|
|
|
|
*/
|
|
|
|
ClientGroup(Client* c);
|
|
|
|
~ClientGroup();
|
|
|
|
|
2012-01-01 13:31:11 +00:00
|
|
|
public Q_SLOTS:
|
2011-01-30 14:34:42 +00:00
|
|
|
/**
|
|
|
|
* Adds \p c to the group before \p before in the list. If \p becomeVisible is \i true then
|
|
|
|
* the added client will become also the visible client.
|
|
|
|
*/
|
2012-01-01 13:31:11 +00:00
|
|
|
void add(KWin::Client* c, int before = -1, bool becomeVisible = false);
|
2011-01-30 14:34:42 +00:00
|
|
|
/**
|
|
|
|
* Remove the client at index \p index from the group. If \p newGeom is set then the client
|
|
|
|
* will move and resize to the specified geometry, otherwise it will stay where the group
|
|
|
|
* is located. If \p toNullGroup is not true then the client will be added to a new group
|
|
|
|
* of its own.
|
|
|
|
*/
|
|
|
|
void remove(int index, const QRect& newGeom = QRect(), bool toNullGroup = false);
|
|
|
|
/**
|
|
|
|
* Remove \p c from the group. If \p newGeom is set then the client will move and resize to
|
|
|
|
* the specified geometry, otherwise it will stay where the group is located. If
|
|
|
|
* \p toNullGroup is not true then the client will be added to a new group of its own.
|
|
|
|
*/
|
2012-01-01 13:31:11 +00:00
|
|
|
void remove(KWin::Client* c, const QRect& newGeom = QRect(), bool toNullGroup = false);
|
2011-01-30 14:34:42 +00:00
|
|
|
/**
|
|
|
|
* Remove all clients from this group. Results in all clients except the first being moved
|
|
|
|
to a group of their own.
|
|
|
|
*/
|
|
|
|
void removeAll();
|
|
|
|
/**
|
|
|
|
* Close all clients in this group.
|
|
|
|
*/
|
|
|
|
void closeAll();
|
|
|
|
/**
|
|
|
|
* Move the client at index \p index to the position before the client at index \p before
|
|
|
|
* in the list.
|
|
|
|
*/
|
|
|
|
void move(int index, int before);
|
|
|
|
/**
|
|
|
|
* Move \p c to the position before \p before in the list.
|
|
|
|
*/
|
2012-01-01 13:31:11 +00:00
|
|
|
void move(KWin::Client* c, KWin::Client* before);
|
2011-01-30 14:34:42 +00:00
|
|
|
/**
|
|
|
|
* Display the right-click client menu belonging to the client at index \p index at the
|
|
|
|
* global coordinates specified by \p pos.
|
|
|
|
*/
|
|
|
|
void displayClientMenu(int index, const QPoint& pos);
|
|
|
|
/**
|
|
|
|
* Display the right-click client menu belonging to \p c at the global coordinates
|
|
|
|
* specified by \p pos.
|
|
|
|
*/
|
2012-01-01 13:31:11 +00:00
|
|
|
void displayClientMenu(KWin::Client* c, const QPoint& pos);
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2012-01-01 13:31:11 +00:00
|
|
|
public:
|
2011-01-30 14:34:42 +00:00
|
|
|
/**
|
|
|
|
* Returns the list index of \p c.
|
|
|
|
*/
|
2012-01-01 13:31:11 +00:00
|
|
|
Q_SCRIPTABLE int indexOfClient(KWin::Client* c);
|
2011-01-30 14:34:42 +00:00
|
|
|
/**
|
|
|
|
* Returns the list index of the currently visible client in the group.
|
|
|
|
*/
|
|
|
|
int indexOfVisibleClient();
|
|
|
|
/**
|
|
|
|
* Returns whether or not this group contains \p c.
|
|
|
|
*/
|
2012-01-01 13:31:11 +00:00
|
|
|
Q_SCRIPTABLE bool contains(KWin::Client* c);
|
2011-01-30 14:34:42 +00:00
|
|
|
/**
|
|
|
|
* Returns whether or not this group contains the active client.
|
|
|
|
*/
|
|
|
|
bool containsActiveClient();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the list of all the clients contained in this group in their current order.
|
|
|
|
*/
|
2012-01-01 13:53:48 +00:00
|
|
|
const ClientList &clients() const;
|
2011-01-30 14:34:42 +00:00
|
|
|
/**
|
|
|
|
* Returns a list of the captions and icons of all the clients contained in this group
|
|
|
|
* in their current order.
|
|
|
|
*/
|
|
|
|
QList< ClientGroupItem > items() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the currently visible client.
|
|
|
|
*/
|
|
|
|
Client* visible();
|
|
|
|
/**
|
|
|
|
* Makes the client at index \p index the visible one in the group.
|
|
|
|
*/
|
|
|
|
void setVisible(int index);
|
|
|
|
/**
|
|
|
|
* Makes \p c the visible client in the group.
|
|
|
|
*/
|
|
|
|
void setVisible(Client* c);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns combined minimum size of all clients in the group.
|
|
|
|
*/
|
|
|
|
QSize minSize() const;
|
|
|
|
/**
|
|
|
|
* Returns combined maximum size of all clients in the group.
|
|
|
|
*/
|
|
|
|
QSize maxSize() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensures that all the clients in the group have identical geometries and states using
|
|
|
|
* \p main as the primary client to copy the settings off. If \p only is set then only
|
|
|
|
* that client is updated to match \p main.
|
|
|
|
*/
|
|
|
|
void updateStates(Client* main, Client* only = NULL);
|
|
|
|
|
2012-01-01 13:31:11 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
/**
|
|
|
|
* Emitted when the visible Client in this group changes.
|
|
|
|
**/
|
|
|
|
void visibleChanged();
|
|
|
|
/**
|
|
|
|
* Emitted when the group's minimum size changes.
|
|
|
|
**/
|
|
|
|
void minSizeChanged();
|
|
|
|
/**
|
|
|
|
* Emitted when the group's maximum size changes.
|
|
|
|
**/
|
|
|
|
void maxSizeChanged();
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Regenerate the list of client captions and icons.
|
|
|
|
*/
|
|
|
|
void updateItems();
|
|
|
|
/**
|
|
|
|
* Determine the combined minimum and maximum sizes of all clients in the group.
|
|
|
|
*/
|
|
|
|
void updateMinMaxSize();
|
|
|
|
|
|
|
|
ClientList clients_;
|
|
|
|
QList< ClientGroupItem > items_;
|
|
|
|
int visible_;
|
|
|
|
|
|
|
|
QSize minSize_;
|
|
|
|
QSize maxSize_;
|
|
|
|
|
|
|
|
friend class Client;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline int ClientGroup::indexOfClient(Client* c)
|
|
|
|
{
|
|
|
|
return clients_.indexOf(c);
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
|
|
|
inline int ClientGroup::indexOfVisibleClient()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
return visible_;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
inline bool ClientGroup::contains(Client* c)
|
|
|
|
{
|
|
|
|
return clients_.contains(c);
|
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
2012-01-01 13:53:48 +00:00
|
|
|
inline const ClientList &ClientGroup::clients() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
return clients_;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
|
|
|
inline QList< ClientGroupItem > ClientGroup::items() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
return items_;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
|
|
|
inline Client* ClientGroup::visible()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-11-13 19:11:00 +00:00
|
|
|
return clients_.at(visible_);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
|
|
|
inline QSize ClientGroup::minSize() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
return minSize_;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
|
|
|
inline QSize ClientGroup::maxSize() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
return maxSize_;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-11-15 03:24:04 +00:00
|
|
|
|
|
|
|
}
|
2012-01-01 13:31:11 +00:00
|
|
|
Q_DECLARE_METATYPE(KWin::ClientGroup*)
|
|
|
|
Q_DECLARE_METATYPE(QList<KWin::ClientGroup*>)
|
2009-11-15 03:24:04 +00:00
|
|
|
|
|
|
|
#endif
|