Move Extensions class to lib/kwinglobals.*

svn path=/trunk/KDE/kdebase/workspace/; revision=717329
This commit is contained in:
Rivo Laks 2007-09-26 16:31:06 +00:00
parent 85e46eead6
commit a3781228cb
5 changed files with 223 additions and 180 deletions

View file

@ -47,6 +47,19 @@ endif(OPENGL_FOUND)
if (X11_Xrender_FOUND)
target_link_libraries(kwineffects ${X11_Xrender_LIB})
endif (X11_Xrender_FOUND)
if (X11_Xrandr_FOUND)
target_link_libraries(kwineffects ${X11_Xrandr_LIB})
endif (X11_Xrandr_FOUND)
if (X11_Xcomposite_FOUND)
target_link_libraries(kwineffects ${X11_Xcomposite_LIB})
endif (X11_Xcomposite_FOUND)
if (X11_Xdamage_FOUND)
target_link_libraries(kwineffects ${X11_Xdamage_LIB})
endif (X11_Xdamage_FOUND)
if (X11_Xfixes_FOUND)
target_link_libraries(kwineffects ${X11_Xfixes_LIB})
endif (X11_Xfixes_FOUND)
install( FILES kwinglobals.h kwineffects.h DESTINATION ${INCLUDE_INSTALL_DIR})

View file

@ -10,8 +10,183 @@ License. See the file "COPYING" for the exact licensing terms.
#include "kwinglobals.h"
#include <config-workspace.h>
#include <config-X11.h>
#include <kdebug.h>
#include <X11/Xlib.h>
#include <X11/extensions/shape.h>
#ifdef HAVE_XRENDER
#include <X11/extensions/Xrender.h>
#endif
#ifdef HAVE_XFIXES
#include <X11/extensions/Xfixes.h>
#endif
#ifdef HAVE_XDAMAGE
#include <X11/extensions/Xdamage.h>
#endif
#ifdef HAVE_XRANDR
#include <X11/extensions/Xrandr.h>
#endif
#ifdef HAVE_XCOMPOSITE
#include <X11/extensions/Xcomposite.h>
#endif
#ifdef HAVE_OPENGL
#include <GL/glx.h>
#endif
#ifdef HAVE_XSYNC
#include <X11/extensions/sync.h>
#endif
namespace KWin
{
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_glx = false;
bool Extensions::has_sync = false;
int Extensions::sync_event_base = 0;
void Extensions::init()
{
int dummy;
shape_version = 0;
if( XShapeQueryExtension( display(), &shape_event_base, &dummy ))
{
int major, minor;
if( XShapeQueryVersion( display(), &major, &minor ))
shape_version = major * 0x10 + minor;
}
#ifdef HAVE_XRANDR
has_randr = XRRQueryExtension( display(), &randr_event_base, &dummy );
if( has_randr )
{
int major, minor;
XRRQueryVersion( display(), &major, &minor );
has_randr = ( major > 1 || ( major == 1 && minor >= 1 ) );
}
#else
has_randr = false;
#endif
#ifdef HAVE_XDAMAGE
has_damage = XDamageQueryExtension( display(), &damage_event_base, &dummy );
#else
has_damage = false;
#endif
composite_version = 0;
#ifdef HAVE_XCOMPOSITE
if( XCompositeQueryExtension( display(), &dummy, &dummy ))
{
int major = 0, minor = 0;
XCompositeQueryVersion( display(), &major, &minor );
composite_version = major * 0x10 + minor;
}
#endif
fixes_version = 0;
#ifdef HAVE_XFIXES
if( XFixesQueryExtension( display(), &dummy, &dummy ))
{
int major = 0, minor = 0;
XFixesQueryVersion( display(), &major, &minor );
fixes_version = major * 0x10 + minor;
}
#endif
render_version = 0;
#ifdef HAVE_XRENDER
if( XRenderQueryExtension( display(), &dummy, &dummy ))
{
int major = 0, minor = 0;
XRenderQueryVersion( display(), &major, &minor );
render_version = major * 0x10 + minor;
}
#endif
has_glx = false;
#ifdef HAVE_OPENGL
has_glx = glXQueryExtension( display(), &dummy, &dummy );
#endif
#ifdef HAVE_XSYNC
if( XSyncQueryExtension( display(), &sync_event_base, &dummy ))
{
int major = 0, minor = 0;
if( XSyncInitialize( display(), &major, &minor ))
has_sync = true;
}
#endif
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;
}
int Extensions::shapeNotifyEvent()
{
return shape_event_base + ShapeNotify;
}
// does the window w need a shape combine mask around it?
bool Extensions::hasShape( Window w )
{
int xws, yws, xbs, ybs;
unsigned int wws, hws, wbs, hbs;
int boundingShaped = 0, clipShaped = 0;
if( !shapeAvailable())
return false;
XShapeQueryExtents(display(), w,
&boundingShaped, &xws, &yws, &wws, &hws,
&clipShaped, &xbs, &ybs, &wbs, &hbs);
return boundingShaped != 0;
}
bool Extensions::shapeInputAvailable()
{
return shape_version >= 0x11; // 1.1
}
int Extensions::randrNotifyEvent()
{
#ifdef HAVE_XRANDR
return randr_event_base + RRScreenChangeNotify;
#else
return 0;
#endif
}
int Extensions::damageNotifyEvent()
{
#ifdef HAVE_XDAMAGE
return damage_event_base + XDamageNotify;
#else
return 0;
#endif
}
bool Extensions::compositeOverlayAvailable()
{
return composite_version >= 0x03; // 0.3
}
bool Extensions::fixesRegionAvailable()
{
return fixes_version >= 0x30; // 3
}
int Extensions::syncAlarmNotifyEvent()
{
#ifdef HAVE_XSYNC
return sync_event_base + XSyncAlarmNotify;
#else
return 0;
#endif
}
} // namespace

View file

@ -95,6 +95,41 @@ KWIN_EXPORT int displayHeight()
return XDisplayHeight( display(), DefaultScreen( display()));
}
class KWIN_EXPORT Extensions
{
public:
static void init();
static bool shapeAvailable() { return shape_version > 0; }
static bool shapeInputAvailable();
static int shapeNotifyEvent();
static bool hasShape( Window w );
static bool randrAvailable() { return has_randr; }
static int randrNotifyEvent();
static bool damageAvailable() { return has_damage; }
static int damageNotifyEvent();
static bool compositeAvailable() { return composite_version > 0; }
static bool compositeOverlayAvailable();
static bool renderAvailable() { return render_version > 0; }
static bool fixesAvailable() { return fixes_version > 0; }
static bool fixesRegionAvailable();
static bool glxAvailable() { return has_glx; }
static bool syncAvailable() { return has_sync; }
static int syncAlarmNotifyEvent();
private:
static int shape_version;
static int shape_event_base;
static bool has_randr;
static int randr_event_base;
static bool has_damage;
static int damage_event_base;
static int composite_version;
static int render_version;
static int fixes_version;
static bool has_glx;
static bool has_sync;
static int sync_event_base;
};
} // namespace
#endif

145
utils.cpp
View file

@ -67,151 +67,6 @@ namespace KWin
#ifndef KCMRULES
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_glx = false;
bool Extensions::has_sync = false;
int Extensions::sync_event_base = 0;
void Extensions::init()
{
int dummy;
shape_version = 0;
if( XShapeQueryExtension( display(), &shape_event_base, &dummy ))
{
int major, minor;
if( XShapeQueryVersion( display(), &major, &minor ))
shape_version = major * 0x10 + minor;
}
#ifdef HAVE_XRANDR
has_randr = XRRQueryExtension( display(), &randr_event_base, &dummy );
if( has_randr )
{
int major, minor;
XRRQueryVersion( display(), &major, &minor );
has_randr = ( major > 1 || ( major == 1 && minor >= 1 ) );
}
#else
has_randr = false;
#endif
#ifdef HAVE_XDAMAGE
has_damage = XDamageQueryExtension( display(), &damage_event_base, &dummy );
#else
has_damage = false;
#endif
composite_version = 0;
#ifdef HAVE_XCOMPOSITE
if( XCompositeQueryExtension( display(), &dummy, &dummy ))
{
int major = 0, minor = 0;
XCompositeQueryVersion( display(), &major, &minor );
composite_version = major * 0x10 + minor;
}
#endif
fixes_version = 0;
#ifdef HAVE_XFIXES
if( XFixesQueryExtension( display(), &dummy, &dummy ))
{
int major = 0, minor = 0;
XFixesQueryVersion( display(), &major, &minor );
fixes_version = major * 0x10 + minor;
}
#endif
render_version = 0;
#ifdef HAVE_XRENDER
if( XRenderQueryExtension( display(), &dummy, &dummy ))
{
int major = 0, minor = 0;
XRenderQueryVersion( display(), &major, &minor );
render_version = major * 0x10 + minor;
}
#endif
has_glx = false;
#ifdef HAVE_OPENGL
has_glx = glXQueryExtension( display(), &dummy, &dummy );
#endif
#ifdef HAVE_XSYNC
if( XSyncQueryExtension( display(), &sync_event_base, &dummy ))
{
int major = 0, minor = 0;
if( XSyncInitialize( display(), &major, &minor ))
has_sync = true;
}
#endif
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;
}
int Extensions::shapeNotifyEvent()
{
return shape_event_base + ShapeNotify;
}
// does the window w need a shape combine mask around it?
bool Extensions::hasShape( Window w )
{
int xws, yws, xbs, ybs;
unsigned int wws, hws, wbs, hbs;
int boundingShaped = 0, clipShaped = 0;
if( !shapeAvailable())
return false;
XShapeQueryExtents(display(), w,
&boundingShaped, &xws, &yws, &wws, &hws,
&clipShaped, &xbs, &ybs, &wbs, &hbs);
return boundingShaped != 0;
}
bool Extensions::shapeInputAvailable()
{
return shape_version >= 0x11; // 1.1
}
int Extensions::randrNotifyEvent()
{
#ifdef HAVE_XRANDR
return randr_event_base + RRScreenChangeNotify;
#else
return 0;
#endif
}
int Extensions::damageNotifyEvent()
{
#ifdef HAVE_XDAMAGE
return damage_event_base + XDamageNotify;
#else
return 0;
#endif
}
bool Extensions::compositeOverlayAvailable()
{
return composite_version >= 0x03; // 0.3
}
bool Extensions::fixesRegionAvailable()
{
return fixes_version >= 0x30; // 3
}
int Extensions::syncAlarmNotifyEvent()
{
#ifdef HAVE_XSYNC
return sync_event_base + XSyncAlarmNotify;
#else
return 0;
#endif
}
void Motif::readFlags( WId w, bool& noborder, bool& resize, bool& move,
bool& minimize, bool& maximize, bool& close )
{

35
utils.h
View file

@ -133,41 +133,6 @@ enum HiddenPreviews // whether to keep all windows mapped when compositing
HiddenPreviewsActive // keep windows mapped
};
class Extensions
{
public:
static void init();
static bool shapeAvailable() { return shape_version > 0; }
static bool shapeInputAvailable();
static int shapeNotifyEvent();
static bool hasShape( Window w );
static bool randrAvailable() { return has_randr; }
static int randrNotifyEvent();
static bool damageAvailable() { return has_damage; }
static int damageNotifyEvent();
static bool compositeAvailable() { return composite_version > 0; }
static bool compositeOverlayAvailable();
static bool renderAvailable() { return render_version > 0; }
static bool fixesAvailable() { return fixes_version > 0; }
static bool fixesRegionAvailable();
static bool glxAvailable() { return has_glx; }
static bool syncAvailable() { return has_sync; }
static int syncAlarmNotifyEvent();
private:
static int shape_version;
static int shape_event_base;
static bool has_randr;
static int randr_event_base;
static bool has_damage;
static int damage_event_base;
static int composite_version;
static int render_version;
static int fixes_version;
static bool has_glx;
static bool has_sync;
static int sync_event_base;
};
// compile with XShape older than 1.0
#ifndef ShapeInput
const int ShapeInput = 2;