2007-11-27 19:40:25 +00:00
|
|
|
/********************************************************************
|
2007-04-29 17:35:43 +00:00
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
|
|
|
|
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
2007-11-27 19:40:25 +00:00
|
|
|
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/>.
|
|
|
|
*********************************************************************/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
This file contains things relevant to window grouping.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
//#define QT_CLEAN_NAMESPACE
|
|
|
|
|
|
|
|
#include "group.h"
|
2007-10-05 22:21:25 +00:00
|
|
|
#include <QTextStream>
|
2007-04-29 17:35:43 +00:00
|
|
|
#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"
|
|
|
|
|
|
|
|
#include <kstartupinfo.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
|
|
|
|
|
|
|
/*
|
|
|
|
TODO
|
|
|
|
Rename as many uses of 'transient' as possible (hasTransient->hasSubwindow,etc.),
|
|
|
|
or I'll get it backwards in half of the cases again.
|
|
|
|
*/
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
//***************************************
|
|
|
|
// Workspace
|
|
|
|
//***************************************
|
|
|
|
|
2013-04-30 13:41:59 +00:00
|
|
|
Group* Workspace::findGroup(xcb_window_t leader) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-09-06 14:30:26 +00:00
|
|
|
Q_ASSERT(leader != XCB_WINDOW_NONE);
|
2011-01-30 14:34:42 +00:00
|
|
|
for (GroupList::ConstIterator it = groups.constBegin();
|
|
|
|
it != groups.constEnd();
|
|
|
|
++it)
|
|
|
|
if ((*it)->leader() == leader)
|
2007-04-29 17:35:43 +00:00
|
|
|
return *it;
|
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
|
|
|
return nullptr;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// Client is group transient, but has no group set. Try to find
|
|
|
|
// group with windows with the same client leader.
|
2019-09-24 08:48:08 +00:00
|
|
|
Group* Workspace::findClientLeaderGroup(const X11Client *c) 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
|
|
|
Group* ret = nullptr;
|
2011-01-30 14:34:42 +00:00
|
|
|
for (ClientList::ConstIterator it = clients.constBegin();
|
|
|
|
it != clients.constEnd();
|
|
|
|
++it) {
|
|
|
|
if (*it == c)
|
2007-04-29 17:35:43 +00:00
|
|
|
continue;
|
2011-01-30 14:34:42 +00:00
|
|
|
if ((*it)->wmClientLeader() == c->wmClientLeader()) {
|
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 (ret == nullptr || ret == (*it)->group())
|
2007-04-29 17:35:43 +00:00
|
|
|
ret = (*it)->group();
|
2011-01-30 14:34:42 +00:00
|
|
|
else {
|
2007-04-29 17:35:43 +00:00
|
|
|
// There are already two groups with the same client leader.
|
|
|
|
// This most probably means the app uses group transients without
|
|
|
|
// setting group for its windows. Merging the two groups is a bad
|
|
|
|
// hack, but there's no really good solution for this case.
|
2007-04-30 09:44:32 +00:00
|
|
|
ClientList old_group = (*it)->group()->members();
|
2007-04-29 17:35:43 +00:00
|
|
|
// old_group autodeletes when being empty
|
2011-01-30 14:34:42 +00:00
|
|
|
for (int pos = 0;
|
|
|
|
pos < old_group.count();
|
|
|
|
++pos) {
|
2019-09-24 08:48:08 +00:00
|
|
|
X11Client *tmp = old_group[ pos ];
|
2011-01-30 14:34:42 +00:00
|
|
|
if (tmp != c)
|
|
|
|
tmp->changeClientLeaderGroup(ret);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2015-09-14 08:55:27 +00:00
|
|
|
void Workspace::updateMinimizedOfTransients(AbstractClient* c)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
// if mainwindow is minimized or shaded, minimize transients too
|
2011-01-30 14:34:42 +00:00
|
|
|
if (c->isMinimized()) {
|
2015-09-11 12:23:32 +00:00
|
|
|
for (auto it = c->transients().constBegin();
|
2011-01-30 14:34:42 +00:00
|
|
|
it != c->transients().constEnd();
|
|
|
|
++it) {
|
2010-11-10 03:01:49 +00:00
|
|
|
if ((*it)->isModal())
|
|
|
|
continue; // there's no reason to hide modal dialogs with the main client
|
2011-01-30 14:34:42 +00:00
|
|
|
// but to keep them to eg. watch progress or whatever
|
2011-06-24 10:19:47 +00:00
|
|
|
if (!(*it)->isMinimized()) {
|
2009-01-09 14:07:03 +00:00
|
|
|
(*it)->minimize();
|
2011-01-30 14:34:42 +00:00
|
|
|
updateMinimizedOfTransients((*it));
|
2009-01-09 14:07:03 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
if (c->isModal()) { // if a modal dialog is minimized, minimize its mainwindow too
|
2015-09-11 13:55:23 +00:00
|
|
|
foreach (AbstractClient * c2, c->mainClients())
|
2011-01-30 14:34:42 +00:00
|
|
|
c2->minimize();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// else unmiminize the transients
|
2015-09-11 12:23:32 +00:00
|
|
|
for (auto it = c->transients().constBegin();
|
2011-01-30 14:34:42 +00:00
|
|
|
it != c->transients().constEnd();
|
|
|
|
++it) {
|
2011-06-24 10:19:47 +00:00
|
|
|
if ((*it)->isMinimized()) {
|
2009-01-09 14:07:03 +00:00
|
|
|
(*it)->unminimize();
|
2011-01-30 14:34:42 +00:00
|
|
|
updateMinimizedOfTransients((*it));
|
2009-01-09 14:07:03 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
if (c->isModal()) {
|
2015-09-11 13:55:23 +00:00
|
|
|
foreach (AbstractClient * c2, c->mainClients())
|
2011-01-30 14:34:42 +00:00
|
|
|
c2->unminimize();
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
|
2019-02-02 18:17:44 +00:00
|
|
|
/**
|
|
|
|
* Sets the client \a c's transient windows' on_all_desktops property to \a on_all_desktops.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2015-09-14 09:37:19 +00:00
|
|
|
void Workspace::updateOnAllDesktopsOfTransients(AbstractClient* c)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2015-09-11 12:23:32 +00:00
|
|
|
for (auto it = c->transients().constBegin();
|
2011-01-30 14:34:42 +00:00
|
|
|
it != c->transients().constEnd();
|
|
|
|
++it) {
|
|
|
|
if ((*it)->isOnAllDesktops() != c->isOnAllDesktops())
|
|
|
|
(*it)->setOnAllDesktops(c->isOnAllDesktops());
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// A new window has been mapped. Check if it's not a mainwindow for some already existing transient window.
|
2013-04-30 13:41:59 +00:00
|
|
|
void Workspace::checkTransients(xcb_window_t w)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
for (ClientList::ConstIterator it = clients.constBegin();
|
|
|
|
it != clients.constEnd();
|
|
|
|
++it)
|
|
|
|
(*it)->checkTransient(w);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
//****************************************
|
|
|
|
// Toplevel
|
|
|
|
//****************************************
|
|
|
|
|
|
|
|
// hacks for broken apps here
|
|
|
|
// all resource classes are forced to be lowercase
|
2011-01-30 14:34:42 +00:00
|
|
|
bool Toplevel::resourceMatch(const Toplevel* c1, const Toplevel* c2)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return c1->resourceClass() == c2->resourceClass();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
//****************************************
|
|
|
|
// Client
|
|
|
|
//****************************************
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::belongToSameApplication(const X11Client *c1, const X11Client *c2, SameApplicationChecks checks)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
bool same_app = false;
|
2007-04-29 21:04:13 +00:00
|
|
|
|
|
|
|
// tests that definitely mean they belong together
|
2011-01-30 14:34:42 +00:00
|
|
|
if (c1 == c2)
|
2007-04-29 17:35:43 +00:00
|
|
|
same_app = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (c1->isTransient() && c2->hasTransient(c1, true))
|
2007-04-29 17:35:43 +00:00
|
|
|
same_app = true; // c1 has c2 as mainwindow
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (c2->isTransient() && c1->hasTransient(c2, true))
|
2007-04-29 17:35:43 +00:00
|
|
|
same_app = true; // c2 has c1 as mainwindow
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (c1->group() == c2->group())
|
2007-04-29 21:04:13 +00:00
|
|
|
same_app = true; // same group
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (c1->wmClientLeader() == c2->wmClientLeader()
|
|
|
|
&& c1->wmClientLeader() != c1->window() // if WM_CLIENT_LEADER is not set, it returns window(),
|
|
|
|
&& c2->wmClientLeader() != c2->window()) // don't use in this test then
|
2007-04-29 21:04:13 +00:00
|
|
|
same_app = true; // same client leader
|
|
|
|
|
|
|
|
// tests that mean they most probably don't belong together
|
2017-11-05 09:10:17 +00:00
|
|
|
else if ((c1->pid() != c2->pid() && !checks.testFlag(SameApplicationCheck::AllowCrossProcesses))
|
2011-01-30 14:34:42 +00:00
|
|
|
|| c1->wmClientMachine(false) != c2->wmClientMachine(false))
|
2007-04-29 17:35:43 +00:00
|
|
|
; // different processes
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (c1->wmClientLeader() != c2->wmClientLeader()
|
|
|
|
&& c1->wmClientLeader() != c1->window() // if WM_CLIENT_LEADER is not set, it returns window(),
|
2017-11-05 09:10:17 +00:00
|
|
|
&& c2->wmClientLeader() != c2->window() // don't use in this test then
|
|
|
|
&& !checks.testFlag(SameApplicationCheck::AllowCrossProcesses))
|
2007-04-29 17:35:43 +00:00
|
|
|
; // different client leader
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (!resourceMatch(c1, c2))
|
2007-04-29 17:35:43 +00:00
|
|
|
; // different apps
|
2017-11-05 09:10:17 +00:00
|
|
|
else if (!sameAppWindowRoleMatch(c1, c2, checks.testFlag(SameApplicationCheck::RelaxedForActive))
|
|
|
|
&& !checks.testFlag(SameApplicationCheck::AllowCrossProcesses))
|
2007-04-29 17:35:43 +00:00
|
|
|
; // "different" apps
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (c1->pid() == 0 || c2->pid() == 0)
|
2007-04-29 17:35:43 +00:00
|
|
|
; // old apps that don't have _NET_WM_PID, consider them different
|
2011-01-30 14:34:42 +00:00
|
|
|
// if they weren't found to match above
|
2007-04-29 17:35:43 +00:00
|
|
|
else
|
|
|
|
same_app = true; // looks like it's the same app
|
2007-04-29 21:04:13 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
return same_app;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// Non-transient windows with window role containing '#' are always
|
|
|
|
// considered belonging to different applications (unless
|
|
|
|
// the window role is exactly the same). KMainWindow sets
|
|
|
|
// window role this way by default, and different KMainWindow
|
|
|
|
// usually "are" different application from user's point of view.
|
|
|
|
// This help with no-focus-stealing for e.g. konqy reusing.
|
|
|
|
// On the other hand, if one of the windows is active, they are
|
|
|
|
// considered belonging to the same application. This is for
|
|
|
|
// the cases when opening new mainwindow directly from the application,
|
|
|
|
// e.g. 'Open New Window' in konqy ( active_hack == true ).
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::sameAppWindowRoleMatch(const X11Client *c1, const X11Client *c2, bool active_hack)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (c1->isTransient()) {
|
2019-09-24 08:48:08 +00:00
|
|
|
while (const X11Client *t = dynamic_cast<const X11Client *>(c1->transientFor()))
|
2015-09-11 09:37:40 +00:00
|
|
|
c1 = t;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (c1->groupTransient())
|
2007-04-29 17:35:43 +00:00
|
|
|
return c1->group() == c2->group();
|
|
|
|
#if 0
|
2011-01-30 14:34:42 +00:00
|
|
|
// if a group transient is in its own group, it didn't possibly have a group,
|
|
|
|
// and therefore should be considered belonging to the same app like
|
|
|
|
// all other windows from the same app
|
|
|
|
|| c1->group()->leaderClient() == c1 || c2->group()->leaderClient() == c2;
|
2007-04-29 17:35:43 +00:00
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (c2->isTransient()) {
|
2019-09-24 08:48:08 +00:00
|
|
|
while (const X11Client *t = dynamic_cast<const X11Client *>(c2->transientFor()))
|
2015-09-11 09:37:40 +00:00
|
|
|
c2 = t;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (c2->groupTransient())
|
2007-04-29 17:35:43 +00:00
|
|
|
return c1->group() == c2->group();
|
|
|
|
#if 0
|
2011-01-30 14:34:42 +00:00
|
|
|
|| c1->group()->leaderClient() == c1 || c2->group()->leaderClient() == c2;
|
2007-04-29 17:35:43 +00:00
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
int pos1 = c1->windowRole().indexOf('#');
|
|
|
|
int pos2 = c2->windowRole().indexOf('#');
|
2014-04-10 09:33:57 +00:00
|
|
|
if ((pos1 >= 0 && pos2 >= 0)) {
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!active_hack) // without the active hack for focus stealing prevention,
|
2007-04-29 17:35:43 +00:00
|
|
|
return c1 == c2; // different mainwindows are always different apps
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!c1->isActive() && !c2->isActive())
|
2007-04-29 17:35:43 +00:00
|
|
|
return c1 == c2;
|
|
|
|
else
|
|
|
|
return true;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return true;
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
Transiency stuff: ICCCM 4.1.2.6, NETWM 7.3
|
|
|
|
|
|
|
|
WM_TRANSIENT_FOR is basically means "this is my mainwindow".
|
|
|
|
For NET::Unknown windows, transient windows are considered to be NET::Dialog
|
|
|
|
windows, for compatibility with non-NETWM clients. KWin may adjust the value
|
|
|
|
of this property in some cases (window pointing to itself or creating a loop,
|
|
|
|
keeping NET::Splash windows above other windows from the same app, etc.).
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
X11Client::transient_for_id is the value of the WM_TRANSIENT_FOR property, after
|
|
|
|
possibly being adjusted by KWin. X11Client::transient_for points to the Client
|
|
|
|
this Client is transient for, or is NULL. If X11Client::transient_for_id is
|
2007-04-29 17:35:43 +00:00
|
|
|
poiting to the root window, the window is considered to be transient
|
|
|
|
for the whole window group, as suggested in NETWM 7.3.
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
In the case of group transient window, X11Client::transient_for is NULL,
|
|
|
|
and X11Client::groupTransient() returns true. Such window is treated as
|
2007-04-29 17:35:43 +00:00
|
|
|
if it were transient for every window in its window group that has been
|
|
|
|
mapped _before_ it (or, to be exact, was added to the same group before it).
|
|
|
|
Otherwise two group transients can create loops, which can lead very very
|
|
|
|
nasty things (bug #67914 and all its dupes).
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
X11Client::original_transient_for_id is the value of the property, which
|
|
|
|
may be different if X11Client::transient_for_id if e.g. forcing NET::Splash
|
2007-04-29 17:35:43 +00:00
|
|
|
to be kept on top of its window group, or when the mainwindow is not mapped
|
|
|
|
yet, in which case the window is temporarily made group transient,
|
|
|
|
and when the mainwindow is mapped, transiency is re-evaluated.
|
|
|
|
|
|
|
|
This can get a bit complicated with with e.g. two Konqueror windows created
|
|
|
|
by the same process. They should ideally appear like two independent applications
|
|
|
|
to the user. This should be accomplished by all windows in the same process
|
|
|
|
having the same window group (needs to be changed in Qt at the moment), and
|
|
|
|
using non-group transients poiting to their relevant mainwindow for toolwindows
|
|
|
|
etc. KWin should handle both group and non-group transient dialogs well.
|
|
|
|
|
|
|
|
In other words:
|
|
|
|
- non-transient windows : isTransient() == false
|
|
|
|
- normal transients : transientFor() != NULL
|
|
|
|
- group transients : groupTransient() == true
|
|
|
|
|
|
|
|
- list of mainwindows : mainClients() (call once and loop over the result)
|
|
|
|
- list of transients : transients()
|
|
|
|
- every window in the group : group()->members()
|
|
|
|
*/
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
Xcb::TransientFor X11Client::fetchTransient() const
|
2015-01-15 15:23:29 +00:00
|
|
|
{
|
|
|
|
return Xcb::TransientFor(window());
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::readTransientProperty(Xcb::TransientFor &transientFor)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-05-03 06:53:35 +00:00
|
|
|
xcb_window_t new_transient_for_id = XCB_WINDOW_NONE;
|
|
|
|
if (transientFor.getTransientFor(&new_transient_for_id)) {
|
|
|
|
m_originalTransientForId = new_transient_for_id;
|
2011-01-30 14:34:42 +00:00
|
|
|
new_transient_for_id = verifyTransientFor(new_transient_for_id, true);
|
|
|
|
} else {
|
2013-05-03 06:53:35 +00:00
|
|
|
m_originalTransientForId = XCB_WINDOW_NONE;
|
|
|
|
new_transient_for_id = verifyTransientFor(XCB_WINDOW_NONE, false);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
setTransient(new_transient_for_id);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::readTransient()
|
2015-01-15 15:23:29 +00:00
|
|
|
{
|
|
|
|
Xcb::TransientFor transientFor = fetchTransient();
|
|
|
|
readTransientProperty(transientFor);
|
|
|
|
}
|
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::setTransient(xcb_window_t new_transient_for_id)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-05-03 06:53:35 +00:00
|
|
|
if (new_transient_for_id != m_transientForId) {
|
2007-04-29 17:35:43 +00:00
|
|
|
removeFromMainClients();
|
2019-09-24 08:48:08 +00:00
|
|
|
X11Client *transient_for = nullptr;
|
2013-05-03 06:53:35 +00:00
|
|
|
m_transientForId = new_transient_for_id;
|
|
|
|
if (m_transientForId != XCB_WINDOW_NONE && !groupTransient()) {
|
2014-03-20 08:19:53 +00:00
|
|
|
transient_for = workspace()->findClient(Predicate::WindowMatch, m_transientForId);
|
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
|
|
|
Q_ASSERT(transient_for != nullptr); // verifyTransient() had to check this
|
2011-01-30 14:34:42 +00:00
|
|
|
transient_for->addTransient(this);
|
|
|
|
} // checkGroup() will check 'check_active_modal'
|
2015-09-11 09:37:40 +00:00
|
|
|
setTransientFor(transient_for);
|
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
|
|
|
checkGroup(nullptr, true); // force, because transiency has changed
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->updateClientLayer(this);
|
2010-12-31 13:44:17 +00:00
|
|
|
workspace()->resetUpdateToolWindowsTimer();
|
2011-12-22 16:00:08 +00:00
|
|
|
emit transientChanged();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
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 X11Client::removeFromMainClients()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2015-09-17 12:17:55 +00:00
|
|
|
if (transientFor())
|
|
|
|
transientFor()->removeTransient(this);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (groupTransient()) {
|
|
|
|
for (ClientList::ConstIterator it = group()->members().constBegin();
|
|
|
|
it != group()->members().constEnd();
|
|
|
|
++it)
|
|
|
|
(*it)->removeTransient(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// *sigh* this transiency handling is madness :(
|
|
|
|
// This one is called when destroying/releasing a window.
|
|
|
|
// It makes sure this client is removed from all grouping
|
|
|
|
// related lists.
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::cleanGrouping()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-09-02 11:14:39 +00:00
|
|
|
// qDebug() << "CLEANGROUPING:" << this;
|
2011-01-30 14:34:42 +00:00
|
|
|
// for ( ClientList::ConstIterator it = group()->members().begin();
|
2007-04-29 17:35:43 +00:00
|
|
|
// it != group()->members().end();
|
|
|
|
// ++it )
|
2013-09-02 11:14:39 +00:00
|
|
|
// qDebug() << "CL:" << *it;
|
2007-04-29 17:35:43 +00:00
|
|
|
// ClientList mains;
|
|
|
|
// mains = mainClients();
|
2011-01-30 14:34:42 +00:00
|
|
|
// for ( ClientList::ConstIterator it = mains.begin();
|
2007-04-29 17:35:43 +00:00
|
|
|
// it != mains.end();
|
|
|
|
// ++it )
|
2013-09-02 11:14:39 +00:00
|
|
|
// qDebug() << "MN:" << *it;
|
2007-04-29 17:35:43 +00:00
|
|
|
removeFromMainClients();
|
2013-09-02 11:14:39 +00:00
|
|
|
// qDebug() << "CLEANGROUPING2:" << this;
|
2011-01-30 14:34:42 +00:00
|
|
|
// for ( ClientList::ConstIterator it = group()->members().begin();
|
2007-04-29 17:35:43 +00:00
|
|
|
// it != group()->members().end();
|
|
|
|
// ++it )
|
2013-09-02 11:14:39 +00:00
|
|
|
// qDebug() << "CL2:" << *it;
|
2007-04-29 17:35:43 +00:00
|
|
|
// mains = mainClients();
|
2011-01-30 14:34:42 +00:00
|
|
|
// for ( ClientList::ConstIterator it = mains.begin();
|
2007-04-29 17:35:43 +00:00
|
|
|
// it != mains.end();
|
|
|
|
// ++it )
|
2013-09-02 11:14:39 +00:00
|
|
|
// qDebug() << "MN2:" << *it;
|
2015-09-14 08:55:27 +00:00
|
|
|
for (auto it = transients().constBegin();
|
|
|
|
it != transients().constEnd();
|
2011-01-30 14:34:42 +00:00
|
|
|
) {
|
|
|
|
if ((*it)->transientFor() == this) {
|
|
|
|
removeTransient(*it);
|
2015-09-14 08:55:27 +00:00
|
|
|
it = transients().constBegin(); // restart, just in case something more has changed with the list
|
2011-01-30 14:34:42 +00:00
|
|
|
} else
|
2007-04-29 17:35:43 +00:00
|
|
|
++it;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2013-09-02 11:14:39 +00:00
|
|
|
// qDebug() << "CLEANGROUPING3:" << this;
|
2011-01-30 14:34:42 +00:00
|
|
|
// for ( ClientList::ConstIterator it = group()->members().begin();
|
2007-04-29 17:35:43 +00:00
|
|
|
// it != group()->members().end();
|
|
|
|
// ++it )
|
2013-09-02 11:14:39 +00:00
|
|
|
// qDebug() << "CL3:" << *it;
|
2007-04-29 17:35:43 +00:00
|
|
|
// mains = mainClients();
|
2011-01-30 14:34:42 +00:00
|
|
|
// for ( ClientList::ConstIterator it = mains.begin();
|
2007-04-29 17:35:43 +00:00
|
|
|
// it != mains.end();
|
|
|
|
// ++it )
|
2013-09-02 11:14:39 +00:00
|
|
|
// qDebug() << "MN3:" << *it;
|
2007-04-29 17:35:43 +00:00
|
|
|
// HACK
|
|
|
|
// removeFromMainClients() did remove 'this' from transient
|
|
|
|
// lists of all group members, but then made windows that
|
|
|
|
// were transient for 'this' group transient, which again
|
|
|
|
// added 'this' to those transient lists :(
|
|
|
|
ClientList group_members = group()->members();
|
2011-01-30 14:34:42 +00:00
|
|
|
group()->removeMember(this);
|
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
|
|
|
in_group = nullptr;
|
2011-01-30 14:34:42 +00:00
|
|
|
for (ClientList::ConstIterator it = group_members.constBegin();
|
|
|
|
it != group_members.constEnd();
|
|
|
|
++it)
|
|
|
|
(*it)->removeTransient(this);
|
2013-09-02 11:14:39 +00:00
|
|
|
// qDebug() << "CLEANGROUPING4:" << this;
|
2011-01-30 14:34:42 +00:00
|
|
|
// for ( ClientList::ConstIterator it = group_members.begin();
|
2007-04-29 17:35:43 +00:00
|
|
|
// it != group_members.end();
|
|
|
|
// ++it )
|
2013-09-02 11:14:39 +00:00
|
|
|
// qDebug() << "CL4:" << *it;
|
2015-09-09 19:45:55 +00:00
|
|
|
m_transientForId = XCB_WINDOW_NONE;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// Make sure that no group transient is considered transient
|
|
|
|
// for a window that is (directly or indirectly) transient for it
|
|
|
|
// (including another group transients).
|
|
|
|
// Non-group transients not causing loops are checked in verifyTransientFor().
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::checkGroupTransients()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
for (ClientList::ConstIterator it1 = group()->members().constBegin();
|
|
|
|
it1 != group()->members().constEnd();
|
|
|
|
++it1) {
|
|
|
|
if (!(*it1)->groupTransient()) // check all group transients in the group
|
2007-04-29 17:35:43 +00:00
|
|
|
continue; // TODO optimize to check only the changed ones?
|
2011-01-30 14:34:42 +00:00
|
|
|
for (ClientList::ConstIterator it2 = group()->members().constBegin();
|
|
|
|
it2 != group()->members().constEnd();
|
|
|
|
++it2) { // group transients can be transient only for others in the group,
|
|
|
|
// so don't make them transient for the ones that are transient for it
|
|
|
|
if (*it1 == *it2)
|
2007-04-29 17:35:43 +00:00
|
|
|
continue;
|
2015-09-11 09:37:40 +00:00
|
|
|
for (AbstractClient* cl = (*it2)->transientFor();
|
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
|
|
|
cl != nullptr;
|
2011-01-30 14:34:42 +00:00
|
|
|
cl = cl->transientFor()) {
|
|
|
|
if (cl == *it1) {
|
|
|
|
// don't use removeTransient(), that would modify *it2 too
|
2015-09-14 08:55:27 +00:00
|
|
|
(*it2)->removeTransientFromList(*it1);
|
2007-04-29 17:35:43 +00:00
|
|
|
continue;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
// if *it1 and *it2 are both group transients, and are transient for each other,
|
|
|
|
// make only *it2 transient for *it1 (i.e. subwindow), as *it2 came later,
|
|
|
|
// and should be therefore on top of *it1
|
|
|
|
// TODO This could possibly be optimized, it also requires hasTransient() to check for loops.
|
2011-01-30 14:34:42 +00:00
|
|
|
if ((*it2)->groupTransient() && (*it1)->hasTransient(*it2, true) && (*it2)->hasTransient(*it1, true))
|
2015-09-14 08:55:27 +00:00
|
|
|
(*it2)->removeTransientFromList(*it1);
|
2007-04-29 17:35:43 +00:00
|
|
|
// if there are already windows W1 and W2, W2 being transient for W1, and group transient W3
|
|
|
|
// is added, make it transient only for W2, not for W1, because it's already indirectly
|
|
|
|
// transient for it - the indirect transiency actually shouldn't break anything,
|
|
|
|
// but it can lead to exponentially expensive operations (#95231)
|
|
|
|
// TODO this is pretty slow as well
|
2011-01-30 14:34:42 +00:00
|
|
|
for (ClientList::ConstIterator it3 = group()->members().constBegin();
|
|
|
|
it3 != group()->members().constEnd();
|
|
|
|
++it3) {
|
|
|
|
if (*it1 == *it2 || *it2 == *it3 || *it1 == *it3)
|
2007-04-29 17:35:43 +00:00
|
|
|
continue;
|
2011-01-30 14:34:42 +00:00
|
|
|
if ((*it2)->hasTransient(*it1, false) && (*it3)->hasTransient(*it1, false)) {
|
|
|
|
if ((*it2)->hasTransient(*it3, true))
|
2015-09-14 08:55:27 +00:00
|
|
|
(*it2)->removeTransientFromList(*it1);
|
2011-01-30 14:34:42 +00:00
|
|
|
if ((*it3)->hasTransient(*it2, true))
|
2015-09-14 08:55:27 +00:00
|
|
|
(*it3)->removeTransientFromList(*it1);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-02-02 18:17:44 +00:00
|
|
|
/**
|
|
|
|
* Check that the window is not transient for itself, and similar nonsense.
|
2019-07-29 18:58:33 +00:00
|
|
|
*/
|
2019-09-24 08:48:08 +00:00
|
|
|
xcb_window_t X11Client::verifyTransientFor(xcb_window_t new_transient_for, bool set)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-05-03 06:53:35 +00:00
|
|
|
xcb_window_t new_property_value = new_transient_for;
|
2007-04-29 17:35:43 +00:00
|
|
|
// make sure splashscreens are shown above all their app's windows, even though
|
|
|
|
// they're in Normal layer
|
2013-05-03 06:53:35 +00:00
|
|
|
if (isSplash() && new_transient_for == XCB_WINDOW_NONE)
|
2007-07-19 16:24:51 +00:00
|
|
|
new_transient_for = rootWindow();
|
2013-05-03 06:53:35 +00:00
|
|
|
if (new_transient_for == XCB_WINDOW_NONE) {
|
|
|
|
if (set) // sometimes WM_TRANSIENT_FOR is set to None, instead of root window
|
2007-07-19 16:24:51 +00:00
|
|
|
new_property_value = new_transient_for = rootWindow();
|
2007-04-29 17:35:43 +00:00
|
|
|
else
|
2013-05-03 06:53:35 +00:00
|
|
|
return XCB_WINDOW_NONE;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (new_transient_for == window()) { // pointing to self
|
|
|
|
// also fix the property itself
|
2014-12-05 10:42:15 +00:00
|
|
|
qCWarning(KWIN_CORE) << "Client " << this << " has WM_TRANSIENT_FOR poiting to itself." ;
|
2007-07-19 16:24:51 +00:00
|
|
|
new_property_value = new_transient_for = rootWindow();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
// The transient_for window may be embedded in another application,
|
|
|
|
// so kwin cannot see it. Try to find the managed client for the
|
|
|
|
// window and fix the transient_for property if possible.
|
2013-05-03 06:53:35 +00:00
|
|
|
xcb_window_t before_search = new_transient_for;
|
|
|
|
while (new_transient_for != XCB_WINDOW_NONE
|
2011-01-30 14:34:42 +00:00
|
|
|
&& new_transient_for != rootWindow()
|
2014-03-20 08:19:53 +00:00
|
|
|
&& !workspace()->findClient(Predicate::WindowMatch, new_transient_for)) {
|
2013-05-03 06:53:35 +00:00
|
|
|
Xcb::Tree tree(new_transient_for);
|
|
|
|
if (tree.isNull()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
break;
|
2013-05-03 06:53:35 +00:00
|
|
|
}
|
|
|
|
new_transient_for = tree->parent;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2019-09-24 08:48:08 +00:00
|
|
|
if (X11Client *new_transient_for_client = workspace()->findClient(Predicate::WindowMatch, new_transient_for)) {
|
2011-01-30 14:34:42 +00:00
|
|
|
if (new_transient_for != before_search) {
|
2014-12-05 10:42:15 +00:00
|
|
|
qCDebug(KWIN_CORE) << "Client " << this << " has WM_TRANSIENT_FOR poiting to non-toplevel window "
|
2015-07-20 11:35:45 +00:00
|
|
|
<< before_search << ", child of " << new_transient_for_client << ", adjusting.";
|
2007-04-29 17:35:43 +00:00
|
|
|
new_property_value = new_transient_for; // also fix the property
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
} else
|
2007-04-29 17:35:43 +00:00
|
|
|
new_transient_for = before_search; // nice try
|
|
|
|
// loop detection
|
|
|
|
// group transients cannot cause loops, because they're considered transient only for non-transient
|
|
|
|
// windows in the group
|
|
|
|
int count = 20;
|
2013-05-03 06:53:35 +00:00
|
|
|
xcb_window_t loop_pos = new_transient_for;
|
|
|
|
while (loop_pos != XCB_WINDOW_NONE && loop_pos != rootWindow()) {
|
2019-09-24 08:48:08 +00:00
|
|
|
X11Client *pos = workspace()->findClient(Predicate::WindowMatch, loop_pos);
|
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 (pos == nullptr)
|
2007-04-29 17:35:43 +00:00
|
|
|
break;
|
2013-05-03 06:53:35 +00:00
|
|
|
loop_pos = pos->m_transientForId;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (--count == 0 || pos == this) {
|
2014-12-05 10:42:15 +00:00
|
|
|
qCWarning(KWIN_CORE) << "Client " << this << " caused WM_TRANSIENT_FOR loop." ;
|
2007-07-19 16:24:51 +00:00
|
|
|
new_transient_for = rootWindow();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (new_transient_for != rootWindow()
|
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
|
|
|
&& workspace()->findClient(Predicate::WindowMatch, new_transient_for) == nullptr) {
|
2011-01-30 14:34:42 +00:00
|
|
|
// it's transient for a specific window, but that window is not mapped
|
2007-07-19 16:24:51 +00:00
|
|
|
new_transient_for = rootWindow();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2013-05-03 06:53:35 +00:00
|
|
|
if (new_property_value != m_originalTransientForId)
|
2013-06-26 23:05:13 +00:00
|
|
|
Xcb::setTransientFor(window(), new_property_value);
|
2011-01-30 14:34:42 +00:00
|
|
|
return new_transient_for;
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::addTransient(AbstractClient* cl)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2015-09-14 08:55:27 +00:00
|
|
|
AbstractClient::addTransient(cl);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (workspace()->mostRecentlyActivatedClient() == this && cl->isModal())
|
2007-04-29 17:35:43 +00:00
|
|
|
check_active_modal = true;
|
2013-09-02 11:14:39 +00:00
|
|
|
// qDebug() << "ADDTRANS:" << this << ":" << cl;
|
|
|
|
// qDebug() << kBacktrace();
|
2011-01-30 14:34:42 +00:00
|
|
|
// for ( ClientList::ConstIterator it = transients_list.begin();
|
2007-04-29 17:35:43 +00:00
|
|
|
// it != transients_list.end();
|
|
|
|
// ++it )
|
2013-09-02 11:14:39 +00:00
|
|
|
// qDebug() << "AT:" << (*it);
|
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 X11Client::removeTransient(AbstractClient* cl)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-09-02 11:14:39 +00:00
|
|
|
// qDebug() << "REMOVETRANS:" << this << ":" << cl;
|
|
|
|
// qDebug() << kBacktrace();
|
2007-04-29 17:35:43 +00:00
|
|
|
// cl is transient for this, but this is going away
|
|
|
|
// make cl group transient
|
2015-09-14 08:55:27 +00:00
|
|
|
AbstractClient::removeTransient(cl);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (cl->transientFor() == this) {
|
2019-09-24 08:48:08 +00:00
|
|
|
if (X11Client *c = dynamic_cast<X11Client *>(cl)) {
|
2015-09-14 08:55:27 +00:00
|
|
|
c->m_transientForId = XCB_WINDOW_NONE;
|
|
|
|
c->setTransientFor(nullptr); // SELI
|
2007-07-19 16:24:51 +00:00
|
|
|
// SELI cl->setTransient( rootWindow());
|
2015-09-14 08:55:27 +00:00
|
|
|
c->setTransient(XCB_WINDOW_NONE);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// A new window has been mapped. Check if it's not a mainwindow for this already existing window.
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::checkTransient(xcb_window_t w)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-05-03 06:53:35 +00:00
|
|
|
if (m_originalTransientForId != w)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
w = verifyTransientFor(w, true);
|
|
|
|
setTransient(w);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// returns true if cl is the transient_for window for this client,
|
|
|
|
// or recursively the transient_for window
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::hasTransient(const AbstractClient* cl, bool indirect) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-09-24 08:48:08 +00:00
|
|
|
if (const X11Client *c = dynamic_cast<const X11Client *>(cl)) {
|
2015-09-11 12:14:21 +00:00
|
|
|
// checkGroupTransients() uses this to break loops, so hasTransient() must detect them
|
|
|
|
ConstClientList set;
|
|
|
|
return hasTransientInternal(c, indirect, set);
|
|
|
|
}
|
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::hasTransientInternal(const X11Client *cl, bool indirect, ConstClientList& set) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2019-09-24 08:48:08 +00:00
|
|
|
if (const X11Client *t = dynamic_cast<const X11Client *>(cl->transientFor())) {
|
2015-09-11 09:37:40 +00:00
|
|
|
if (t == this)
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!indirect)
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (set.contains(cl))
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
set.append(cl);
|
2015-09-11 09:37:40 +00:00
|
|
|
return hasTransientInternal(t, indirect, set);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (!cl->isTransient())
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (group() != cl->group())
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
|
|
|
// cl is group transient, search from top
|
2019-09-24 08:48:08 +00:00
|
|
|
if (transients().contains(const_cast< X11Client *>(cl)))
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!indirect)
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (set.contains(this))
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
set.append(this);
|
2015-09-11 12:23:32 +00:00
|
|
|
for (auto it = transients().constBegin();
|
2011-01-30 14:34:42 +00:00
|
|
|
it != transients().constEnd();
|
2015-09-14 08:55:27 +00:00
|
|
|
++it) {
|
2019-09-24 08:48:08 +00:00
|
|
|
const X11Client *c = qobject_cast<const X11Client *>(*it);
|
2015-09-14 08:55:27 +00:00
|
|
|
if (!c) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (c->hasTransientInternal(cl, indirect, set))
|
2007-04-29 17:35:43 +00:00
|
|
|
return true;
|
2015-09-14 08:55:27 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
QList<AbstractClient*> X11Client::mainClients() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (!isTransient())
|
2015-09-11 13:55:23 +00:00
|
|
|
return QList<AbstractClient*>();
|
|
|
|
if (const AbstractClient *t = transientFor())
|
|
|
|
return QList<AbstractClient*>{const_cast< AbstractClient* >(t)};
|
|
|
|
QList<AbstractClient*> result;
|
2015-09-09 19:45:55 +00:00
|
|
|
Q_ASSERT(group());
|
2011-01-30 14:34:42 +00:00
|
|
|
for (ClientList::ConstIterator it = group()->members().constBegin();
|
|
|
|
it != group()->members().constEnd();
|
|
|
|
++it)
|
|
|
|
if ((*it)->hasTransient(this, false))
|
|
|
|
result.append(*it);
|
2007-04-29 17:35:43 +00:00
|
|
|
return result;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
AbstractClient* X11Client::findModal(bool allow_itself)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2015-09-11 12:23:32 +00:00
|
|
|
for (auto it = transients().constBegin();
|
2011-01-30 14:34:42 +00:00
|
|
|
it != transients().constEnd();
|
|
|
|
++it)
|
2015-03-05 12:59:18 +00:00
|
|
|
if (AbstractClient* ret = (*it)->findModal(true))
|
2007-04-29 17:35:43 +00:00
|
|
|
return ret;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isModal() && allow_itself)
|
2007-04-29 17:35:43 +00:00
|
|
|
return this;
|
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
|
|
|
return nullptr;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
// X11Client::window_group only holds the contents of the hint,
|
2007-04-29 17:35:43 +00:00
|
|
|
// but it should be used only to find the group, not for anything else
|
|
|
|
// Argument is only when some specific group needs to be set.
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::checkGroup(Group* set_group, bool force)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
Group* old_group = in_group;
|
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 (old_group != nullptr)
|
2007-04-30 09:49:41 +00:00
|
|
|
old_group->ref(); // turn off automatic deleting
|
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 (set_group != nullptr) {
|
2011-01-30 14:34:42 +00:00
|
|
|
if (set_group != in_group) {
|
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 (in_group != nullptr)
|
2011-01-30 14:34:42 +00:00
|
|
|
in_group->removeMember(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
in_group = set_group;
|
2011-01-30 14:34:42 +00:00
|
|
|
in_group->addMember(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2014-09-12 11:56:34 +00:00
|
|
|
} else if (info->groupLeader() != XCB_WINDOW_NONE) {
|
|
|
|
Group* new_group = workspace()->findGroup(info->groupLeader());
|
2019-09-24 08:48:08 +00:00
|
|
|
X11Client *t = qobject_cast<X11Client *>(transientFor());
|
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 (t != nullptr && t->group() != new_group) {
|
2011-01-30 14:34:42 +00:00
|
|
|
// move the window to the right group (e.g. a dialog provided
|
|
|
|
// by different app, but transient for this one, so make it part of that group)
|
2015-09-11 09:37:40 +00:00
|
|
|
new_group = t->group();
|
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 (new_group == nullptr) // doesn't exist yet
|
2014-09-12 11:56:34 +00:00
|
|
|
new_group = new Group(info->groupLeader());
|
2011-01-30 14:34:42 +00:00
|
|
|
if (new_group != in_group) {
|
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 (in_group != nullptr)
|
2011-01-30 14:34:42 +00:00
|
|
|
in_group->removeMember(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
in_group = new_group;
|
2011-01-30 14:34:42 +00:00
|
|
|
in_group->addMember(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
2019-09-24 08:48:08 +00:00
|
|
|
if (X11Client *t = qobject_cast<X11Client *>(transientFor())) {
|
2011-01-30 14:34:42 +00:00
|
|
|
// doesn't have window group set, but is transient for something
|
|
|
|
// so make it part of that group
|
2015-09-11 09:37:40 +00:00
|
|
|
Group* new_group = t->group();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (new_group != in_group) {
|
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 (in_group != nullptr)
|
2011-01-30 14:34:42 +00:00
|
|
|
in_group->removeMember(this);
|
2015-09-11 09:37:40 +00:00
|
|
|
in_group = t->group();
|
2011-01-30 14:34:42 +00:00
|
|
|
in_group->addMember(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
} else if (groupTransient()) {
|
|
|
|
// group transient which actually doesn't have a group :(
|
|
|
|
// try creating group with other windows with the same client leader
|
|
|
|
Group* new_group = workspace()->findClientLeaderGroup(this);
|
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 (new_group == nullptr)
|
2019-09-06 14:30:26 +00:00
|
|
|
new_group = new Group(XCB_WINDOW_NONE);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (new_group != in_group) {
|
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 (in_group != nullptr)
|
2011-01-30 14:34:42 +00:00
|
|
|
in_group->removeMember(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
in_group = new_group;
|
2011-01-30 14:34:42 +00:00
|
|
|
in_group->addMember(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
} else { // Not transient without a group, put it in its client leader group.
|
|
|
|
// This might be stupid if grouping was used for e.g. taskbar grouping
|
|
|
|
// or minimizing together the whole group, but as long as it is used
|
|
|
|
// only for dialogs it's better to keep windows from one app in one group.
|
|
|
|
Group* new_group = workspace()->findClientLeaderGroup(this);
|
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 (in_group != nullptr && in_group != new_group) {
|
2011-01-30 14:34:42 +00:00
|
|
|
in_group->removeMember(this);
|
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
|
|
|
in_group = nullptr;
|
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 (new_group == nullptr)
|
2019-09-06 14:30:26 +00:00
|
|
|
new_group = new Group(XCB_WINDOW_NONE);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (in_group != new_group) {
|
2007-04-30 11:33:14 +00:00
|
|
|
in_group = new_group;
|
2011-01-30 14:34:42 +00:00
|
|
|
in_group->addMember(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (in_group != old_group || force) {
|
2015-09-14 08:55:27 +00:00
|
|
|
for (auto it = transients().constBegin();
|
|
|
|
it != transients().constEnd();
|
2011-01-30 14:34:42 +00:00
|
|
|
) {
|
2018-12-31 17:57:13 +00:00
|
|
|
auto *c = *it;
|
2011-01-30 14:34:42 +00:00
|
|
|
// group transients in the old group are no longer transient for it
|
2015-09-14 08:55:27 +00:00
|
|
|
if (c->groupTransient() && c->group() != group()) {
|
|
|
|
removeTransientFromList(c);
|
|
|
|
it = transients().constBegin(); // restart, just in case something more has changed with the list
|
|
|
|
} else
|
2007-04-29 17:35:43 +00:00
|
|
|
++it;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (groupTransient()) {
|
2007-04-30 09:45:56 +00:00
|
|
|
// no longer transient for ones in the old group
|
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 (old_group != nullptr) {
|
2011-01-30 14:34:42 +00:00
|
|
|
for (ClientList::ConstIterator it = old_group->members().constBegin();
|
|
|
|
it != old_group->members().constEnd();
|
|
|
|
++it)
|
|
|
|
(*it)->removeTransient(this);
|
|
|
|
}
|
2007-04-30 09:45:56 +00:00
|
|
|
// and make transient for all in the new group
|
2011-01-30 14:34:42 +00:00
|
|
|
for (ClientList::ConstIterator it = group()->members().constBegin();
|
|
|
|
it != group()->members().constEnd();
|
|
|
|
++it) {
|
|
|
|
if (*it == this)
|
2007-04-30 09:45:56 +00:00
|
|
|
break; // this means the window is only transient for windows mapped before it
|
2011-01-30 14:34:42 +00:00
|
|
|
(*it)->addTransient(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
// group transient splashscreens should be transient even for windows
|
|
|
|
// in group mapped later
|
2011-01-30 14:34:42 +00:00
|
|
|
for (ClientList::ConstIterator it = group()->members().constBegin();
|
|
|
|
it != group()->members().constEnd();
|
|
|
|
++it) {
|
|
|
|
if (!(*it)->isSplash())
|
2007-04-29 17:35:43 +00:00
|
|
|
continue;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!(*it)->groupTransient())
|
2007-04-29 17:35:43 +00:00
|
|
|
continue;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (*it == this || hasTransient(*it, true)) // TODO indirect?
|
2007-04-29 17:35:43 +00:00
|
|
|
continue;
|
2011-01-30 14:34:42 +00:00
|
|
|
addTransient(*it);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
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 (old_group != nullptr)
|
2007-04-30 09:49:41 +00:00
|
|
|
old_group->deref(); // can be now deleted if empty
|
2007-04-29 17:35:43 +00:00
|
|
|
checkGroupTransients();
|
|
|
|
checkActiveModal();
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->updateClientLayer(this);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-04-30 09:44:32 +00:00
|
|
|
// used by Workspace::findClientLeaderGroup()
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::changeClientLeaderGroup(Group* gr)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-30 09:44:32 +00:00
|
|
|
// transientFor() != NULL are in the group of their mainwindow, so keep them there
|
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 (transientFor() != nullptr)
|
2007-04-30 09:44:32 +00:00
|
|
|
return;
|
|
|
|
// also don't change the group for window which have group set
|
2014-09-12 11:56:34 +00:00
|
|
|
if (info->groupLeader())
|
2007-04-30 09:44:32 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
checkGroup(gr); // change group
|
|
|
|
}
|
2007-04-30 09:44:32 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
bool X11Client::check_active_modal = false;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2019-09-24 08:48:08 +00:00
|
|
|
void X11Client::checkActiveModal()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
// if the active window got new modal transient, activate it.
|
|
|
|
// cannot be done in AddTransient(), because there may temporarily
|
|
|
|
// exist loops, breaking findModal
|
2019-09-24 08:48:08 +00:00
|
|
|
X11Client *check_modal = dynamic_cast<X11Client *>(workspace()->mostRecentlyActivatedClient());
|
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 (check_modal != nullptr && check_modal->check_active_modal) {
|
2019-09-24 08:48:08 +00:00
|
|
|
X11Client *new_modal = dynamic_cast<X11Client *>(check_modal->findModal());
|
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 (new_modal != nullptr && new_modal != check_modal) {
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!new_modal->isManaged())
|
2007-04-29 17:35:43 +00:00
|
|
|
return; // postpone check until end of manage()
|
2011-01-30 14:34:42 +00:00
|
|
|
workspace()->activateClient(new_modal);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
check_modal->check_active_modal = false;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
} // namespace
|