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 "effects.h"
|
|
|
|
|
|
|
|
#include "deleted.h"
|
|
|
|
#include "client.h"
|
|
|
|
#include "group.h"
|
|
|
|
#include "scene_xrender.h"
|
|
|
|
#include "scene_opengl.h"
|
2008-01-02 15:37:46 +00:00
|
|
|
#include "unmanaged.h"
|
2007-04-29 17:35:43 +00:00
|
|
|
#include "workspace.h"
|
|
|
|
#include "kwinglutils.h"
|
|
|
|
|
|
|
|
#include <QFile>
|
|
|
|
|
|
|
|
#include "kdebug.h"
|
|
|
|
#include "klibloader.h"
|
|
|
|
#include "kdesktopfile.h"
|
|
|
|
#include "kconfiggroup.h"
|
|
|
|
#include "kstandarddirs.h"
|
2007-05-28 11:12:20 +00:00
|
|
|
#include <kservice.h>
|
|
|
|
#include <kservicetypetrader.h>
|
|
|
|
#include <kplugininfo.h>
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
EffectsHandlerImpl::EffectsHandlerImpl(CompositingType type)
|
|
|
|
: EffectsHandler(type)
|
|
|
|
, keyboard_grab_effect( NULL )
|
2007-11-01 17:47:41 +00:00
|
|
|
, fullscreen_effect( 0 )
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
2007-05-28 11:23:00 +00:00
|
|
|
reconfigure();
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
EffectsHandlerImpl::~EffectsHandlerImpl()
|
|
|
|
{
|
|
|
|
if( keyboard_grab_effect != NULL )
|
|
|
|
ungrabKeyboard();
|
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
unloadEffect( ep.first );
|
|
|
|
foreach( InputWindowPair pos, input_windows )
|
|
|
|
XDestroyWindow( display(), pos.second );
|
|
|
|
}
|
|
|
|
|
2007-05-28 11:23:00 +00:00
|
|
|
void EffectsHandlerImpl::reconfigure()
|
|
|
|
{
|
|
|
|
KSharedConfig::Ptr _config = KGlobal::config();
|
|
|
|
KConfigGroup conf(_config, "Plugins");
|
|
|
|
|
|
|
|
KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect");
|
2007-07-21 18:30:06 +00:00
|
|
|
QStringList effectsToBeLoaded;
|
|
|
|
// First unload necessary effects
|
2007-05-28 11:23:00 +00:00
|
|
|
foreach( KService::Ptr service, offers )
|
|
|
|
{
|
|
|
|
KPluginInfo plugininfo( service );
|
2007-06-25 10:03:40 +00:00
|
|
|
plugininfo.load( conf );
|
2007-05-28 11:23:00 +00:00
|
|
|
|
2007-05-29 11:42:47 +00:00
|
|
|
bool isloaded = isEffectLoaded( plugininfo.pluginName() );
|
|
|
|
bool shouldbeloaded = plugininfo.isPluginEnabled();
|
2007-07-21 18:30:06 +00:00
|
|
|
if( !shouldbeloaded && isloaded )
|
2007-05-28 11:23:00 +00:00
|
|
|
unloadEffect( plugininfo.pluginName() );
|
2007-07-21 18:30:06 +00:00
|
|
|
if( shouldbeloaded )
|
|
|
|
effectsToBeLoaded.append( plugininfo.pluginName() );
|
|
|
|
}
|
|
|
|
// Then load those that should be loaded
|
|
|
|
foreach( QString effectName, effectsToBeLoaded )
|
|
|
|
{
|
|
|
|
if( !isEffectLoaded( effectName ))
|
|
|
|
{
|
|
|
|
loadEffect( effectName );
|
|
|
|
}
|
2007-05-28 11:23:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// the idea is that effects call this function again which calls the next one
|
2007-09-20 17:53:15 +00:00
|
|
|
void EffectsHandlerImpl::prePaintScreen( ScreenPrePaintData& data, int time )
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
|
|
|
if( current_paint_screen < loaded_effects.size())
|
|
|
|
{
|
2007-07-07 14:01:32 +00:00
|
|
|
loaded_effects[current_paint_screen++].second->prePaintScreen( data, time );
|
2007-04-29 17:35:43 +00:00
|
|
|
--current_paint_screen;
|
|
|
|
}
|
|
|
|
// no special final code
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::paintScreen( int mask, QRegion region, ScreenPaintData& data )
|
|
|
|
{
|
|
|
|
if( current_paint_screen < loaded_effects.size())
|
|
|
|
{
|
|
|
|
loaded_effects[current_paint_screen++].second->paintScreen( mask, region, data );
|
|
|
|
--current_paint_screen;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
scene->finalPaintScreen( mask, region, data );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::postPaintScreen()
|
|
|
|
{
|
|
|
|
if( current_paint_screen < loaded_effects.size())
|
|
|
|
{
|
|
|
|
loaded_effects[current_paint_screen++].second->postPaintScreen();
|
|
|
|
--current_paint_screen;
|
|
|
|
}
|
|
|
|
// no special final code
|
|
|
|
}
|
|
|
|
|
2007-07-07 14:01:32 +00:00
|
|
|
void EffectsHandlerImpl::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time )
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
|
|
|
if( current_paint_window < loaded_effects.size())
|
|
|
|
{
|
2007-07-07 14:01:32 +00:00
|
|
|
loaded_effects[current_paint_window++].second->prePaintWindow( w, data, time );
|
2007-04-29 17:35:43 +00:00
|
|
|
--current_paint_window;
|
|
|
|
}
|
|
|
|
// no special final code
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
|
|
|
{
|
|
|
|
if( current_paint_window < loaded_effects.size())
|
|
|
|
{
|
|
|
|
loaded_effects[current_paint_window++].second->paintWindow( w, mask, region, data );
|
|
|
|
--current_paint_window;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
scene->finalPaintWindow( static_cast<EffectWindowImpl*>( w ), mask, region, data );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::postPaintWindow( EffectWindow* w )
|
|
|
|
{
|
|
|
|
if( current_paint_window < loaded_effects.size())
|
|
|
|
{
|
|
|
|
loaded_effects[current_paint_window++].second->postPaintWindow( w );
|
|
|
|
--current_paint_window;
|
|
|
|
}
|
|
|
|
// no special final code
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::drawWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
|
|
|
|
{
|
|
|
|
if( current_draw_window < loaded_effects.size())
|
|
|
|
{
|
|
|
|
loaded_effects[current_draw_window++].second->drawWindow( w, mask, region, data );
|
|
|
|
--current_draw_window;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
scene->finalDrawWindow( static_cast<EffectWindowImpl*>( w ), mask, region, data );
|
|
|
|
}
|
|
|
|
|
|
|
|
// start another painting pass
|
|
|
|
void EffectsHandlerImpl::startPaint()
|
|
|
|
{
|
|
|
|
assert( current_paint_screen == 0 );
|
|
|
|
assert( current_paint_window == 0 );
|
|
|
|
assert( current_draw_window == 0 );
|
|
|
|
assert( current_transform == 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::windowUserMovedResized( EffectWindow* c, bool first, bool last )
|
|
|
|
{
|
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->windowUserMovedResized( c, first, last );
|
|
|
|
}
|
|
|
|
|
2007-09-03 15:00:43 +00:00
|
|
|
void EffectsHandlerImpl::windowOpacityChanged( EffectWindow* c, double old_opacity )
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
|
|
|
if( static_cast<EffectWindowImpl*>(c)->window()->opacity() == old_opacity )
|
|
|
|
return;
|
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->windowOpacityChanged( c, old_opacity );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::windowAdded( EffectWindow* c )
|
|
|
|
{
|
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->windowAdded( c );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::windowDeleted( EffectWindow* c )
|
|
|
|
{
|
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->windowDeleted( c );
|
2007-05-24 14:41:56 +00:00
|
|
|
Toplevel* c2 = static_cast< EffectWindowImpl* >( c )->window();
|
|
|
|
elevated_windows.removeAll( c2 );
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::windowClosed( EffectWindow* c )
|
|
|
|
{
|
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->windowClosed( c );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::windowActivated( EffectWindow* c )
|
|
|
|
{
|
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->windowActivated( c );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::windowMinimized( EffectWindow* c )
|
|
|
|
{
|
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->windowMinimized( c );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::windowUnminimized( EffectWindow* c )
|
|
|
|
{
|
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->windowUnminimized( c );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::desktopChanged( int old )
|
|
|
|
{
|
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->desktopChanged( old );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::windowDamaged( EffectWindow* w, const QRect& r )
|
|
|
|
{
|
|
|
|
if( w == NULL )
|
|
|
|
return;
|
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->windowDamaged( w, r );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::windowGeometryShapeChanged( EffectWindow* w, const QRect& old )
|
|
|
|
{
|
|
|
|
if( w == NULL ) // during late cleanup effectWindow() may be already NULL
|
|
|
|
return; // in some functions that may still call this
|
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->windowGeometryShapeChanged( w, old );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::tabBoxAdded( int mode )
|
|
|
|
{
|
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->tabBoxAdded( mode );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::tabBoxClosed()
|
|
|
|
{
|
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->tabBoxClosed();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::tabBoxUpdated()
|
|
|
|
{
|
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->tabBoxUpdated();
|
|
|
|
}
|
|
|
|
|
2007-11-01 17:47:41 +00:00
|
|
|
void EffectsHandlerImpl::setActiveFullScreenEffect( Effect* e )
|
|
|
|
{
|
|
|
|
fullscreen_effect = e;
|
|
|
|
}
|
|
|
|
|
|
|
|
Effect* EffectsHandlerImpl::activeFullScreenEffect() const
|
|
|
|
{
|
|
|
|
return fullscreen_effect;
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
bool EffectsHandlerImpl::borderActivated( ElectricBorder border )
|
|
|
|
{
|
|
|
|
bool ret = false;
|
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
if( ep.second->borderActivated( border ))
|
|
|
|
ret = true; // bail out or tell all?
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-01-02 15:34:12 +00:00
|
|
|
void EffectsHandlerImpl::mouseChanged( const QPoint& pos, const QPoint& oldpos,
|
|
|
|
Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons,
|
|
|
|
Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers )
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
|
|
|
foreach( EffectPair ep, loaded_effects )
|
2008-01-02 15:34:12 +00:00
|
|
|
ep.second->mouseChanged( pos, oldpos, buttons, oldbuttons, modifiers, oldmodifiers );
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectsHandlerImpl::grabKeyboard( Effect* effect )
|
|
|
|
{
|
|
|
|
if( keyboard_grab_effect != NULL )
|
|
|
|
return false;
|
|
|
|
bool ret = grabXKeyboard();
|
|
|
|
if( !ret )
|
|
|
|
return false;
|
|
|
|
keyboard_grab_effect = effect;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::ungrabKeyboard()
|
|
|
|
{
|
|
|
|
assert( keyboard_grab_effect != NULL );
|
|
|
|
ungrabXKeyboard();
|
|
|
|
keyboard_grab_effect = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::grabbedKeyboardEvent( QKeyEvent* e )
|
|
|
|
{
|
|
|
|
if( keyboard_grab_effect != NULL )
|
|
|
|
keyboard_grab_effect->grabbedKeyboardEvent( e );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectsHandlerImpl::hasKeyboardGrab() const
|
|
|
|
{
|
|
|
|
return keyboard_grab_effect != NULL;
|
|
|
|
}
|
|
|
|
|
2008-01-02 15:21:33 +00:00
|
|
|
void EffectsHandlerImpl::propertyNotify( EffectWindow* c, long atom )
|
|
|
|
{
|
|
|
|
if( !registered_atoms.contains( atom ))
|
|
|
|
return;
|
|
|
|
foreach( EffectPair ep, loaded_effects )
|
|
|
|
ep.second->propertyNotify( c, atom );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::registerPropertyType( long atom, bool reg )
|
|
|
|
{
|
|
|
|
if( reg )
|
|
|
|
++registered_atoms[ atom ]; // initialized to 0 if not present yet
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( --registered_atoms[ atom ] == 0 )
|
|
|
|
registered_atoms.remove( atom );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void EffectsHandlerImpl::activateWindow( EffectWindow* c )
|
|
|
|
{
|
|
|
|
if( Client* cl = dynamic_cast< Client* >( static_cast<EffectWindowImpl*>(c)->window()))
|
|
|
|
Workspace::self()->activateClient( cl, true );
|
|
|
|
}
|
|
|
|
|
|
|
|
EffectWindow* EffectsHandlerImpl::activeWindow() const
|
|
|
|
{
|
|
|
|
return Workspace::self()->activeClient() ? Workspace::self()->activeClient()->effectWindow() : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::moveWindow( EffectWindow* w, const QPoint& pos )
|
|
|
|
{
|
|
|
|
Client* cl = dynamic_cast< Client* >( static_cast<EffectWindowImpl*>(w)->window());
|
|
|
|
if( cl && cl->isMovable())
|
|
|
|
cl->move( pos );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::windowToDesktop( EffectWindow* w, int desktop )
|
|
|
|
{
|
2007-12-17 17:29:50 +00:00
|
|
|
Client* cl = dynamic_cast< Client* >( static_cast<EffectWindowImpl*>(w)->window());
|
|
|
|
if( cl && !cl->isDesktop() && !cl->isDock() && !cl->isTopMenu())
|
2007-04-29 17:35:43 +00:00
|
|
|
Workspace::self()->sendClientToDesktop( cl, desktop, true );
|
|
|
|
}
|
|
|
|
|
|
|
|
int EffectsHandlerImpl::currentDesktop() const
|
|
|
|
{
|
|
|
|
return Workspace::self()->currentDesktop();
|
|
|
|
}
|
|
|
|
|
|
|
|
int EffectsHandlerImpl::numberOfDesktops() const
|
|
|
|
{
|
|
|
|
return Workspace::self()->numberOfDesktops();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::setCurrentDesktop( int desktop )
|
|
|
|
{
|
|
|
|
Workspace::self()->setCurrentDesktop( desktop );
|
|
|
|
}
|
|
|
|
|
|
|
|
QString EffectsHandlerImpl::desktopName( int desktop ) const
|
|
|
|
{
|
|
|
|
return Workspace::self()->desktopName( desktop );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::calcDesktopLayout(int* x, int* y, Qt::Orientation* orientation) const
|
|
|
|
{
|
|
|
|
Workspace::self()->calcDesktopLayout( x, y, orientation );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectsHandlerImpl::optionRollOverDesktops() const
|
|
|
|
{
|
|
|
|
return options->rollOverDesktops;
|
|
|
|
}
|
|
|
|
|
2007-11-20 16:17:08 +00:00
|
|
|
int EffectsHandlerImpl::desktopToLeft( int desktop, bool wrap ) const
|
|
|
|
{
|
|
|
|
return Workspace::self()->desktopToLeft( desktop, wrap );
|
|
|
|
}
|
|
|
|
|
|
|
|
int EffectsHandlerImpl::desktopToRight( int desktop, bool wrap ) const
|
|
|
|
{
|
|
|
|
return Workspace::self()->desktopToRight( desktop, wrap );
|
|
|
|
}
|
|
|
|
|
|
|
|
int EffectsHandlerImpl::desktopUp( int desktop, bool wrap ) const
|
|
|
|
{
|
|
|
|
return Workspace::self()->desktopUp( desktop, wrap );
|
|
|
|
}
|
|
|
|
|
|
|
|
int EffectsHandlerImpl::desktopDown( int desktop, bool wrap ) const
|
|
|
|
{
|
|
|
|
return Workspace::self()->desktopDown( desktop, wrap );
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
int EffectsHandlerImpl::displayWidth() const
|
|
|
|
{
|
|
|
|
return KWin::displayWidth();
|
|
|
|
}
|
|
|
|
|
|
|
|
int EffectsHandlerImpl::displayHeight() const
|
|
|
|
{
|
|
|
|
return KWin::displayWidth();
|
|
|
|
}
|
|
|
|
|
2008-01-02 15:37:46 +00:00
|
|
|
EffectWindow* EffectsHandlerImpl::findWindow( WId id ) const
|
|
|
|
{
|
|
|
|
if( Client* w = Workspace::self()->findClient( WindowMatchPredicate( id )))
|
|
|
|
return w->effectWindow();
|
|
|
|
if( Unmanaged* w = Workspace::self()->findUnmanaged( WindowMatchPredicate( id )))
|
|
|
|
return w->effectWindow();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
EffectWindowList EffectsHandlerImpl::stackingOrder() const
|
|
|
|
{
|
|
|
|
ClientList list = Workspace::self()->stackingOrder();
|
|
|
|
EffectWindowList ret;
|
|
|
|
foreach( Client* c, list )
|
|
|
|
ret.append( effectWindow( c ));
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-05-24 14:41:56 +00:00
|
|
|
void EffectsHandlerImpl::setElevatedWindow( EffectWindow* w, bool set )
|
|
|
|
{
|
|
|
|
Toplevel* c = static_cast< EffectWindowImpl* >( w )->window();
|
|
|
|
elevated_windows.removeAll( c );
|
|
|
|
if( set )
|
|
|
|
elevated_windows.append( c );
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
void EffectsHandlerImpl::setTabBoxWindow(EffectWindow* w)
|
|
|
|
{
|
|
|
|
if( Client* c = dynamic_cast< Client* >( static_cast< EffectWindowImpl* >( w )->window()))
|
|
|
|
Workspace::self()->setTabBoxClient( c );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::setTabBoxDesktop(int desktop)
|
|
|
|
{
|
|
|
|
Workspace::self()->setTabBoxDesktop( desktop );
|
|
|
|
}
|
|
|
|
|
|
|
|
EffectWindowList EffectsHandlerImpl::currentTabBoxWindowList() const
|
|
|
|
{
|
|
|
|
EffectWindowList ret;
|
|
|
|
ClientList clients = Workspace::self()->currentTabBoxClientList();
|
|
|
|
foreach( Client* c, clients )
|
|
|
|
ret.append( c->effectWindow());
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::refTabBox()
|
|
|
|
{
|
|
|
|
Workspace::self()->refTabBox();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::unrefTabBox()
|
|
|
|
{
|
|
|
|
Workspace::self()->unrefTabBox();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::closeTabBox()
|
|
|
|
{
|
|
|
|
Workspace::self()->closeTabBox();
|
|
|
|
}
|
|
|
|
|
|
|
|
QList< int > EffectsHandlerImpl::currentTabBoxDesktopList() const
|
|
|
|
{
|
|
|
|
return Workspace::self()->currentTabBoxDesktopList();
|
|
|
|
}
|
|
|
|
|
|
|
|
int EffectsHandlerImpl::currentTabBoxDesktop() const
|
|
|
|
{
|
|
|
|
return Workspace::self()->currentTabBoxDesktop();
|
|
|
|
}
|
|
|
|
|
|
|
|
EffectWindow* EffectsHandlerImpl::currentTabBoxWindow() const
|
|
|
|
{
|
|
|
|
if( Client* c = Workspace::self()->currentTabBoxClient())
|
|
|
|
return c->effectWindow();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::pushRenderTarget(GLRenderTarget* target)
|
|
|
|
{
|
2007-12-17 14:14:53 +00:00
|
|
|
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
2007-04-29 17:35:43 +00:00
|
|
|
target->enable();
|
|
|
|
render_targets.push(target);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
GLRenderTarget* EffectsHandlerImpl::popRenderTarget()
|
|
|
|
{
|
2007-12-17 14:14:53 +00:00
|
|
|
#ifdef KWIN_HAVE_OPENGL_COMPOSITING
|
2007-04-29 17:35:43 +00:00
|
|
|
GLRenderTarget* ret = render_targets.pop();
|
|
|
|
ret->disable();
|
|
|
|
if( !render_targets.isEmpty() )
|
|
|
|
render_targets.top()->enable();
|
|
|
|
return ret;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::addRepaintFull()
|
|
|
|
{
|
|
|
|
Workspace::self()->addRepaintFull();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::addRepaint( const QRect& r )
|
|
|
|
{
|
|
|
|
Workspace::self()->addRepaint( r );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::addRepaint( int x, int y, int w, int h )
|
|
|
|
{
|
|
|
|
Workspace::self()->addRepaint( x, y, w, h );
|
|
|
|
}
|
|
|
|
|
2007-11-20 18:58:30 +00:00
|
|
|
int EffectsHandlerImpl::activeScreen() const
|
|
|
|
{
|
|
|
|
return Workspace::self()->activeScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect EffectsHandlerImpl::clientArea( clientAreaOption opt, int screen, int desktop ) const
|
|
|
|
{
|
|
|
|
return Workspace::self()->clientArea( opt, screen, desktop );
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect EffectsHandlerImpl::clientArea( clientAreaOption opt, const EffectWindow* c ) const
|
|
|
|
{
|
|
|
|
const Toplevel* t = static_cast< const EffectWindowImpl* >(c)->window();
|
|
|
|
if( const Client* cl = dynamic_cast< const Client* >( t ))
|
|
|
|
return Workspace::self()->clientArea( opt, cl );
|
|
|
|
else
|
|
|
|
return Workspace::self()->clientArea( opt, t->geometry().center(), Workspace::self()->currentDesktop());
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
QRect EffectsHandlerImpl::clientArea( clientAreaOption opt, const QPoint& p, int desktop ) const
|
|
|
|
{
|
|
|
|
return Workspace::self()->clientArea( opt, p, desktop );
|
|
|
|
}
|
|
|
|
|
|
|
|
Window EffectsHandlerImpl::createInputWindow( Effect* e, int x, int y, int w, int h, const QCursor& cursor )
|
|
|
|
{
|
|
|
|
XSetWindowAttributes attrs;
|
|
|
|
attrs.override_redirect = True;
|
|
|
|
Window win = XCreateWindow( display(), rootWindow(), x, y, w, h, 0, 0, InputOnly, CopyFromParent,
|
|
|
|
CWOverrideRedirect, &attrs );
|
|
|
|
// TODO keeping on top?
|
|
|
|
// TODO enter/leave notify?
|
|
|
|
XSelectInput( display(), win, ButtonPressMask | ButtonReleaseMask | PointerMotionMask );
|
|
|
|
XDefineCursor( display(), win, cursor.handle());
|
|
|
|
XMapWindow( display(), win );
|
|
|
|
input_windows.append( qMakePair( e, win ));
|
|
|
|
return win;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::destroyInputWindow( Window w )
|
|
|
|
{
|
|
|
|
foreach( InputWindowPair pos, input_windows )
|
|
|
|
{
|
|
|
|
if( pos.second == w )
|
|
|
|
{
|
|
|
|
input_windows.removeAll( pos );
|
|
|
|
XDestroyWindow( display(), w );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectsHandlerImpl::checkInputWindowEvent( XEvent* e )
|
|
|
|
{
|
|
|
|
if( e->type != ButtonPress && e->type != ButtonRelease && e->type != MotionNotify )
|
|
|
|
return false;
|
|
|
|
foreach( InputWindowPair pos, input_windows )
|
|
|
|
{
|
|
|
|
if( pos.second == e->xany.window )
|
|
|
|
{
|
|
|
|
switch( e->type )
|
|
|
|
{
|
|
|
|
case ButtonPress:
|
|
|
|
{
|
|
|
|
XButtonEvent* e2 = &e->xbutton;
|
|
|
|
Qt::MouseButton button = x11ToQtMouseButton( e2->button );
|
|
|
|
Qt::MouseButtons buttons = x11ToQtMouseButtons( e2->state ) | button;
|
|
|
|
QMouseEvent ev( QEvent::MouseButtonPress,
|
|
|
|
QPoint( e2->x, e2->y ), QPoint( e2->x_root, e2->y_root ),
|
|
|
|
button, buttons, x11ToQtKeyboardModifiers( e2->state ));
|
|
|
|
pos.first->windowInputMouseEvent( pos.second, &ev );
|
|
|
|
break; // --->
|
|
|
|
}
|
|
|
|
case ButtonRelease:
|
|
|
|
{
|
|
|
|
XButtonEvent* e2 = &e->xbutton;
|
|
|
|
Qt::MouseButton button = x11ToQtMouseButton( e2->button );
|
|
|
|
Qt::MouseButtons buttons = x11ToQtMouseButtons( e2->state ) & ~button;
|
|
|
|
QMouseEvent ev( QEvent::MouseButtonRelease,
|
|
|
|
QPoint( e2->x, e2->y ), QPoint( e2->x_root, e2->y_root ),
|
|
|
|
button, buttons, x11ToQtKeyboardModifiers( e2->state ));
|
|
|
|
pos.first->windowInputMouseEvent( pos.second, &ev );
|
|
|
|
break; // --->
|
|
|
|
}
|
|
|
|
case MotionNotify:
|
|
|
|
{
|
|
|
|
XMotionEvent* e2 = &e->xmotion;
|
|
|
|
QMouseEvent ev( QEvent::MouseMove, QPoint( e2->x, e2->y ), QPoint( e2->x_root, e2->y_root ),
|
|
|
|
Qt::NoButton, x11ToQtMouseButtons( e2->state ), x11ToQtKeyboardModifiers( e2->state ));
|
|
|
|
pos.first->windowInputMouseEvent( pos.second, &ev );
|
|
|
|
break; // --->
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true; // eat event
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::checkInputWindowStacking()
|
|
|
|
{
|
|
|
|
if( input_windows.count() == 0 )
|
|
|
|
return;
|
|
|
|
Window* wins = new Window[ input_windows.count() ];
|
|
|
|
int pos = 0;
|
|
|
|
foreach( InputWindowPair it, input_windows )
|
|
|
|
wins[ pos++ ] = it.second;
|
|
|
|
XRaiseWindow( display(), wins[ 0 ] );
|
|
|
|
XRestackWindows( display(), wins, pos );
|
|
|
|
delete[] wins;
|
|
|
|
}
|
|
|
|
|
|
|
|
QPoint EffectsHandlerImpl::cursorPos() const
|
|
|
|
{
|
|
|
|
return Workspace::self()->cursorPos();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::checkElectricBorder(const QPoint &pos, Time time)
|
|
|
|
{
|
|
|
|
Workspace::self()->checkElectricBorder( pos, time );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::reserveElectricBorder( ElectricBorder border )
|
|
|
|
{
|
|
|
|
Workspace::self()->reserveElectricBorder( border );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::unreserveElectricBorder( ElectricBorder border )
|
|
|
|
{
|
|
|
|
Workspace::self()->unreserveElectricBorder( border );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::reserveElectricBorderSwitching( bool reserve )
|
|
|
|
{
|
|
|
|
Workspace::self()->reserveElectricBorderSwitching( reserve );
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned long EffectsHandlerImpl::xrenderBufferPicture()
|
|
|
|
{
|
2007-12-17 14:14:53 +00:00
|
|
|
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
|
2007-04-29 17:35:43 +00:00
|
|
|
if( SceneXrender* s = dynamic_cast< SceneXrender* >( scene ))
|
|
|
|
return s->bufferPicture();
|
|
|
|
#endif
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
2007-07-06 12:38:41 +00:00
|
|
|
KLibrary* EffectsHandlerImpl::findEffectLibrary( KService* service )
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
2007-07-06 12:38:41 +00:00
|
|
|
QString libname = service->library();
|
2007-05-14 19:46:21 +00:00
|
|
|
KLibrary* library = KLibLoader::self()->library(libname);
|
2007-04-29 17:35:43 +00:00
|
|
|
if( !library )
|
|
|
|
{
|
2007-08-20 21:33:48 +00:00
|
|
|
kError( 1212 ) << "couldn't open library for effect '" <<
|
2007-07-06 12:38:41 +00:00
|
|
|
service->name() << "'" << endl;
|
2007-04-29 17:35:43 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return library;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::toggleEffect( const QString& name )
|
|
|
|
{
|
2007-05-29 11:42:47 +00:00
|
|
|
if( isEffectLoaded( name ))
|
|
|
|
unloadEffect( name );
|
|
|
|
else
|
|
|
|
loadEffect( name );
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
2007-07-20 21:13:10 +00:00
|
|
|
bool EffectsHandlerImpl::loadEffect( const QString& name )
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
|
|
|
Workspace::self()->addRepaintFull();
|
|
|
|
assert( current_paint_screen == 0 );
|
|
|
|
assert( current_paint_window == 0 );
|
|
|
|
assert( current_draw_window == 0 );
|
|
|
|
assert( current_transform == 0 );
|
|
|
|
|
2007-05-28 11:12:20 +00:00
|
|
|
if( !name.startsWith("kwin4_effect_") )
|
2007-08-20 21:33:48 +00:00
|
|
|
kWarning( 1212 ) << "Effect names usually have kwin4_effect_ prefix" ;
|
2007-05-28 11:12:20 +00:00
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
// Make sure a single effect won't be loaded multiple times
|
2007-07-06 13:39:03 +00:00
|
|
|
for(QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it)
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
|
|
|
if( (*it).first == name )
|
|
|
|
{
|
2007-08-03 06:59:24 +00:00
|
|
|
kDebug( 1212 ) << "EffectsHandler::loadEffect : Effect already loaded : " << name;
|
2007-07-20 21:13:10 +00:00
|
|
|
return true;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-20 21:33:48 +00:00
|
|
|
kDebug( 1212 ) << "Trying to load " << name;
|
2007-07-06 12:38:41 +00:00
|
|
|
QString internalname = name.toLower();
|
|
|
|
|
|
|
|
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(internalname);
|
|
|
|
KService::List offers = KServiceTypeTrader::self()->query("KWin/Effect", constraint);
|
|
|
|
if(offers.isEmpty())
|
|
|
|
{
|
2007-08-20 21:33:48 +00:00
|
|
|
kError( 1212 ) << "Couldn't find effect " << name << endl;
|
2007-07-20 21:13:10 +00:00
|
|
|
return false;
|
2007-07-06 12:38:41 +00:00
|
|
|
}
|
2007-07-21 18:30:06 +00:00
|
|
|
KService::Ptr service = offers.first();
|
2007-07-06 12:38:41 +00:00
|
|
|
|
|
|
|
KLibrary* library = findEffectLibrary( service.data() );
|
2007-04-29 17:35:43 +00:00
|
|
|
if( !library )
|
|
|
|
{
|
2007-07-20 21:13:10 +00:00
|
|
|
return false;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
2007-12-17 14:10:21 +00:00
|
|
|
QString version_symbol = "effect_version_" + name;
|
|
|
|
KLibrary::void_function_ptr version_func = library->resolveFunction(version_symbol.toAscii());
|
|
|
|
if( version_func == NULL )
|
|
|
|
{
|
|
|
|
kWarning( 1212 ) << "Effect " << name << " does not provide required API version, ignoring.";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
typedef int (*t_versionfunc)();
|
|
|
|
int version = reinterpret_cast< t_versionfunc >( version_func )(); // call it
|
2008-01-02 15:17:58 +00:00
|
|
|
// Version must be the same or less, but major must be the same.
|
2008-01-02 15:18:34 +00:00
|
|
|
// With major 0 minor must match exactly.
|
2007-12-17 14:10:21 +00:00
|
|
|
if( version > KWIN_EFFECT_API_VERSION
|
2008-01-02 15:18:34 +00:00
|
|
|
|| ( version >> 8 ) != KWIN_EFFECT_API_VERSION_MAJOR
|
|
|
|
|| ( KWIN_EFFECT_API_VERSION_MAJOR == 0 && version != KWIN_EFFECT_API_VERSION ))
|
2007-12-17 14:10:21 +00:00
|
|
|
{
|
|
|
|
kWarning( 1212 ) << "Effect " << name << " requires unsupported API version " << version;
|
|
|
|
return false;
|
|
|
|
}
|
2007-04-29 17:35:43 +00:00
|
|
|
QString supported_symbol = "effect_supported_" + name;
|
|
|
|
KLibrary::void_function_ptr supported_func = library->resolveFunction(supported_symbol.toAscii().data());
|
|
|
|
QString create_symbol = "effect_create_" + name;
|
|
|
|
KLibrary::void_function_ptr create_func = library->resolveFunction(create_symbol.toAscii().data());
|
|
|
|
if( supported_func )
|
|
|
|
{
|
|
|
|
typedef bool (*t_supportedfunc)();
|
|
|
|
t_supportedfunc supported = reinterpret_cast<t_supportedfunc>(supported_func);
|
|
|
|
if(!supported())
|
|
|
|
{
|
2007-08-03 06:59:24 +00:00
|
|
|
kWarning( 1212 ) << "EffectsHandler::loadEffect : Effect " << name << " is not supported" ;
|
2007-04-29 17:35:43 +00:00
|
|
|
library->unload();
|
2007-07-20 21:13:10 +00:00
|
|
|
return false;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!create_func)
|
|
|
|
{
|
|
|
|
kError( 1212 ) << "EffectsHandler::loadEffect : effect_create function not found" << endl;
|
|
|
|
library->unload();
|
2007-07-20 21:13:10 +00:00
|
|
|
return false;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
typedef Effect* (*t_createfunc)();
|
|
|
|
t_createfunc create = reinterpret_cast<t_createfunc>(create_func);
|
|
|
|
|
2007-07-21 18:30:06 +00:00
|
|
|
// Make sure all depenedencies have been loaded
|
|
|
|
// TODO: detect circular deps
|
|
|
|
KPluginInfo plugininfo( service );
|
|
|
|
QStringList dependencies = plugininfo.dependencies();
|
|
|
|
foreach( QString depName, dependencies )
|
|
|
|
{
|
|
|
|
if( !loadEffect(depName))
|
|
|
|
{
|
|
|
|
kError() << "EffectsHandler::loadEffect : Couldn't load dependencies for effect " << name << endl;
|
|
|
|
library->unload();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
Effect* e = create();
|
|
|
|
|
2007-07-06 12:38:41 +00:00
|
|
|
effect_order.insert( service->property( "X-Ordering" ).toInt(), EffectPair( name, e ));
|
|
|
|
effectsChanged();
|
2007-04-29 17:35:43 +00:00
|
|
|
effect_libraries[ name ] = library;
|
2007-07-20 21:13:10 +00:00
|
|
|
|
|
|
|
return true;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EffectsHandlerImpl::unloadEffect( const QString& name )
|
|
|
|
{
|
|
|
|
Workspace::self()->addRepaintFull();
|
|
|
|
assert( current_paint_screen == 0 );
|
|
|
|
assert( current_paint_window == 0 );
|
|
|
|
assert( current_draw_window == 0 );
|
|
|
|
assert( current_transform == 0 );
|
|
|
|
|
2007-07-06 13:39:03 +00:00
|
|
|
for( QMap< int, EffectPair >::iterator it = effect_order.begin(); it != effect_order.end(); ++it)
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
2007-07-06 12:38:41 +00:00
|
|
|
if ( it.value().first == name )
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
2007-08-03 06:59:24 +00:00
|
|
|
kDebug( 1212 ) << "EffectsHandler::unloadEffect : Unloading Effect : " << name;
|
2007-11-01 17:47:41 +00:00
|
|
|
if( activeFullScreenEffect() == it.value().second )
|
|
|
|
{
|
|
|
|
setActiveFullScreenEffect( 0 );
|
|
|
|
}
|
2007-07-06 12:38:41 +00:00
|
|
|
delete it.value().second;
|
|
|
|
effect_order.erase(it);
|
|
|
|
effectsChanged();
|
2007-04-29 17:35:43 +00:00
|
|
|
effect_libraries[ name ]->unload();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-03 06:59:24 +00:00
|
|
|
kDebug( 1212 ) << "EffectsHandler::unloadEffect : Effect not loaded : " << name;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
2007-05-29 11:42:47 +00:00
|
|
|
void EffectsHandlerImpl::reloadEffect( const QString& name )
|
|
|
|
{
|
|
|
|
if( isEffectLoaded( name ))
|
|
|
|
{
|
|
|
|
unloadEffect( name );
|
|
|
|
loadEffect( name );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectsHandlerImpl::isEffectLoaded( const QString& name )
|
|
|
|
{
|
2007-07-06 13:39:03 +00:00
|
|
|
for( QVector< EffectPair >::iterator it = loaded_effects.begin(); it != loaded_effects.end(); ++it)
|
2007-05-29 11:42:47 +00:00
|
|
|
if ( (*it).first == name )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-07-06 12:38:41 +00:00
|
|
|
void EffectsHandlerImpl::effectsChanged()
|
|
|
|
{
|
|
|
|
loaded_effects.clear();
|
2007-12-30 14:04:51 +00:00
|
|
|
kDebug(1212) << "Recreating effects' list:";
|
2007-07-06 12:38:41 +00:00
|
|
|
foreach( EffectPair effect, effect_order )
|
|
|
|
{
|
2007-12-30 14:04:51 +00:00
|
|
|
kDebug(1212) << effect.first;
|
2007-07-06 12:38:41 +00:00
|
|
|
loaded_effects.append( effect );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
//****************************************
|
|
|
|
// EffectWindowImpl
|
|
|
|
//****************************************
|
|
|
|
|
|
|
|
EffectWindowImpl::EffectWindowImpl() : EffectWindow()
|
|
|
|
, toplevel( NULL )
|
|
|
|
, sw( NULL )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
EffectWindowImpl::~EffectWindowImpl()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isPaintingEnabled()
|
|
|
|
{
|
|
|
|
return sceneWindow()->isPaintingEnabled();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectWindowImpl::enablePainting( int reason )
|
|
|
|
{
|
|
|
|
sceneWindow()->enablePainting( reason );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectWindowImpl::disablePainting( int reason )
|
|
|
|
{
|
|
|
|
sceneWindow()->disablePainting( reason );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectWindowImpl::addRepaint( const QRect& r )
|
|
|
|
{
|
|
|
|
toplevel->addRepaint( r );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectWindowImpl::addRepaint( int x, int y, int w, int h )
|
|
|
|
{
|
|
|
|
toplevel->addRepaint( x, y, w, h );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectWindowImpl::addRepaintFull()
|
|
|
|
{
|
|
|
|
toplevel->addRepaintFull();
|
|
|
|
}
|
|
|
|
|
|
|
|
int EffectWindowImpl::desktop() const
|
|
|
|
{
|
|
|
|
return toplevel->desktop();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isOnAllDesktops() const
|
|
|
|
{
|
|
|
|
return desktop() == NET::OnAllDesktops;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString EffectWindowImpl::caption() const
|
|
|
|
{
|
|
|
|
if( Client* c = dynamic_cast<Client*>( toplevel ))
|
|
|
|
return c->caption();
|
|
|
|
else
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
QString EffectWindowImpl::windowClass() const
|
|
|
|
{
|
|
|
|
return toplevel->resourceName() + ' ' + toplevel->resourceClass();
|
|
|
|
}
|
|
|
|
|
2007-11-13 19:59:53 +00:00
|
|
|
QString EffectWindowImpl::windowRole() const
|
|
|
|
{
|
|
|
|
return toplevel->windowRole();
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
QPixmap EffectWindowImpl::icon() const
|
|
|
|
{
|
|
|
|
if( Client* c = dynamic_cast<Client*>( toplevel ))
|
|
|
|
return c->icon();
|
|
|
|
return QPixmap(); // TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
const EffectWindowGroup* EffectWindowImpl::group() const
|
|
|
|
{
|
|
|
|
if( Client* c = dynamic_cast< Client* >( toplevel ))
|
|
|
|
return c->group()->effectGroup();
|
|
|
|
return NULL; // TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isMinimized() const
|
|
|
|
{
|
|
|
|
if( Client* c = dynamic_cast<Client*>( toplevel ))
|
|
|
|
return c->isMinimized();
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-09-03 15:00:43 +00:00
|
|
|
double EffectWindowImpl::opacity() const
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
|
|
|
return toplevel->opacity();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isDeleted() const
|
|
|
|
{
|
|
|
|
return (dynamic_cast<Deleted*>( toplevel ) != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectWindowImpl::refWindow()
|
|
|
|
{
|
|
|
|
if( Deleted* d = dynamic_cast< Deleted* >( toplevel ))
|
|
|
|
return d->refWindow();
|
|
|
|
abort(); // TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectWindowImpl::unrefWindow()
|
|
|
|
{
|
|
|
|
if( Deleted* d = dynamic_cast< Deleted* >( toplevel ))
|
2007-05-09 16:10:49 +00:00
|
|
|
return d->unrefWindow( true ); // delayed
|
2007-04-29 17:35:43 +00:00
|
|
|
abort(); // TODO
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectWindowImpl::setWindow( Toplevel* w )
|
|
|
|
{
|
|
|
|
toplevel = w;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectWindowImpl::setSceneWindow( Scene::Window* w )
|
|
|
|
{
|
|
|
|
sw = w;
|
|
|
|
}
|
|
|
|
|
|
|
|
int EffectWindowImpl::x() const
|
|
|
|
{
|
|
|
|
return toplevel->x();
|
|
|
|
}
|
|
|
|
|
|
|
|
int EffectWindowImpl::y() const
|
|
|
|
{
|
|
|
|
return toplevel->y();
|
|
|
|
}
|
|
|
|
|
|
|
|
int EffectWindowImpl::width() const
|
|
|
|
{
|
|
|
|
return toplevel->width();
|
|
|
|
}
|
|
|
|
|
|
|
|
int EffectWindowImpl::height() const
|
|
|
|
{
|
|
|
|
return toplevel->height();
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect EffectWindowImpl::geometry() const
|
|
|
|
{
|
|
|
|
return toplevel->geometry();
|
|
|
|
}
|
|
|
|
|
2007-12-07 18:03:24 +00:00
|
|
|
QRegion EffectWindowImpl::shape() const
|
|
|
|
{
|
|
|
|
return sw ? sw->shape() : geometry();
|
|
|
|
}
|
|
|
|
|
2008-01-03 19:39:18 +00:00
|
|
|
bool EffectWindowImpl::hasOwnShape() const
|
|
|
|
{
|
|
|
|
return toplevel->shape();
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
QSize EffectWindowImpl::size() const
|
|
|
|
{
|
|
|
|
return toplevel->size();
|
|
|
|
}
|
|
|
|
|
|
|
|
QPoint EffectWindowImpl::pos() const
|
|
|
|
{
|
|
|
|
return toplevel->pos();
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect EffectWindowImpl::rect() const
|
|
|
|
{
|
|
|
|
return toplevel->rect();
|
|
|
|
}
|
|
|
|
|
2007-07-19 13:32:46 +00:00
|
|
|
QRect EffectWindowImpl::contentsRect() const
|
|
|
|
{
|
|
|
|
return QRect( toplevel->clientPos(), toplevel->clientSize());
|
|
|
|
}
|
|
|
|
|
2008-01-02 15:21:33 +00:00
|
|
|
QByteArray EffectWindowImpl::readProperty( long atom, long type, int format ) const
|
|
|
|
{
|
|
|
|
int len = 32768;
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
unsigned char* data;
|
|
|
|
Atom rtype;
|
|
|
|
int rformat;
|
|
|
|
unsigned long nitems, after;
|
|
|
|
if( XGetWindowProperty( QX11Info::display(), window()->window(),
|
|
|
|
atom, 0, len, False, AnyPropertyType,
|
|
|
|
&rtype, &rformat, &nitems, &after, &data ) == Success )
|
|
|
|
{
|
|
|
|
if( after > 0 )
|
|
|
|
{
|
|
|
|
XFree( data );
|
|
|
|
len *= 2;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if( long( rtype ) == type && rformat == format )
|
|
|
|
{
|
2008-01-07 16:54:46 +00:00
|
|
|
int bytelen = format == 8 ? nitems : format == 16 ? nitems * sizeof( short ) : nitems * sizeof( long );
|
|
|
|
QByteArray ret( reinterpret_cast< const char* >( data ), bytelen );
|
2008-01-02 15:21:33 +00:00
|
|
|
XFree( data );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
else // wrong format, type or something
|
|
|
|
{
|
|
|
|
XFree( data );
|
|
|
|
return QByteArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // XGetWindowProperty() failed
|
|
|
|
return QByteArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
bool EffectWindowImpl::isMovable() const
|
|
|
|
{
|
|
|
|
if( Client* c = dynamic_cast< Client* >( toplevel ))
|
|
|
|
return c->isMovable();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isUserMove() const
|
|
|
|
{
|
|
|
|
if( Client* c = dynamic_cast< Client* >( toplevel ))
|
|
|
|
return c->isMove();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isUserResize() const
|
|
|
|
{
|
|
|
|
if( Client* c = dynamic_cast< Client* >( toplevel ))
|
|
|
|
return c->isResize();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
QRect EffectWindowImpl::iconGeometry() const
|
|
|
|
{
|
|
|
|
if( Client* c = dynamic_cast< Client* >( toplevel ))
|
|
|
|
return c->iconGeometry();
|
|
|
|
return QRect();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isDesktop() const
|
|
|
|
{
|
|
|
|
return toplevel->isDesktop();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isDock() const
|
|
|
|
{
|
|
|
|
return toplevel->isDock();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isToolbar() const
|
|
|
|
{
|
|
|
|
return toplevel->isToolbar();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isTopMenu() const
|
|
|
|
{
|
|
|
|
return toplevel->isTopMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isMenu() const
|
|
|
|
{
|
|
|
|
return toplevel->isMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isNormalWindow() const
|
|
|
|
{
|
|
|
|
return toplevel->isNormalWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isSpecialWindow() const
|
|
|
|
{
|
|
|
|
if( Client* c = dynamic_cast<Client*>( toplevel ))
|
|
|
|
return c->isSpecialWindow();
|
|
|
|
else
|
2008-01-02 15:17:58 +00:00
|
|
|
return true;
|
2007-04-29 17:35:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isDialog() const
|
|
|
|
{
|
|
|
|
return toplevel->isDialog();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isSplash() const
|
|
|
|
{
|
|
|
|
return toplevel->isSplash();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isUtility() const
|
|
|
|
{
|
|
|
|
return toplevel->isUtility();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isDropdownMenu() const
|
|
|
|
{
|
|
|
|
return toplevel->isDropdownMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isPopupMenu() const
|
|
|
|
{
|
|
|
|
return toplevel->isPopupMenu();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isTooltip() const
|
|
|
|
{
|
|
|
|
return toplevel->isTooltip();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isNotification() const
|
|
|
|
{
|
|
|
|
return toplevel->isNotification();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isComboBox() const
|
|
|
|
{
|
|
|
|
return toplevel->isComboBox();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EffectWindowImpl::isDNDIcon() const
|
|
|
|
{
|
|
|
|
return toplevel->isDNDIcon();
|
|
|
|
}
|
|
|
|
|
2008-01-02 15:17:58 +00:00
|
|
|
bool EffectWindowImpl::isManaged() const
|
|
|
|
{
|
|
|
|
return dynamic_cast< const Client* >( toplevel ) != NULL;
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
bool EffectWindowImpl::isModal() const
|
|
|
|
{
|
|
|
|
if( Client* c = dynamic_cast< Client* >( toplevel ))
|
|
|
|
return c->isModal();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
EffectWindow* EffectWindowImpl::findModal()
|
|
|
|
{
|
|
|
|
if( Client* c = dynamic_cast< Client* >( toplevel ))
|
|
|
|
{
|
|
|
|
if( Client* c2 = c->findModal())
|
|
|
|
return c2->effectWindow();
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
EffectWindowList EffectWindowImpl::mainWindows() const
|
|
|
|
{
|
|
|
|
if( Client* c = dynamic_cast< Client* >( toplevel ))
|
|
|
|
{
|
|
|
|
EffectWindowList ret;
|
|
|
|
ClientList mainclients = c->mainClients();
|
|
|
|
foreach( Client* tmp, mainclients )
|
|
|
|
ret.append( tmp->effectWindow());
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
return EffectWindowList();
|
|
|
|
}
|
|
|
|
|
2007-08-08 14:42:06 +00:00
|
|
|
WindowQuadList EffectWindowImpl::buildQuads() const
|
|
|
|
{
|
|
|
|
return sceneWindow()->buildQuads();
|
|
|
|
}
|
|
|
|
|
2007-04-29 17:35:43 +00:00
|
|
|
EffectWindow* effectWindow( Toplevel* w )
|
|
|
|
{
|
|
|
|
EffectWindowImpl* ret = w->effectWindow();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
EffectWindow* effectWindow( Scene::Window* w )
|
|
|
|
{
|
|
|
|
EffectWindowImpl* ret = w->window()->effectWindow();
|
|
|
|
ret->setSceneWindow( w );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
//****************************************
|
|
|
|
// EffectWindowGroupImpl
|
|
|
|
//****************************************
|
|
|
|
|
|
|
|
|
|
|
|
EffectWindowList EffectWindowGroupImpl::members() const
|
|
|
|
{
|
|
|
|
EffectWindowList ret;
|
|
|
|
foreach( Toplevel* c, group->members())
|
|
|
|
ret.append( c->effectWindow());
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|