1
/********************************************************************
2
KWin - the KDE window manager
3
This file is part of the KDE project.
5
Copyright (C) 2004 Lubos Lunak <l.lunak@kde.org>
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program. If not, see <http://www.gnu.org/licenses/>.
19
*********************************************************************/
25
#include <netwm_def.h>
27
#include <kconfiggroup.h>
30
#include "placement.h"
31
#include <kdecoration.h>
43
#ifndef KCMRULES // only for kwin core
46
: public KDecorationDefines
49
WindowRules(const QVector< Rules* >& rules);
52
void discardTemporary();
53
bool contains(const Rules* rule) const;
54
void remove(Rules* rule);
55
Placement::Policy checkPlacement(Placement::Policy placement) const;
56
QRect checkGeometry(QRect rect, bool init = false) const;
57
// use 'invalidPoint' with checkPosition, unlike QSize() and QRect(), QPoint() is a valid point
58
QPoint checkPosition(QPoint pos, bool init = false) const;
59
QSize checkSize(QSize s, bool init = false) const;
60
QSize checkMinSize(QSize s) const;
61
QSize checkMaxSize(QSize s) const;
62
int checkOpacityActive(int s) const;
63
int checkOpacityInactive(int s) const;
64
int checkTilingOption(int s) const;
65
bool checkIgnoreGeometry(bool ignore) const;
66
int checkDesktop(int desktop, bool init = false) const;
67
NET::WindowType checkType(NET::WindowType type) const;
68
MaximizeMode checkMaximize(MaximizeMode mode, bool init = false) const;
69
bool checkMinimize(bool minimized, bool init = false) const;
70
ShadeMode checkShade(ShadeMode shade, bool init = false) const;
71
bool checkSkipTaskbar(bool skip, bool init = false) const;
72
bool checkSkipPager(bool skip, bool init = false) const;
73
bool checkSkipSwitcher(bool skip, bool init = false) const;
74
bool checkKeepAbove(bool above, bool init = false) const;
75
bool checkKeepBelow(bool below, bool init = false) const;
76
bool checkFullScreen(bool fs, bool init = false) const;
77
bool checkNoBorder(bool noborder, bool init = false) const;
78
bool checkBlockCompositing(bool block) const;
79
int checkFSP(int fsp) const;
80
bool checkAcceptFocus(bool focus) const;
81
Options::MoveResizeMode checkMoveResizeMode(Options::MoveResizeMode mode) const;
82
bool checkCloseable(bool closeable) const;
83
bool checkAutogrouping(bool autogroup) const;
84
bool checkAutogroupInForeground(bool fg) const;
85
QString checkAutogroupById(QString id) const;
86
bool checkStrictGeometry(bool strict) const;
87
QString checkShortcut(QString s, bool init = false) const;
88
bool checkDisableGlobalShortcuts(bool disable) const;
89
bool checkIgnorePosition(bool ignore) const; // obsolete
91
MaximizeMode checkMaximizeVert(MaximizeMode mode, bool init) const;
92
MaximizeMode checkMaximizeHoriz(MaximizeMode mode, bool init) const;
93
QVector< Rules* > rules;
98
: public KDecorationDefines
102
Rules(const KConfigGroup&);
103
Rules(const QString&, bool temporary);
104
void write(KConfigGroup&) const;
105
bool isEmpty() const;
107
void discardUsed(bool withdrawn);
108
bool match(const Client* c) const;
109
bool update(Client*);
110
bool isTemporary() const;
111
bool discardTemporary(bool force); // removes if temporary and forced or too old
112
bool applyPlacement(Placement::Policy& placement) const;
113
bool applyGeometry(QRect& rect, bool init) const;
114
// use 'invalidPoint' with applyPosition, unlike QSize() and QRect(), QPoint() is a valid point
115
bool applyPosition(QPoint& pos, bool init) const;
116
bool applySize(QSize& s, bool init) const;
117
bool applyMinSize(QSize& s) const;
118
bool applyMaxSize(QSize& s) const;
119
bool applyOpacityActive(int& s) const;
120
bool applyOpacityInactive(int& s) const;
121
bool applyTilingOption(int& s) const;
122
bool applyIgnoreGeometry(bool& ignore) const;
123
bool applyDesktop(int& desktop, bool init) const;
124
bool applyType(NET::WindowType& type) const;
125
bool applyMaximizeVert(MaximizeMode& mode, bool init) const;
126
bool applyMaximizeHoriz(MaximizeMode& mode, bool init) const;
127
bool applyMinimize(bool& minimized, bool init) const;
128
bool applyShade(ShadeMode& shade, bool init) const;
129
bool applySkipTaskbar(bool& skip, bool init) const;
130
bool applySkipPager(bool& skip, bool init) const;
131
bool applySkipSwitcher(bool& skip, bool init) const;
132
bool applyKeepAbove(bool& above, bool init) const;
133
bool applyKeepBelow(bool& below, bool init) const;
134
bool applyFullScreen(bool& fs, bool init) const;
135
bool applyNoBorder(bool& noborder, bool init) const;
136
bool applyBlockCompositing(bool& block) const;
137
bool applyFSP(int& fsp) const;
138
bool applyAcceptFocus(bool& focus) const;
139
bool applyMoveResizeMode(Options::MoveResizeMode& mode) const;
140
bool applyCloseable(bool& closeable) const;
141
bool applyAutogrouping(bool& autogroup) const;
142
bool applyAutogroupInForeground(bool& fg) const;
143
bool applyAutogroupById(QString& id) const;
144
bool applyStrictGeometry(bool& strict) const;
145
bool applyShortcut(QString& shortcut, bool init) const;
146
bool applyDisableGlobalShortcuts(bool& disable) const;
147
bool applyIgnorePosition(bool& ignore) const; // obsolete
150
bool matchType(NET::WindowType match_type) const;
151
bool matchWMClass(const QByteArray& match_class, const QByteArray& match_name) const;
152
bool matchRole(const QByteArray& match_role) const;
153
bool matchTitle(const QString& match_title) const;
154
bool matchClientMachine(const QByteArray& match_machine) const;
155
// All these values are saved to the cfg file, and are also used in kstart!
158
DontAffect, // use the default value
159
Force, // force the given value
160
Apply, // apply only after initial mapping
161
Remember, // like apply, and remember the value when the window is withdrawn
162
ApplyNow, // apply immediatelly, then forget the setting
163
ForceTemporarily // apply and force until the window is withdrawn
166
UnusedSetRule = Unused,
167
SetRuleDummy = 256 // so that it's at least short int
170
UnusedForceRule = Unused,
171
ForceRuleDummy = 256 // so that it's at least short int
175
UnimportantMatch = FirstStringMatch,
179
LastStringMatch = RegExpMatch
181
void readFromCfg(const KConfigGroup& cfg);
182
static SetRule readSetRule(const KConfigGroup&, const QString& key);
183
static ForceRule readForceRule(const KConfigGroup&, const QString& key);
184
static NET::WindowType readType(const KConfigGroup&, const QString& key);
186
static bool checkSetRule(SetRule rule, bool init);
187
static bool checkForceRule(ForceRule rule);
188
static bool checkSetStop(SetRule rule);
189
static bool checkForceStop(ForceRule rule);
191
int temporary_state; // e.g. for kstart
194
StringMatch wmclassmatch;
195
bool wmclasscomplete;
196
QByteArray windowrole;
197
StringMatch windowrolematch;
199
StringMatch titlematch;
200
QByteArray extrarole;
201
StringMatch extrarolematch;
202
QByteArray clientmachine;
203
StringMatch clientmachinematch;
204
unsigned long types; // types for matching
205
Placement::Policy placement;
206
ForceRule placementrule;
208
SetRule positionrule;
212
ForceRule minsizerule;
214
ForceRule maxsizerule;
216
ForceRule opacityactiverule;
218
ForceRule opacityinactiverule;
220
ForceRule tilingoptionrule;
222
ForceRule ignorepositionrule;
225
NET::WindowType type; // type for setting
228
SetRule maximizevertrule;
230
SetRule maximizehorizrule;
232
SetRule minimizerule;
236
SetRule skiptaskbarrule;
238
SetRule skippagerrule;
240
SetRule skipswitcherrule;
246
SetRule fullscreenrule;
248
SetRule noborderrule;
249
bool blockcompositing;
250
ForceRule blockcompositingrule;
252
ForceRule fsplevelrule;
254
ForceRule acceptfocusrule;
255
Options::MoveResizeMode moveresizemode;
256
ForceRule moveresizemoderule;
258
ForceRule closeablerule;
260
ForceRule autogrouprule;
262
ForceRule autogroupfgrule;
264
ForceRule autogroupidrule;
266
ForceRule strictgeometryrule;
268
SetRule shortcutrule;
269
bool disableglobalshortcuts;
270
ForceRule disableglobalshortcutsrule;
271
friend QDebug& operator<<(QDebug& stream, const Rules*);
276
bool Rules::checkSetRule(SetRule rule, bool init)
278
if (rule > (SetRule)DontAffect) { // Unused or DontAffect
279
if (rule == (SetRule)Force || rule == (SetRule) ApplyNow
280
|| rule == (SetRule) ForceTemporarily || init)
287
bool Rules::checkForceRule(ForceRule rule)
289
return rule == (ForceRule)Force || rule == (ForceRule) ForceTemporarily;
293
bool Rules::checkSetStop(SetRule rule)
295
return rule != UnusedSetRule;
299
bool Rules::checkForceStop(ForceRule rule)
301
return rule != UnusedForceRule;
305
WindowRules::WindowRules(const QVector< Rules* >& r)
311
WindowRules::WindowRules()
316
bool WindowRules::contains(const Rules* rule) const
318
return qFind(rules.begin(), rules.end(), rule) != rules.end();
322
void WindowRules::remove(Rules* rule)
324
QVector< Rules* >::Iterator pos = qFind(rules.begin(), rules.end(), rule);
325
if (pos != rules.end())
331
QDebug& operator<<(QDebug& stream, const Rules*);