2006-07-04 20:02:07 +00:00
|
|
|
/*****************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
|
|
|
You can Freely distribute this program under the GNU General Public
|
|
|
|
License. See the file "COPYING" for the exact licensing terms.
|
|
|
|
******************************************************************/
|
|
|
|
|
|
|
|
#ifndef KWIN_TOPLEVEL_H
|
|
|
|
#define KWIN_TOPLEVEL_H
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <qobject.h>
|
|
|
|
#include <kdecoration.h>
|
|
|
|
|
|
|
|
#include "utils.h"
|
|
|
|
|
|
|
|
namespace KWinInternal
|
|
|
|
{
|
|
|
|
|
|
|
|
class Workspace;
|
2007-01-22 22:57:22 +00:00
|
|
|
class EffectWindow;
|
2006-07-04 20:02:07 +00:00
|
|
|
|
|
|
|
class Toplevel
|
|
|
|
: public QObject, public KDecorationDefines
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
Toplevel( Workspace *ws );
|
|
|
|
Window handle() const;
|
|
|
|
Workspace* workspace() const;
|
|
|
|
QRect geometry() const;
|
|
|
|
QSize size() const;
|
|
|
|
QPoint pos() const;
|
|
|
|
QRect rect() const;
|
|
|
|
int x() const;
|
|
|
|
int y() const;
|
|
|
|
int width() const;
|
|
|
|
int height() const;
|
2006-07-06 13:17:44 +00:00
|
|
|
|
|
|
|
// prefer isXXX() instead
|
|
|
|
virtual NET::WindowType windowType( bool direct = false, int supported_types = SUPPORTED_WINDOW_TYPES_MASK ) const = 0;
|
|
|
|
bool hasNETSupport() const;
|
|
|
|
bool isDesktop() const;
|
|
|
|
bool isDock() const;
|
|
|
|
bool isToolbar() const;
|
|
|
|
bool isTopMenu() const;
|
|
|
|
bool isMenu() const;
|
|
|
|
bool isNormalWindow() const; // normal as in 'NET::Normal or NET::Unknown non-transient'
|
|
|
|
bool isDialog() const;
|
|
|
|
bool isSplash() const;
|
|
|
|
bool isUtility() const;
|
|
|
|
|
2007-01-12 23:21:36 +00:00
|
|
|
Pixmap windowPixmap( bool allow_create = true ); // for use with compositing
|
2006-07-05 20:52:57 +00:00
|
|
|
Visual* visual() const;
|
2006-09-30 17:28:27 +00:00
|
|
|
bool shape() const;
|
2006-07-05 22:26:34 +00:00
|
|
|
virtual double opacity() const = 0;
|
2006-10-21 15:23:01 +00:00
|
|
|
int depth() const;
|
2006-09-30 18:09:41 +00:00
|
|
|
bool hasAlpha() const;
|
2006-07-04 20:02:07 +00:00
|
|
|
void setupCompositing();
|
2007-01-22 22:51:30 +00:00
|
|
|
void finishCompositing();
|
2006-07-13 18:17:49 +00:00
|
|
|
void addDamage( const QRect& r );
|
|
|
|
void addDamage( int x, int y, int w, int h );
|
2006-10-24 19:28:17 +00:00
|
|
|
void addDamageFull();
|
2006-09-30 15:40:03 +00:00
|
|
|
QRegion damage() const;
|
2006-11-24 21:28:00 +00:00
|
|
|
void resetDamage( const QRect& r );
|
2007-01-22 22:57:22 +00:00
|
|
|
EffectWindow* effectWindow();
|
2007-01-15 18:03:04 +00:00
|
|
|
|
2006-07-05 21:46:01 +00:00
|
|
|
protected:
|
2007-01-15 15:42:32 +00:00
|
|
|
virtual ~Toplevel();
|
2006-07-04 20:02:07 +00:00
|
|
|
void setHandle( Window id );
|
2006-09-30 17:28:27 +00:00
|
|
|
void detectShape( Window id );
|
2006-07-05 16:04:11 +00:00
|
|
|
void damageNotifyEvent( XDamageNotifyEvent* e );
|
2007-01-12 23:21:36 +00:00
|
|
|
Pixmap createWindowPixmap() const;
|
|
|
|
void discardWindowPixmap();
|
2006-07-04 20:02:07 +00:00
|
|
|
QRect geom;
|
2006-07-05 20:52:57 +00:00
|
|
|
Visual* vis;
|
2006-10-21 15:23:01 +00:00
|
|
|
int bit_depth;
|
2006-07-04 20:02:07 +00:00
|
|
|
virtual void debug( kdbgstream& stream ) const = 0;
|
2007-01-22 22:51:30 +00:00
|
|
|
void copyToDeleted( Toplevel* c );
|
2006-07-04 20:02:07 +00:00
|
|
|
friend kdbgstream& operator<<( kdbgstream& stream, const Toplevel* );
|
|
|
|
private:
|
2007-01-22 22:51:30 +00:00
|
|
|
// when adding new data members, check also copyToDeleted()
|
2006-07-04 20:02:07 +00:00
|
|
|
Window id;
|
|
|
|
Workspace* wspace;
|
2007-01-12 23:21:36 +00:00
|
|
|
Pixmap window_pix;
|
2006-07-05 16:04:11 +00:00
|
|
|
Damage damage_handle;
|
2006-09-30 15:40:03 +00:00
|
|
|
QRegion damage_region;
|
2006-09-30 17:28:27 +00:00
|
|
|
bool is_shape;
|
2007-01-22 22:57:22 +00:00
|
|
|
EffectWindow* effect_window;
|
2006-07-04 20:02:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
inline Window Toplevel::handle() const
|
|
|
|
{
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void Toplevel::setHandle( Window w )
|
|
|
|
{
|
|
|
|
assert( id == None && w != None );
|
|
|
|
id = w;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline Workspace* Toplevel::workspace() const
|
|
|
|
{
|
|
|
|
return wspace;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline QRect Toplevel::geometry() const
|
|
|
|
{
|
|
|
|
return geom;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline QSize Toplevel::size() const
|
|
|
|
{
|
|
|
|
return geom.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline QPoint Toplevel::pos() const
|
|
|
|
{
|
|
|
|
return geom.topLeft();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int Toplevel::x() const
|
|
|
|
{
|
|
|
|
return geom.x();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int Toplevel::y() const
|
|
|
|
{
|
|
|
|
return geom.y();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int Toplevel::width() const
|
|
|
|
{
|
|
|
|
return geom.width();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int Toplevel::height() const
|
|
|
|
{
|
|
|
|
return geom.height();
|
|
|
|
}
|
|
|
|
|
|
|
|
inline QRect Toplevel::rect() const
|
|
|
|
{
|
|
|
|
return QRect( 0, 0, width(), height());
|
|
|
|
}
|
|
|
|
|
2006-07-05 20:52:57 +00:00
|
|
|
inline Visual* Toplevel::visual() const
|
|
|
|
{
|
|
|
|
return vis;
|
|
|
|
}
|
|
|
|
|
2006-07-06 13:17:44 +00:00
|
|
|
inline bool Toplevel::isDesktop() const
|
|
|
|
{
|
|
|
|
return windowType() == NET::Desktop;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Toplevel::isDock() const
|
|
|
|
{
|
|
|
|
return windowType() == NET::Dock;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Toplevel::isTopMenu() const
|
|
|
|
{
|
|
|
|
return windowType() == NET::TopMenu;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Toplevel::isMenu() const
|
|
|
|
{
|
|
|
|
return windowType() == NET::Menu && !isTopMenu(); // because of backwards comp.
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Toplevel::isToolbar() const
|
|
|
|
{
|
|
|
|
return windowType() == NET::Toolbar;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Toplevel::isSplash() const
|
|
|
|
{
|
|
|
|
return windowType() == NET::Splash;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Toplevel::isUtility() const
|
|
|
|
{
|
|
|
|
return windowType() == NET::Utility;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Toplevel::isDialog() const
|
|
|
|
{
|
|
|
|
return windowType() == NET::Dialog;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool Toplevel::isNormalWindow() const
|
|
|
|
{
|
|
|
|
return windowType() == NET::Normal;
|
|
|
|
}
|
|
|
|
|
2007-01-12 23:21:36 +00:00
|
|
|
inline Pixmap Toplevel::windowPixmap( bool allow_create )
|
|
|
|
{
|
|
|
|
if( window_pix == None && allow_create )
|
|
|
|
window_pix = createWindowPixmap();
|
|
|
|
return window_pix;
|
|
|
|
}
|
|
|
|
|
2006-09-30 15:40:03 +00:00
|
|
|
inline QRegion Toplevel::damage() const
|
2006-07-13 18:17:49 +00:00
|
|
|
{
|
|
|
|
return damage_region;
|
|
|
|
}
|
|
|
|
|
2006-09-30 17:28:27 +00:00
|
|
|
inline bool Toplevel::shape() const
|
|
|
|
{
|
|
|
|
return is_shape;
|
|
|
|
}
|
|
|
|
|
2006-10-21 15:23:01 +00:00
|
|
|
inline int Toplevel::depth() const
|
|
|
|
{
|
|
|
|
return bit_depth;
|
|
|
|
}
|
|
|
|
|
2006-09-30 18:09:41 +00:00
|
|
|
inline bool Toplevel::hasAlpha() const
|
|
|
|
{
|
2006-10-21 15:23:01 +00:00
|
|
|
return depth() == 32;
|
2006-09-30 18:09:41 +00:00
|
|
|
}
|
|
|
|
|
2007-01-22 22:57:22 +00:00
|
|
|
inline
|
|
|
|
EffectWindow* Toplevel::effectWindow()
|
|
|
|
{
|
|
|
|
return effect_window;
|
|
|
|
}
|
|
|
|
|
2006-07-04 20:02:07 +00:00
|
|
|
#ifdef NDEBUG
|
|
|
|
inline
|
|
|
|
kndbgstream& operator<<( kndbgstream& stream, const Toplevel* ) { return stream; }
|
|
|
|
inline
|
|
|
|
kndbgstream& operator<<( kndbgstream& stream, const ToplevelList& ) { return stream; }
|
|
|
|
inline
|
|
|
|
kndbgstream& operator<<( kndbgstream& stream, const ConstToplevelList& ) { return stream; }
|
|
|
|
#else
|
|
|
|
kdbgstream& operator<<( kdbgstream& stream, const Toplevel* );
|
|
|
|
kdbgstream& operator<<( kdbgstream& stream, const ToplevelList& );
|
|
|
|
kdbgstream& operator<<( kdbgstream& stream, const ConstToplevelList& );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
KWIN_COMPARE_PREDICATE( HandleMatchPredicate, Toplevel, Window, cl->handle() == value );
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#endif
|