1
/*****************************************************************
2
KWin - the KDE window manager
3
This file is part of the KDE project.
5
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
7
You can Freely distribute this program under the GNU General Public
8
License. See the file "COPYING" for the exact licensing terms.
9
******************************************************************/
11
#ifndef KWIN_TOPLEVEL_H
12
#define KWIN_TOPLEVEL_H
14
#include <config-X11.h>
18
#include <kdecoration.h>
21
#include "workspace.h"
24
#include <X11/extensions/Xdamage.h>
33
class EffectWindowImpl;
36
: public QObject, public KDecorationDefines
40
Toplevel( Workspace *ws );
41
Window frameId() const;
42
Window window() const;
43
Workspace* workspace() const;
44
QRect geometry() const;
52
virtual QPoint clientPos() const = 0; // inside of geometry()
53
virtual QSize clientSize() const = 0;
55
// prefer isXXX() instead
56
NET::WindowType windowType( bool direct = false, int supported_types = SUPPORTED_WINDOW_TYPES_MASK ) const;
57
bool hasNETSupport() const;
58
bool isDesktop() const;
60
bool isToolbar() const;
61
bool isTopMenu() const;
63
bool isNormalWindow() const; // normal as in 'NET::Normal or NET::Unknown non-transient'
64
bool isDialog() const;
65
bool isSplash() const;
66
bool isUtility() const;
67
bool isDropdownMenu() const;
68
bool isPopupMenu() const; // a context popup, not dropdown, not torn-off
69
bool isTooltip() const;
70
bool isNotification() const;
71
bool isComboBox() const;
72
bool isDNDIcon() const;
74
virtual int desktop() const = 0;
75
bool isOnDesktop( int d ) const;
76
bool isOnCurrentDesktop() const;
77
bool isOnAllDesktops() const;
79
QByteArray windowRole() const;
80
QByteArray sessionId();
81
QByteArray resourceName() const;
82
QByteArray resourceClass() const;
83
QByteArray wmCommand();
84
QByteArray wmClientMachine( bool use_localhost ) const;
85
Window wmClientLeader() const;
87
static bool resourceMatch( const Toplevel* c1, const Toplevel* c2 );
89
Pixmap windowPixmap( bool allow_create = true ); // may return None (e.g. at a bad moment while resizing)
90
bool readyForPainting() const; // true if the window has been already painted its contents
91
Visual* visual() const;
93
void setOpacity( float opacity );
94
float opacity() const;
96
bool hasAlpha() const;
97
void setupCompositing();
98
void finishCompositing();
99
void addRepaint( const QRect& r );
100
void addRepaint( int x, int y, int w, int h );
101
void addRepaintFull();
102
// these call workspace->addRepaint(), but first transform the damage if needed
103
void addWorkspaceRepaint( const QRect& r );
104
void addWorkspaceRepaint( int x, int y, int w, int h );
105
QRegion repaints() const;
106
void resetRepaints( const QRect& r );
107
QRegion damage() const;
108
void resetDamage( const QRect& r );
109
EffectWindowImpl* effectWindow();
113
void setWindowHandles( Window client, Window frame );
114
void detectShape( Window id );
115
virtual void propertyNotifyEvent( XPropertyEvent* e );
117
virtual void damageNotifyEvent( XDamageNotifyEvent* e );
119
Pixmap createWindowPixmap();
120
void discardWindowPixmap();
121
void addDamage( const QRect& r );
122
void addDamage( int x, int y, int w, int h );
123
void addDamageFull();
124
void getWmClientLeader();
125
void getWmClientMachine();
126
void getResourceClass();
127
void getWindowRole();
128
virtual void debug( kdbgstream& stream ) const = 0;
129
void copyToDeleted( Toplevel* c );
130
void disownDataPassedToDeleted();
131
friend kdbgstream& operator<<( kdbgstream& stream, const Toplevel* );
136
bool ready_for_painting;
138
static QByteArray staticWindowRole(WId);
139
static QByteArray staticSessionId(WId);
140
static QByteArray staticWmCommand(WId);
141
static QByteArray staticWmClientMachine(WId);
142
static Window staticWmClientLeader(WId);
143
// when adding new data members, check also copyToDeleted()
149
Damage damage_handle;
151
QRegion damage_region; // damage is really damaged window (XDamage) and texture needs
152
QRegion repaints_region; // updating, repaint just requires repaint of that area
154
EffectWindowImpl* effect_window;
155
QByteArray resource_name;
156
QByteArray resource_class;
157
QByteArray client_machine;
158
WId wmClientLeaderWin;
159
QByteArray window_role;
160
// when adding new data members, check also copyToDeleted()
163
inline Window Toplevel::window() const
168
inline Window Toplevel::frameId() const
173
inline void Toplevel::setWindowHandles( Window w, Window f )
175
assert( client == None && w != None );
177
assert( frame == None && f != None );
181
inline Workspace* Toplevel::workspace() const
186
inline QRect Toplevel::geometry() const
191
inline QSize Toplevel::size() const
196
inline QPoint Toplevel::pos() const
198
return geom.topLeft();
201
inline int Toplevel::x() const
206
inline int Toplevel::y() const
211
inline int Toplevel::width() const
216
inline int Toplevel::height() const
218
return geom.height();
221
inline QRect Toplevel::rect() const
223
return QRect( 0, 0, width(), height());
226
inline bool Toplevel::readyForPainting() const
228
return ready_for_painting;
231
inline Visual* Toplevel::visual() const
236
inline bool Toplevel::isDesktop() const
238
return windowType() == NET::Desktop;
241
inline bool Toplevel::isDock() const
243
return windowType() == NET::Dock;
246
inline bool Toplevel::isTopMenu() const
248
return windowType() == NET::TopMenu;
251
inline bool Toplevel::isMenu() const
253
return windowType() == NET::Menu && !isTopMenu(); // because of backwards comp.
256
inline bool Toplevel::isToolbar() const
258
return windowType() == NET::Toolbar;
261
inline bool Toplevel::isSplash() const
263
return windowType() == NET::Splash;
266
inline bool Toplevel::isUtility() const
268
return windowType() == NET::Utility;
271
inline bool Toplevel::isDialog() const
273
return windowType() == NET::Dialog;
276
inline bool Toplevel::isNormalWindow() const
278
return windowType() == NET::Normal;
281
inline bool Toplevel::isDropdownMenu() const
283
return windowType() == NET::DropdownMenu;
286
inline bool Toplevel::isPopupMenu() const
288
return windowType() == NET::PopupMenu;
291
inline bool Toplevel::isTooltip() const
293
return windowType() == NET::Tooltip;
296
inline bool Toplevel::isNotification() const
298
return windowType() == NET::Notification;
301
inline bool Toplevel::isComboBox() const
303
return windowType() == NET::ComboBox;
306
inline bool Toplevel::isDNDIcon() const
308
return windowType() == NET::DNDIcon;
311
inline Pixmap Toplevel::windowPixmap( bool allow_create )
313
if( window_pix == None && allow_create )
314
window_pix = createWindowPixmap();
318
inline QRegion Toplevel::damage() const
320
return damage_region;
323
inline QRegion Toplevel::repaints() const
325
return repaints_region;
328
inline bool Toplevel::shape() const
333
inline int Toplevel::depth() const
338
inline bool Toplevel::hasAlpha() const
340
return depth() == 32;
344
EffectWindowImpl* Toplevel::effectWindow()
346
return effect_window;
349
inline bool Toplevel::isOnAllDesktops() const
351
return desktop() == NET::OnAllDesktops;
354
inline bool Toplevel::isOnDesktop( int d ) const
356
return desktop() == d || /*desk == 0 ||*/ isOnAllDesktops();
359
inline bool Toplevel::isOnCurrentDesktop() const
361
return isOnDesktop( workspace()->currentDesktop());
364
inline QByteArray Toplevel::resourceName() const
366
return resource_name; // it is always lowercase
369
inline QByteArray Toplevel::resourceClass() const
371
return resource_class; // it is always lowercase
374
inline QByteArray Toplevel::windowRole() const
379
inline pid_t Toplevel::pid() const
386
kndbgstream& operator<<( kndbgstream& stream, const Toplevel* ) { return stream; }
388
kndbgstream& operator<<( kndbgstream& stream, const ToplevelList& ) { return stream; }
390
kndbgstream& operator<<( kndbgstream& stream, const ConstToplevelList& ) { return stream; }
392
kdbgstream& operator<<( kdbgstream& stream, const Toplevel* );
393
kdbgstream& operator<<( kdbgstream& stream, const ToplevelList& );
394
kdbgstream& operator<<( kdbgstream& stream, const ConstToplevelList& );
397
KWIN_COMPARE_PREDICATE( WindowMatchPredicate, Toplevel, Window, cl->window() == value );
398
KWIN_COMPARE_PREDICATE( FrameIdMatchPredicate, Toplevel, Window, cl->frameId() == value );