• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KWinLibraries

kwinglobals.cpp

Go to the documentation of this file.
00001 /********************************************************************
00002  KWin - the KDE window manager
00003  This file is part of the KDE project.
00004 
00005 Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
00006 
00007 This program is free software; you can redistribute it and/or modify
00008 it under the terms of the GNU General Public License as published by
00009 the Free Software Foundation; either version 2 of the License, or
00010 (at your option) any later version.
00011 
00012 This program is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with this program.  If not, see <http://www.gnu.org/licenses/>.
00019 *********************************************************************/
00020 
00021 #include "kwinglobals.h"
00022 
00023 #include <config-workspace.h>
00024 #include <config-X11.h>
00025 
00026 #include <assert.h>
00027 
00028 #include <kdebug.h>
00029 
00030 #include <X11/Xlib.h>
00031 #include <X11/extensions/shape.h>
00032 
00033 #ifdef HAVE_XRENDER
00034 #include <X11/extensions/Xrender.h>
00035 #endif
00036 #ifdef HAVE_XFIXES
00037 #include <X11/extensions/Xfixes.h>
00038 #endif
00039 #ifdef HAVE_XDAMAGE
00040 #include <X11/extensions/Xdamage.h>
00041 #endif
00042 #ifdef HAVE_XRANDR
00043 #include <X11/extensions/Xrandr.h>
00044 #endif
00045 #ifdef HAVE_XCOMPOSITE
00046 #include <X11/extensions/Xcomposite.h>
00047 #endif
00048 #ifdef HAVE_OPENGL
00049 #include <GL/glx.h>
00050 #endif
00051 #ifdef HAVE_XSYNC
00052 #include <X11/extensions/sync.h>
00053 #endif
00054 
00055 namespace KWin
00056 {
00057 
00058 int Extensions::shape_version = 0;
00059 int Extensions::shape_event_base = 0;
00060 bool Extensions::has_randr = false;
00061 int Extensions::randr_event_base = 0;
00062 bool Extensions::has_damage = false;
00063 int Extensions::damage_event_base = 0;
00064 int Extensions::composite_version = 0;
00065 int Extensions::fixes_version = 0;
00066 int Extensions::render_version = 0;
00067 bool Extensions::has_glx = false;
00068 bool Extensions::has_sync = false;
00069 int Extensions::sync_event_base = 0;
00070 // for fillExtensionsData()
00071 const char* Extensions::data_extensions[ 32 ];
00072 int Extensions::data_nextensions;
00073 int Extensions::data_opcodes[ 32 ];
00074 int Extensions::data_error_bases[ 32 ];
00075 
00076 void Extensions::addData( const char* name )
00077     {
00078     assert( data_nextensions < 32 );
00079     int opcode, event_base, error_base;
00080     XQueryExtension( display(), name, &opcode, &event_base, &error_base );
00081     data_extensions[ data_nextensions ] = name;
00082     data_opcodes[ data_nextensions ] = opcode;
00083     data_error_bases[ data_nextensions ] = error_base;
00084     ++data_nextensions;
00085     }
00086 
00087 void Extensions::init()
00088     {
00089     int event_base, error_base;
00090     data_nextensions = 0;
00091     shape_version = 0;
00092     if( XShapeQueryExtension( display(), &shape_event_base, &error_base ))
00093         {
00094         int major, minor;
00095         if( XShapeQueryVersion( display(), &major, &minor ))
00096             {
00097             shape_version = major * 0x10 + minor;
00098             addData( "SHAPE" );
00099             }
00100         }
00101 #ifdef HAVE_XRANDR
00102     has_randr = XRRQueryExtension( display(), &randr_event_base, &error_base );
00103     if( has_randr )
00104         {
00105         int major, minor;
00106         XRRQueryVersion( display(), &major, &minor );
00107         has_randr = ( major > 1 || ( major == 1 && minor >= 1 ) );
00108         addData( "RANDR" );
00109         }
00110 #else
00111     has_randr = false;
00112 #endif
00113 #ifdef HAVE_XDAMAGE
00114     has_damage = XDamageQueryExtension( display(), &damage_event_base, &error_base );
00115     if( has_damage )
00116         addData( "DAMAGE" );
00117 #else
00118     has_damage = false;
00119 #endif
00120     composite_version = 0;
00121 #ifdef HAVE_XCOMPOSITE
00122     if( XCompositeQueryExtension( display(), &event_base, &error_base ))
00123         {
00124         int major = 0, minor = 0;
00125         XCompositeQueryVersion( display(), &major, &minor );
00126         composite_version = major * 0x10 + minor;
00127         addData( "Composite" );
00128         }
00129 #endif
00130     fixes_version = 0;
00131 #ifdef HAVE_XFIXES
00132     if( XFixesQueryExtension( display(), &event_base, &error_base ))
00133         {
00134         int major = 0, minor = 0;
00135         XFixesQueryVersion( display(), &major, &minor );
00136         fixes_version = major * 0x10 + minor;
00137         addData( "XFIXES" );
00138         }
00139 #endif
00140     render_version = 0;
00141 #ifdef HAVE_XRENDER
00142     if( XRenderQueryExtension( display(), &event_base, &error_base ))
00143         {
00144         int major = 0, minor = 0;
00145         XRenderQueryVersion( display(), &major, &minor );
00146         render_version = major * 0x10 + minor;
00147         addData( "RENDER" );
00148         }
00149 #endif
00150     has_glx = false;
00151 #ifdef HAVE_OPENGL
00152     has_glx = glXQueryExtension( display(), &event_base, &error_base );
00153     if( has_glx )
00154         addData( "GLX" );
00155 #endif
00156 #ifdef HAVE_XSYNC
00157     if( XSyncQueryExtension( display(), &sync_event_base, &error_base ))
00158         {
00159         int major = 0, minor = 0;
00160         if( XSyncInitialize( display(), &major, &minor ))
00161             {
00162             has_sync = true;
00163             addData( "SYNC" );
00164             }
00165         }
00166 #endif
00167     kDebug( 1212 ) << "Extensions: shape: 0x" << QString::number( shape_version, 16 )
00168         << " composite: 0x" << QString::number( composite_version, 16 )
00169         << " render: 0x" << QString::number( render_version, 16 )
00170         << " fixes: 0x" << QString::number( fixes_version, 16 ) << endl;
00171     }
00172 
00173 void Extensions::fillExtensionsData( const char**& extensions, int& nextensions, int*&opcodes, int*& error_bases )
00174     {
00175     extensions = data_extensions;
00176     nextensions = data_nextensions;
00177     opcodes = data_opcodes;
00178     error_bases = data_error_bases;
00179     }
00180 
00181 int Extensions::shapeNotifyEvent()
00182     {
00183     return shape_event_base + ShapeNotify;
00184     }
00185 
00186 // does the window w need a shape combine mask around it?
00187 bool Extensions::hasShape( Window w )
00188     {
00189     int xws, yws, xbs, ybs;
00190     unsigned int wws, hws, wbs, hbs;
00191     int boundingShaped = 0, clipShaped = 0;
00192     if( !shapeAvailable())
00193         return false;
00194     XShapeQueryExtents(display(), w,
00195                        &boundingShaped, &xws, &yws, &wws, &hws,
00196                        &clipShaped, &xbs, &ybs, &wbs, &hbs);
00197     return boundingShaped != 0;
00198     }
00199 
00200 bool Extensions::shapeInputAvailable()
00201     {
00202     return shape_version >= 0x11; // 1.1
00203     }
00204 
00205 int Extensions::randrNotifyEvent()
00206     {
00207 #ifdef HAVE_XRANDR
00208     return randr_event_base + RRScreenChangeNotify;
00209 #else
00210     return 0;
00211 #endif
00212     }
00213 
00214 int Extensions::damageNotifyEvent()
00215     {
00216 #ifdef HAVE_XDAMAGE
00217     return damage_event_base + XDamageNotify;
00218 #else
00219     return 0;
00220 #endif
00221     }
00222 
00223 bool Extensions::compositeOverlayAvailable()
00224     {
00225     return composite_version >= 0x03; // 0.3
00226     }
00227 
00228 bool Extensions::fixesRegionAvailable()
00229     {
00230     return fixes_version >= 0x30; // 3
00231     }
00232 
00233 int Extensions::syncAlarmNotifyEvent()
00234     {
00235 #ifdef HAVE_XSYNC
00236     return sync_event_base + XSyncAlarmNotify;
00237 #else
00238     return 0;
00239 #endif
00240     }
00241 
00242 } // namespace
00243 

KWinLibraries

Skip menu "KWinLibraries"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • KWin
  •   KWin Libraries
  • Libraries
  •   libkworkspace
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal