2007-11-27 22:40:25 +03:00
|
|
|
/********************************************************************
|
2007-04-29 21:35:43 +04:00
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
2007-11-27 22:40:25 +03: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 21:35:43 +04:00
|
|
|
|
|
|
|
#include "toplevel.h"
|
|
|
|
|
2013-04-04 18:14:12 +04:00
|
|
|
#ifdef KWIN_BUILD_ACTIVITIES
|
|
|
|
#include "activities.h"
|
|
|
|
#endif
|
2007-04-29 21:35:43 +04:00
|
|
|
#include "atoms.h"
|
|
|
|
#include "client.h"
|
2013-01-07 11:07:27 +04:00
|
|
|
#include "client_machine.h"
|
2007-04-29 21:35:43 +04:00
|
|
|
#include "effects.h"
|
2013-04-03 14:19:27 +04:00
|
|
|
#include "screens.h"
|
2011-03-27 14:33:07 +04:00
|
|
|
#include "shadow.h"
|
2012-12-21 18:11:31 +04:00
|
|
|
#include "xcbutils.h"
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2015-02-24 12:54:28 +03:00
|
|
|
#include <KWayland/Server/surface_interface.h>
|
|
|
|
|
2013-09-02 15:14:39 +04:00
|
|
|
#include <QDebug>
|
|
|
|
|
2007-04-29 21:35:43 +04:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2013-05-08 15:39:06 +04:00
|
|
|
Toplevel::Toplevel()
|
2014-04-25 14:06:39 +04:00
|
|
|
: m_visual(XCB_NONE)
|
2015-06-01 17:25:21 +03:00
|
|
|
, bit_depth(24)
|
2011-01-30 17:34:42 +03:00
|
|
|
, info(NULL)
|
2012-10-31 21:01:31 +04:00
|
|
|
, ready_for_painting(true)
|
2012-11-15 10:48:08 +04:00
|
|
|
, m_isDamaged(false)
|
2013-09-10 09:09:44 +04:00
|
|
|
, m_client()
|
2011-01-30 17:34:42 +03:00
|
|
|
, damage_handle(None)
|
|
|
|
, is_shape(false)
|
|
|
|
, effect_window(NULL)
|
2013-01-07 11:07:27 +04:00
|
|
|
, m_clientMachine(new ClientMachine(this))
|
2011-01-30 17:34:42 +03:00
|
|
|
, wmClientLeaderWin(0)
|
|
|
|
, unredirect(false)
|
|
|
|
, unredirectSuspend(false)
|
2012-03-28 22:29:33 +04:00
|
|
|
, m_damageReplyPending(false)
|
2013-03-26 10:45:08 +04:00
|
|
|
, m_screen(0)
|
2014-01-24 15:34:16 +04:00
|
|
|
, m_skipCloseAnimation(false)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2012-08-23 15:42:59 +04:00
|
|
|
connect(this, SIGNAL(damaged(KWin::Toplevel*,QRect)), SIGNAL(needsRepaint()));
|
2013-04-03 14:19:27 +04:00
|
|
|
connect(screens(), SIGNAL(changed()), SLOT(checkScreen()));
|
2013-05-11 00:03:59 +04:00
|
|
|
connect(screens(), SIGNAL(countChanged(int,int)), SLOT(checkScreen()));
|
2013-03-26 10:45:08 +04:00
|
|
|
setupCheckScreenConnection();
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
Toplevel::~Toplevel()
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
|
|
|
assert(damage_handle == None);
|
2007-04-29 21:35:43 +04:00
|
|
|
delete info;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
QDebug& operator<<(QDebug& stream, const Toplevel* cl)
|
|
|
|
{
|
|
|
|
if (cl == NULL)
|
2007-04-29 21:35:43 +04:00
|
|
|
return stream << "\'NULL\'";
|
2011-01-30 17:34:42 +03:00
|
|
|
cl->debug(stream);
|
2007-04-29 21:35:43 +04:00
|
|
|
return stream;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
QDebug& operator<<(QDebug& stream, const ToplevelList& list)
|
|
|
|
{
|
2007-04-29 21:35:43 +04:00
|
|
|
stream << "LIST:(";
|
|
|
|
bool first = true;
|
2011-01-30 17:34:42 +03:00
|
|
|
for (ToplevelList::ConstIterator it = list.begin();
|
|
|
|
it != list.end();
|
|
|
|
++it) {
|
|
|
|
if (!first)
|
2007-04-29 21:35:43 +04:00
|
|
|
stream << ":";
|
|
|
|
first = false;
|
|
|
|
stream << *it;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
stream << ")";
|
|
|
|
return stream;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2011-07-14 00:50:31 +04:00
|
|
|
QRect Toplevel::decorationRect() const
|
|
|
|
{
|
2012-03-10 14:34:56 +04:00
|
|
|
return rect();
|
2011-07-14 00:50:31 +04:00
|
|
|
}
|
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void Toplevel::detectShape(Window id)
|
|
|
|
{
|
2012-01-15 14:03:15 +04:00
|
|
|
const bool wasShape = is_shape;
|
2012-12-21 18:11:31 +04:00
|
|
|
is_shape = Xcb::Extensions::self()->hasShape(id);
|
2012-01-15 14:03:15 +04:00
|
|
|
if (wasShape != is_shape) {
|
|
|
|
emit shapedChanged();
|
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
// used only by Deleted::copy()
|
2011-01-30 17:34:42 +03:00
|
|
|
void Toplevel::copyToDeleted(Toplevel* c)
|
|
|
|
{
|
2007-04-29 21:35:43 +04:00
|
|
|
geom = c->geom;
|
2014-04-25 14:06:39 +04:00
|
|
|
m_visual = c->m_visual;
|
2007-04-29 21:35:43 +04:00
|
|
|
bit_depth = c->bit_depth;
|
|
|
|
info = c->info;
|
2013-09-10 09:09:44 +04:00
|
|
|
m_client.reset(c->m_client, false);
|
2007-06-25 12:51:44 +04:00
|
|
|
ready_for_painting = c->ready_for_painting;
|
2007-04-29 21:35:43 +04:00
|
|
|
damage_handle = None;
|
|
|
|
damage_region = c->damage_region;
|
|
|
|
repaints_region = c->repaints_region;
|
|
|
|
is_shape = c->is_shape;
|
|
|
|
effect_window = c->effect_window;
|
2011-01-30 17:34:42 +03:00
|
|
|
if (effect_window != NULL)
|
|
|
|
effect_window->setWindow(this);
|
2007-04-29 21:35:43 +04:00
|
|
|
resource_name = c->resourceName();
|
|
|
|
resource_class = c->resourceClass();
|
2013-01-07 11:07:27 +04:00
|
|
|
m_clientMachine = c->m_clientMachine;
|
|
|
|
m_clientMachine->setParent(this);
|
2007-04-29 21:35:43 +04:00
|
|
|
wmClientLeaderWin = c->wmClientLeader();
|
2011-10-22 13:02:49 +04:00
|
|
|
opaque_region = c->opaqueRegion();
|
2013-03-26 10:45:08 +04:00
|
|
|
m_screen = c->m_screen;
|
2014-01-24 15:34:16 +04:00
|
|
|
m_skipCloseAnimation = c->m_skipCloseAnimation;
|
2015-08-18 15:40:26 +03:00
|
|
|
m_internalFBO = c->m_internalFBO;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
// before being deleted, remove references to everything that's now
|
|
|
|
// owner by Deleted
|
|
|
|
void Toplevel::disownDataPassedToDeleted()
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2007-04-29 21:35:43 +04:00
|
|
|
info = NULL;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2009-06-12 00:12:11 +04:00
|
|
|
QRect Toplevel::visibleRect() const
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2012-05-05 18:38:02 +04:00
|
|
|
QRect r = decorationRect();
|
2011-11-25 04:00:54 +04:00
|
|
|
if (hasShadow() && !shadow()->shadowRegion().isEmpty()) {
|
2012-05-05 18:38:02 +04:00
|
|
|
r |= shadow()->shadowRegion().boundingRect();
|
2011-03-27 14:33:07 +04:00
|
|
|
}
|
2012-05-05 18:38:02 +04:00
|
|
|
return r.translated(geometry().topLeft());
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2009-06-12 00:12:11 +04:00
|
|
|
|
2015-01-15 16:33:28 +03:00
|
|
|
Xcb::Property Toplevel::fetchWmClientLeader() const
|
|
|
|
{
|
|
|
|
return Xcb::Property(false, window(), atoms->wm_client_leader, XCB_ATOM_WINDOW, 0, 10000);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Toplevel::readWmClientLeader(Xcb::Property &prop)
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2014-04-15 12:09:25 +04:00
|
|
|
wmClientLeaderWin = prop.value<xcb_window_t>(window());
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2015-01-15 16:33:28 +03:00
|
|
|
void Toplevel::getWmClientLeader()
|
|
|
|
{
|
|
|
|
auto prop = fetchWmClientLeader();
|
|
|
|
readWmClientLeader(prop);
|
|
|
|
}
|
|
|
|
|
2007-04-29 21:35:43 +04:00
|
|
|
/*!
|
|
|
|
Returns sessionId for this client,
|
|
|
|
taken either from its window or from the leader window.
|
|
|
|
*/
|
2012-04-12 23:52:44 +04:00
|
|
|
QByteArray Toplevel::sessionId() const
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2014-04-15 12:09:25 +04:00
|
|
|
QByteArray result = Xcb::StringProperty(window(), atoms->sm_client_id);
|
2011-01-30 17:34:42 +03:00
|
|
|
if (result.isEmpty() && wmClientLeaderWin && wmClientLeaderWin != window())
|
2014-04-15 12:09:25 +04:00
|
|
|
result = Xcb::StringProperty(wmClientLeaderWin, atoms->sm_client_id);
|
2007-04-29 21:35:43 +04:00
|
|
|
return result;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
void Toplevel::getWmClientMachine()
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2013-01-07 11:07:27 +04:00
|
|
|
m_clientMachine->resolve(window(), wmClientLeader());
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns client machine for this client,
|
|
|
|
taken either from its window or from the leader window.
|
|
|
|
*/
|
2011-01-30 17:34:42 +03:00
|
|
|
QByteArray Toplevel::wmClientMachine(bool use_localhost) const
|
|
|
|
{
|
2013-01-07 11:07:27 +04:00
|
|
|
if (!m_clientMachine) {
|
|
|
|
// this should never happen
|
|
|
|
return QByteArray();
|
|
|
|
}
|
|
|
|
if (use_localhost && m_clientMachine->isLocal()) {
|
2011-01-30 17:34:42 +03:00
|
|
|
// special name for the local machine (localhost)
|
2013-01-07 11:07:27 +04:00
|
|
|
return ClientMachine::localhost();
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2013-01-07 11:07:27 +04:00
|
|
|
return m_clientMachine->hostName();
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns client leader window for this client.
|
|
|
|
Returns the client window itself if no leader window is defined.
|
|
|
|
*/
|
|
|
|
Window Toplevel::wmClientLeader() const
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2007-04-29 21:35:43 +04:00
|
|
|
if (wmClientLeaderWin)
|
|
|
|
return wmClientLeaderWin;
|
|
|
|
return window();
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
|
|
|
void Toplevel::getResourceClass()
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2015-07-20 10:37:36 +03:00
|
|
|
setResourceClass(QByteArray(info->windowClassName()).toLower(), QByteArray(info->windowClassClass()).toLower());
|
|
|
|
}
|
|
|
|
|
|
|
|
void Toplevel::setResourceClass(const QByteArray &name, const QByteArray &className)
|
|
|
|
{
|
|
|
|
resource_name = name;
|
|
|
|
resource_class = className;
|
2014-04-11 10:06:26 +04:00
|
|
|
emit windowClassChanged();
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2007-09-03 19:00:43 +04:00
|
|
|
double Toplevel::opacity() const
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
|
|
|
if (info->opacity() == 0xffffffff)
|
2007-04-29 21:35:43 +04:00
|
|
|
return 1.0;
|
|
|
|
return info->opacity() * 1.0 / 0xffffffff;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
void Toplevel::setOpacity(double new_opacity)
|
|
|
|
{
|
2007-09-03 19:00:43 +04:00
|
|
|
double old_opacity = opacity();
|
2011-01-30 17:34:42 +03:00
|
|
|
new_opacity = qBound(0.0, new_opacity, 1.0);
|
|
|
|
if (old_opacity == new_opacity)
|
2007-04-29 21:35:43 +04:00
|
|
|
return;
|
2011-01-30 17:34:42 +03:00
|
|
|
info->setOpacity(static_cast< unsigned long >(new_opacity * 0xffffffff));
|
|
|
|
if (compositing()) {
|
2007-04-29 21:35:43 +04:00
|
|
|
addRepaintFull();
|
2011-03-06 12:30:23 +03:00
|
|
|
emit opacityChanged(this, old_opacity);
|
2007-04-29 21:35:43 +04:00
|
|
|
}
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2007-04-29 21:35:43 +04:00
|
|
|
|
2012-01-24 20:00:40 +04:00
|
|
|
void Toplevel::setReadyForPainting()
|
|
|
|
{
|
|
|
|
if (!ready_for_painting) {
|
|
|
|
ready_for_painting = true;
|
|
|
|
if (compositing()) {
|
|
|
|
addRepaintFull();
|
|
|
|
emit windowShown(this);
|
2012-01-12 10:42:55 +04:00
|
|
|
if (Client *cl = dynamic_cast<Client*>(this)) {
|
|
|
|
if (cl->tabGroup() && cl->tabGroup()->current() == cl)
|
|
|
|
cl->tabGroup()->setCurrent(cl, true);
|
|
|
|
}
|
2012-01-24 20:00:40 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-23 18:41:27 +04:00
|
|
|
void Toplevel::deleteEffectWindow()
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2008-05-23 18:41:27 +04:00
|
|
|
delete effect_window;
|
|
|
|
effect_window = NULL;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2008-05-23 18:41:27 +04:00
|
|
|
|
2013-03-26 10:45:08 +04:00
|
|
|
void Toplevel::checkScreen()
|
2011-01-30 17:34:42 +03:00
|
|
|
{
|
2013-04-03 14:19:27 +04:00
|
|
|
if (screens()->count() == 1) {
|
2013-03-26 10:45:08 +04:00
|
|
|
if (m_screen != 0) {
|
|
|
|
m_screen = 0;
|
|
|
|
emit screenChanged();
|
|
|
|
}
|
|
|
|
return;
|
2008-06-09 20:09:56 +04:00
|
|
|
}
|
2013-04-03 14:19:27 +04:00
|
|
|
const int s = screens()->number(geometry().center());
|
2013-03-26 10:45:08 +04:00
|
|
|
if (s != m_screen) {
|
|
|
|
m_screen = s;
|
|
|
|
emit screenChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Toplevel::setupCheckScreenConnection()
|
|
|
|
{
|
|
|
|
connect(this, SIGNAL(geometryShapeChanged(KWin::Toplevel*,QRect)), SLOT(checkScreen()));
|
|
|
|
connect(this, SIGNAL(geometryChanged()), SLOT(checkScreen()));
|
|
|
|
checkScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Toplevel::removeCheckScreenConnection()
|
|
|
|
{
|
|
|
|
disconnect(this, SIGNAL(geometryShapeChanged(KWin::Toplevel*,QRect)), this, SLOT(checkScreen()));
|
|
|
|
disconnect(this, SIGNAL(geometryChanged()), this, SLOT(checkScreen()));
|
|
|
|
}
|
|
|
|
|
|
|
|
int Toplevel::screen() const
|
|
|
|
{
|
|
|
|
return m_screen;
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2008-06-09 20:09:56 +04:00
|
|
|
|
2011-01-30 17:34:42 +03:00
|
|
|
bool Toplevel::isOnScreen(int screen) const
|
|
|
|
{
|
2013-04-03 14:19:27 +04:00
|
|
|
return screens()->geometry(screen).intersects(geometry());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Toplevel::isOnActiveScreen() const
|
|
|
|
{
|
|
|
|
return isOnScreen(screens()->current());
|
2011-01-30 17:34:42 +03:00
|
|
|
}
|
2008-06-09 20:09:56 +04:00
|
|
|
|
2011-03-27 14:33:07 +04:00
|
|
|
void Toplevel::getShadow()
|
|
|
|
{
|
2011-07-02 23:39:01 +04:00
|
|
|
QRect dirtyRect; // old & new shadow region
|
2012-03-25 01:42:29 +04:00
|
|
|
const QRect oldVisibleRect = visibleRect();
|
2011-03-27 14:33:07 +04:00
|
|
|
if (hasShadow()) {
|
2011-07-02 23:39:01 +04:00
|
|
|
dirtyRect = shadow()->shadowRegion().boundingRect();
|
2011-04-03 13:31:33 +04:00
|
|
|
effectWindow()->sceneWindow()->shadow()->updateShadow();
|
2011-03-27 14:33:07 +04:00
|
|
|
} else {
|
2011-04-03 13:31:33 +04:00
|
|
|
Shadow::createShadow(this);
|
2011-07-02 23:39:01 +04:00
|
|
|
}
|
|
|
|
if (hasShadow())
|
|
|
|
dirtyRect |= shadow()->shadowRegion().boundingRect();
|
2012-03-25 01:42:29 +04:00
|
|
|
if (oldVisibleRect != visibleRect())
|
|
|
|
emit paddingChanged(this, oldVisibleRect);
|
2011-07-02 23:39:01 +04:00
|
|
|
if (dirtyRect.isValid()) {
|
|
|
|
dirtyRect.translate(pos());
|
2012-03-16 21:53:19 +04:00
|
|
|
addLayerRepaint(dirtyRect);
|
2011-03-27 14:33:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Toplevel::hasShadow() const
|
|
|
|
{
|
2011-04-03 13:31:33 +04:00
|
|
|
if (effectWindow() && effectWindow()->sceneWindow()) {
|
|
|
|
return effectWindow()->sceneWindow()->shadow() != NULL;
|
|
|
|
}
|
|
|
|
return false;
|
2011-03-27 14:33:07 +04:00
|
|
|
}
|
|
|
|
|
2011-04-03 13:31:33 +04:00
|
|
|
Shadow *Toplevel::shadow()
|
2011-03-27 14:33:07 +04:00
|
|
|
{
|
2011-04-03 13:31:33 +04:00
|
|
|
if (effectWindow() && effectWindow()->sceneWindow()) {
|
|
|
|
return effectWindow()->sceneWindow()->shadow();
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const Shadow *Toplevel::shadow() const
|
|
|
|
{
|
|
|
|
if (effectWindow() && effectWindow()->sceneWindow()) {
|
|
|
|
return effectWindow()->sceneWindow()->shadow();
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-03-27 14:33:07 +04:00
|
|
|
}
|
2008-06-09 20:09:56 +04:00
|
|
|
|
2014-07-24 10:55:57 +04:00
|
|
|
bool Toplevel::wantsShadowToBeRendered() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-10-22 13:02:49 +04:00
|
|
|
void Toplevel::getWmOpaqueRegion()
|
|
|
|
{
|
2015-01-22 17:46:12 +03:00
|
|
|
const auto rects = info->opaqueRegion();
|
2011-10-22 13:02:49 +04:00
|
|
|
QRegion new_opaque_region;
|
2015-01-22 17:46:12 +03:00
|
|
|
for (const auto &r : rects) {
|
|
|
|
new_opaque_region += QRect(r.pos.x, r.pos.y, r.size.width, r.size.height);
|
|
|
|
}
|
2011-10-22 13:02:49 +04:00
|
|
|
|
|
|
|
opaque_region = new_opaque_region;
|
|
|
|
}
|
|
|
|
|
2012-01-15 13:51:09 +04:00
|
|
|
bool Toplevel::isClient() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Toplevel::isDeleted() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-04-04 18:14:12 +04:00
|
|
|
bool Toplevel::isOnCurrentActivity() const
|
|
|
|
{
|
|
|
|
#ifdef KWIN_BUILD_ACTIVITIES
|
2015-07-07 12:48:42 +03:00
|
|
|
if (!Activities::self()) {
|
|
|
|
return true;
|
|
|
|
}
|
2013-04-04 18:14:12 +04:00
|
|
|
return isOnActivity(Activities::self()->current());
|
|
|
|
#else
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-04-24 12:46:34 +04:00
|
|
|
void Toplevel::elevate(bool elevate)
|
|
|
|
{
|
|
|
|
if (!effectWindow()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
effectWindow()->elevate(elevate);
|
2013-07-02 14:45:55 +04:00
|
|
|
addWorkspaceRepaint(visibleRect());
|
2013-04-24 12:46:34 +04:00
|
|
|
}
|
|
|
|
|
2013-04-26 13:18:57 +04:00
|
|
|
pid_t Toplevel::pid() const
|
|
|
|
{
|
|
|
|
return info->pid();
|
|
|
|
}
|
|
|
|
|
2013-09-10 10:13:33 +04:00
|
|
|
xcb_window_t Toplevel::frameId() const
|
|
|
|
{
|
|
|
|
return m_client;
|
|
|
|
}
|
|
|
|
|
2015-01-15 17:19:04 +03:00
|
|
|
Xcb::Property Toplevel::fetchSkipCloseAnimation() const
|
|
|
|
{
|
|
|
|
return Xcb::Property(false, window(), atoms->kde_skip_close_animation, XCB_ATOM_CARDINAL, 0, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Toplevel::readSkipCloseAnimation(Xcb::Property &property)
|
2014-01-24 15:34:16 +04:00
|
|
|
{
|
2014-04-15 12:09:25 +04:00
|
|
|
setSkipCloseAnimation(property.toBool());
|
2014-01-24 15:34:16 +04:00
|
|
|
}
|
|
|
|
|
2015-01-15 17:19:04 +03:00
|
|
|
void Toplevel::getSkipCloseAnimation()
|
|
|
|
{
|
|
|
|
Xcb::Property property = fetchSkipCloseAnimation();
|
|
|
|
readSkipCloseAnimation(property);
|
|
|
|
}
|
|
|
|
|
2014-01-24 15:34:16 +04:00
|
|
|
bool Toplevel::skipsCloseAnimation() const
|
|
|
|
{
|
|
|
|
return m_skipCloseAnimation;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Toplevel::setSkipCloseAnimation(bool set)
|
|
|
|
{
|
|
|
|
if (set == m_skipCloseAnimation) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
m_skipCloseAnimation = set;
|
|
|
|
emit skipCloseAnimationChanged();
|
|
|
|
}
|
|
|
|
|
2015-02-24 12:54:28 +03:00
|
|
|
void Toplevel::setSurface(KWayland::Server::SurfaceInterface *surface)
|
|
|
|
{
|
|
|
|
if (m_surface == surface) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
using namespace KWayland::Server;
|
|
|
|
if (m_surface) {
|
|
|
|
disconnect(m_surface, &SurfaceInterface::damaged, this, &Toplevel::addDamage);
|
|
|
|
}
|
|
|
|
m_surface = surface;
|
|
|
|
connect(m_surface, &SurfaceInterface::damaged, this, &Toplevel::addDamage);
|
2015-06-01 17:51:27 +03:00
|
|
|
connect(m_surface, &SurfaceInterface::destroyed, this,
|
|
|
|
[this] {
|
|
|
|
m_surface = nullptr;
|
|
|
|
}
|
|
|
|
);
|
2015-02-24 12:54:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void Toplevel::addDamage(const QRegion &damage)
|
|
|
|
{
|
|
|
|
m_isDamaged = true;
|
|
|
|
damage_region += damage;
|
|
|
|
repaints_region += damage;
|
|
|
|
for (const QRect &r : damage.rects()) {
|
|
|
|
emit damaged(this, r);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-04 10:53:51 +03:00
|
|
|
QByteArray Toplevel::windowRole() const
|
|
|
|
{
|
|
|
|
return QByteArray(info->windowRole());
|
|
|
|
}
|
|
|
|
|
2015-06-01 17:25:21 +03:00
|
|
|
void Toplevel::setDepth(int depth)
|
|
|
|
{
|
|
|
|
if (bit_depth == depth) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const bool oldAlpha = hasAlpha();
|
|
|
|
bit_depth = depth;
|
|
|
|
if (oldAlpha != hasAlpha()) {
|
|
|
|
emit hasAlphaChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-19 00:19:13 +03:00
|
|
|
QRegion Toplevel::inputShape() const
|
|
|
|
{
|
|
|
|
if (m_surface) {
|
|
|
|
return m_surface->input();
|
2015-08-10 17:31:45 +03:00
|
|
|
} else {
|
|
|
|
// TODO: maybe also for X11?
|
|
|
|
return QRegion();
|
|
|
|
}
|
2015-06-19 00:19:13 +03:00
|
|
|
}
|
|
|
|
|
2015-08-18 15:40:26 +03:00
|
|
|
void Toplevel::setInternalFramebufferObject(const QSharedPointer<QOpenGLFramebufferObject> &fbo)
|
|
|
|
{
|
|
|
|
if (m_internalFBO != fbo) {
|
|
|
|
discardWindowPixmap();
|
|
|
|
m_internalFBO = fbo;
|
|
|
|
}
|
|
|
|
setDepth(32);
|
|
|
|
}
|
|
|
|
|
2015-12-07 16:25:08 +03:00
|
|
|
QMatrix4x4 Toplevel::inputTransformation() const
|
|
|
|
{
|
|
|
|
QMatrix4x4 m;
|
|
|
|
m.translate(-x(), -y());
|
|
|
|
return m;
|
|
|
|
}
|
|
|
|
|
2007-04-29 21:35:43 +04:00
|
|
|
} // namespace
|
|
|
|
|