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 "kwinglobals.h"
|
|
|
|
|
2011-06-11 12:48:16 +00:00
|
|
|
#include <QPainter>
|
|
|
|
#include <QPaintEngine>
|
|
|
|
#include <QPixmap>
|
|
|
|
|
2007-09-26 16:31:06 +00:00
|
|
|
#include <config-workspace.h>
|
|
|
|
#include <config-X11.h>
|
|
|
|
|
2008-02-24 11:41:55 +00:00
|
|
|
#include <assert.h>
|
|
|
|
|
2007-09-26 16:31:06 +00:00
|
|
|
#include <kdebug.h>
|
|
|
|
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/extensions/shape.h>
|
|
|
|
|
|
|
|
#include <X11/extensions/Xrender.h>
|
|
|
|
#include <X11/extensions/Xfixes.h>
|
|
|
|
#include <X11/extensions/Xdamage.h>
|
|
|
|
#include <X11/extensions/Xrandr.h>
|
|
|
|
#include <X11/extensions/Xcomposite.h>
|
|
|
|
#ifdef HAVE_XSYNC
|
|
|
|
#include <X11/extensions/sync.h>
|
|
|
|
#endif
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2007-09-26 16:31:06 +00:00
|
|
|
int Extensions::shape_version = 0;
|
|
|
|
int Extensions::shape_event_base = 0;
|
|
|
|
bool Extensions::has_randr = false;
|
|
|
|
int Extensions::randr_event_base = 0;
|
|
|
|
bool Extensions::has_damage = false;
|
|
|
|
int Extensions::damage_event_base = 0;
|
|
|
|
int Extensions::composite_version = 0;
|
|
|
|
int Extensions::fixes_version = 0;
|
|
|
|
int Extensions::render_version = 0;
|
|
|
|
bool Extensions::has_sync = false;
|
|
|
|
int Extensions::sync_event_base = 0;
|
2011-06-11 12:48:16 +00:00
|
|
|
bool Extensions::non_native_pixmaps = false;
|
2008-02-24 11:41:55 +00:00
|
|
|
// for fillExtensionsData()
|
|
|
|
const char* Extensions::data_extensions[ 32 ];
|
|
|
|
int Extensions::data_nextensions;
|
|
|
|
int Extensions::data_opcodes[ 32 ];
|
|
|
|
int Extensions::data_error_bases[ 32 ];
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Extensions::addData(const char* name)
|
|
|
|
{
|
|
|
|
assert(data_nextensions < 32);
|
2008-02-24 11:41:55 +00:00
|
|
|
int opcode, event_base, error_base;
|
2011-01-30 14:34:42 +00:00
|
|
|
XQueryExtension(display(), name, &opcode, &event_base, &error_base);
|
2008-02-24 11:41:55 +00:00
|
|
|
data_extensions[ data_nextensions ] = name;
|
|
|
|
data_opcodes[ data_nextensions ] = opcode;
|
|
|
|
data_error_bases[ data_nextensions ] = error_base;
|
|
|
|
++data_nextensions;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-09-26 16:31:06 +00:00
|
|
|
|
|
|
|
void Extensions::init()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2008-02-24 11:41:55 +00:00
|
|
|
int event_base, error_base;
|
|
|
|
data_nextensions = 0;
|
2007-09-26 16:31:06 +00:00
|
|
|
shape_version = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (XShapeQueryExtension(display(), &shape_event_base, &error_base)) {
|
2007-09-26 16:31:06 +00:00
|
|
|
int major, minor;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (XShapeQueryVersion(display(), &major, &minor)) {
|
2007-09-26 16:31:06 +00:00
|
|
|
shape_version = major * 0x10 + minor;
|
2011-01-30 14:34:42 +00:00
|
|
|
addData("SHAPE");
|
2007-09-26 16:31:06 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
has_randr = XRRQueryExtension(display(), &randr_event_base, &error_base);
|
|
|
|
if (has_randr) {
|
2007-09-26 16:31:06 +00:00
|
|
|
int major, minor;
|
2011-01-30 14:34:42 +00:00
|
|
|
XRRQueryVersion(display(), &major, &minor);
|
|
|
|
has_randr = (major > 1 || (major == 1 && minor >= 1));
|
|
|
|
addData("RANDR");
|
|
|
|
}
|
|
|
|
has_damage = XDamageQueryExtension(display(), &damage_event_base, &error_base);
|
|
|
|
if (has_damage)
|
|
|
|
addData("DAMAGE");
|
2007-09-26 16:31:06 +00:00
|
|
|
composite_version = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (XCompositeQueryExtension(display(), &event_base, &error_base)) {
|
2007-09-26 16:31:06 +00:00
|
|
|
int major = 0, minor = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
XCompositeQueryVersion(display(), &major, &minor);
|
2007-09-26 16:31:06 +00:00
|
|
|
composite_version = major * 0x10 + minor;
|
2011-01-30 14:34:42 +00:00
|
|
|
addData("Composite");
|
|
|
|
}
|
2007-09-26 16:31:06 +00:00
|
|
|
fixes_version = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (XFixesQueryExtension(display(), &event_base, &error_base)) {
|
2007-09-26 16:31:06 +00:00
|
|
|
int major = 0, minor = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
XFixesQueryVersion(display(), &major, &minor);
|
2007-09-26 16:31:06 +00:00
|
|
|
fixes_version = major * 0x10 + minor;
|
2011-01-30 14:34:42 +00:00
|
|
|
addData("XFIXES");
|
|
|
|
}
|
2007-09-26 16:31:06 +00:00
|
|
|
render_version = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (XRenderQueryExtension(display(), &event_base, &error_base)) {
|
2007-09-26 16:31:06 +00:00
|
|
|
int major = 0, minor = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
XRenderQueryVersion(display(), &major, &minor);
|
2007-09-26 16:31:06 +00:00
|
|
|
render_version = major * 0x10 + minor;
|
2011-01-30 14:34:42 +00:00
|
|
|
addData("RENDER");
|
|
|
|
}
|
2007-09-26 16:31:06 +00:00
|
|
|
#ifdef HAVE_XSYNC
|
2011-01-30 14:34:42 +00:00
|
|
|
if (XSyncQueryExtension(display(), &sync_event_base, &error_base)) {
|
2007-09-26 16:31:06 +00:00
|
|
|
int major = 0, minor = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (XSyncInitialize(display(), &major, &minor)) {
|
2007-09-26 16:31:06 +00:00
|
|
|
has_sync = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
addData("SYNC");
|
2007-09-26 16:31:06 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
#endif
|
2011-06-11 12:48:16 +00:00
|
|
|
QPixmap pix(1,1);
|
|
|
|
QPainter p(&pix);
|
|
|
|
non_native_pixmaps = p.paintEngine()->type() != QPaintEngine::X11;
|
|
|
|
p.end();
|
2011-01-30 14:34:42 +00:00
|
|
|
kDebug(1212) << "Extensions: shape: 0x" << QString::number(shape_version, 16)
|
|
|
|
<< " composite: 0x" << QString::number(composite_version, 16)
|
|
|
|
<< " render: 0x" << QString::number(render_version, 16)
|
|
|
|
<< " fixes: 0x" << QString::number(fixes_version, 16) << endl;
|
|
|
|
}
|
2007-09-26 16:31:06 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void Extensions::fillExtensionsData(const char**& extensions, int& nextensions, int*&opcodes, int*& error_bases)
|
|
|
|
{
|
2008-02-24 11:41:55 +00:00
|
|
|
extensions = data_extensions;
|
|
|
|
nextensions = data_nextensions;
|
|
|
|
opcodes = data_opcodes;
|
|
|
|
error_bases = data_error_bases;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2008-02-24 11:41:55 +00:00
|
|
|
|
2007-09-26 16:31:06 +00:00
|
|
|
int Extensions::shapeNotifyEvent()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-09-26 16:31:06 +00:00
|
|
|
return shape_event_base + ShapeNotify;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-09-26 16:31:06 +00:00
|
|
|
|
|
|
|
// does the window w need a shape combine mask around it?
|
2011-01-30 14:34:42 +00:00
|
|
|
bool Extensions::hasShape(Window w)
|
|
|
|
{
|
2007-09-26 16:31:06 +00:00
|
|
|
int xws, yws, xbs, ybs;
|
|
|
|
unsigned int wws, hws, wbs, hbs;
|
|
|
|
int boundingShaped = 0, clipShaped = 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (!shapeAvailable())
|
2007-09-26 16:31:06 +00:00
|
|
|
return false;
|
|
|
|
XShapeQueryExtents(display(), w,
|
|
|
|
&boundingShaped, &xws, &yws, &wws, &hws,
|
|
|
|
&clipShaped, &xbs, &ybs, &wbs, &hbs);
|
|
|
|
return boundingShaped != 0;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-09-26 16:31:06 +00:00
|
|
|
|
|
|
|
bool Extensions::shapeInputAvailable()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-09-26 16:31:06 +00:00
|
|
|
return shape_version >= 0x11; // 1.1
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-09-26 16:31:06 +00:00
|
|
|
|
|
|
|
int Extensions::randrNotifyEvent()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-09-26 16:31:06 +00:00
|
|
|
return randr_event_base + RRScreenChangeNotify;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-09-26 16:31:06 +00:00
|
|
|
|
|
|
|
int Extensions::damageNotifyEvent()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-09-26 16:31:06 +00:00
|
|
|
return damage_event_base + XDamageNotify;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-09-26 16:31:06 +00:00
|
|
|
|
|
|
|
bool Extensions::compositeOverlayAvailable()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-09-26 16:31:06 +00:00
|
|
|
return composite_version >= 0x03; // 0.3
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-09-26 16:31:06 +00:00
|
|
|
|
|
|
|
bool Extensions::fixesRegionAvailable()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-09-26 16:31:06 +00:00
|
|
|
return fixes_version >= 0x30; // 3
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-09-26 16:31:06 +00:00
|
|
|
|
|
|
|
int Extensions::syncAlarmNotifyEvent()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2007-09-26 16:31:06 +00:00
|
|
|
#ifdef HAVE_XSYNC
|
|
|
|
return sync_event_base + XSyncAlarmNotify;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2007-09-26 16:31:06 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
} // namespace
|
|
|
|
|