~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kwin/client.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/********************************************************************
 
2
 KWin - the KDE window manager
 
3
 This file is part of the KDE project.
 
4
 
 
5
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
 
6
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
 
7
 
 
8
This program is free software; you can redistribute it and/or modify
 
9
it under the terms of the GNU General Public License as published by
 
10
the Free Software Foundation; either version 2 of the License, or
 
11
(at your option) any later version.
 
12
 
 
13
This program is distributed in the hope that it will be useful,
 
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
GNU General Public License for more details.
 
17
 
 
18
You should have received a copy of the GNU General Public License
 
19
along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
*********************************************************************/
 
21
 
 
22
#ifndef KWIN_CLIENT_H
 
23
#define KWIN_CLIENT_H
 
24
 
 
25
#include <config-X11.h>
 
26
 
 
27
#include <QFrame>
 
28
#include <QPixmap>
 
29
#include <netwm.h>
 
30
#include <kdebug.h>
 
31
#include <assert.h>
 
32
#include <kshortcut.h>
 
33
#include <X11/X.h>
 
34
#include <X11/Xlib.h>
 
35
#include <X11/Xutil.h>
 
36
#include <fixx11h.h>
 
37
 
 
38
#include <QScriptValue>
 
39
#include "scripting/client.h"
 
40
 
 
41
#include "utils.h"
 
42
#include "options.h"
 
43
#include "workspace.h"
 
44
#include "kdecoration.h"
 
45
#include "rules.h"
 
46
#include "toplevel.h"
 
47
#include "clientgroup.h"
 
48
 
 
49
#ifdef HAVE_XSYNC
 
50
#include <X11/extensions/sync.h>
 
51
#endif
 
52
 
 
53
// TODO: Cleanup the order of things in this .h file
 
54
 
 
55
class QProcess;
 
56
class QTimer;
 
57
class KStartupInfoData;
 
58
 
 
59
namespace SWrapper
 
60
{
 
61
class Client;
 
62
}
 
63
 
 
64
typedef QPair<SWrapper::Client*, QScriptValue> ClientResolution;
 
65
 
 
66
namespace KWin
 
67
{
 
68
namespace TabBox
 
69
{
 
70
 
 
71
class TabBoxClientImpl;
 
72
}
 
73
 
 
74
 
 
75
class Workspace;
 
76
class Client;
 
77
class Bridge;
 
78
class PaintRedirector;
 
79
 
 
80
class Client
 
81
    : public Toplevel
 
82
{
 
83
    Q_OBJECT
 
84
public:
 
85
    Client(Workspace* ws);
 
86
    Window wrapperId() const;
 
87
    Window decorationId() const;
 
88
 
 
89
    const Client* transientFor() const;
 
90
    Client* transientFor();
 
91
    bool isTransient() const;
 
92
    bool groupTransient() const;
 
93
    bool wasOriginallyGroupTransient() const;
 
94
    ClientList mainClients() const; // Call once before loop , is not indirect
 
95
    ClientList allMainClients() const; // Call once before loop , is indirect
 
96
    bool hasTransient(const Client* c, bool indirect) const;
 
97
    const ClientList& transients() const; // Is not indirect
 
98
    void checkTransient(Window w);
 
99
    Client* findModal(bool allow_itself = false);
 
100
    const Group* group() const;
 
101
    Group* group();
 
102
    void checkGroup(Group* gr = NULL, bool force = false);
 
103
    void changeClientLeaderGroup(Group* gr);
 
104
    const WindowRules* rules() const;
 
105
    void removeRule(Rules* r);
 
106
    void setupWindowRules(bool ignore_temporary);
 
107
    void applyWindowRules();
 
108
    void updateWindowRules();
 
109
    void updateFullscreenMonitors(NETFullscreenMonitors topology);
 
110
 
 
111
    /**
 
112
     * Returns true for "special" windows and false for windows which are "normal"
 
113
     * (normal=window which has a border, can be moved by the user, can be closed, etc.)
 
114
     * true for Desktop, Dock, Splash, Override and TopMenu (and Toolbar??? - for now)
 
115
     * false for Normal, Dialog, Utility and Menu (and Toolbar??? - not yet) TODO
 
116
     */
 
117
    bool isSpecialWindow() const;
 
118
    bool hasNETSupport() const;
 
119
 
 
120
    /**
 
121
      * This is a public object with no wrappers or anything to keep it fast,
 
122
      * so in essence, direct access is allowed. Please be very careful while
 
123
      * using this object
 
124
      */
 
125
    QHash<QScriptEngine*, ClientResolution>* scriptCache;
 
126
 
 
127
    QSize minSize() const;
 
128
    QSize maxSize() const;
 
129
    virtual QPoint clientPos() const; // Inside of geometry()
 
130
    virtual QSize clientSize() const;
 
131
    virtual QRect visibleRect() const;
 
132
 
 
133
    bool windowEvent(XEvent* e);
 
134
    virtual bool eventFilter(QObject* o, QEvent* e);
 
135
#ifdef HAVE_XSYNC
 
136
    void syncEvent(XSyncAlarmNotifyEvent* e);
 
137
#endif
 
138
 
 
139
    bool manage(Window w, bool isMapped);
 
140
    void releaseWindow(bool on_shutdown = false);
 
141
    void destroyClient();
 
142
 
 
143
    /// How to resize the window in order to obey constains (mainly aspect ratios)
 
144
    enum Sizemode {
 
145
        SizemodeAny,
 
146
        SizemodeFixedW, ///< Try not to affect width
 
147
        SizemodeFixedH, ///< Try not to affect height
 
148
        SizemodeMax ///< Try not to make it larger in either direction
 
149
    };
 
150
    QSize adjustedSize(const QSize&, Sizemode mode = SizemodeAny) const;
 
151
    QSize adjustedSize() const;
 
152
 
 
153
    QPixmap icon() const;
 
154
    QPixmap icon(const QSize& size) const;
 
155
    QPixmap miniIcon() const;
 
156
    QPixmap bigIcon() const;
 
157
    QPixmap hugeIcon() const;
 
158
 
 
159
    bool isActive() const;
 
160
    void setActive(bool);
 
161
 
 
162
    virtual int desktop() const;
 
163
    void setDesktop(int);
 
164
    void setOnAllDesktops(bool set);
 
165
 
 
166
    virtual QStringList activities() const;
 
167
    void setOnActivity(const QString &activity, bool enable);
 
168
    void setOnAllActivities(bool set);
 
169
    void setOnActivities(QStringList newActivitiesList);
 
170
    void updateActivities(bool includeTransients);
 
171
 
 
172
    /// Is not minimized and not hidden. I.e. normally visible on some virtual desktop.
 
173
    bool isShown(bool shaded_is_shown) const;
 
174
    bool isHiddenInternal() const; // For compositing
 
175
 
 
176
    bool isShade() const; // True only for ShadeNormal
 
177
    ShadeMode shadeMode() const; // Prefer isShade()
 
178
    void setShade(ShadeMode mode);
 
179
    bool isShadeable() const;
 
180
 
 
181
    bool isMinimized() const;
 
182
    bool isMaximizable() const;
 
183
    QRect geometryRestore() const;
 
184
    MaximizeMode maximizeModeRestore() const;
 
185
    MaximizeMode maximizeMode() const;
 
186
    bool isMinimizable() const;
 
187
    void setMaximize(bool vertically, bool horizontally);
 
188
    QRect iconGeometry() const;
 
189
 
 
190
    void setFullScreen(bool set, bool user);
 
191
    bool isFullScreen() const;
 
192
    bool isFullScreenable(bool fullscreen_hack = false) const;
 
193
    bool isActiveFullScreen() const;
 
194
    bool userCanSetFullScreen() const;
 
195
    QRect geometryFSRestore() const {
 
196
        return geom_fs_restore;    // Only for session saving
 
197
    }
 
198
    int fullScreenMode() const {
 
199
        return fullscreen_mode;    // only for session saving
 
200
    }
 
201
 
 
202
    bool noBorder() const;
 
203
    void setNoBorder(bool set);
 
204
    bool userCanSetNoBorder() const;
 
205
    void checkNoBorder();
 
206
 
 
207
    bool skipTaskbar(bool from_outside = false) const;
 
208
    void setSkipTaskbar(bool set, bool from_outside);
 
209
 
 
210
    bool skipPager() const;
 
211
    void setSkipPager(bool);
 
212
 
 
213
    bool skipSwitcher() const;
 
214
    void setSkipSwitcher(bool set);
 
215
 
 
216
    bool keepAbove() const;
 
217
    void setKeepAbove(bool);
 
218
    bool keepBelow() const;
 
219
    void setKeepBelow(bool);
 
220
    Layer layer() const;
 
221
    Layer belongsToLayer() const;
 
222
    void invalidateLayer();
 
223
    int sessionStackingOrder() const;
 
224
 
 
225
    void setModal(bool modal);
 
226
    bool isModal() const;
 
227
 
 
228
    // Auxiliary functions, depend on the windowType
 
229
    bool wantsTabFocus() const;
 
230
    bool wantsInput() const;
 
231
 
 
232
    bool isResizable() const;
 
233
    bool isMovable() const;
 
234
    bool isMovableAcrossScreens() const;
 
235
    bool isCloseable() const; ///< May be closed by the user (May have a close button)
 
236
 
 
237
    void takeActivity(int flags, bool handled, allowed_t);   // Takes ActivityFlags as arg (in utils.h)
 
238
    void takeFocus(allowed_t);
 
239
    void demandAttention(bool set = true);
 
240
 
 
241
    void setMask(const QRegion& r, int mode = X::Unsorted);
 
242
    QRegion mask() const;
 
243
 
 
244
    void updateDecoration(bool check_workspace_pos, bool force = false);
 
245
    bool checkBorderSizes(bool also_resize);
 
246
    void triggerDecorationRepaint();
 
247
 
 
248
    void updateShape();
 
249
 
 
250
    void setGeometry(int x, int y, int w, int h, ForceGeometry_t force = NormalGeometrySet, bool emitJs = true);
 
251
    void setGeometry(const QRect& r, ForceGeometry_t force = NormalGeometrySet, bool emitJs = true);
 
252
    void move(int x, int y, ForceGeometry_t force = NormalGeometrySet);
 
253
    void move(const QPoint& p, ForceGeometry_t force = NormalGeometrySet);
 
254
    /// plainResize() simply resizes
 
255
    void plainResize(int w, int h, ForceGeometry_t force = NormalGeometrySet, bool emitJs = true);
 
256
    void plainResize(const QSize& s, ForceGeometry_t force = NormalGeometrySet, bool emitJs = true);
 
257
    /// resizeWithChecks() resizes according to gravity, and checks workarea position
 
258
    void resizeWithChecks(int w, int h, ForceGeometry_t force = NormalGeometrySet);
 
259
    void resizeWithChecks(const QSize& s, ForceGeometry_t force = NormalGeometrySet);
 
260
    void keepInArea(QRect area, bool partial = false);
 
261
    void setElectricBorderMode(QuickTileMode mode);
 
262
    QuickTileMode electricBorderMode() const;
 
263
    void setElectricBorderMaximizing(bool maximizing);
 
264
    bool isElectricBorderMaximizing() const;
 
265
    QRect electricBorderMaximizeGeometry(QPoint pos, int desktop);
 
266
    QSize sizeForClientSize(const QSize&, Sizemode mode = SizemodeAny, bool noframe = false) const;
 
267
 
 
268
    /** Set the quick tile mode ("snap") of this window.
 
269
     * This will also handle preserving and restoring of window geometry as necessary.
 
270
     * @param mode The tile mode (left/right) to give this window.
 
271
     */
 
272
    void setQuickTileMode(QuickTileMode mode, bool keyboard = false);
 
273
 
 
274
    void growHorizontal();
 
275
    void shrinkHorizontal();
 
276
    void growVertical();
 
277
    void shrinkVertical();
 
278
 
 
279
    bool providesContextHelp() const;
 
280
    KShortcut shortcut() const;
 
281
    void setShortcut(const QString& cut);
 
282
 
 
283
    WindowOperation mouseButtonToWindowOperation(Qt::MouseButtons button);
 
284
    bool performMouseCommand(Options::MouseCommand, const QPoint& globalPos, bool handled = false);
 
285
 
 
286
    QRect adjustedClientArea(const QRect& desktop, const QRect& area) const;
 
287
 
 
288
    Colormap colormap() const;
 
289
 
 
290
    /// Updates visibility depending on being shaded, virtual desktop, etc.
 
291
    void updateVisibility();
 
292
    /// Hides a client - Basically like minimize, but without effects, it's simply hidden
 
293
    void hideClient(bool hide);
 
294
    bool hiddenPreview() const; ///< Window is mapped in order to get a window pixmap
 
295
 
 
296
    virtual void setupCompositing();
 
297
    virtual void finishCompositing();
 
298
    inline bool isBlockingCompositing() { return blocks_compositing; }
 
299
    void updateCompositeBlocking(bool readProperty = false);
 
300
 
 
301
    QString caption(bool full = true) const;
 
302
    void updateCaption();
 
303
 
 
304
    void keyPressEvent(uint key_code);   // FRAME ??
 
305
    void updateMouseGrab();
 
306
    Window moveResizeGrabWindow() const;
 
307
 
 
308
    const QPoint calculateGravitation(bool invert, int gravity = 0) const;   // FRAME public?
 
309
 
 
310
    void NETMoveResize(int x_root, int y_root, NET::Direction direction);
 
311
    void NETMoveResizeWindow(int flags, int x, int y, int width, int height);
 
312
    void restackWindow(Window above, int detail, NET::RequestSource source, Time timestamp,
 
313
                       bool send_event = false);
 
314
 
 
315
    void gotPing(Time timestamp);
 
316
 
 
317
    void checkWorkspacePosition();
 
318
    void updateUserTime(Time time = CurrentTime);
 
319
    Time userTime() const;
 
320
    bool hasUserTimeSupport() const;
 
321
    bool ignoreFocusStealing() const;
 
322
 
 
323
    /// Does 'delete c;'
 
324
    static void deleteClient(Client* c, allowed_t);
 
325
 
 
326
    static bool belongToSameApplication(const Client* c1, const Client* c2, bool active_hack = false);
 
327
    static bool sameAppWindowRoleMatch(const Client* c1, const Client* c2, bool active_hack);
 
328
    static void readIcons(Window win, QPixmap* icon, QPixmap* miniicon, QPixmap* bigicon, QPixmap* hugeicon);
 
329
 
 
330
    void minimize(bool avoid_animation = false);
 
331
    void unminimize(bool avoid_animation = false);
 
332
    void closeWindow();
 
333
    void killWindow();
 
334
    void maximize(MaximizeMode);
 
335
    void toggleShade();
 
336
    void showContextHelp();
 
337
    void cancelShadeHoverTimer();
 
338
    void cancelAutoRaise();
 
339
    void checkActiveModal();
 
340
    StrutRect strutRect(StrutArea area) const;
 
341
    StrutRects strutRects() const;
 
342
    bool hasStrut() const;
 
343
 
 
344
    // Tabbing functions
 
345
    ClientGroup* clientGroup() const; // Returns a pointer to client_group
 
346
    void setClientGroup(ClientGroup* group);
 
347
    /*
 
348
    *   If shown is true the client is mapped and raised, if false
 
349
    *   the client is unmapped and hidden, this function is called
 
350
    *   when the tabbing group of the client switches its visible
 
351
    *   client.
 
352
    */
 
353
    void setClientShown(bool shown);
 
354
    /*
 
355
    *   When a click is done in the decoration and it calls the group
 
356
    *   to change the visible client it starts to move-resize the new
 
357
    *   client, this function stops it.
 
358
    */
 
359
    void dontMoveResize();
 
360
 
 
361
    /**
 
362
     * Whether or not the window has a strut that expands through the invisible area of
 
363
     * an xinerama setup where the monitors are not the same resolution.
 
364
     */
 
365
    bool hasOffscreenXineramaStrut() const;
 
366
 
 
367
    bool isMove() const {
 
368
        return moveResizeMode && mode == PositionCenter;
 
369
    }
 
370
    bool isResize() const {
 
371
        return moveResizeMode && mode != PositionCenter;
 
372
    }
 
373
 
 
374
    // Decorations <-> Effects
 
375
    const QPixmap *topDecoPixmap() const {
 
376
        return &decorationPixmapTop;
 
377
    }
 
378
    const QPixmap *leftDecoPixmap() const {
 
379
        return &decorationPixmapLeft;
 
380
    }
 
381
    const QPixmap *bottomDecoPixmap() const {
 
382
        return &decorationPixmapBottom;
 
383
    }
 
384
    const QPixmap *rightDecoPixmap() const {
 
385
        return &decorationPixmapRight;
 
386
    }
 
387
 
 
388
    int paddingLeft() const {
 
389
        return padding_left;
 
390
    }
 
391
    int paddingRight() const {
 
392
        return padding_right;
 
393
    }
 
394
    int paddingTop() const {
 
395
        return padding_top;
 
396
    }
 
397
    int paddingBottom() const {
 
398
        return padding_bottom;
 
399
    }
 
400
 
 
401
    bool decorationPixmapRequiresRepaint();
 
402
    void ensureDecorationPixmapsPainted();
 
403
 
 
404
    QRect decorationRect() const;
 
405
 
 
406
    QRect transparentRect() const;
 
407
 
 
408
    QRegion decorationPendingRegion() const;
 
409
 
 
410
    enum CoordinateMode {
 
411
        DecorationRelative, // Relative to the top left corner of the decoration
 
412
        WindowRelative      // Relative to the top left corner of the window
 
413
    };
 
414
    void layoutDecorationRects(QRect &left, QRect &top, QRect &right, QRect &bottom, CoordinateMode mode) const;
 
415
    virtual void addRepaintFull();
 
416
 
 
417
    TabBox::TabBoxClientImpl* tabBoxClient() const {
 
418
        return m_tabBoxClient;
 
419
    }
 
420
 
 
421
    //sets whether the client should be treated as a SessionInteract window
 
422
    void setSessionInteract(bool needed);
 
423
 
 
424
private slots:
 
425
    void autoRaise();
 
426
    void shadeHover();
 
427
    void shadeUnhover();
 
428
    void shortcutActivated();
 
429
    void delayedMoveResize();
 
430
 
 
431
private:
 
432
    friend class Bridge; // FRAME
 
433
    virtual void processMousePressEvent(QMouseEvent* e);
 
434
 
 
435
private:
 
436
    // Use Workspace::createClient()
 
437
    virtual ~Client(); ///< Use destroyClient() or releaseWindow()
 
438
 
 
439
    Position mousePosition(const QPoint&) const;
 
440
    void updateCursor();
 
441
 
 
442
    // Transparent stuff
 
443
    void drawbound(const QRect& geom);
 
444
    void clearbound();
 
445
    void doDrawbound(const QRect& geom, bool clear);
 
446
 
 
447
    // Handlers for X11 events
 
448
    bool mapRequestEvent(XMapRequestEvent* e);
 
449
    void unmapNotifyEvent(XUnmapEvent* e);
 
450
    void destroyNotifyEvent(XDestroyWindowEvent* e);
 
451
    void configureRequestEvent(XConfigureRequestEvent* e);
 
452
    virtual void propertyNotifyEvent(XPropertyEvent* e);
 
453
    void clientMessageEvent(XClientMessageEvent* e);
 
454
    void enterNotifyEvent(XCrossingEvent* e);
 
455
    void leaveNotifyEvent(XCrossingEvent* e);
 
456
    void focusInEvent(XFocusInEvent* e);
 
457
    void focusOutEvent(XFocusOutEvent* e);
 
458
#ifdef HAVE_XDAMAGE
 
459
    virtual void damageNotifyEvent(XDamageNotifyEvent* e);
 
460
#endif
 
461
 
 
462
    bool buttonPressEvent(Window w, int button, int state, int x, int y, int x_root, int y_root);
 
463
    bool buttonReleaseEvent(Window w, int button, int state, int x, int y, int x_root, int y_root);
 
464
    bool motionNotifyEvent(Window w, int state, int x, int y, int x_root, int y_root);
 
465
    void checkQuickTilingMaximizationZones(int xroot, int yroot);
 
466
 
 
467
    bool processDecorationButtonPress(int button, int state, int x, int y, int x_root, int y_root,
 
468
                                      bool ignoreMenu = false);
 
469
 
 
470
protected:
 
471
    virtual void debug(QDebug& stream) const;
 
472
    virtual bool shouldUnredirect() const;
 
473
 
 
474
private slots:
 
475
    void pingTimeout();
 
476
    void processKillerExited();
 
477
    void demandAttentionKNotify();
 
478
    void syncTimeout();
 
479
    void delayedSetShortcut();
 
480
    void repaintDecorationPending();
 
481
 
 
482
    //Signals for the scripting interface
 
483
    //Signals make an excellent way for communication
 
484
    //in between objects as compared to simple function
 
485
    //calls
 
486
signals:
 
487
    void s_clientMoved();
 
488
    void clientManaging(KWin::Client*);
 
489
    void s_minimized();
 
490
    void s_unminimized();
 
491
    void maximizeSet(QPair<bool, bool>);
 
492
    void s_activated();
 
493
    void s_fullScreenSet(bool, bool);
 
494
    void clientClosed(KWin::Client*);
 
495
    void clientMaximizedStateChanged(KWin::Client*, KDecorationDefines::MaximizeMode);
 
496
    void clientMinimized(KWin::Client* client, bool animate);
 
497
    void clientUnminimized(KWin::Client* client, bool animate);
 
498
    void clientGeometryShapeChanged(KWin::Client* client, const QRect& old);
 
499
    void clientStartUserMovedResized(KWin::Client*);
 
500
    void clientStepUserMovedResized(KWin::Client *, const QRect&);
 
501
    void clientFinishUserMovedResized(KWin::Client*);
 
502
 
 
503
    // To make workspace-client calls, a few slots are also
 
504
    // required
 
505
public slots:
 
506
    void sl_activated();
 
507
 
 
508
private:
 
509
    void exportMappingState(int s);   // ICCCM 4.1.3.1, 4.1.4, NETWM 2.5.1
 
510
    bool isManaged() const; ///< Returns false if this client is not yet managed
 
511
    void updateAllowedActions(bool force = false);
 
512
    QRect fullscreenMonitorsArea(NETFullscreenMonitors topology) const;
 
513
    void changeMaximize(bool horizontal, bool vertical, bool adjust);
 
514
    int checkFullScreenHack(const QRect& geom) const;   // 0 - None, 1 - One xinerama screen, 2 - Full area
 
515
    void updateFullScreenHack(const QRect& geom);
 
516
    void getWmNormalHints();
 
517
    void getMotifHints();
 
518
    void getIcons();
 
519
    void fetchName();
 
520
    void fetchIconicName();
 
521
    QString readName() const;
 
522
    void setCaption(const QString& s, bool force = false);
 
523
    bool hasTransientInternal(const Client* c, bool indirect, ConstClientList& set) const;
 
524
    void finishWindowRules();
 
525
    void setShortcutInternal(const KShortcut& cut);
 
526
 
 
527
    void checkDirection(int new_diff, int old_diff, QRect& rect, const QRect& area);
 
528
    void configureRequest(int value_mask, int rx, int ry, int rw, int rh, int gravity, bool from_tool);
 
529
    NETExtendedStrut strut() const;
 
530
    int checkShadeGeometry(int w, int h);
 
531
    void blockGeometryUpdates(bool block);
 
532
    void getSyncCounter();
 
533
    void sendSyncRequest();
 
534
 
 
535
    bool startMoveResize();
 
536
    void finishMoveResize(bool cancel);
 
537
    void leaveMoveResize();
 
538
    void checkUnrestrictedMoveResize();
 
539
    void handleMoveResize(int x, int y, int x_root, int y_root);
 
540
    void startDelayedMoveResize();
 
541
    void stopDelayedMoveResize();
 
542
    void positionGeometryTip();
 
543
    void grabButton(int mod);
 
544
    void ungrabButton(int mod);
 
545
    void resetMaximize();
 
546
    void resizeDecoration(const QSize& s);
 
547
    void performMoveResize();
 
548
 
 
549
    void pingWindow();
 
550
    void killProcess(bool ask, Time timestamp = CurrentTime);
 
551
    void updateUrgency();
 
552
    static void sendClientMessage(Window w, Atom a, Atom protocol,
 
553
                                  long data1 = 0, long data2 = 0, long data3 = 0);
 
554
 
 
555
    void embedClient(Window w, const XWindowAttributes& attr);
 
556
    void detectNoBorder();
 
557
    void destroyDecoration();
 
558
    void updateFrameExtents();
 
559
 
 
560
    void internalShow(allowed_t);
 
561
    void internalHide(allowed_t);
 
562
    void internalKeep(allowed_t);
 
563
    void map(allowed_t);
 
564
    void unmap(allowed_t);
 
565
    void updateHiddenPreview();
 
566
 
 
567
    void updateInputShape();
 
568
    void repaintDecorationPixmap(QPixmap& pix, const QRect& r, const QPixmap& src, QRegion reg);
 
569
    void resizeDecorationPixmaps();
 
570
 
 
571
    Time readUserTimeMapTimestamp(const KStartupInfoId* asn_id, const KStartupInfoData* asn_data,
 
572
                                  bool session) const;
 
573
    Time readUserCreationTime() const;
 
574
    void startupIdChanged();
 
575
 
 
576
    Window client;
 
577
    Window wrapper;
 
578
    KDecoration* decoration;
 
579
    Bridge* bridge;
 
580
    int desk;
 
581
    QStringList activityList;
 
582
    bool buttonDown;
 
583
    bool moveResizeMode;
 
584
    bool move_faked_activity;
 
585
    Window move_resize_grab_window;
 
586
    bool move_resize_has_keyboard_grab;
 
587
    bool unrestrictedMoveResize;
 
588
 
 
589
    Position mode;
 
590
    QPoint moveOffset;
 
591
    QPoint invertedMoveOffset;
 
592
    QRect moveResizeGeom;
 
593
    QRect initialMoveResizeGeom;
 
594
    XSizeHints xSizeHint;
 
595
    void sendSyntheticConfigureNotify();
 
596
    enum MappingState {
 
597
        Withdrawn, ///< Not handled, as per ICCCM WithdrawnState
 
598
        Mapped, ///< The frame is mapped
 
599
        Unmapped, ///< The frame is not mapped
 
600
        Kept ///< The frame should be unmapped, but is kept (For compositing)
 
601
    };
 
602
    MappingState mapping_state;
 
603
 
 
604
    /** The quick tile mode of this window.
 
605
     */
 
606
    int quick_tile_mode;
 
607
    QRect geom_pretile;
 
608
 
 
609
    void readTransient();
 
610
    Window verifyTransientFor(Window transient_for, bool set);
 
611
    void addTransient(Client* cl);
 
612
    void removeTransient(Client* cl);
 
613
    void removeFromMainClients();
 
614
    void cleanGrouping();
 
615
    void checkGroupTransients();
 
616
    void setTransient(Window new_transient_for_id);
 
617
    Client* transient_for;
 
618
    Window transient_for_id;
 
619
    Window original_transient_for_id;
 
620
    ClientList transients_list; // SELI TODO: Make this ordered in stacking order?
 
621
    ShadeMode shade_mode;
 
622
    uint active : 1;
 
623
    uint deleting : 1; ///< True when doing cleanup and destroying the client
 
624
    uint keep_above : 1; ///< NET::KeepAbove (was stays_on_top)
 
625
    uint skip_taskbar : 1;
 
626
    uint original_skip_taskbar : 1; ///< Unaffected by KWin
 
627
    uint Pdeletewindow : 1; ///< Does the window understand the DeleteWindow protocol?
 
628
    uint Ptakefocus : 1;///< Does the window understand the TakeFocus protocol?
 
629
    uint Ptakeactivity : 1; ///< Does it support _NET_WM_TAKE_ACTIVITY
 
630
    uint Pcontexthelp : 1; ///< Does the window understand the ContextHelp protocol?
 
631
    uint Pping : 1; ///< Does it support _NET_WM_PING?
 
632
    uint input : 1; ///< Does the window want input in its wm_hints
 
633
    uint skip_pager : 1;
 
634
    uint skip_switcher : 1;
 
635
    uint motif_may_resize : 1;
 
636
    uint motif_may_move : 1;
 
637
    uint motif_may_close : 1;
 
638
    uint keep_below : 1; ///< NET::KeepBelow
 
639
    uint minimized : 1;
 
640
    uint hidden : 1; ///< Forcibly hidden by calling hide()
 
641
    uint modal : 1; ///< NET::Modal
 
642
    uint noborder : 1;
 
643
    uint app_noborder : 1; ///< App requested no border via window type, shape extension, etc.
 
644
    uint motif_noborder : 1; ///< App requested no border via Motif WM hints
 
645
    uint urgency : 1; ///< XWMHints, UrgencyHint
 
646
    uint ignore_focus_stealing : 1; ///< Don't apply focus stealing prevention to this client
 
647
    uint demands_attention : 1;
 
648
    bool blocks_compositing;
 
649
    WindowRules client_rules;
 
650
    void getWMHints();
 
651
    void readIcons();
 
652
    void getWindowProtocols();
 
653
    QPixmap icon_pix;
 
654
    QPixmap miniicon_pix;
 
655
    QPixmap bigicon_pix;
 
656
    QPixmap hugeicon_pix;
 
657
    QCursor cursor;
 
658
    // DON'T reorder - Saved to config files !!!
 
659
    enum FullScreenMode {
 
660
        FullScreenNone,
 
661
        FullScreenNormal,
 
662
        FullScreenHack ///< Non-NETWM fullscreen (noborder and size of desktop)
 
663
    };
 
664
    FullScreenMode fullscreen_mode;
 
665
    MaximizeMode max_mode;
 
666
    QRect geom_restore;
 
667
    QRect geom_fs_restore;
 
668
    MaximizeMode maxmode_restore;
 
669
    QTimer* autoRaiseTimer;
 
670
    QTimer* shadeHoverTimer;
 
671
    QTimer* delayedMoveResizeTimer;
 
672
    Colormap cmap;
 
673
    QString cap_normal, cap_iconic, cap_suffix;
 
674
    Group* in_group;
 
675
    Window window_group;
 
676
    ClientGroup* client_group;
 
677
    Layer in_layer;
 
678
    QTimer* ping_timer;
 
679
    QProcess* process_killer;
 
680
    Time ping_timestamp;
 
681
    Time user_time;
 
682
    unsigned long allowed_actions;
 
683
    QSize client_size;
 
684
    int block_geometry_updates; // > 0 = New geometry is remembered, but not actually set
 
685
    enum PendingGeometry_t {
 
686
        PendingGeometryNone,
 
687
        PendingGeometryNormal,
 
688
        PendingGeometryForced
 
689
    };
 
690
    PendingGeometry_t pending_geometry_update;
 
691
    QRect geom_before_block;
 
692
    QRect deco_rect_before_block;
 
693
    bool shade_geometry_change;
 
694
#ifdef HAVE_XSYNC
 
695
    XSyncCounter sync_counter;
 
696
    XSyncValue sync_counter_value;
 
697
    XSyncAlarm sync_alarm;
 
698
#endif
 
699
    QTimer* sync_timeout;
 
700
    bool sync_resize_pending;
 
701
    int border_left, border_right, border_top, border_bottom;
 
702
    int padding_left, padding_right, padding_top, padding_bottom;
 
703
    QRegion _mask;
 
704
    static bool check_active_modal; ///< \see Client::checkActiveModal()
 
705
    KShortcut _shortcut;
 
706
    int sm_stacking_order;
 
707
    friend struct FetchNameInternalPredicate;
 
708
    friend struct CheckIgnoreFocusStealingProcedure;
 
709
    friend struct ResetupRulesProcedure;
 
710
    friend class GeometryUpdatesBlocker;
 
711
    QTimer* demandAttentionKNotifyTimer;
 
712
    QPixmap decorationPixmapLeft, decorationPixmapRight, decorationPixmapTop, decorationPixmapBottom;
 
713
    // we (instead of Qt) initialize the Pixmaps, and have to free them
 
714
    bool m_responsibleForDecoPixmap;
 
715
    PaintRedirector* paintRedirector;
 
716
    TabBox::TabBoxClientImpl* m_tabBoxClient;
 
717
 
 
718
    bool electricMaximizing;
 
719
    QuickTileMode electricMode;
 
720
 
 
721
    friend bool performTransiencyCheck();
 
722
    friend class SWrapper::Client;
 
723
 
 
724
    void checkActivities();
 
725
    bool activitiesDefined; //whether the x property was actually set
 
726
 
 
727
    bool needsSessionInteract;
 
728
};
 
729
 
 
730
/**
 
731
 * Helper for Client::blockGeometryUpdates() being called in pairs (true/false)
 
732
 */
 
733
class GeometryUpdatesBlocker
 
734
{
 
735
public:
 
736
    GeometryUpdatesBlocker(Client* c)
 
737
        : cl(c) {
 
738
        cl->blockGeometryUpdates(true);
 
739
    }
 
740
    ~GeometryUpdatesBlocker() {
 
741
        cl->blockGeometryUpdates(false);
 
742
    }
 
743
 
 
744
private:
 
745
    Client* cl;
 
746
};
 
747
 
 
748
/**
 
749
 * NET WM Protocol handler class
 
750
 */
 
751
class WinInfo : public NETWinInfo2
 
752
{
 
753
private:
 
754
    typedef KWin::Client Client; // Because of NET::Client
 
755
 
 
756
public:
 
757
    WinInfo(Client* c, Display * display, Window window,
 
758
            Window rwin, const unsigned long pr[], int pr_size);
 
759
    virtual void changeDesktop(int desktop);
 
760
    virtual void changeFullscreenMonitors(NETFullscreenMonitors topology);
 
761
    virtual void changeState(unsigned long state, unsigned long mask);
 
762
    void disable();
 
763
 
 
764
private:
 
765
    Client * m_client;
 
766
};
 
767
 
 
768
inline Window Client::wrapperId() const
 
769
{
 
770
    return wrapper;
 
771
}
 
772
 
 
773
inline Window Client::decorationId() const
 
774
{
 
775
    return decoration != NULL ? decoration->widget()->winId() : None;
 
776
}
 
777
 
 
778
inline const Client* Client::transientFor() const
 
779
{
 
780
    return transient_for;
 
781
}
 
782
 
 
783
inline Client* Client::transientFor()
 
784
{
 
785
    return transient_for;
 
786
}
 
787
 
 
788
inline bool Client::groupTransient() const
 
789
{
 
790
    return transient_for_id == rootWindow();
 
791
}
 
792
 
 
793
// Needed because verifyTransientFor() may set transient_for_id to root window,
 
794
// if the original value has a problem (window doesn't exist, etc.)
 
795
inline bool Client::wasOriginallyGroupTransient() const
 
796
{
 
797
    return original_transient_for_id == rootWindow();
 
798
}
 
799
 
 
800
inline bool Client::isTransient() const
 
801
{
 
802
    return transient_for_id != None;
 
803
}
 
804
 
 
805
inline const ClientList& Client::transients() const
 
806
{
 
807
    return transients_list;
 
808
}
 
809
 
 
810
inline const Group* Client::group() const
 
811
{
 
812
    return in_group;
 
813
}
 
814
 
 
815
inline Group* Client::group()
 
816
{
 
817
    return in_group;
 
818
}
 
819
 
 
820
inline void Client::setClientGroup(ClientGroup* group)
 
821
{
 
822
    client_group = group;
 
823
}
 
824
 
 
825
inline ClientGroup* Client::clientGroup() const
 
826
{
 
827
    return client_group;
 
828
}
 
829
 
 
830
inline bool Client::isMinimized() const
 
831
{
 
832
    return minimized;
 
833
}
 
834
 
 
835
inline bool Client::isActive() const
 
836
{
 
837
    return active;
 
838
}
 
839
 
 
840
inline bool Client::isShown(bool shaded_is_shown) const
 
841
{
 
842
    return !isMinimized() && (!isShade() || shaded_is_shown) && !hidden &&
 
843
           (clientGroup() == NULL || clientGroup()->visible() == this);
 
844
}
 
845
 
 
846
inline bool Client::isHiddenInternal() const
 
847
{
 
848
    return hidden;
 
849
}
 
850
 
 
851
inline bool Client::isShade() const
 
852
{
 
853
    return shade_mode == ShadeNormal;
 
854
}
 
855
 
 
856
inline ShadeMode Client::shadeMode() const
 
857
{
 
858
    return shade_mode;
 
859
}
 
860
 
 
861
inline QPixmap Client::icon() const
 
862
{
 
863
    return icon_pix;
 
864
}
 
865
 
 
866
inline QPixmap Client::miniIcon() const
 
867
{
 
868
    return miniicon_pix;
 
869
}
 
870
 
 
871
inline QPixmap Client::bigIcon() const
 
872
{
 
873
    return bigicon_pix;
 
874
}
 
875
 
 
876
inline QPixmap Client::hugeIcon() const
 
877
{
 
878
    return hugeicon_pix;
 
879
}
 
880
 
 
881
inline QRect Client::geometryRestore() const
 
882
{
 
883
    return geom_restore;
 
884
}
 
885
 
 
886
inline Client::MaximizeMode Client::maximizeModeRestore() const
 
887
{
 
888
    return maxmode_restore;
 
889
}
 
890
 
 
891
inline Client::MaximizeMode Client::maximizeMode() const
 
892
{
 
893
    return max_mode;
 
894
}
 
895
 
 
896
inline bool Client::skipTaskbar(bool from_outside) const
 
897
{
 
898
    return from_outside ? original_skip_taskbar : skip_taskbar;
 
899
}
 
900
 
 
901
inline bool Client::skipPager() const
 
902
{
 
903
    return skip_pager;
 
904
}
 
905
 
 
906
inline bool Client::skipSwitcher() const
 
907
{
 
908
    return skip_switcher;
 
909
}
 
910
 
 
911
inline bool Client::keepAbove() const
 
912
{
 
913
    return keep_above;
 
914
}
 
915
 
 
916
inline bool Client::keepBelow() const
 
917
{
 
918
    return keep_below;
 
919
}
 
920
 
 
921
inline bool Client::isFullScreen() const
 
922
{
 
923
    return fullscreen_mode != FullScreenNone;
 
924
}
 
925
 
 
926
inline bool Client::isModal() const
 
927
{
 
928
    return modal;
 
929
}
 
930
 
 
931
inline bool Client::hasNETSupport() const
 
932
{
 
933
    return info->hasNETSupport();
 
934
}
 
935
 
 
936
inline Colormap Client::colormap() const
 
937
{
 
938
    return cmap;
 
939
}
 
940
 
 
941
inline void Client::invalidateLayer()
 
942
{
 
943
    in_layer = UnknownLayer;
 
944
}
 
945
 
 
946
inline int Client::sessionStackingOrder() const
 
947
{
 
948
    return sm_stacking_order;
 
949
}
 
950
 
 
951
inline bool Client::isManaged() const
 
952
{
 
953
    return mapping_state != Withdrawn;
 
954
}
 
955
 
 
956
inline QPoint Client::clientPos() const
 
957
{
 
958
    return QPoint(border_left, border_top);
 
959
}
 
960
 
 
961
inline QSize Client::clientSize() const
 
962
{
 
963
    return client_size;
 
964
}
 
965
 
 
966
inline QRect Client::visibleRect() const
 
967
{
 
968
    return Toplevel::visibleRect().adjusted(-padding_left, -padding_top, padding_right, padding_bottom);
 
969
}
 
970
 
 
971
inline void Client::setGeometry(const QRect& r, ForceGeometry_t force, bool emitJs)
 
972
{
 
973
    setGeometry(r.x(), r.y(), r.width(), r.height(), force, emitJs);
 
974
}
 
975
 
 
976
inline void Client::move(const QPoint& p, ForceGeometry_t force)
 
977
{
 
978
    move(p.x(), p.y(), force);
 
979
}
 
980
 
 
981
inline void Client::plainResize(const QSize& s, ForceGeometry_t force, bool emitJs)
 
982
{
 
983
    plainResize(s.width(), s.height(), force, emitJs);
 
984
}
 
985
 
 
986
inline void Client::resizeWithChecks(const QSize& s, ForceGeometry_t force)
 
987
{
 
988
    resizeWithChecks(s.width(), s.height(), force);
 
989
}
 
990
 
 
991
inline bool Client::hasUserTimeSupport() const
 
992
{
 
993
    return info->userTime() != -1U;
 
994
}
 
995
 
 
996
inline bool Client::ignoreFocusStealing() const
 
997
{
 
998
    return ignore_focus_stealing;
 
999
}
 
1000
 
 
1001
inline const WindowRules* Client::rules() const
 
1002
{
 
1003
    return &client_rules;
 
1004
}
 
1005
 
 
1006
KWIN_PROCEDURE(CheckIgnoreFocusStealingProcedure, Client, cl->ignore_focus_stealing = options->checkIgnoreFocusStealing(cl));
 
1007
 
 
1008
inline Window Client::moveResizeGrabWindow() const
 
1009
{
 
1010
    return move_resize_grab_window;
 
1011
}
 
1012
 
 
1013
inline KShortcut Client::shortcut() const
 
1014
{
 
1015
    return _shortcut;
 
1016
}
 
1017
 
 
1018
inline void Client::removeRule(Rules* rule)
 
1019
{
 
1020
    client_rules.remove(rule);
 
1021
}
 
1022
 
 
1023
inline bool Client::hiddenPreview() const
 
1024
{
 
1025
    return mapping_state == Kept;
 
1026
}
 
1027
 
 
1028
KWIN_COMPARE_PREDICATE(WrapperIdMatchPredicate, Client, Window, cl->wrapperId() == value);
 
1029
 
 
1030
} // namespace
 
1031
 
 
1032
#endif