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

KWin

toplevel.h

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 #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 NETWinInfo;
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; // true if it's at least partially there
00064         int screen() const; // the screen where the center is
00065         virtual QPoint clientPos() const = 0; // inside of geometry()
00066         virtual QSize clientSize() const = 0;
00067 
00068         // prefer isXXX() instead
00069         // 0 for supported types means default for managed/unmanaged types
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; // normal as in 'NET::Normal or NET::Unknown non-transient'
00078         bool isDialog() const;
00079         bool isSplash() const;
00080         bool isUtility() const;
00081         bool isDropdownMenu() const;
00082         bool isPopupMenu() const; // a context popup, not dropdown, not torn-off
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 ); // may return None (e.g. at a bad moment while resizing)
00104         bool readyForPainting() const; // true if the window has been already painted its contents
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         void setupCompositing();
00112         void finishCompositing();
00113         void addRepaint( const QRect& r );
00114         void addRepaint( int x, int y, int w, int h );
00115         void addRepaintFull();
00116         // these call workspace->addRepaint(), but first transform the damage if needed
00117         void addWorkspaceRepaint( const QRect& r );
00118         void addWorkspaceRepaint( int x, int y, int w, int h );
00119         QRegion repaints() const;
00120         void resetRepaints( const QRect& r );
00121         QRegion damage() const;
00122         void resetDamage( const QRect& r );
00123         EffectWindowImpl* effectWindow();
00124 
00125     protected:
00126         virtual ~Toplevel();
00127         void setWindowHandles( Window client, Window frame );
00128         void detectShape( Window id );
00129         virtual void propertyNotifyEvent( XPropertyEvent* e );
00130 #ifdef HAVE_XDAMAGE
00131         virtual void damageNotifyEvent( XDamageNotifyEvent* e );
00132 #endif
00133         Pixmap createWindowPixmap();
00134         void discardWindowPixmap();
00135         void addDamage( const QRect& r );
00136         void addDamage( int x, int y, int w, int h );
00137         void addDamageFull();
00138         void getWmClientLeader();
00139         void getWmClientMachine();
00140         void getResourceClass();
00141         void getWindowRole();
00142         virtual void debug( kdbgstream& stream ) const = 0;
00143         void copyToDeleted( Toplevel* c );
00144         void disownDataPassedToDeleted();
00145         friend kdbgstream& operator<<( kdbgstream& stream, const Toplevel* );
00146         void deleteEffectWindow();
00147         QRect geom;
00148         Visual* vis;
00149         int bit_depth;
00150         NETWinInfo* info;
00151         bool ready_for_painting;
00152     private:
00153         static QByteArray staticWindowRole(WId);
00154         static QByteArray staticSessionId(WId);
00155         static QByteArray staticWmCommand(WId);
00156         static QByteArray staticWmClientMachine(WId);
00157         static Window staticWmClientLeader(WId);
00158         // when adding new data members, check also copyToDeleted()
00159         Window client;
00160         Window frame;
00161         Workspace* wspace;
00162         Pixmap window_pix;
00163 #ifdef HAVE_XDAMAGE
00164         Damage damage_handle;
00165 #endif
00166         QRegion damage_region; // damage is really damaged window (XDamage) and texture needs
00167         QRegion repaints_region; // updating, repaint just requires repaint of that area
00168         bool is_shape;
00169         EffectWindowImpl* effect_window;
00170         QByteArray resource_name;
00171         QByteArray resource_class;
00172         QByteArray client_machine;
00173         WId wmClientLeaderWin;
00174         QByteArray window_role;
00175         // when adding new data members, check also copyToDeleted()
00176     };
00177 
00178 inline Window Toplevel::window() const
00179     {
00180     return client;
00181     }
00182 
00183 inline Window Toplevel::frameId() const
00184     {
00185     return frame;
00186     }
00187 
00188 inline void Toplevel::setWindowHandles( Window w, Window f )
00189     {
00190     assert( client == None && w != None );
00191     client = w;
00192     assert( frame == None && f != None );
00193     frame = f;
00194     }
00195 
00196 inline Workspace* Toplevel::workspace() const
00197     {
00198     return wspace;
00199     }
00200 
00201 inline QRect Toplevel::geometry() const
00202     {
00203     return geom;
00204     }
00205 
00206 inline QSize Toplevel::size() const
00207     {
00208     return geom.size();
00209     }
00210 
00211 inline QPoint Toplevel::pos() const
00212     {
00213     return geom.topLeft();
00214     }
00215 
00216 inline int Toplevel::x() const
00217     {
00218     return geom.x();
00219     }
00220 
00221 inline int Toplevel::y() const
00222     {
00223     return geom.y();
00224     }
00225 
00226 inline int Toplevel::width() const
00227     {
00228     return geom.width();
00229     }
00230 
00231 inline int Toplevel::height() const
00232     {
00233     return geom.height();
00234     }
00235 
00236 inline QRect Toplevel::rect() const
00237     {
00238     return QRect( 0, 0, width(), height());
00239     }
00240 
00241 inline bool Toplevel::readyForPainting() const
00242     {
00243     return ready_for_painting;
00244     }
00245 
00246 inline Visual* Toplevel::visual() const
00247     {
00248     return vis;
00249     }
00250 
00251 inline bool Toplevel::isDesktop() const
00252     {
00253     return windowType() == NET::Desktop;
00254     }
00255 
00256 inline bool Toplevel::isDock() const
00257     {
00258     return windowType() == NET::Dock;
00259     }
00260 
00261 inline bool Toplevel::isTopMenu() const
00262     {
00263     return windowType() == NET::TopMenu;
00264     }
00265 
00266 inline bool Toplevel::isMenu() const
00267     {
00268     return windowType() == NET::Menu && !isTopMenu(); // because of backwards comp.
00269     }
00270 
00271 inline bool Toplevel::isToolbar() const
00272     {
00273     return windowType() == NET::Toolbar;
00274     }
00275 
00276 inline bool Toplevel::isSplash() const
00277     {
00278     return windowType() == NET::Splash;
00279     }
00280 
00281 inline bool Toplevel::isUtility() const
00282     {
00283     return windowType() == NET::Utility;
00284     }
00285 
00286 inline bool Toplevel::isDialog() const
00287     {
00288     return windowType() == NET::Dialog;
00289     }
00290 
00291 inline bool Toplevel::isNormalWindow() const
00292     {
00293     return windowType() == NET::Normal;
00294     }
00295 
00296 inline bool Toplevel::isDropdownMenu() const
00297     {
00298     return windowType() == NET::DropdownMenu;
00299     }
00300 
00301 inline bool Toplevel::isPopupMenu() const
00302     {
00303     return windowType() == NET::PopupMenu;
00304     }
00305 
00306 inline bool Toplevel::isTooltip() const
00307     {
00308     return windowType() == NET::Tooltip;
00309     }
00310 
00311 inline bool Toplevel::isNotification() const
00312     {
00313     return windowType() == NET::Notification;
00314     }
00315 
00316 inline bool Toplevel::isComboBox() const
00317     {
00318     return windowType() == NET::ComboBox;
00319     }
00320 
00321 inline bool Toplevel::isDNDIcon() const
00322     {
00323     return windowType() == NET::DNDIcon;
00324     }
00325 
00326 inline Pixmap Toplevel::windowPixmap( bool allow_create )
00327     {
00328     if( window_pix == None && allow_create )
00329         window_pix = createWindowPixmap();
00330     return window_pix;
00331     }
00332 
00333 inline QRegion Toplevel::damage() const
00334     {
00335     return damage_region;
00336     }
00337 
00338 inline QRegion Toplevel::repaints() const
00339     {
00340     return repaints_region;
00341     }
00342 
00343 inline bool Toplevel::shape() const
00344     {
00345     return is_shape;
00346     }
00347 
00348 inline int Toplevel::depth() const
00349     {
00350     return bit_depth;
00351     }
00352 
00353 inline bool Toplevel::hasAlpha() const
00354     {
00355     return depth() == 32;
00356     }
00357 
00358 inline
00359 EffectWindowImpl* Toplevel::effectWindow()
00360     {
00361     return effect_window;
00362     }
00363 
00364 inline bool Toplevel::isOnAllDesktops() const
00365     {
00366     return desktop() == NET::OnAllDesktops;
00367     }
00368 
00369 inline bool Toplevel::isOnDesktop( int d ) const
00370     {
00371     return desktop() == d || /*desk == 0 ||*/ isOnAllDesktops();
00372     }
00373 
00374 inline bool Toplevel::isOnCurrentDesktop() const
00375     {
00376     return isOnDesktop( workspace()->currentDesktop());
00377     }
00378 
00379 inline QByteArray Toplevel::resourceName() const
00380     {
00381     return resource_name; // it is always lowercase
00382     }
00383 
00384 inline QByteArray Toplevel::resourceClass() const
00385     {
00386     return resource_class; // it is always lowercase
00387     }
00388 
00389 inline QByteArray Toplevel::windowRole() const
00390     {
00391     return window_role;
00392     }
00393 
00394 inline pid_t Toplevel::pid() const
00395     {
00396     return info->pid();
00397     }
00398 
00399 kdbgstream& operator<<( kdbgstream& stream, const Toplevel* );
00400 kdbgstream& operator<<( kdbgstream& stream, const ToplevelList& );
00401 kdbgstream& operator<<( kdbgstream& stream, const ConstToplevelList& );
00402 
00403 KWIN_COMPARE_PREDICATE( WindowMatchPredicate, Toplevel, Window, cl->window() == value );
00404 KWIN_COMPARE_PREDICATE( FrameIdMatchPredicate, Toplevel, Window, cl->frameId() == value );
00405 
00406 } // namespace
00407 
00408 #endif

KWin

Skip menu "KWin"
  • Main Page
  • 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
  •   libplasma
  •   libsolidcontrol
  •   libtaskmanager
  • Plasma
  •   Animators
  •   Applets
  •   Engines
  • Solid Modules
Generated for API Reference by doxygen 1.5.4
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