2012-01-12 06:42:55 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2011/2012 The KWin team <kwin@kde.org>
|
|
|
|
|
|
|
|
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_TABGROUP_H
|
|
|
|
#define KWIN_TABGROUP_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2018-05-05 10:06:24 +00:00
|
|
|
class AbstractClient;
|
2012-01-12 06:42:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* A group contains at least one client and DOES 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.
|
|
|
|
*
|
|
|
|
* rohanp: Had to convert this object to a QObject to make it easier for adding
|
|
|
|
* scripting interface to TabGroup.
|
|
|
|
*
|
|
|
|
* If a group contains multiple clients then only one will ever be mapped at
|
|
|
|
* any given time.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2012-01-12 06:42:55 +00:00
|
|
|
class TabGroup
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Creates a new group containing \p c.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2018-05-05 10:06:24 +00:00
|
|
|
explicit TabGroup(AbstractClient* c);
|
2012-01-12 06:42:55 +00:00
|
|
|
~TabGroup();
|
|
|
|
|
2012-03-15 23:15:13 +00:00
|
|
|
enum State {
|
2012-05-31 08:20:20 +00:00
|
|
|
None = 0, Minimized = 1<<0, Maximized = 1<<1, Shaded = 1<<2,
|
2012-03-15 23:15:13 +00:00
|
|
|
Geometry = 1<<3, Desktop = 1<<4, Activity = 1<<5,
|
|
|
|
Layer = 1<<6, QuickTile = 1<<7, All = 0xffffffff
|
|
|
|
};
|
|
|
|
Q_DECLARE_FLAGS(States, State)
|
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
/**
|
|
|
|
* Activate next tab (flips)
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2012-01-12 06:42:55 +00:00
|
|
|
void activateNext();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Activate previous tab (flips)
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2012-01-12 06:42:55 +00:00
|
|
|
void activatePrev();
|
|
|
|
|
2012-03-15 23:15:13 +00:00
|
|
|
/**
|
|
|
|
* Allows to alter several attributes in random order and trigger a general update at the end
|
|
|
|
* (must still be explicitly called)
|
|
|
|
* this is to prevent side effects, mostly for geometry adjustments during maximization and QuickTiling
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2012-03-15 23:15:13 +00:00
|
|
|
void blockStateUpdates(bool);
|
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
/**
|
|
|
|
* Close all clients in this group.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2012-01-12 06:42:55 +00:00
|
|
|
void closeAll();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether client \p c is member of this group
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2018-05-05 10:06:24 +00:00
|
|
|
bool contains(AbstractClient* c) const;
|
2012-01-12 06:42:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The amount of clients in this group
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2012-01-12 06:42:55 +00:00
|
|
|
int count() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether or not this group contains the active client.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2012-01-12 06:42:55 +00:00
|
|
|
bool isActive() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether this group is empty (used by workspace to remove it)
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2012-01-12 06:42:55 +00:00
|
|
|
bool isEmpty() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the list of all the clients contained in this group in their current order.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2018-05-05 10:06:24 +00:00
|
|
|
const QVector<AbstractClient*> &clients() const;
|
2012-01-12 06:42:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the currently visible client.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2018-05-05 10:06:24 +00:00
|
|
|
AbstractClient* current() const;
|
2012-01-12 06:42:55 +00:00
|
|
|
/**
|
|
|
|
* Makes \p c the visible client in the group - force is only used when the window becomes ready for painting.
|
|
|
|
* Any other usage just causes pointless action
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2018-05-05 10:06:24 +00:00
|
|
|
void setCurrent(AbstractClient* c, bool force = false);
|
2012-01-12 06:42:55 +00:00
|
|
|
|
2012-04-22 20:27:04 +00:00
|
|
|
/**
|
|
|
|
* Alignes the dynamic Qt @param property of all clients to the one of @param c
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2018-05-05 10:06:24 +00:00
|
|
|
void sync(const char *property, AbstractClient *c);
|
2012-04-22 20:27:04 +00:00
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
/**
|
|
|
|
* Returns combined minimum size of all clients in the group.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2012-01-12 06:42:55 +00:00
|
|
|
QSize minSize() const;
|
|
|
|
/**
|
|
|
|
* Returns combined maximum size of all clients in the group.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2012-01-12 06:42:55 +00:00
|
|
|
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.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2018-05-05 10:06:24 +00:00
|
|
|
void updateStates(AbstractClient* main, States states, AbstractClient* only = NULL);
|
2012-01-12 06:42:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* updates geometry restrictions of this group, basically called from Client::getWmNormalHints(), otherwise rather private
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2012-01-12 06:42:55 +00:00
|
|
|
void updateMinMaxSize();
|
|
|
|
|
2013-07-22 14:07:39 +00:00
|
|
|
Q_SIGNALS:
|
2012-01-12 06:42:55 +00:00
|
|
|
void minSizeChanged();
|
|
|
|
void maxSizeChanged();
|
|
|
|
|
|
|
|
private:
|
2018-05-05 19:24:49 +00:00
|
|
|
friend class AbstractClient;
|
2012-01-12 06:42:55 +00:00
|
|
|
friend class Client;
|
|
|
|
// friend bool Client::tabTo(Client*, bool, bool);
|
2018-05-05 10:06:24 +00:00
|
|
|
bool add(KWin::AbstractClient *c, AbstractClient *other, bool behind, bool activateC);
|
|
|
|
void move(KWin::AbstractClient* c, KWin::AbstractClient* before, bool behind);
|
2012-01-12 06:42:55 +00:00
|
|
|
|
|
|
|
// friend bool Client::untab(const QRect&);
|
2018-05-05 10:06:24 +00:00
|
|
|
bool remove(KWin::AbstractClient *c);
|
2012-01-12 06:42:55 +00:00
|
|
|
|
2018-05-05 10:06:24 +00:00
|
|
|
QVector<AbstractClient*> m_clients;
|
|
|
|
AbstractClient *m_current;
|
2012-01-12 06:42:55 +00:00
|
|
|
QSize m_minSize;
|
|
|
|
QSize m_maxSize;
|
2012-03-15 23:15:13 +00:00
|
|
|
int m_stateUpdatesBlocked;
|
2012-05-31 08:20:20 +00:00
|
|
|
States m_pendingUpdates;
|
2012-01-12 06:42:55 +00:00
|
|
|
};
|
|
|
|
|
2018-05-05 10:06:24 +00:00
|
|
|
inline bool TabGroup::contains(AbstractClient* c) const
|
2012-01-12 06:42:55 +00:00
|
|
|
{
|
|
|
|
return c && m_clients.contains(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int TabGroup::count() const
|
|
|
|
{
|
|
|
|
return m_clients.count();
|
|
|
|
}
|
|
|
|
|
2018-05-05 10:06:24 +00:00
|
|
|
inline const QVector<AbstractClient*> &TabGroup::clients() const
|
2012-01-12 06:42:55 +00:00
|
|
|
{
|
|
|
|
return m_clients;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool TabGroup::isEmpty() const
|
|
|
|
{
|
|
|
|
return m_clients.isEmpty();
|
|
|
|
}
|
|
|
|
|
2018-05-05 10:06:24 +00:00
|
|
|
inline AbstractClient* TabGroup::current() const
|
2012-01-12 06:42:55 +00:00
|
|
|
{
|
|
|
|
return m_current;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline QSize TabGroup::minSize() const
|
|
|
|
{
|
|
|
|
return m_minSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline QSize TabGroup::maxSize() const
|
|
|
|
{
|
|
|
|
return m_maxSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-03-15 23:15:13 +00:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::TabGroup::States)
|
|
|
|
|
2012-01-12 06:42:55 +00:00
|
|
|
#endif
|