KWin
toplevel.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KWIN_TOPLEVEL_H
00022 #define KWIN_TOPLEVEL_H
00023
00024 #include <config-X11.h>
00025
00026 #include <assert.h>
00027 #include <QObject>
00028 #include <kdecoration.h>
00029 #include <kdebug.h>
00030
00031 #include "utils.h"
00032 #include "workspace.h"
00033
00034 #ifdef HAVE_XDAMAGE
00035 #include <X11/extensions/Xdamage.h>
00036 #endif
00037
00038 class NETWinInfo2;
00039
00040 namespace KWin
00041 {
00042
00043 class Workspace;
00044 class EffectWindowImpl;
00045
00046 class Toplevel
00047 : public QObject, public KDecorationDefines
00048 {
00049 Q_OBJECT
00050 public:
00051 Toplevel( Workspace *ws );
00052 Window frameId() const;
00053 Window window() const;
00054 Workspace* workspace() const;
00055 QRect geometry() const;
00056 QSize size() const;
00057 QPoint pos() const;
00058 QRect rect() const;
00059 int x() const;
00060 int y() const;
00061 int width() const;
00062 int height() const;
00063 bool isOnScreen( int screen ) const;
00064 int screen() const;
00065 virtual QPoint clientPos() const = 0;
00066 virtual QSize clientSize() const = 0;
00067
00068
00069
00070 NET::WindowType windowType( bool direct = false, int supported_types = 0 ) const;
00071 bool hasNETSupport() const;
00072 bool isDesktop() const;
00073 bool isDock() const;
00074 bool isToolbar() const;
00075 bool isTopMenu() const;
00076 bool isMenu() const;
00077 bool isNormalWindow() const;
00078 bool isDialog() const;
00079 bool isSplash() const;
00080 bool isUtility() const;
00081 bool isDropdownMenu() const;
00082 bool isPopupMenu() const;
00083 bool isTooltip() const;
00084 bool isNotification() const;
00085 bool isComboBox() const;
00086 bool isDNDIcon() const;
00087
00088 virtual int desktop() const = 0;
00089 bool isOnDesktop( int d ) const;
00090 bool isOnCurrentDesktop() const;
00091 bool isOnAllDesktops() const;
00092
00093 QByteArray windowRole() const;
00094 QByteArray sessionId();
00095 QByteArray resourceName() const;
00096 QByteArray resourceClass() const;
00097 QByteArray wmCommand();
00098 QByteArray wmClientMachine( bool use_localhost ) const;
00099 Window wmClientLeader() const;
00100 pid_t pid() const;
00101 static bool resourceMatch( const Toplevel* c1, const Toplevel* c2 );
00102
00103 Pixmap windowPixmap( bool allow_create = true );
00104 bool readyForPainting() const;
00105 Visual* visual() const;
00106 bool shape() const;
00107 void setOpacity( double opacity );
00108 double opacity() const;
00109 int depth() const;
00110 bool hasAlpha() const;
00111 virtual void setupCompositing();
00112 virtual void finishCompositing();
00113 bool updateUnredirectedState();
00114 bool unredirected() const;
00115 void suspendUnredirect( bool suspend );
00116 void addRepaint( const QRect& r );
00117 void addRepaint( int x, int y, int w, int h );
00118 void addRepaintFull();
00119
00120 void addWorkspaceRepaint( const QRect& r );
00121 void addWorkspaceRepaint( int x, int y, int w, int h );
00122 QRegion repaints() const;
00123 void resetRepaints( const QRect& r );
00124 QRegion damage() const;
00125 void resetDamage( const QRect& r );
00126 EffectWindowImpl* effectWindow();
00127
00128 protected:
00129 virtual ~Toplevel();
00130 void setWindowHandles( Window client, Window frame );
00131 void detectShape( Window id );
00132 virtual void propertyNotifyEvent( XPropertyEvent* e );
00133 #ifdef HAVE_XDAMAGE
00134 virtual void damageNotifyEvent( XDamageNotifyEvent* e );
00135 #endif
00136 Pixmap createWindowPixmap();
00137 void discardWindowPixmap();
00138 void addDamage( const QRect& r );
00139 void addDamage( int x, int y, int w, int h );
00140 void addDamageFull();
00141 void getWmClientLeader();
00142 void getWmClientMachine();
00143 void getResourceClass();
00144 void getWindowRole();
00145 virtual void debug( kdbgstream& stream ) const = 0;
00146 void copyToDeleted( Toplevel* c );
00147 void disownDataPassedToDeleted();
00148 friend kdbgstream& operator<<( kdbgstream& stream, const Toplevel* );
00149 void deleteEffectWindow();
00150 virtual bool shouldUnredirect() const = 0;
00151 QRect geom;
00152 Visual* vis;
00153 int bit_depth;
00154 NETWinInfo2* info;
00155 bool ready_for_painting;
00156 private:
00157 static QByteArray staticWindowRole(WId);
00158 static QByteArray staticSessionId(WId);
00159 static QByteArray staticWmCommand(WId);
00160 static QByteArray staticWmClientMachine(WId);
00161 static Window staticWmClientLeader(WId);
00162
00163 Window client;
00164 Window frame;
00165 Workspace* wspace;
00166 Pixmap window_pix;
00167 #ifdef HAVE_XDAMAGE
00168 Damage damage_handle;
00169 #endif
00170 QRegion damage_region;
00171 QRegion repaints_region;
00172 bool is_shape;
00173 EffectWindowImpl* effect_window;
00174 QByteArray resource_name;
00175 QByteArray resource_class;
00176 QByteArray client_machine;
00177 WId wmClientLeaderWin;
00178 QByteArray window_role;
00179 bool unredirect;
00180 bool unredirectSuspend;
00181
00182 };
00183
00184 inline Window Toplevel::window() const
00185 {
00186 return client;
00187 }
00188
00189 inline Window Toplevel::frameId() const
00190 {
00191 return frame;
00192 }
00193
00194 inline void Toplevel::setWindowHandles( Window w, Window f )
00195 {
00196 assert( client == None && w != None );
00197 client = w;
00198 assert( frame == None && f != None );
00199 frame = f;
00200 }
00201
00202 inline Workspace* Toplevel::workspace() const
00203 {
00204 return wspace;
00205 }
00206
00207 inline QRect Toplevel::geometry() const
00208 {
00209 return geom;
00210 }
00211
00212 inline QSize Toplevel::size() const
00213 {
00214 return geom.size();
00215 }
00216
00217 inline QPoint Toplevel::pos() const
00218 {
00219 return geom.topLeft();
00220 }
00221
00222 inline int Toplevel::x() const
00223 {
00224 return geom.x();
00225 }
00226
00227 inline int Toplevel::y() const
00228 {
00229 return geom.y();
00230 }
00231
00232 inline int Toplevel::width() const
00233 {
00234 return geom.width();
00235 }
00236
00237 inline int Toplevel::height() const
00238 {
00239 return geom.height();
00240 }
00241
00242 inline QRect Toplevel::rect() const
00243 {
00244 return QRect( 0, 0, width(), height());
00245 }
00246
00247 inline bool Toplevel::readyForPainting() const
00248 {
00249 return ready_for_painting;
00250 }
00251
00252 inline Visual* Toplevel::visual() const
00253 {
00254 return vis;
00255 }
00256
00257 inline bool Toplevel::isDesktop() const
00258 {
00259 return windowType() == NET::Desktop;
00260 }
00261
00262 inline bool Toplevel::isDock() const
00263 {
00264 return windowType() == NET::Dock;
00265 }
00266
00267 inline bool Toplevel::isTopMenu() const
00268 {
00269 return windowType() == NET::TopMenu;
00270 }
00271
00272 inline bool Toplevel::isMenu() const
00273 {
00274 return windowType() == NET::Menu && !isTopMenu();
00275 }
00276
00277 inline bool Toplevel::isToolbar() const
00278 {
00279 return windowType() == NET::Toolbar;
00280 }
00281
00282 inline bool Toplevel::isSplash() const
00283 {
00284 return windowType() == NET::Splash;
00285 }
00286
00287 inline bool Toplevel::isUtility() const
00288 {
00289 return windowType() == NET::Utility;
00290 }
00291
00292 inline bool Toplevel::isDialog() const
00293 {
00294 return windowType() == NET::Dialog;
00295 }
00296
00297 inline bool Toplevel::isNormalWindow() const
00298 {
00299 return windowType() == NET::Normal;
00300 }
00301
00302 inline bool Toplevel::isDropdownMenu() const
00303 {
00304 return windowType() == NET::DropdownMenu;
00305 }
00306
00307 inline bool Toplevel::isPopupMenu() const
00308 {
00309 return windowType() == NET::PopupMenu;
00310 }
00311
00312 inline bool Toplevel::isTooltip() const
00313 {
00314 return windowType() == NET::Tooltip;
00315 }
00316
00317 inline bool Toplevel::isNotification() const
00318 {
00319 return windowType() == NET::Notification;
00320 }
00321
00322 inline bool Toplevel::isComboBox() const
00323 {
00324 return windowType() == NET::ComboBox;
00325 }
00326
00327 inline bool Toplevel::isDNDIcon() const
00328 {
00329 return windowType() == NET::DNDIcon;
00330 }
00331
00332 inline Pixmap Toplevel::windowPixmap( bool allow_create )
00333 {
00334 if( window_pix == None && allow_create )
00335 window_pix = createWindowPixmap();
00336 return window_pix;
00337 }
00338
00339 inline QRegion Toplevel::damage() const
00340 {
00341 return damage_region;
00342 }
00343
00344 inline QRegion Toplevel::repaints() const
00345 {
00346 return repaints_region;
00347 }
00348
00349 inline bool Toplevel::shape() const
00350 {
00351 return is_shape;
00352 }
00353
00354 inline int Toplevel::depth() const
00355 {
00356 return bit_depth;
00357 }
00358
00359 inline bool Toplevel::hasAlpha() const
00360 {
00361 return depth() == 32;
00362 }
00363
00364 inline
00365 EffectWindowImpl* Toplevel::effectWindow()
00366 {
00367 return effect_window;
00368 }
00369
00370 inline bool Toplevel::isOnAllDesktops() const
00371 {
00372 return desktop() == NET::OnAllDesktops;
00373 }
00374
00375 inline bool Toplevel::isOnDesktop( int d ) const
00376 {
00377 return desktop() == d || isOnAllDesktops();
00378 }
00379
00380 inline bool Toplevel::isOnCurrentDesktop() const
00381 {
00382 return isOnDesktop( workspace()->currentDesktop());
00383 }
00384
00385 inline QByteArray Toplevel::resourceName() const
00386 {
00387 return resource_name;
00388 }
00389
00390 inline QByteArray Toplevel::resourceClass() const
00391 {
00392 return resource_class;
00393 }
00394
00395 inline QByteArray Toplevel::windowRole() const
00396 {
00397 return window_role;
00398 }
00399
00400 inline pid_t Toplevel::pid() const
00401 {
00402 return info->pid();
00403 }
00404
00405 inline bool Toplevel::unredirected() const
00406 {
00407 return unredirect;
00408 }
00409
00410 kdbgstream& operator<<( kdbgstream& stream, const Toplevel* );
00411 kdbgstream& operator<<( kdbgstream& stream, const ToplevelList& );
00412 kdbgstream& operator<<( kdbgstream& stream, const ConstToplevelList& );
00413
00414 KWIN_COMPARE_PREDICATE( WindowMatchPredicate, Toplevel, Window, cl->window() == value );
00415 KWIN_COMPARE_PREDICATE( FrameIdMatchPredicate, Toplevel, Window, cl->frameId() == value );
00416
00417 }
00418
00419 #endif