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) 2006 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
|
|
|
|
|
|
|
#include "toplevel.h"
|
|
|
|
|
|
|
|
#include <kxerrorhandler.h>
|
|
|
|
|
|
|
|
#include "atoms.h"
|
|
|
|
#include "client.h"
|
|
|
|
#include "effects.h"
|
2011-03-27 10:33:07 +00:00
|
|
|
#include "shadow.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
Toplevel::Toplevel(Workspace* ws)
|
|
|
|
: vis(NULL)
|
|
|
|
, info(NULL)
|
2012-08-24 21:03:58 +00:00
|
|
|
, ready_for_painting(false)
|
2011-01-30 14:34:42 +00:00
|
|
|
, client(None)
|
|
|
|
, frame(None)
|
|
|
|
, wspace(ws)
|
|
|
|
, window_pix(None)
|
|
|
|
, damage_handle(None)
|
|
|
|
, is_shape(false)
|
|
|
|
, effect_window(NULL)
|
|
|
|
, wmClientLeaderWin(0)
|
|
|
|
, unredirect(false)
|
|
|
|
, unredirectSuspend(false)
|
|
|
|
{
|
2012-08-24 21:03:58 +00:00
|
|
|
m_readyForPaintingTimer = new QTimer(this);
|
|
|
|
m_readyForPaintingTimer->setSingleShot(true);
|
|
|
|
connect(m_readyForPaintingTimer, SIGNAL(timeout()), SLOT(setReadyForPainting()));
|
|
|
|
m_readyForPaintingTimer->start(50);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
Toplevel::~Toplevel()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
assert(damage_handle == None);
|
2007-04-29 17:35:43 +00:00
|
|
|
discardWindowPixmap();
|
|
|
|
delete info;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QDebug& operator<<(QDebug& stream, const Toplevel* cl)
|
|
|
|
{
|
|
|
|
if (cl == NULL)
|
2007-04-29 17:35:43 +00:00
|
|
|
return stream << "\'NULL\'";
|
2011-01-30 14:34:42 +00:00
|
|
|
cl->debug(stream);
|
2007-04-29 17:35:43 +00:00
|
|
|
return stream;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QDebug& operator<<(QDebug& stream, const ToplevelList& list)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
stream << "LIST:(";
|
|
|
|
bool first = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
for (ToplevelList::ConstIterator it = list.begin();
|
|
|
|
it != list.end();
|
|
|
|
++it) {
|
|
|
|
if (!first)
|
2007-04-29 17:35:43 +00:00
|
|
|
stream << ":";
|
|
|
|
first = false;
|
|
|
|
stream << *it;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
stream << ")";
|
|
|
|
return stream;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QDebug& operator<<(QDebug& stream, const ConstToplevelList& list)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
stream << "LIST:(";
|
|
|
|
bool first = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
for (ConstToplevelList::ConstIterator it = list.begin();
|
|
|
|
it != list.end();
|
|
|
|
++it) {
|
|
|
|
if (!first)
|
2007-04-29 17:35:43 +00:00
|
|
|
stream << ":";
|
|
|
|
first = false;
|
|
|
|
stream << *it;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
stream << ")";
|
|
|
|
return stream;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2011-07-13 20:50:31 +00:00
|
|
|
QRect Toplevel::decorationRect() const
|
|
|
|
{
|
2012-03-10 10:34:56 +00:00
|
|
|
return rect();
|
2011-07-13 20:50:31 +00:00
|
|
|
}
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Toplevel::detectShape(Window id)
|
|
|
|
{
|
2012-01-15 10:03:15 +00:00
|
|
|
const bool wasShape = is_shape;
|
2011-01-30 14:34:42 +00:00
|
|
|
is_shape = Extensions::hasShape(id);
|
2012-01-15 10:03:15 +00:00
|
|
|
if (wasShape != is_shape) {
|
|
|
|
emit shapedChanged();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// used only by Deleted::copy()
|
2011-01-30 14:34:42 +00:00
|
|
|
void Toplevel::copyToDeleted(Toplevel* c)
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
geom = c->geom;
|
|
|
|
vis = c->vis;
|
|
|
|
bit_depth = c->bit_depth;
|
|
|
|
info = c->info;
|
|
|
|
client = c->client;
|
|
|
|
frame = c->frame;
|
|
|
|
wspace = c->wspace;
|
|
|
|
window_pix = c->window_pix;
|
2007-06-25 08:51:44 +00:00
|
|
|
ready_for_painting = c->ready_for_painting;
|
2007-04-29 17:35:43 +00: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 14:34:42 +00:00
|
|
|
if (effect_window != NULL)
|
|
|
|
effect_window->setWindow(this);
|
2007-04-29 17:35:43 +00:00
|
|
|
resource_name = c->resourceName();
|
|
|
|
resource_class = c->resourceClass();
|
2011-01-30 14:34:42 +00:00
|
|
|
client_machine = c->wmClientMachine(false);
|
2007-04-29 17:35:43 +00:00
|
|
|
wmClientLeaderWin = c->wmClientLeader();
|
|
|
|
window_role = c->windowRole();
|
2011-10-22 09:02:49 +00:00
|
|
|
opaque_region = c->opaqueRegion();
|
2007-04-29 17:35:43 +00:00
|
|
|
// this needs to be done already here, otherwise 'c' could very likely
|
|
|
|
// call discardWindowPixmap() in something called during cleanup
|
|
|
|
c->window_pix = None;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
// before being deleted, remove references to everything that's now
|
|
|
|
// owner by Deleted
|
|
|
|
void Toplevel::disownDataPassedToDeleted()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
info = NULL;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2009-06-11 20:12:11 +00:00
|
|
|
QRect Toplevel::visibleRect() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-05-05 14:38:02 +00:00
|
|
|
QRect r = decorationRect();
|
2011-11-25 00:00:54 +00:00
|
|
|
if (hasShadow() && !shadow()->shadowRegion().isEmpty()) {
|
2012-05-05 14:38:02 +00:00
|
|
|
r |= shadow()->shadowRegion().boundingRect();
|
2011-03-27 10:33:07 +00:00
|
|
|
}
|
2012-05-05 14:38:02 +00:00
|
|
|
return r.translated(geometry().topLeft());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-06-11 20:12:11 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
NET::WindowType Toplevel::windowType(bool direct, int supported_types) const
|
|
|
|
{
|
|
|
|
if (supported_types == 0)
|
|
|
|
supported_types = dynamic_cast< const Client* >(this) != NULL
|
|
|
|
? SUPPORTED_MANAGED_WINDOW_TYPES_MASK : SUPPORTED_UNMANAGED_WINDOW_TYPES_MASK;
|
|
|
|
NET::WindowType wt = info->windowType(supported_types);
|
|
|
|
if (direct)
|
2007-04-29 17:35:43 +00:00
|
|
|
return wt;
|
2011-01-30 14:34:42 +00:00
|
|
|
const Client* cl = dynamic_cast< const Client* >(this);
|
|
|
|
NET::WindowType wt2 = cl ? cl->rules()->checkType(wt) : wt;
|
|
|
|
if (wt != wt2) {
|
2007-04-29 17:35:43 +00:00
|
|
|
wt = wt2;
|
2011-01-30 14:34:42 +00:00
|
|
|
info->setWindowType(wt); // force hint change
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
// hacks here
|
2011-01-30 14:34:42 +00:00
|
|
|
if (wt == NET::Unknown && cl != NULL) // this is more or less suggested in NETWM spec
|
2007-04-29 17:35:43 +00:00
|
|
|
wt = cl->isTransient() ? NET::Dialog : NET::Normal;
|
|
|
|
return wt;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void Toplevel::getWindowRole()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
window_role = getStringProperty(window(), atoms->wm_window_role).toLower();
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns SM_CLIENT_ID property for a given window.
|
|
|
|
*/
|
|
|
|
QByteArray Toplevel::staticSessionId(WId w)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return getStringProperty(w, atoms->sm_client_id);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns WM_COMMAND property for a given window.
|
|
|
|
*/
|
|
|
|
QByteArray Toplevel::staticWmCommand(WId w)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
return getStringProperty(w, XA_WM_COMMAND, ' ');
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns WM_CLIENT_LEADER property for a given window.
|
|
|
|
*/
|
|
|
|
Window Toplevel::staticWmClientLeader(WId w)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
Atom type;
|
|
|
|
int format, status;
|
|
|
|
unsigned long nitems = 0;
|
|
|
|
unsigned long extra = 0;
|
|
|
|
unsigned char *data = 0;
|
|
|
|
Window result = w;
|
|
|
|
KXErrorHandler err;
|
2011-01-30 14:34:42 +00:00
|
|
|
status = XGetWindowProperty(display(), w, atoms->wm_client_leader, 0, 10000,
|
|
|
|
false, XA_WINDOW, &type, &format,
|
|
|
|
&nitems, &extra, &data);
|
|
|
|
if (status == Success && !err.error(false)) {
|
2007-04-29 17:35:43 +00:00
|
|
|
if (data && nitems > 0)
|
|
|
|
result = *((Window*) data);
|
|
|
|
XFree(data);
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return result;
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
void Toplevel::getWmClientLeader()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
wmClientLeaderWin = staticWmClientLeader(window());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns sessionId for this client,
|
|
|
|
taken either from its window or from the leader window.
|
|
|
|
*/
|
2012-04-12 19:52:44 +00:00
|
|
|
QByteArray Toplevel::sessionId() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
QByteArray result = staticSessionId(window());
|
2011-01-30 14:34:42 +00:00
|
|
|
if (result.isEmpty() && wmClientLeaderWin && wmClientLeaderWin != window())
|
2007-04-29 17:35:43 +00:00
|
|
|
result = staticSessionId(wmClientLeaderWin);
|
|
|
|
return result;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns command property for this client,
|
|
|
|
taken either from its window or from the leader window.
|
|
|
|
*/
|
|
|
|
QByteArray Toplevel::wmCommand()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
QByteArray result = staticWmCommand(window());
|
2011-01-30 14:34:42 +00:00
|
|
|
if (result.isEmpty() && wmClientLeaderWin && wmClientLeaderWin != window())
|
2007-04-29 17:35:43 +00:00
|
|
|
result = staticWmCommand(wmClientLeaderWin);
|
|
|
|
return result;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void Toplevel::getWmClientMachine()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
client_machine = getStringProperty(window(), XA_WM_CLIENT_MACHINE);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (client_machine.isEmpty() && wmClientLeaderWin && wmClientLeaderWin != window())
|
2007-04-29 17:35:43 +00:00
|
|
|
client_machine = getStringProperty(wmClientLeaderWin, XA_WM_CLIENT_MACHINE);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (client_machine.isEmpty())
|
2007-04-29 17:35:43 +00:00
|
|
|
client_machine = "localhost";
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns client machine for this client,
|
|
|
|
taken either from its window or from the leader window.
|
|
|
|
*/
|
2011-01-30 14:34:42 +00:00
|
|
|
QByteArray Toplevel::wmClientMachine(bool use_localhost) const
|
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
QByteArray result = client_machine;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (use_localhost) {
|
|
|
|
// special name for the local machine (localhost)
|
|
|
|
if (result != "localhost" && isLocalMachine(result))
|
2007-04-29 17:35:43 +00:00
|
|
|
result = "localhost";
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return result;
|
|
|
|
}
|
2007-04-29 17:35:43 +00: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 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
if (wmClientLeaderWin)
|
|
|
|
return wmClientLeaderWin;
|
|
|
|
return window();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void Toplevel::getResourceClass()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-04-29 17:35:43 +00:00
|
|
|
XClassHint classHint;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (XGetClassHint(display(), window(), &classHint)) {
|
2007-11-13 19:25:44 +00:00
|
|
|
// Qt3.2 and older had this all lowercase, Qt3.3 capitalized resource class.
|
|
|
|
// Force lowercase, so that workarounds listing resource classes still work.
|
2011-01-30 14:34:42 +00:00
|
|
|
resource_name = QByteArray(classHint.res_name).toLower();
|
|
|
|
resource_class = QByteArray(classHint.res_class).toLower();
|
|
|
|
XFree(classHint.res_name);
|
|
|
|
XFree(classHint.res_class);
|
|
|
|
} else {
|
2007-04-29 17:35:43 +00:00
|
|
|
resource_name = resource_class = QByteArray();
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2007-09-03 15:00:43 +00:00
|
|
|
double Toplevel::opacity() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
if (info->opacity() == 0xffffffff)
|
2007-04-29 17:35:43 +00:00
|
|
|
return 1.0;
|
|
|
|
return info->opacity() * 1.0 / 0xffffffff;
|
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 Toplevel::setOpacity(double new_opacity)
|
|
|
|
{
|
2007-09-03 15:00:43 +00:00
|
|
|
double old_opacity = opacity();
|
2011-01-30 14:34:42 +00:00
|
|
|
new_opacity = qBound(0.0, new_opacity, 1.0);
|
|
|
|
if (old_opacity == new_opacity)
|
2007-04-29 17:35:43 +00:00
|
|
|
return;
|
2011-01-30 14:34:42 +00:00
|
|
|
info->setOpacity(static_cast< unsigned long >(new_opacity * 0xffffffff));
|
|
|
|
if (compositing()) {
|
2007-04-29 17:35:43 +00:00
|
|
|
addRepaintFull();
|
2011-03-06 09:30:23 +00:00
|
|
|
emit opacityChanged(this, old_opacity);
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
2012-01-24 16:00:40 +00:00
|
|
|
void Toplevel::setReadyForPainting()
|
|
|
|
{
|
|
|
|
if (!ready_for_painting) {
|
2012-08-24 21:03:58 +00:00
|
|
|
delete m_readyForPaintingTimer;
|
|
|
|
m_readyForPaintingTimer = 0;
|
2012-01-24 16:00:40 +00:00
|
|
|
ready_for_painting = true;
|
|
|
|
if (compositing()) {
|
|
|
|
addRepaintFull();
|
|
|
|
emit windowShown(this);
|
2012-01-12 06:42:55 +00:00
|
|
|
if (Client *cl = dynamic_cast<Client*>(this)) {
|
|
|
|
if (cl->tabGroup() && cl->tabGroup()->current() == cl)
|
|
|
|
cl->tabGroup()->setCurrent(cl, true);
|
|
|
|
}
|
2012-01-24 16:00:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-23 14:41:27 +00:00
|
|
|
void Toplevel::deleteEffectWindow()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-05-23 14:41:27 +00:00
|
|
|
delete effect_window;
|
|
|
|
effect_window = NULL;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-05-23 14:41:27 +00:00
|
|
|
|
2008-06-09 16:09:56 +00:00
|
|
|
int Toplevel::screen() const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
int s = workspace()->screenNumber(geometry().center());
|
|
|
|
if (s < 0) {
|
2009-02-18 04:05:37 +00:00
|
|
|
kDebug(1212) << "Invalid screen: Center" << geometry().center() << ", screen" << s;
|
2011-01-30 14:34:42 +00:00
|
|
|
return 0;
|
2008-06-09 16:09:56 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
return s;
|
|
|
|
}
|
2008-06-09 16:09:56 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
bool Toplevel::isOnScreen(int screen) const
|
|
|
|
{
|
|
|
|
return workspace()->screenGeometry(screen).intersects(geometry());
|
|
|
|
}
|
2008-06-09 16:09:56 +00:00
|
|
|
|
2011-03-27 10:33:07 +00:00
|
|
|
void Toplevel::getShadow()
|
|
|
|
{
|
2011-07-02 19:39:01 +00:00
|
|
|
QRect dirtyRect; // old & new shadow region
|
2012-03-24 21:42:29 +00:00
|
|
|
const QRect oldVisibleRect = visibleRect();
|
2011-03-27 10:33:07 +00:00
|
|
|
if (hasShadow()) {
|
2011-07-02 19:39:01 +00:00
|
|
|
dirtyRect = shadow()->shadowRegion().boundingRect();
|
2011-04-03 09:31:33 +00:00
|
|
|
effectWindow()->sceneWindow()->shadow()->updateShadow();
|
2011-03-27 10:33:07 +00:00
|
|
|
} else {
|
2011-04-03 09:31:33 +00:00
|
|
|
Shadow::createShadow(this);
|
2011-07-02 19:39:01 +00:00
|
|
|
}
|
|
|
|
if (hasShadow())
|
|
|
|
dirtyRect |= shadow()->shadowRegion().boundingRect();
|
2012-03-24 21:42:29 +00:00
|
|
|
if (oldVisibleRect != visibleRect())
|
|
|
|
emit paddingChanged(this, oldVisibleRect);
|
2011-07-02 19:39:01 +00:00
|
|
|
if (dirtyRect.isValid()) {
|
|
|
|
dirtyRect.translate(pos());
|
2012-03-16 17:53:19 +00:00
|
|
|
addLayerRepaint(dirtyRect);
|
2011-03-27 10:33:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Toplevel::hasShadow() const
|
|
|
|
{
|
2011-04-03 09:31:33 +00:00
|
|
|
if (effectWindow() && effectWindow()->sceneWindow()) {
|
|
|
|
return effectWindow()->sceneWindow()->shadow() != NULL;
|
|
|
|
}
|
|
|
|
return false;
|
2011-03-27 10:33:07 +00:00
|
|
|
}
|
|
|
|
|
2011-04-03 09:31:33 +00:00
|
|
|
Shadow *Toplevel::shadow()
|
2011-03-27 10:33:07 +00:00
|
|
|
{
|
2011-04-03 09:31:33 +00: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 10:33:07 +00:00
|
|
|
}
|
2008-06-09 16:09:56 +00:00
|
|
|
|
2011-10-22 09:02:49 +00:00
|
|
|
void Toplevel::getWmOpaqueRegion()
|
|
|
|
{
|
|
|
|
const int length=32768;
|
|
|
|
unsigned long bytes_after_return=0;
|
|
|
|
QRegion new_opaque_region;
|
|
|
|
do {
|
|
|
|
unsigned long* data;
|
|
|
|
Atom type;
|
|
|
|
int rformat;
|
|
|
|
unsigned long nitems;
|
|
|
|
if (XGetWindowProperty(display(), client,
|
2011-12-13 20:17:19 +00:00
|
|
|
atoms->net_wm_opaque_region, 0, length, false, XA_CARDINAL,
|
2011-10-22 09:02:49 +00:00
|
|
|
&type, &rformat, &nitems, &bytes_after_return,
|
|
|
|
reinterpret_cast< unsigned char** >(&data)) == Success) {
|
|
|
|
if (type != XA_CARDINAL || rformat != 32 || nitems%4) {
|
|
|
|
// it can happen, that the window does not provide this property
|
|
|
|
XFree(data);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < nitems;) {
|
|
|
|
const int x = data[i++];
|
|
|
|
const int y = data[i++];
|
|
|
|
const int w = data[i++];
|
|
|
|
const int h = data[i++];
|
|
|
|
|
|
|
|
new_opaque_region += QRect(x,y,w,h);
|
|
|
|
}
|
|
|
|
XFree(data);
|
|
|
|
} else {
|
|
|
|
kWarning(1212) << "XGetWindowProperty failed";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (bytes_after_return > 0);
|
|
|
|
|
|
|
|
opaque_region = new_opaque_region;
|
|
|
|
}
|
|
|
|
|
2012-01-15 09:51:09 +00:00
|
|
|
bool Toplevel::isClient() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Toplevel::isDeleted() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#include "toplevel.moc"
|