1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Matthias Ettrich (ettrich@kde.org)
3 Copyright (C) 2007 Lubos Lunak (l.lunak@kde.org)
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20/*
21 * kwindowinfo.h. Part of the KDE project.
22 */
23
24#ifndef KWINDOWINFO_H
25#define KWINDOWINFO_H
26
27#include <kdeui_export.h>
28#include <QtGui/QWidgetList> //For WId
29
30#include <netwm_def.h>
31
32/**
33 * Information about a window.
34 */
35class KDEUI_EXPORT KWindowInfo
36{
37public:
38 /**
39 * Reads all the info about the given window.
40 */
41 KWindowInfo( WId window, unsigned long properties, unsigned long properties2 = 0 );
42 KWindowInfo(); // to make QList and others happy
43 ~KWindowInfo();
44 /**
45 * Returns false if this window info is not valid (most probably the given
46 * window doesn't exist).
47 * @param withdrawn_is_valid if true, windows in the withdrawn state
48 * (i.e. not managed) are also considered. This is usually not the case.
49 */
50 bool valid( bool withdrawn_is_valid = false ) const;
51 /**
52 * Returns the window identifier.
53 */
54 WId win() const;
55 /**
56 * Returns the window's state flags (see the NET::State enum for details).
57 * Requires NET::WMState passed to KWin::windowInfo().
58 */
59 unsigned long state() const;
60 /**
61 * Returns true if the window has the given state flag set (see the NET::State enum for details).
62 * Requires NET::WMState passed to KWin::windowInfo().
63 */
64 bool hasState( unsigned long s ) const;
65 /**
66 * Returns true if the window is minimized. Note that it is true only if
67 * the window is truly minimized, not shaded or on another virtual desktops,
68 * which makes it different from mappingState() == NET::Iconic
69 * or QWidget::isMinimized().
70 * Requires NET::WMState and NET::XAWMState passed to KWin::windowInfo().
71 */
72 bool isMinimized() const;
73 /**
74 * Returns the mapping state of the window (see NET::MappingState). Note that
75 * it's very likely that you don't want to use this function, and use isOnDesktop(),
76 * isMinimized() etc. instead.
77 * Requires NET::XAWMState passed to KWin::windowInfo().
78 */
79 NET::MappingState mappingState() const;
80 /**
81 * Returns the window extended (partial) strut.
82 * Requires NET::WM2ExtendedStrut passed to KWin::windowInfo().
83 */
84 NETExtendedStrut extendedStrut() const;
85 /**
86 * Returns the window type of this window (see NET::WindowType). The argument
87 * should be all window types your application supports (see NET::WindowTypeMask).
88 * Requires NET::WMWindowType passed to KWin::windowInfo().
89 */
90 NET::WindowType windowType( int supported_types ) const;
91 /**
92 * Returns the visible name of the window (i.e. including possible <2> appended
93 * when there are two or more windows with the same name).
94 * Requires NET::WMVisibleName passed to KWin::windowInfo().
95 */
96 QString visibleName() const;
97 /**
98 * Returns a visible name with state.
99 *
100 * This is a simple convenience function that returns the
101 * visible name but with parentheses around minimized windows.
102 * Requires NET::WMVisibleName, NET::WMState and NET::XAWMState passed
103 * to KWin::windowInfo().
104 * @return the window name with state
105 */
106 QString visibleNameWithState() const;
107 /**
108 * Returns the name of the window, as specified by the application, without
109 * any modifications. You should often use visibleName() instead.
110 * Requires NET::WMName passed to KWin::windowInfo().
111 */
112 QString name() const;
113 /**
114 * Returns the visible name of the window that should be shown in taskbar
115 * and all other "iconic" representations of the window. Note that this
116 * has nothing to do with normal icons.
117 * Requires NET::WMVisibleIconName passed to KWin::windowInfo().
118 */
119 QString visibleIconName() const;
120 /**
121 * Returns a visible name with state.
122 *
123 * This is a simple convenience function that returns the
124 * visible iconic name but with parentheses around minimized windows.
125 * Note that this has nothing to do with normal icons.
126 * Requires NET::WMVisibleIconName, NET::WMState and NET::XAWMState passed
127 * to KWin::windowInfo().
128 * @return the window iconic name with state
129 */
130 QString visibleIconNameWithState() const;
131 /**
132 * Returns the name of the window that should be shown in taskbar and all other
133 * "iconic" representations of the window. Note that this has nothing to do
134 * with normal icons.
135 * Requires NET::WMIconName passed to KWin::windowInfo().
136 */
137 QString iconName() const;
138 /**
139 * Returns true if the window is on the currently active virtual desktop.
140 * Requires NET::WMDesktop passed to KWin::windowInfo().
141 */
142 bool isOnCurrentDesktop() const;
143 /**
144 * Returns true if the window is on the given virtual desktop.
145 * Requires NET::WMDesktop passed to KWin::windowInfo().
146 */
147 bool isOnDesktop( int desktop ) const;
148 /**
149 * Returns true if the window is on all desktops
150 * (equal to desktop()==NET::OnAllDesktops).
151 * Requires NET::WMDesktop passed to KWin::windowInfo().
152 */
153 bool onAllDesktops() const;
154 /**
155 * Returns the virtual desktop this window is on (NET::OnAllDesktops if the window
156 * is on all desktops). You should prefer using isOnDesktop().
157 * Requires NET::WMDesktop passed to KWin::windowInfo().
158 */
159 int desktop() const;
160 /**
161 * Returns the position and size of the window contents.
162 * Requires NET::WMGeometry passed to KWin::windowInfo().
163 */
164 QRect geometry() const;
165 /**
166 * Returns the frame geometry of the window, i.e. including the window decoration.
167 * Requires NET::WMFrameExtents passed to KWin::windowInfo().
168 */
169 QRect frameGeometry() const;
170 /**
171 * Returns the WM_TRANSIENT_FOR property for the window, i.e. the mainwindow
172 * for this window.
173 * Requires NET::WM2TransientFor passed to KWin::windowInfo().
174 */
175 WId transientFor() const;
176 /**
177 * Returns the leader window for the group the window is in, if any.
178 * Requires NET::WM2GroupLeader passed to KWin::windowInfo().
179 */
180 WId groupLeader() const;
181
182 /**
183 * Returns the class component of the window class for the window
184 * (i.e. WM_CLASS property).
185 * Requires NET::WM2WindowClass passed to KWin::windowInfo().
186 */
187 QByteArray windowClassClass() const;
188
189 /**
190 * Returns the name component of the window class for the window
191 * (i.e. WM_CLASS property).
192 * Requires NET::WM2WindowClass passed to KWin::windowInfo().
193 */
194 QByteArray windowClassName() const;
195
196 /**
197 * Returns the window role for the window (i.e. WM_WINDOW_ROLE property).
198 * Requires NET::WM2WindowRole passed to KWin::windowInfo().
199 */
200 QByteArray windowRole() const;
201
202 /**
203 * Returns the client machine for the window (i.e. WM_CLIENT_MACHINE property).
204 * Requires NET::WMClientMachine passed to KWin::windowInfo().
205 */
206 QByteArray clientMachine() const;
207
208 /**
209 * Returns true if the given action is currently supported for the window
210 * by the window manager.
211 * Requires NET::WM2AllowedActions passed to KWin::windowInfo().
212 */
213 bool actionSupported( NET::Action action ) const;
214
215 KWindowInfo( const KWindowInfo& );
216 KWindowInfo& operator=( const KWindowInfo& );
217private:
218 class Private;
219 Private * d; //krazy:exclude=dpointer (implicitly shared)
220#ifdef Q_WS_MAC
221 // KWindowSystem needs access to the d-pointer
222 friend class KWindowSystem;
223 friend class KWindowSystemPrivate;
224#endif
225};
226
227#endif // multiple inclusion guard
228
229