2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 1999, 2000 Matthias Ettrich <ettrich@kde.org>
|
|
|
|
SPDX-FileCopyrightText: 2003 Lubos Lunak <l.lunak@kde.org>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
//#define QT_CLEAN_NAMESPACE
|
|
|
|
|
|
|
|
#include "group.h"
|
|
|
|
#include "workspace.h"
|
2019-09-24 08:48:08 +00:00
|
|
|
#include "x11client.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "effects.h"
|
|
|
|
|
2013-12-06 13:41:23 +00:00
|
|
|
#include <KWindowSystem>
|
2013-09-02 11:14:39 +00:00
|
|
|
#include <QDebug>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
//********************************************
|
|
|
|
// Group
|
|
|
|
//********************************************
|
|
|
|
|
2019-09-06 14:30:26 +00:00
|
|
|
Group::Group(xcb_window_t leader_P)
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
: leader_client(nullptr),
|
2011-01-30 14:34:42 +00:00
|
|
|
leader_wid(leader_P),
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
leader_info(nullptr),
|
2011-01-30 14:34:42 +00:00
|
|
|
user_time(-1U),
|
|
|
|
refcount(0)
|
|
|
|
{
|
2019-09-06 14:30:26 +00:00
|
|
|
if (leader_P != XCB_WINDOW_NONE) {
|
2014-03-20 08:19:53 +00:00
|
|
|
leader_client = workspace()->findClient(Predicate::WindowMatch, leader_P);
|
2013-11-18 12:54:30 +00:00
|
|
|
leader_info = new NETWinInfo(connection(), leader_P, rootWindow(),
|
2019-09-19 15:16:14 +00:00
|
|
|
NET::Properties(), NET::WM2StartupId);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
effect_group = new EffectWindowGroupImpl(this);
|
2013-04-26 07:47:45 +00:00
|
|
|
workspace()->addGroup(this);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
Group::~Group()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
delete leader_info;
|
|
|
|
delete effect_group;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-12-06 13:41:23 +00:00
|
|
|
QIcon Group::icon() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
if (leader_client != nullptr)
|
2007-04-29 17:35:43 +00:00
|
|
|
return leader_client->icon();
|
2019-09-06 14:30:26 +00:00
|
|
|
else if (leader_wid != XCB_WINDOW_NONE) {
|
2013-12-06 13:41:23 +00:00
|
|
|
QIcon ic;
|
2015-02-17 13:09:53 +00:00
|
|
|
NETWinInfo info(connection(), leader_wid, rootWindow(), NET::WMIcon, NET::WM2IconPixmap);
|
|
|
|
auto readIcon = [&ic, &info, this](int size, bool scale = true) {
|
|
|
|
const QPixmap pix = KWindowSystem::icon(leader_wid, size, size, scale, KWindowSystem::NETWM | KWindowSystem::WMHints, &info);
|
2013-12-06 13:41:23 +00:00
|
|
|
if (!pix.isNull()) {
|
|
|
|
ic.addPixmap(pix);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
readIcon(16);
|
|
|
|
readIcon(32);
|
|
|
|
readIcon(48, false);
|
|
|
|
readIcon(64, false);
|
|
|
|
readIcon(128, false);
|
2007-04-29 17:35:43 +00:00
|
|
|
return ic;
|
|
|
|
}
|
2013-12-06 13:41:23 +00:00
|
|
|
return QIcon();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void Group::addMember(X11Client *member_P)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
_members.append(member_P);
|
2013-09-02 11:14:39 +00:00
|
|
|
// qDebug() << "GROUPADD:" << this << ":" << member_P;
|
|
|
|
// qDebug() << kBacktrace();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void Group::removeMember(X11Client *member_P)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-09-02 11:14:39 +00:00
|
|
|
// qDebug() << "GROUPREMOVE:" << this << ":" << member_P;
|
|
|
|
// qDebug() << kBacktrace();
|
2011-01-30 14:34:42 +00:00
|
|
|
Q_ASSERT(_members.contains(member_P));
|
|
|
|
_members.removeAll(member_P);
|
2007-04-30 09:49:41 +00:00
|
|
|
// there are cases when automatic deleting of groups must be delayed,
|
|
|
|
// e.g. when removing a member and doing some operation on the possibly
|
|
|
|
// other members of the group (which would be however deleted already
|
|
|
|
// if there were no other members)
|
2011-01-30 14:34:42 +00:00
|
|
|
if (refcount == 0 && _members.isEmpty()) {
|
2013-04-26 07:47:45 +00:00
|
|
|
workspace()->removeGroup(this);
|
2007-04-30 09:49:41 +00:00
|
|
|
delete this;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-30 09:49:41 +00:00
|
|
|
|
|
|
|
void Group::ref()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-30 09:49:41 +00:00
|
|
|
++refcount;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-30 09:49:41 +00:00
|
|
|
|
|
|
|
void Group::deref()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (--refcount == 0 && _members.isEmpty()) {
|
2013-04-26 07:47:45 +00:00
|
|
|
workspace()->removeGroup(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
delete this;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void Group::gotLeader(X11Client *leader_P)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-08-31 14:28:37 +00:00
|
|
|
Q_ASSERT(leader_P->window() == leader_wid);
|
2007-04-29 17:35:43 +00:00
|
|
|
leader_client = leader_P;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void Group::lostLeader()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-08-31 14:28:37 +00:00
|
|
|
Q_ASSERT(!_members.contains(leader_client));
|
Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.
This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).
Test Plan: Compiles.
Reviewers: #kwin, davidedmundson, romangg
Reviewed By: #kwin, davidedmundson, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 14:46:54 +00:00
|
|
|
leader_client = nullptr;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (_members.isEmpty()) {
|
2013-04-26 07:47:45 +00:00
|
|
|
workspace()->removeGroup(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
delete this;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
} // namespace
|