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
|
|
|
|
|
|
|
// SELI zmenit doc
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
This file contains things relevant to stacking order and layers.
|
|
|
|
|
|
|
|
Design:
|
|
|
|
|
|
|
|
Normal unconstrained stacking order, as requested by the user (by clicking
|
|
|
|
on windows to raise them, etc.), is in Workspace::unconstrained_stacking_order.
|
|
|
|
That list shouldn't be used at all, except for building
|
|
|
|
Workspace::stacking_order. The building is done
|
|
|
|
in Workspace::constrainedStackingOrder(). Only Workspace::stackingOrder() should
|
|
|
|
be used to get the stacking order, because it also checks the stacking order
|
|
|
|
is up to date.
|
|
|
|
All clients are also stored in Workspace::clients (except for isDesktop() clients,
|
|
|
|
as those are very special, and are stored in Workspace::desktops), in the order
|
|
|
|
the clients were created.
|
|
|
|
|
2014-01-20 10:02:07 +00:00
|
|
|
Every window has one layer assigned in which it is. There are 7 layers,
|
2015-01-02 11:11:54 +00:00
|
|
|
from bottom : DesktopLayer, BelowLayer, NormalLayer, DockLayer, AboveLayer, NotificationLayer,
|
|
|
|
ActiveLayer and OnScreenDisplayLayer (see also NETWM sect.7.10.). The layer a window is in depends
|
2014-01-20 10:02:07 +00:00
|
|
|
on the window type, and on other things like whether the window is active. We extend the layers
|
2015-01-02 11:11:54 +00:00
|
|
|
provided in NETWM by the NotificationLayer and OnScreenDisplayLayer.
|
|
|
|
The NoficationLayer contains notification windows which are kept above all windows except the active
|
|
|
|
fullscreen window. The OnScreenDisplayLayer is used for eg. volume and brightness change feedback and
|
|
|
|
is kept above all windows since it provides immediate response to a user action.
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
NET::Splash clients belong to the Normal layer. NET::TopMenu clients
|
|
|
|
belong to Dock layer. Clients that are both NET::Dock and NET::KeepBelow
|
|
|
|
are in the Normal layer in order to keep the 'allow window to cover
|
|
|
|
the panel' Kicker setting to work as intended (this may look like a slight
|
|
|
|
spec violation, but a) I have no better idea, b) the spec allows adjusting
|
|
|
|
the stacking order if the WM thinks it's a good idea . We put all
|
|
|
|
NET::KeepAbove above all Docks too, even though the spec suggests putting
|
|
|
|
them in the same layer.
|
|
|
|
|
|
|
|
Most transients are in the same layer as their mainwindow,
|
|
|
|
see Workspace::constrainedStackingOrder(), they may also be in higher layers, but
|
|
|
|
they should never be below their mainwindow.
|
|
|
|
|
|
|
|
When some client attribute changes (above/below flag, transiency...),
|
|
|
|
Workspace::updateClientLayer() should be called in order to make
|
|
|
|
sure it's moved to the appropriate layer ClientList if needed.
|
|
|
|
|
|
|
|
Currently the things that affect client in which layer a client
|
|
|
|
belongs: KeepAbove/Keep Below flags, window type, fullscreen
|
|
|
|
state and whether the client is active, mainclient (transiency).
|
|
|
|
|
|
|
|
Make sure updateStackingOrder() is called in order to make
|
|
|
|
Workspace::stackingOrder() up to date and propagated to the world.
|
|
|
|
Using Workspace::blockStackingUpdates() (or the StackingUpdatesBlocker
|
|
|
|
helper class) it's possible to temporarily disable updates
|
|
|
|
and the stacking order will be updated once after it's allowed again.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include "utils.h"
|
|
|
|
#include "client.h"
|
2012-11-20 16:26:50 +00:00
|
|
|
#include "focuschain.h"
|
2013-04-26 08:41:24 +00:00
|
|
|
#include "netinfo.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "workspace.h"
|
|
|
|
#include "tabbox.h"
|
|
|
|
#include "group.h"
|
|
|
|
#include "rules.h"
|
2013-04-03 10:19:27 +00:00
|
|
|
#include "screens.h"
|
2007-05-23 16:22:59 +00:00
|
|
|
#include "unmanaged.h"
|
2008-04-24 12:53:03 +00:00
|
|
|
#include "deleted.h"
|
2010-09-25 18:51:18 +00:00
|
|
|
#include "effects.h"
|
2011-08-21 19:50:23 +00:00
|
|
|
#include "composite.h"
|
2013-01-21 08:04:06 +00:00
|
|
|
#include "screenedge.h"
|
2015-05-21 08:35:03 +00:00
|
|
|
#include "shell_client.h"
|
|
|
|
#include "wayland_server.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-09-02 11:14:39 +00:00
|
|
|
#include <QDebug>
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
//*******************************
|
|
|
|
// Workspace
|
|
|
|
//*******************************
|
|
|
|
|
2015-03-13 08:26:09 +00:00
|
|
|
void Workspace::updateClientLayer(AbstractClient* c)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-11-17 16:37:46 +00:00
|
|
|
if (c)
|
|
|
|
c->updateLayer();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Workspace::updateStackingOrder(bool propagate_new_clients)
|
|
|
|
{
|
|
|
|
if (block_stacking_updates > 0) {
|
|
|
|
if (propagate_new_clients)
|
2007-04-29 17:35:43 +00:00
|
|
|
blocked_propagating_new_clients = true;
|
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2012-04-08 08:07:35 +00:00
|
|
|
ToplevelList new_stacking_order = constrainedStackingOrder();
|
2012-09-25 20:46:03 +00:00
|
|
|
bool changed = (force_restacking || new_stacking_order != stacking_order);
|
2007-07-04 09:51:10 +00:00
|
|
|
force_restacking = false;
|
2007-04-29 17:35:43 +00:00
|
|
|
stacking_order = new_stacking_order;
|
|
|
|
#if 0
|
2014-12-05 10:42:15 +00:00
|
|
|
qCDebug(KWIN_CORE) << "stacking:" << changed;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (changed || propagate_new_clients) {
|
|
|
|
for (ClientList::ConstIterator it = stacking_order.begin();
|
|
|
|
it != stacking_order.end();
|
|
|
|
++it)
|
2014-12-05 10:42:15 +00:00
|
|
|
qCDebug(KWIN_CORE) << (void*)(*it) << *it << ":" << (*it)->layer();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
if (changed || propagate_new_clients) {
|
|
|
|
propagateClients(propagate_new_clients);
|
2013-01-01 00:47:16 +00:00
|
|
|
emit stackingOrderChanged();
|
2011-08-21 19:50:23 +00:00
|
|
|
if (m_compositor) {
|
|
|
|
m_compositor->addRepaintFull();
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (active_client)
|
2007-04-29 22:37:19 +00:00
|
|
|
active_client->updateMouseGrab();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-02-08 19:59:35 +00:00
|
|
|
/*!
|
|
|
|
* Some fullscreen effects have to raise the screenedge on top of an input window, thus all windows
|
|
|
|
* this function puts them back where they belong for regular use and is some cheap variant of
|
|
|
|
* the regular propagateClients function in that it completely ignores managed clients and everything
|
|
|
|
* else and also does not update the NETWM property.
|
|
|
|
* Called from Effects::destroyInputWindow so far.
|
|
|
|
*/
|
|
|
|
void Workspace::stackScreenEdgesUnderOverrideRedirect()
|
|
|
|
{
|
2013-04-29 10:17:42 +00:00
|
|
|
Xcb::restackWindows(QVector<xcb_window_t>() << rootInfo()->supportWindow() << ScreenEdges::self()->windows());
|
2013-02-08 19:59:35 +00:00
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
/*!
|
|
|
|
Propagates the managed clients to the world.
|
|
|
|
Called ONLY from updateStackingOrder().
|
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
void Workspace::propagateClients(bool propagate_new_clients)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
// restack the windows according to the stacking order
|
2013-02-07 21:18:05 +00:00
|
|
|
// supportWindow > electric borders > clients > hidden clients
|
|
|
|
QVector<xcb_window_t> newWindowStack;
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// Stack all windows under the support window. The support window is
|
|
|
|
// not used for anything (besides the NETWM property), and it's not shown,
|
|
|
|
// but it was lowered after kwin startup. Stacking all clients below
|
|
|
|
// it ensures that no client will be ever shown above override-redirect
|
|
|
|
// windows (e.g. popups).
|
2013-04-29 10:17:42 +00:00
|
|
|
newWindowStack << rootInfo()->supportWindow();
|
2013-02-07 21:18:05 +00:00
|
|
|
|
|
|
|
newWindowStack << ScreenEdges::self()->windows();
|
|
|
|
|
|
|
|
newWindowStack.reserve(newWindowStack.size() + 2*stacking_order.size()); // *2 for inputWindow
|
|
|
|
|
|
|
|
for (int i = stacking_order.size() - 1; i >= 0; --i) {
|
2012-04-08 08:07:35 +00:00
|
|
|
Client *client = qobject_cast<Client*>(stacking_order.at(i));
|
|
|
|
if (!client || client->hiddenPreview()) {
|
2007-07-04 09:51:10 +00:00
|
|
|
continue;
|
2011-06-25 17:50:16 +00:00
|
|
|
}
|
2011-11-09 19:39:13 +00:00
|
|
|
|
|
|
|
if (client->inputId())
|
|
|
|
// Stack the input window above the frame
|
2013-02-07 21:18:05 +00:00
|
|
|
newWindowStack << client->inputId();
|
2011-11-09 19:39:13 +00:00
|
|
|
|
2013-02-07 21:18:05 +00:00
|
|
|
newWindowStack << client->frameId();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2012-01-13 02:08:40 +00:00
|
|
|
|
|
|
|
// when having hidden previews, stack hidden windows below everything else
|
|
|
|
// (as far as pure X stacking order is concerned), in order to avoid having
|
|
|
|
// these windows that should be unmapped to interfere with other windows
|
2013-02-07 21:18:05 +00:00
|
|
|
for (int i = stacking_order.size() - 1; i >= 0; --i) {
|
2012-04-08 08:07:35 +00:00
|
|
|
Client *client = qobject_cast<Client*>(stacking_order.at(i));
|
|
|
|
if (!client || !client->hiddenPreview())
|
2012-01-13 02:08:40 +00:00
|
|
|
continue;
|
2013-02-07 21:18:05 +00:00
|
|
|
newWindowStack << client->frameId();
|
2012-01-13 02:08:40 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
// TODO isn't it too inefficient to restack always all clients?
|
|
|
|
// TODO don't restack not visible windows?
|
2013-04-29 10:17:42 +00:00
|
|
|
assert(newWindowStack.at(0) == rootInfo()->supportWindow());
|
2013-02-07 21:18:05 +00:00
|
|
|
Xcb::restackWindows(newWindowStack);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-06-25 17:50:16 +00:00
|
|
|
int pos = 0;
|
2013-11-18 12:57:46 +00:00
|
|
|
xcb_window_t *cl(nullptr);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (propagate_new_clients) {
|
2013-11-18 12:57:46 +00:00
|
|
|
cl = new xcb_window_t[ desktops.count() + clients.count()];
|
2011-01-30 14:34:42 +00:00
|
|
|
// TODO this is still not completely in the map order
|
|
|
|
for (ClientList::ConstIterator it = desktops.constBegin(); it != desktops.constEnd(); ++it)
|
|
|
|
cl[pos++] = (*it)->window();
|
|
|
|
for (ClientList::ConstIterator it = clients.constBegin(); it != clients.constEnd(); ++it)
|
|
|
|
cl[pos++] = (*it)->window();
|
2013-04-29 10:17:42 +00:00
|
|
|
rootInfo()->setClientList(cl, pos);
|
2007-04-29 17:35:43 +00:00
|
|
|
delete [] cl;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-11-18 12:57:46 +00:00
|
|
|
cl = new xcb_window_t[ stacking_order.count()];
|
2007-04-29 17:35:43 +00:00
|
|
|
pos = 0;
|
2012-09-25 20:46:03 +00:00
|
|
|
for (ToplevelList::ConstIterator it = stacking_order.constBegin(); it != stacking_order.constEnd(); ++it) {
|
|
|
|
if ((*it)->isClient())
|
|
|
|
cl[pos++] = (*it)->window();
|
|
|
|
}
|
2013-04-29 10:17:42 +00:00
|
|
|
rootInfo()->setClientListStacking(cl, pos);
|
2007-04-29 17:35:43 +00:00
|
|
|
delete [] cl;
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2008-10-01 12:49:52 +00:00
|
|
|
// Make the cached stacking order invalid here, in case we need the new stacking order before we get
|
|
|
|
// the matching event, due to X being asynchronous.
|
2009-02-06 14:21:20 +00:00
|
|
|
x_stacking_dirty = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-06 14:21:20 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
/*!
|
|
|
|
Returns topmost visible client. Windows on the dock, the desktop
|
|
|
|
or of any other special kind are excluded. Also if the window
|
|
|
|
doesn't accept focus it's excluded.
|
|
|
|
*/
|
2008-08-23 09:20:42 +00:00
|
|
|
// TODO misleading name for this method, too many slightly different ways to use it
|
2011-01-30 14:34:42 +00:00
|
|
|
Client* Workspace::topClientOnDesktop(int desktop, int screen, bool unconstrained, bool only_normal) const
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
// TODO Q_ASSERT( block_stacking_updates == 0 );
|
2012-04-08 08:07:35 +00:00
|
|
|
ToplevelList list;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!unconstrained)
|
2007-04-29 22:39:07 +00:00
|
|
|
list = stacking_order;
|
2007-04-29 17:35:43 +00:00
|
|
|
else
|
2007-04-29 22:39:07 +00:00
|
|
|
list = unconstrained_stacking_order;
|
2011-01-30 14:34:42 +00:00
|
|
|
for (int i = list.size() - 1;
|
|
|
|
i >= 0;
|
|
|
|
--i) {
|
2012-04-08 08:07:35 +00:00
|
|
|
Client *c = qobject_cast<Client*>(list.at(i));
|
|
|
|
if (!c) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (c->isOnDesktop(desktop) && c->isShown(false) && c->isOnCurrentActivity()) {
|
|
|
|
if (screen != -1 && c->screen() != screen)
|
2008-08-23 09:20:42 +00:00
|
|
|
continue;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!only_normal)
|
2012-04-08 08:07:35 +00:00
|
|
|
return c;
|
|
|
|
if (c->wantsTabFocus() && !c->isSpecialWindow())
|
|
|
|
return c;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
Client* Workspace::findDesktop(bool topmost, int desktop) const
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
// TODO Q_ASSERT( block_stacking_updates == 0 );
|
2011-01-30 14:34:42 +00:00
|
|
|
if (topmost) {
|
|
|
|
for (int i = stacking_order.size() - 1; i >= 0; i--) {
|
2012-04-08 08:07:35 +00:00
|
|
|
Client *c = qobject_cast<Client*>(stacking_order.at(i));
|
|
|
|
if (c && c->isOnDesktop(desktop) && c->isDesktop()
|
2011-01-30 14:34:42 +00:00
|
|
|
&& c->isShown(true))
|
2007-04-29 17:35:43 +00:00
|
|
|
return c;
|
|
|
|
}
|
2012-04-08 08:07:35 +00:00
|
|
|
} else { // bottom-most
|
|
|
|
foreach (Toplevel * c, stacking_order) {
|
|
|
|
Client *client = qobject_cast<Client*>(c);
|
|
|
|
if (client && c->isOnDesktop(desktop) && c->isDesktop()
|
|
|
|
&& client->isShown(true))
|
|
|
|
return client;
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2015-03-05 12:35:54 +00:00
|
|
|
void Workspace::raiseOrLowerClient(AbstractClient *c)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
if (!c) return;
|
2015-03-05 12:35:54 +00:00
|
|
|
AbstractClient* topmost = NULL;
|
2007-04-29 17:35:43 +00:00
|
|
|
// TODO Q_ASSERT( block_stacking_updates == 0 );
|
2011-01-30 14:34:42 +00:00
|
|
|
if (most_recently_raised && stacking_order.contains(most_recently_raised) &&
|
|
|
|
most_recently_raised->isShown(true) && c->isOnCurrentDesktop())
|
2007-04-29 17:35:43 +00:00
|
|
|
topmost = most_recently_raised;
|
|
|
|
else
|
2012-11-16 07:23:47 +00:00
|
|
|
topmost = topClientOnDesktop(c->isOnAllDesktops() ? VirtualDesktopManager::self()->current() : c->desktop(),
|
2012-02-20 09:25:13 +00:00
|
|
|
options->isSeparateScreenFocus() ? c->screen() : -1);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (c == topmost)
|
2007-04-29 17:35:43 +00:00
|
|
|
lowerClient(c);
|
|
|
|
else
|
|
|
|
raiseClient(c);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
|
2015-03-05 12:35:54 +00:00
|
|
|
void Workspace::lowerClient(AbstractClient* c, bool nogroup)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (!c)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
c->cancelAutoRaise();
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
StackingUpdatesBlocker blocker(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
unconstrained_stacking_order.removeAll(c);
|
|
|
|
unconstrained_stacking_order.prepend(c);
|
|
|
|
if (!nogroup && c->isTransient()) {
|
2008-03-21 17:12:21 +00:00
|
|
|
// lower also all windows in the group, in their reversed stacking order
|
2015-03-05 12:35:54 +00:00
|
|
|
ClientList wins = ensureStackingOrder(static_cast<Client*>(c)->group()->members());
|
2011-01-30 14:34:42 +00:00
|
|
|
for (int i = wins.size() - 1;
|
|
|
|
i >= 0;
|
|
|
|
--i) {
|
|
|
|
if (wins[ i ] != c)
|
|
|
|
lowerClient(wins[ i ], true);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (c == most_recently_raised)
|
2007-04-29 17:35:43 +00:00
|
|
|
most_recently_raised = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Workspace::lowerClientWithinApplication(Client* c)
|
|
|
|
{
|
|
|
|
if (!c)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
c->cancelAutoRaise();
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
StackingUpdatesBlocker blocker(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
unconstrained_stacking_order.removeAll(c);
|
2007-04-29 17:35:43 +00:00
|
|
|
bool lowered = false;
|
|
|
|
// first try to put it below the bottom-most window of the application
|
2012-04-08 08:07:35 +00:00
|
|
|
for (ToplevelList::Iterator it = unconstrained_stacking_order.begin();
|
2011-01-30 14:34:42 +00:00
|
|
|
it != unconstrained_stacking_order.end();
|
2012-05-26 14:57:37 +00:00
|
|
|
++it) {
|
|
|
|
Client *client = qobject_cast<Client*>(*it);
|
|
|
|
if (!client) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (Client::belongToSameApplication(client, c)) {
|
2011-01-30 14:34:42 +00:00
|
|
|
unconstrained_stacking_order.insert(it, c);
|
2007-04-29 17:35:43 +00:00
|
|
|
lowered = true;
|
|
|
|
break;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2012-05-26 14:57:37 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!lowered)
|
|
|
|
unconstrained_stacking_order.prepend(c);
|
2007-04-29 17:35:43 +00:00
|
|
|
// ignore mainwindows
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2015-03-05 12:35:54 +00:00
|
|
|
void Workspace::raiseClient(AbstractClient* c, bool nogroup)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (!c)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
c->cancelAutoRaise();
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
StackingUpdatesBlocker blocker(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!nogroup && c->isTransient()) {
|
2015-09-11 09:37:40 +00:00
|
|
|
QList<AbstractClient*> transients;
|
|
|
|
AbstractClient *transient_parent = c;
|
2009-10-03 15:40:58 +00:00
|
|
|
while ((transient_parent = transient_parent->transientFor()))
|
|
|
|
transients << transient_parent;
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (transient_parent, transients)
|
2011-12-11 18:00:43 +00:00
|
|
|
raiseClient(transient_parent, true);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
unconstrained_stacking_order.removeAll(c);
|
|
|
|
unconstrained_stacking_order.append(c);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!c->isSpecialWindow()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
most_recently_raised = c;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Workspace::raiseClientWithinApplication(Client* c)
|
|
|
|
{
|
|
|
|
if (!c)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
c->cancelAutoRaise();
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
StackingUpdatesBlocker blocker(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
// ignore mainwindows
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// first try to put it above the top-most window of the application
|
2011-12-11 18:00:43 +00:00
|
|
|
for (int i = unconstrained_stacking_order.size() - 1; i > -1 ; --i) {
|
2012-04-08 08:07:35 +00:00
|
|
|
Client *other = qobject_cast<Client*>(unconstrained_stacking_order.at(i));
|
|
|
|
if (!other) {
|
|
|
|
continue;
|
|
|
|
}
|
2011-12-11 18:00:43 +00:00
|
|
|
if (other == c) // don't lower it just because it asked to be raised
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2011-12-11 18:00:43 +00:00
|
|
|
if (Client::belongToSameApplication(other, c)) {
|
2011-01-30 14:34:42 +00:00
|
|
|
unconstrained_stacking_order.removeAll(c);
|
2011-12-11 18:00:43 +00:00
|
|
|
unconstrained_stacking_order.insert(unconstrained_stacking_order.indexOf(other) + 1, c); // insert after the found one
|
|
|
|
break;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-04-30 14:01:25 +00:00
|
|
|
void Workspace::raiseClientRequest(KWin::Client *c, NET::RequestSource src, xcb_timestamp_t timestamp)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (src == NET::FromTool || allowFullClientRaising(c, timestamp))
|
|
|
|
raiseClient(c);
|
|
|
|
else {
|
|
|
|
raiseClientWithinApplication(c);
|
2007-04-29 17:35:43 +00:00
|
|
|
c->demandAttention();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-04-30 14:01:25 +00:00
|
|
|
void Workspace::lowerClientRequest(KWin::Client *c, NET::RequestSource src, xcb_timestamp_t /*timestamp*/)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
// If the client has support for all this focus stealing prevention stuff,
|
|
|
|
// do only lowering within the application, as that's the more logical
|
|
|
|
// variant of lowering when application requests it.
|
|
|
|
// No demanding of attention here of course.
|
2011-01-30 14:34:42 +00:00
|
|
|
if (src == NET::FromTool || !c->hasUserTimeSupport())
|
|
|
|
lowerClient(c);
|
2007-04-29 17:35:43 +00:00
|
|
|
else
|
2011-01-30 14:34:42 +00:00
|
|
|
lowerClientWithinApplication(c);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
|
2015-03-05 11:10:30 +00:00
|
|
|
void Workspace::restack(AbstractClient* c, AbstractClient* under, bool force)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
assert(unconstrained_stacking_order.contains(under));
|
2015-03-05 11:10:30 +00:00
|
|
|
if (!force && !AbstractClient::belongToSameApplication(under, c)) {
|
2011-12-11 18:00:43 +00:00
|
|
|
// put in the stacking order below _all_ windows belonging to the active application
|
2012-04-24 19:10:16 +00:00
|
|
|
for (int i = 0; i < unconstrained_stacking_order.size(); ++i) {
|
2015-03-05 11:10:30 +00:00
|
|
|
AbstractClient *other = qobject_cast<AbstractClient*>(unconstrained_stacking_order.at(i));
|
|
|
|
if (other && other->layer() == c->layer() && AbstractClient::belongToSameApplication(under, other)) {
|
2011-12-11 18:00:43 +00:00
|
|
|
under = (c == other) ? 0 : other;
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2011-12-11 18:00:43 +00:00
|
|
|
if (under) {
|
|
|
|
unconstrained_stacking_order.removeAll(c);
|
|
|
|
unconstrained_stacking_order.insert(unconstrained_stacking_order.indexOf(under), c);
|
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
assert(unconstrained_stacking_order.contains(c));
|
2012-11-20 16:26:50 +00:00
|
|
|
FocusChain::self()->moveAfterClient(c, under);
|
2011-01-30 14:34:42 +00:00
|
|
|
updateStackingOrder();
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2015-03-06 14:32:35 +00:00
|
|
|
void Workspace::restackClientUnderActive(AbstractClient* c)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-09-09 20:38:23 +00:00
|
|
|
if (!active_client || active_client == c || active_client->layer() != c->layer()) {
|
2011-01-30 14:34:42 +00:00
|
|
|
raiseClient(c);
|
2010-10-17 19:49:07 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
restack(c, active_client);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Workspace::restoreSessionStackingOrder(Client* c)
|
|
|
|
{
|
|
|
|
if (c->sessionStackingOrder() < 0)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
StackingUpdatesBlocker blocker(this);
|
|
|
|
unconstrained_stacking_order.removeAll(c);
|
2012-04-08 08:07:35 +00:00
|
|
|
for (ToplevelList::Iterator it = unconstrained_stacking_order.begin(); // from bottom
|
2011-01-30 14:34:42 +00:00
|
|
|
it != unconstrained_stacking_order.end();
|
|
|
|
++it) {
|
2012-04-08 08:07:35 +00:00
|
|
|
Client *current = qobject_cast<Client*>(*it);
|
|
|
|
if (!current) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (current->sessionStackingOrder() > c->sessionStackingOrder()) {
|
2011-01-30 14:34:42 +00:00
|
|
|
unconstrained_stacking_order.insert(it, c);
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
unconstrained_stacking_order.append(c);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns a stacking order based upon \a list that fulfills certain contained.
|
|
|
|
*/
|
2012-04-07 15:29:22 +00:00
|
|
|
ToplevelList Workspace::constrainedStackingOrder()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-04-07 15:29:22 +00:00
|
|
|
ToplevelList layer[ NumLayers ];
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#if 0
|
2014-12-05 10:42:15 +00:00
|
|
|
qCDebug(KWIN_CORE) << "stacking1:";
|
2011-01-30 14:34:42 +00:00
|
|
|
for (ClientList::ConstIterator it = unconstrained_stacking_order.begin();
|
|
|
|
it != unconstrained_stacking_order.end();
|
|
|
|
++it)
|
2014-12-05 10:42:15 +00:00
|
|
|
qCDebug(KWIN_CORE) << (void*)(*it) << *it << ":" << (*it)->layer();
|
2007-04-29 17:35:43 +00:00
|
|
|
#endif
|
|
|
|
// build the order from layers
|
2013-04-03 10:19:27 +00:00
|
|
|
QVector< QMap<Group*, Layer> > minimum_layer(screens()->count());
|
2012-04-08 08:07:35 +00:00
|
|
|
for (ToplevelList::ConstIterator it = unconstrained_stacking_order.constBegin(),
|
2012-03-07 14:19:06 +00:00
|
|
|
end = unconstrained_stacking_order.constEnd(); it != end; ++it) {
|
2007-04-29 17:35:43 +00:00
|
|
|
Layer l = (*it)->layer();
|
2012-03-07 14:19:06 +00:00
|
|
|
|
|
|
|
const int screen = (*it)->screen();
|
2012-04-08 08:07:35 +00:00
|
|
|
Client *c = qobject_cast<Client*>(*it);
|
|
|
|
QMap< Group*, Layer >::iterator mLayer = minimum_layer[screen].find(c ? c->group() : NULL);
|
2012-03-07 14:19:06 +00:00
|
|
|
if (mLayer != minimum_layer[screen].end()) {
|
|
|
|
// If a window is raised above some other window in the same window group
|
|
|
|
// which is in the ActiveLayer (i.e. it's fulscreened), make sure it stays
|
|
|
|
// above that window (see #95731).
|
2014-01-20 10:02:07 +00:00
|
|
|
if (*mLayer == ActiveLayer && (l > BelowLayer))
|
2012-03-07 14:19:06 +00:00
|
|
|
l = ActiveLayer;
|
|
|
|
*mLayer = l;
|
2012-04-08 08:07:35 +00:00
|
|
|
} else if (c) {
|
|
|
|
minimum_layer[screen].insertMulti(c->group(), l);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
layer[ l ].append(*it);
|
|
|
|
}
|
2012-04-07 15:29:22 +00:00
|
|
|
ToplevelList stacking;
|
2011-01-30 14:34:42 +00:00
|
|
|
for (Layer lay = FirstLayer;
|
|
|
|
lay < NumLayers;
|
|
|
|
++lay)
|
2007-04-29 17:35:43 +00:00
|
|
|
stacking += layer[ lay ];
|
|
|
|
#if 0
|
2014-12-05 10:42:15 +00:00
|
|
|
qCDebug(KWIN_CORE) << "stacking2:";
|
2011-01-30 14:34:42 +00:00
|
|
|
for (ClientList::ConstIterator it = stacking.begin();
|
|
|
|
it != stacking.end();
|
|
|
|
++it)
|
2014-12-05 10:42:15 +00:00
|
|
|
qCDebug(KWIN_CORE) << (void*)(*it) << *it << ":" << (*it)->layer();
|
2007-04-29 17:35:43 +00:00
|
|
|
#endif
|
|
|
|
// now keep transients above their mainwindows
|
|
|
|
// TODO this could(?) use some optimization
|
2011-01-30 14:34:42 +00:00
|
|
|
for (int i = stacking.size() - 1;
|
|
|
|
i >= 0;
|
|
|
|
) {
|
2015-09-14 09:05:18 +00:00
|
|
|
AbstractClient *current = qobject_cast<AbstractClient*>(stacking[i]);
|
2012-04-07 15:29:22 +00:00
|
|
|
if (!current || !current->isTransient()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
--i;
|
|
|
|
continue;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
int i2 = -1;
|
2015-09-14 09:05:18 +00:00
|
|
|
Client *ccurrent = qobject_cast<Client*>(current);
|
|
|
|
if (ccurrent && ccurrent->groupTransient()) {
|
|
|
|
if (ccurrent->group()->members().count() > 0) {
|
2011-01-30 14:34:42 +00:00
|
|
|
// find topmost client this one is transient for
|
|
|
|
for (i2 = stacking.size() - 1;
|
|
|
|
i2 >= 0;
|
|
|
|
--i2) {
|
|
|
|
if (stacking[ i2 ] == stacking[ i ]) {
|
2008-07-01 14:09:41 +00:00
|
|
|
i2 = -1; // don't reorder, already the topmost in the group
|
2007-04-29 17:35:43 +00:00
|
|
|
break;
|
|
|
|
}
|
2015-09-11 12:14:21 +00:00
|
|
|
AbstractClient *c2 = qobject_cast<AbstractClient*>(stacking[ i2 ]);
|
2012-04-07 15:29:22 +00:00
|
|
|
if (!c2) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (c2->hasTransient(current, true)
|
|
|
|
&& keepTransientAbove(c2, current))
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
} // else i2 remains pointing at -1
|
|
|
|
} else {
|
|
|
|
for (i2 = stacking.size() - 1;
|
|
|
|
i2 >= 0;
|
|
|
|
--i2) {
|
2015-09-11 11:49:06 +00:00
|
|
|
AbstractClient *c2 = qobject_cast<AbstractClient*>(stacking[ i2 ]);
|
2012-04-07 15:29:22 +00:00
|
|
|
if (!c2) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (c2 == current) {
|
2008-07-01 14:09:41 +00:00
|
|
|
i2 = -1; // don't reorder, already on top of its mainwindow
|
2007-04-29 17:35:43 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-04-07 15:29:22 +00:00
|
|
|
if (c2 == current->transientFor()
|
|
|
|
&& keepTransientAbove(c2, current))
|
2011-01-30 14:34:42 +00:00
|
|
|
break;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
if (i2 == -1) {
|
2007-04-29 17:35:43 +00:00
|
|
|
--i;
|
|
|
|
continue;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
stacking.removeAt(i);
|
|
|
|
--i; // move onto the next item (for next for () iteration)
|
2008-07-01 14:09:41 +00:00
|
|
|
--i2; // adjust index of the mainwindow after the remove above
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!current->transients().isEmpty()) // this one now can be possibly above its transients,
|
2007-04-29 17:35:43 +00:00
|
|
|
i = i2; // so go again higher in the stack order and possibly move those transients again
|
2008-07-01 14:09:41 +00:00
|
|
|
++i2; // insert after (on top of) the mainwindow, it's ok if it2 is now stacking.end()
|
2011-01-30 14:34:42 +00:00
|
|
|
stacking.insert(i2, current);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
#if 0
|
2014-12-05 10:42:15 +00:00
|
|
|
qCDebug(KWIN_CORE) << "stacking3:";
|
2011-01-30 14:34:42 +00:00
|
|
|
for (ClientList::ConstIterator it = stacking.begin();
|
|
|
|
it != stacking.end();
|
|
|
|
++it)
|
2014-12-05 10:42:15 +00:00
|
|
|
qCDebug(KWIN_CORE) << (void*)(*it) << *it << ":" << (*it)->layer();
|
|
|
|
qCDebug(KWIN_CORE) << "\n\n";
|
2007-04-29 17:35:43 +00:00
|
|
|
#endif
|
|
|
|
return stacking;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Workspace::blockStackingUpdates(bool block)
|
|
|
|
{
|
|
|
|
if (block) {
|
|
|
|
if (block_stacking_updates == 0)
|
2007-04-29 17:35:43 +00:00
|
|
|
blocked_propagating_new_clients = false;
|
|
|
|
++block_stacking_updates;
|
2011-01-30 14:34:42 +00:00
|
|
|
} else // !block
|
|
|
|
if (--block_stacking_updates == 0) {
|
|
|
|
updateStackingOrder(blocked_propagating_new_clients);
|
|
|
|
if (effects)
|
|
|
|
static_cast<EffectsHandlerImpl*>(effects)->checkInputWindowStacking();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2015-09-14 07:20:05 +00:00
|
|
|
namespace {
|
|
|
|
template <class T>
|
|
|
|
QList<T*> ensureStackingOrderInList(const ToplevelList &stackingOrder, const QList<T*> &list)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2015-09-14 07:20:05 +00:00
|
|
|
static_assert(std::is_base_of<Toplevel, T>::value,
|
|
|
|
"U must be derived from T");
|
2007-04-29 17:35:43 +00:00
|
|
|
// TODO Q_ASSERT( block_stacking_updates == 0 );
|
2011-01-30 14:34:42 +00:00
|
|
|
if (list.count() < 2)
|
2007-04-29 17:35:43 +00:00
|
|
|
return list;
|
|
|
|
// TODO is this worth optimizing?
|
2015-09-14 07:20:05 +00:00
|
|
|
QList<T*> result = list;
|
|
|
|
for (auto it = stackingOrder.begin();
|
|
|
|
it != stackingOrder.end();
|
2012-04-08 08:07:35 +00:00
|
|
|
++it) {
|
2015-09-14 07:20:05 +00:00
|
|
|
T *c = qobject_cast<T*>(*it);
|
2012-04-08 08:07:35 +00:00
|
|
|
if (!c) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (result.removeAll(c) != 0)
|
|
|
|
result.append(c);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
return result;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2015-09-14 07:20:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Ensure list is in stacking order
|
|
|
|
ClientList Workspace::ensureStackingOrder(const ClientList& list) const
|
|
|
|
{
|
|
|
|
return ensureStackingOrderInList(stacking_order, list);
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<AbstractClient*> Workspace::ensureStackingOrder(const QList<AbstractClient*> &list) const
|
|
|
|
{
|
|
|
|
return ensureStackingOrderInList(stacking_order, list);
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// check whether a transient should be actually kept above its mainwindow
|
|
|
|
// there may be some special cases where this rule shouldn't be enfored
|
2015-09-11 11:49:06 +00:00
|
|
|
bool Workspace::keepTransientAbove(const AbstractClient* mainwindow, const AbstractClient* transient)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
// #93832 - don't keep splashscreens above dialogs
|
2011-01-30 14:34:42 +00:00
|
|
|
if (transient->isSplash() && mainwindow->isDialog())
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
|
|
|
// This is rather a hack for #76026. Don't keep non-modal dialogs above
|
|
|
|
// the mainwindow, but only if they're group transient (since only such dialogs
|
|
|
|
// have taskbar entry in Kicker). A proper way of doing this (both kwin and kicker)
|
|
|
|
// needs to be found.
|
2015-09-11 11:49:06 +00:00
|
|
|
if (const Client *ct = dynamic_cast<const Client*>(transient)) {
|
|
|
|
if (ct->isDialog() && !ct->isModal() && ct->groupTransient())
|
|
|
|
return false;
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
// #63223 - don't keep transients above docks, because the dock is kept high,
|
|
|
|
// and e.g. dialogs for them would be too high too
|
2011-01-30 14:34:42 +00:00
|
|
|
if (mainwindow->isDock())
|
2007-04-29 17:35:43 +00:00
|
|
|
return false;
|
|
|
|
return true;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2008-08-24 10:35:45 +00:00
|
|
|
// Returns all windows in their stacking order on the root window.
|
|
|
|
ToplevelList Workspace::xStackingOrder() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (!x_stacking_dirty)
|
2008-08-24 10:35:45 +00:00
|
|
|
return x_stacking;
|
|
|
|
x_stacking_dirty = false;
|
|
|
|
x_stacking.clear();
|
2013-08-02 06:42:33 +00:00
|
|
|
Xcb::Tree tree(rootWindow());
|
2008-07-04 14:06:23 +00:00
|
|
|
// use our own stacking order, not the X one, as they may differ
|
2012-04-08 08:07:35 +00:00
|
|
|
foreach (Toplevel * c, stacking_order)
|
2011-01-30 14:34:42 +00:00
|
|
|
x_stacking.append(c);
|
2013-08-02 06:42:33 +00:00
|
|
|
|
2015-03-20 11:39:33 +00:00
|
|
|
if (!tree.isNull()) {
|
|
|
|
xcb_window_t *windows = tree.children();
|
|
|
|
const auto count = tree->children_len;
|
|
|
|
int foundUnmanagedCount = unmanaged.count();
|
|
|
|
for (unsigned int i = 0;
|
|
|
|
i < count;
|
|
|
|
++i) {
|
|
|
|
for (auto it = unmanaged.constBegin(); it != unmanaged.constEnd(); ++it) {
|
|
|
|
Unmanaged *u = *it;
|
|
|
|
if (u->window() == windows[i]) {
|
|
|
|
x_stacking.append(u);
|
|
|
|
foundUnmanagedCount--;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (foundUnmanagedCount == 0) {
|
2015-01-15 07:32:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-05-23 16:22:59 +00:00
|
|
|
}
|
2015-05-21 08:35:03 +00:00
|
|
|
if (waylandServer()) {
|
|
|
|
const auto clients = waylandServer()->internalClients();
|
|
|
|
for (auto c: clients) {
|
|
|
|
x_stacking << c;
|
|
|
|
}
|
|
|
|
}
|
2011-08-21 19:50:23 +00:00
|
|
|
if (m_compositor) {
|
|
|
|
const_cast< Workspace* >(this)->m_compositor->checkUnredirect();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return x_stacking;
|
|
|
|
}
|
2007-05-23 16:22:59 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
//*******************************
|
|
|
|
// Client
|
|
|
|
//*******************************
|
|
|
|
|
2013-05-03 08:27:04 +00:00
|
|
|
void Client::restackWindow(xcb_window_t above, int detail, NET::RequestSource src, xcb_timestamp_t timestamp, bool send_event)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2011-12-11 18:00:43 +00:00
|
|
|
Client *other = 0;
|
2013-05-03 08:27:04 +00:00
|
|
|
if (detail == XCB_STACK_MODE_OPPOSITE) {
|
2014-03-20 08:19:53 +00:00
|
|
|
other = workspace()->findClient(Predicate::WindowMatch, above);
|
2011-12-11 18:00:43 +00:00
|
|
|
if (!other) {
|
|
|
|
workspace()->raiseOrLowerClient(this);
|
|
|
|
return;
|
|
|
|
}
|
2012-04-08 08:07:35 +00:00
|
|
|
ToplevelList::const_iterator it = workspace()->stackingOrder().constBegin(),
|
2011-12-11 18:00:43 +00:00
|
|
|
end = workspace()->stackingOrder().constEnd();
|
|
|
|
while (it != end) {
|
|
|
|
if (*it == this) {
|
2013-05-03 08:27:04 +00:00
|
|
|
detail = XCB_STACK_MODE_ABOVE;
|
2011-12-11 18:00:43 +00:00
|
|
|
break;
|
|
|
|
} else if (*it == other) {
|
2013-05-03 08:27:04 +00:00
|
|
|
detail = XCB_STACK_MODE_BELOW;
|
2011-12-11 18:00:43 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
++it;
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2013-05-03 08:27:04 +00:00
|
|
|
else if (detail == XCB_STACK_MODE_TOP_IF) {
|
2014-03-20 08:19:53 +00:00
|
|
|
other = workspace()->findClient(Predicate::WindowMatch, above);
|
2011-12-11 18:00:43 +00:00
|
|
|
if (other && other->geometry().intersects(geometry()))
|
|
|
|
workspace()->raiseClientRequest(this, src, timestamp);
|
|
|
|
return;
|
|
|
|
}
|
2013-05-03 08:27:04 +00:00
|
|
|
else if (detail == XCB_STACK_MODE_BOTTOM_IF) {
|
2014-03-20 08:19:53 +00:00
|
|
|
other = workspace()->findClient(Predicate::WindowMatch, above);
|
2011-12-11 18:00:43 +00:00
|
|
|
if (other && other->geometry().intersects(geometry()))
|
|
|
|
workspace()->lowerClientRequest(this, src, timestamp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!other)
|
2014-03-20 08:19:53 +00:00
|
|
|
other = workspace()->findClient(Predicate::WindowMatch, above);
|
2011-12-11 18:00:43 +00:00
|
|
|
|
2013-05-03 08:27:04 +00:00
|
|
|
if (other && detail == XCB_STACK_MODE_ABOVE) {
|
2012-04-08 08:07:35 +00:00
|
|
|
ToplevelList::const_iterator it = workspace()->stackingOrder().constEnd(),
|
2011-12-11 18:00:43 +00:00
|
|
|
begin = workspace()->stackingOrder().constBegin();
|
|
|
|
while (--it != begin) {
|
|
|
|
|
|
|
|
if (*it == other) { // the other one is top on stack
|
|
|
|
it = begin; // invalidate
|
|
|
|
src = NET::FromTool; // force
|
|
|
|
break;
|
|
|
|
}
|
2012-04-08 08:07:35 +00:00
|
|
|
Client *c = qobject_cast<Client*>(*it);
|
2011-12-11 18:00:43 +00:00
|
|
|
|
2012-04-24 19:10:16 +00:00
|
|
|
if (!c || !( (*it)->isNormalWindow() && c->isShown(true) &&
|
2011-12-11 18:00:43 +00:00
|
|
|
(*it)->isOnCurrentDesktop() && (*it)->isOnCurrentActivity() && (*it)->isOnScreen(screen()) ))
|
|
|
|
continue; // irrelevant clients
|
|
|
|
|
|
|
|
if (*(it - 1) == other)
|
|
|
|
break; // "it" is the one above the target one, stack below "it"
|
|
|
|
}
|
|
|
|
|
|
|
|
if (it != begin && (*(it - 1) == other))
|
2012-04-08 08:07:35 +00:00
|
|
|
other = qobject_cast<Client*>(*it);
|
2011-12-11 18:00:43 +00:00
|
|
|
else
|
|
|
|
other = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (other)
|
|
|
|
workspace()->restack(this, other);
|
2013-05-03 08:27:04 +00:00
|
|
|
else if (detail == XCB_STACK_MODE_BELOW)
|
2011-12-11 18:00:43 +00:00
|
|
|
workspace()->lowerClientRequest(this, src, timestamp);
|
2013-05-03 08:27:04 +00:00
|
|
|
else if (detail == XCB_STACK_MODE_ABOVE)
|
2011-12-11 18:00:43 +00:00
|
|
|
workspace()->raiseClientRequest(this, src, timestamp);
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
if (send_event)
|
|
|
|
sendSyntheticConfigureNotify();
|
|
|
|
}
|
|
|
|
|
2015-03-13 08:36:43 +00:00
|
|
|
void Client::doSetKeepAbove()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
// Update states of all other windows in this group
|
2012-01-12 06:42:55 +00:00
|
|
|
if (tabGroup())
|
2012-03-15 23:15:13 +00:00
|
|
|
tabGroup()->updateStates(this, TabGroup::Layer);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2015-03-13 08:36:43 +00:00
|
|
|
void Client::doSetKeepBelow()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-11-15 03:24:04 +00:00
|
|
|
// Update states of all other windows in this group
|
2012-01-12 06:42:55 +00:00
|
|
|
if (tabGroup())
|
2012-03-15 23:15:13 +00:00
|
|
|
tabGroup()->updateStates(this, TabGroup::Layer);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
Layer Client::layer() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (in_layer == UnknownLayer)
|
|
|
|
const_cast< Client* >(this)->in_layer = belongsToLayer();
|
2007-04-29 17:35:43 +00:00
|
|
|
return in_layer;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
Layer Client::belongsToLayer() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2015-05-13 20:31:22 +00:00
|
|
|
// NOTICE while showingDesktop, desktops move to the AboveLayer
|
|
|
|
// (interchangeable w/ eg. yakuake etc. which will at first remain visible)
|
|
|
|
// and the docks move into the NotificationLayer (which is between Above- and
|
|
|
|
// ActiveLayer, so that active fullscreen windows will still cover everything)
|
|
|
|
// Since the desktop is also activated, nothing should be in the ActiveLayer, though
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isDesktop())
|
2015-02-18 00:37:45 +00:00
|
|
|
return workspace()->showingDesktop() ? AboveLayer : DesktopLayer;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isSplash()) // no damn annoying splashscreens
|
2007-04-29 17:35:43 +00:00
|
|
|
return NormalLayer; // getting in the way of everything else
|
2012-03-16 01:31:50 +00:00
|
|
|
if (isDock()) {
|
2015-05-13 20:31:22 +00:00
|
|
|
if (workspace()->showingDesktop())
|
|
|
|
return NotificationLayer;
|
2007-04-29 17:35:43 +00:00
|
|
|
// slight hack for the 'allow window to cover panel' Kicker setting
|
|
|
|
// don't move keepbelow docks below normal window, but only to the same
|
|
|
|
// layer, so that both may be raised to cover the other
|
2012-03-16 01:31:50 +00:00
|
|
|
if (keepBelow())
|
|
|
|
return NormalLayer;
|
|
|
|
if (keepAbove()) // slight hack for the autohiding panels
|
|
|
|
return AboveLayer;
|
|
|
|
return DockLayer;
|
|
|
|
}
|
2015-01-02 11:11:54 +00:00
|
|
|
if (isOnScreenDisplay())
|
|
|
|
return OnScreenDisplayLayer;
|
2014-01-20 10:02:07 +00:00
|
|
|
if (isNotification())
|
|
|
|
return NotificationLayer;
|
2015-05-13 21:10:19 +00:00
|
|
|
if (workspace()->showingDesktop()) {
|
|
|
|
foreach (const Client *c, group()->members()) {
|
|
|
|
if (c->isDesktop())
|
|
|
|
return AboveLayer;
|
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
if (keepBelow())
|
2007-04-29 17:35:43 +00:00
|
|
|
return BelowLayer;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (isActiveFullScreen())
|
2007-04-29 17:35:43 +00:00
|
|
|
return ActiveLayer;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (keepAbove())
|
2007-04-29 17:35:43 +00:00
|
|
|
return AboveLayer;
|
2015-01-02 11:11:54 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
return NormalLayer;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2013-11-17 16:37:46 +00:00
|
|
|
void Client::updateLayer()
|
|
|
|
{
|
|
|
|
if (layer() == belongsToLayer())
|
|
|
|
return;
|
2015-09-14 10:04:23 +00:00
|
|
|
AbstractClient::updateLayer();
|
2013-11-17 16:37:46 +00:00
|
|
|
}
|
|
|
|
|
2015-09-14 08:55:27 +00:00
|
|
|
bool rec_checkTransientOnTop(const QList<AbstractClient*> &transients, const Client *topmost)
|
2012-02-04 15:45:30 +00:00
|
|
|
{
|
2015-09-14 08:55:27 +00:00
|
|
|
foreach (const AbstractClient *transient, transients) {
|
2012-02-04 15:45:30 +00:00
|
|
|
if (transient == topmost || rec_checkTransientOnTop(transient->transients(), topmost)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-08-23 09:20:42 +00:00
|
|
|
bool Client::isActiveFullScreen() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-02-04 15:45:30 +00:00
|
|
|
if (!isFullScreen())
|
|
|
|
return false;
|
|
|
|
|
2015-03-12 10:56:55 +00:00
|
|
|
const Client* ac = dynamic_cast<Client*>(workspace()->mostRecentlyActivatedClient()); // instead of activeClient() - avoids flicker
|
2013-03-18 16:26:34 +00:00
|
|
|
// according to NETWM spec implementation notes suggests
|
|
|
|
// "focused windows having state _NET_WM_STATE_FULLSCREEN" to be on the highest layer.
|
|
|
|
// we'll also take the screen into account
|
|
|
|
return ac && (ac == this || this->group() == ac->group() || ac->screen() != screen());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-08-23 09:20:42 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
} // namespace
|