1
/********************************************************************
2
KWin - the KDE window manager
3
This file is part of the KDE project.
5
Copyright (C) 2003 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
*********************************************************************/
26
#include <kconfiggroup.h>
31
Bridge::Bridge(Client* cl)
36
#define BRIDGE_HELPER( rettype, prototype, args1, args2, cst ) \
37
rettype Bridge::prototype ( args1 ) cst \
39
return c->prototype( args2 ); \
42
BRIDGE_HELPER(bool, isActive, , , const)
43
BRIDGE_HELPER(bool, isCloseable, , , const)
44
BRIDGE_HELPER(bool, isMaximizable, , , const)
45
BRIDGE_HELPER(Bridge::MaximizeMode, maximizeMode, , , const)
46
BRIDGE_HELPER(bool, isMinimizable, , , const)
47
BRIDGE_HELPER(bool, providesContextHelp, , , const)
48
BRIDGE_HELPER(int, desktop, , , const)
49
BRIDGE_HELPER(bool, isModal, , , const)
50
BRIDGE_HELPER(bool, isShadeable, , , const)
51
BRIDGE_HELPER(bool, isShade, , , const)
52
BRIDGE_HELPER(bool, keepAbove, , , const)
53
BRIDGE_HELPER(bool, keepBelow, , , const)
54
BRIDGE_HELPER(bool, isMovable, , , const)
55
BRIDGE_HELPER(bool, isResizable, , , const)
56
BRIDGE_HELPER(QString, caption, , , const)
57
BRIDGE_HELPER(void, processMousePressEvent, QMouseEvent* e, e,)
58
BRIDGE_HELPER(QRect, geometry, , , const)
59
BRIDGE_HELPER(void, closeWindow, , ,)
60
BRIDGE_HELPER(void, maximize, MaximizeMode m, m,)
61
BRIDGE_HELPER(void, minimize, , ,)
62
BRIDGE_HELPER(void, showContextHelp, , ,)
63
BRIDGE_HELPER(void, setDesktop, int desktop, desktop,)
65
void Bridge::setKeepAbove(bool set)
67
if (c->keepAbove() != set)
68
c->workspace()->performWindowOperation(c, KeepAboveOp);
71
void Bridge::setKeepBelow(bool set)
73
if (c->keepBelow() != set)
74
c->workspace()->performWindowOperation(c, KeepBelowOp);
77
NET::WindowType Bridge::windowType(unsigned long supported_types) const
79
return c->windowType(false, supported_types);
82
QIcon Bridge::icon() const
85
ret.addPixmap(c->miniIcon());
89
bool Bridge::isSetShade() const
91
return c->shadeMode() != ShadeNone;
94
void Bridge::showWindowMenu(const QPoint &p)
96
c->workspace()->showWindowMenu(p, c);
99
void Bridge::showWindowMenu(const QRect &p)
101
c->workspace()->showWindowMenu(p, c);
104
void Bridge::performWindowOperation(WindowOperation op)
106
c->workspace()->performWindowOperation(c, op);
109
void Bridge::setMask(const QRegion& r, int mode)
114
bool Bridge::isPreview() const
119
QRect Bridge::iconGeometry() const
121
NETRect r = c->info->iconGeometry();
122
return QRect(r.pos.x, r.pos.y, r.size.width, r.size.height);
125
WId Bridge::windowId() const
130
void Bridge::titlebarDblClickOperation()
132
c->workspace()->performWindowOperation(c, options->operationTitlebarDblClick());
135
void Bridge::titlebarMouseWheelOperation(int delta)
137
c->performMouseCommand(options->operationTitlebarMouseWheel(delta), cursorPos());
140
void Bridge::setShade(bool set)
142
c->setShade(set ? ShadeNormal : ShadeNone);
145
int Bridge::currentDesktop() const
147
return c->workspace()->currentDesktop();
150
QWidget* Bridge::initialParentWidget() const
155
Qt::WFlags Bridge::initialWFlags() const
160
QRegion Bridge::unobscuredRegion(const QRegion& r) const
163
const ClientList stacking_order = c->workspace()->stackingOrder();
164
int pos = stacking_order.indexOf(c);
166
for (; pos < stacking_order.count(); ++pos) {
167
if (!stacking_order[pos]->isShown(true))
168
continue; // these don't obscure the window
169
if (c->isOnAllDesktops()) {
170
if (!stacking_order[ pos ]->isOnCurrentDesktop())
173
if (!stacking_order[ pos ]->isOnDesktop(c->desktop()))
176
/* the clients all have their mask-regions in local coords
177
so we have to translate them to a shared coord system
179
int dx = stacking_order[ pos ]->x() - c->x();
180
int dy = stacking_order[ pos ]->y() - c->y();
181
QRegion creg = stacking_order[ pos ]->mask();
182
creg.translate(dx, dy);
185
// early out, we are completely obscured
192
void Bridge::grabXServer(bool grab)
197
KWin::ungrabXServer();
200
bool Bridge::compositingActive() const
202
return c->workspace()->compositingActive();
205
QRect Bridge::transparentRect() const
207
return c->transparentRect().translated(-c->decorationRect().topLeft());
210
bool Bridge::isClientGroupActive()
212
if (c->clientGroup())
213
return c->clientGroup()->containsActiveClient();
217
QList< ClientGroupItem > Bridge::clientGroupItems() const
219
if (c->clientGroup())
220
return c->clientGroup()->items();
221
QList< ClientGroupItem > items;
222
QIcon icon(c->icon());
223
icon.addPixmap(c->miniIcon());
224
items.append(ClientGroupItem(c->caption(), icon));
228
long Bridge::itemId(int index)
230
if (!c->clientGroup())
232
const ClientList list = c->clientGroup()->clients();
233
return reinterpret_cast<long>(list.at(index));
236
int Bridge::visibleClientGroupItem()
238
if (c->clientGroup())
239
return c->clientGroup()->indexOfVisibleClient();
243
void Bridge::setVisibleClientGroupItem(int index)
245
if (c->clientGroup())
246
c->clientGroup()->setVisible(index);
249
void Bridge::moveItemInClientGroup(int index, int before)
251
if (c->clientGroup())
252
c->clientGroup()->move(index, before);
255
void Bridge::moveItemToClientGroup(long itemId, int before)
257
Client* item = reinterpret_cast<Client*>(itemId);
258
if (!c->workspace()->hasClient(item)) {
259
kWarning(1212) << "****** ARBITRARY CODE EXECUTION ATTEMPT DETECTED ******";
262
if (item->clientGroup())
263
c->workspace()->moveItemToClientGroup(item->clientGroup(), item->clientGroup()->indexOfClient(item),
264
c->clientGroup(), before);
267
void Bridge::removeFromClientGroup(int index, const QRect& newGeom)
269
if (c->clientGroup())
270
c->clientGroup()->remove(index, newGeom);
273
void Bridge::closeClientGroupItem(int index)
275
if (!c->clientGroup())
277
const ClientList list = c->clientGroup()->clients();
278
if (index >= 0 || index <= list.count())
279
list.at(index)->closeWindow();
282
void Bridge::closeAllInClientGroup()
284
if (c->clientGroup())
285
c->clientGroup()->closeAll();
288
void Bridge::displayClientMenu(int index, const QPoint& pos)
290
if (c->clientGroup())
291
c->clientGroup()->displayClientMenu(index, pos);
294
KDecoration::WindowOperation Bridge::buttonToWindowOperation(Qt::MouseButtons button)
296
return c->mouseButtonToWindowOperation(button);