~ubuntu-branches/ubuntu/wily/kwin/wily-proposed

« back to all changes in this revision

Viewing changes to effects.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2015-08-10 23:16:37 UTC
  • mfrom: (1.1.10)
  • Revision ID: package-import@ubuntu.com-20150810231637-5zb2tstjkez93hml
Tags: 4:5.3.95-0ubuntu1
new upstream beta release

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
#include "xcbutils.h"
58
58
#if HAVE_WAYLAND
59
59
#include "abstract_backend.h"
 
60
#include "shell_client.h"
60
61
#include "wayland_server.h"
61
62
#endif
62
63
 
220
221
    connect(ws, &Workspace::showingDesktopChanged,
221
222
            this, &EffectsHandlerImpl::showingDesktopChanged);
222
223
    connect(ws, &Workspace::currentDesktopChanged, this,
223
 
        [this](int old, Client *c) {
 
224
        [this](int old, AbstractClient *c) {
224
225
            const int newDesktop = VirtualDesktopManager::self()->current();
225
226
            if (old != 0 && newDesktop != old) {
226
227
                emit desktopChanged(old, newDesktop, c ? c->effectWindow() : 0);
230
231
        }
231
232
    );
232
233
    connect(ws, &Workspace::desktopPresenceChanged, this,
233
 
        [this](Client *c, int old) {
 
234
        [this](AbstractClient *c, int old) {
234
235
            if (!c->effectWindow()) {
235
236
                return;
236
237
            }
237
 
            emit desktopPresenceChanged(c->effectWindow(), old, c->desktop());
 
238
            // the visibility update hasn't happed yet, thus the signal is delayed to prevent glitches, see also BUG 347490
 
239
            QMetaObject::invokeMethod(this, "desktopPresenceChanged", Qt::QueuedConnection,
 
240
                                      Q_ARG(KWin::EffectWindow*, c->effectWindow()),
 
241
                                      Q_ARG(int, old),
 
242
                                      Q_ARG(int, c->desktop()));
238
243
        }
239
244
    );
240
245
    connect(ws, &Workspace::clientAdded, this,
252
257
        }
253
258
    );
254
259
    connect(ws, &Workspace::clientActivated, this,
255
 
        [this](KWin::Client *c) {
 
260
        [this](KWin::AbstractClient *c) {
256
261
            emit windowActivated(c ? c->effectWindow() : nullptr);
257
262
        }
258
263
    );
275
280
    connect(screens(), &Screens::sizeChanged,     this, &EffectsHandler::virtualScreenSizeChanged);
276
281
    connect(screens(), &Screens::geometryChanged, this, &EffectsHandler::virtualScreenGeometryChanged);
277
282
#ifdef KWIN_BUILD_ACTIVITIES
278
 
    Activities *activities = Activities::self();
279
 
    connect(activities, &Activities::added,          this, &EffectsHandler::activityAdded);
280
 
    connect(activities, &Activities::removed,        this, &EffectsHandler::activityRemoved);
281
 
    connect(activities, &Activities::currentChanged, this, &EffectsHandler::currentActivityChanged);
 
283
    if (Activities *activities = Activities::self()) {
 
284
        connect(activities, &Activities::added,          this, &EffectsHandler::activityAdded);
 
285
        connect(activities, &Activities::removed,        this, &EffectsHandler::activityRemoved);
 
286
        connect(activities, &Activities::currentChanged, this, &EffectsHandler::currentActivityChanged);
 
287
    }
282
288
#endif
283
289
    connect(ws, &Workspace::stackingOrderChanged, this, &EffectsHandler::stackingOrderChanged);
284
290
#ifdef KWIN_BUILD_TABBOX
297
303
    for (Unmanaged *u : ws->unmanagedList()) {
298
304
        setupUnmanagedConnections(u);
299
305
    }
 
306
#if HAVE_WAYLAND
 
307
    if (auto w = waylandServer()) {
 
308
        connect(w, &WaylandServer::shellClientAdded, this,
 
309
            [this](ShellClient *c) {
 
310
                if (c->readyForPainting())
 
311
                    slotShellClientShown(c);
 
312
                else
 
313
                    connect(c, &Toplevel::windowShown, this, &EffectsHandlerImpl::slotShellClientShown);
 
314
            }
 
315
        );
 
316
    }
 
317
#endif
300
318
    reconfigure();
301
319
}
302
320
 
322
340
void EffectsHandlerImpl::setupClientConnections(Client* c)
323
341
{
324
342
    connect(c, &Client::windowClosed, this, &EffectsHandlerImpl::slotWindowClosed);
325
 
    connect(c, static_cast<void (Client::*)(KWin::Client*, MaximizeMode)>(&Client::clientMaximizedStateChanged),
 
343
    connect(c, static_cast<void (Client::*)(KWin::AbstractClient*, MaximizeMode)>(&Client::clientMaximizedStateChanged),
326
344
            this, &EffectsHandlerImpl::slotClientMaximized);
327
345
    connect(c, &Client::clientStartUserMovedResized, this,
328
346
        [this](Client *c) {
341
359
    );
342
360
    connect(c, &Client::opacityChanged, this, &EffectsHandlerImpl::slotOpacityChanged);
343
361
    connect(c, &Client::clientMinimized, this,
344
 
        [this](Client *c, bool animate) {
 
362
        [this](AbstractClient *c, bool animate) {
345
363
            // TODO: notify effects even if it should not animate?
346
364
            if (animate) {
347
365
                emit windowMinimized(c->effectWindow());
349
367
        }
350
368
    );
351
369
    connect(c, &Client::clientUnminimized, this,
352
 
        [this](Client* c, bool animate) {
 
370
        [this](AbstractClient* c, bool animate) {
353
371
            // TODO: notify effects even if it should not animate?
354
372
            if (animate) {
355
373
                emit windowUnminimized(c->effectWindow());
523
541
    m_currentPaintEffectFrameIterator = m_activeEffects.constBegin();
524
542
}
525
543
 
526
 
void EffectsHandlerImpl::slotClientMaximized(KWin::Client *c, MaximizeMode maxMode)
 
544
void EffectsHandlerImpl::slotClientMaximized(KWin::AbstractClient *c, MaximizeMode maxMode)
527
545
{
528
546
    bool horizontal = false;
529
547
    bool vertical = false;
565
583
        emit windowAdded(c->effectWindow());
566
584
}
567
585
 
 
586
void EffectsHandlerImpl::slotShellClientShown(Toplevel *t)
 
587
{
 
588
#if HAVE_WAYLAND
 
589
    ShellClient *c = static_cast<ShellClient*>(t);
 
590
    connect(c, &ShellClient::windowClosed, this, &EffectsHandlerImpl::slotWindowClosed);
 
591
    connect(c, &ShellClient::geometryShapeChanged, this, &EffectsHandlerImpl::slotGeometryShapeChanged);
 
592
    connect(c, static_cast<void (ShellClient::*)(KWin::AbstractClient*, MaximizeMode)>(&Client::clientMaximizedStateChanged),
 
593
            this, &EffectsHandlerImpl::slotClientMaximized);
 
594
    emit windowAdded(t->effectWindow());
 
595
#endif
 
596
}
 
597
 
568
598
void EffectsHandlerImpl::slotUnmanagedShown(KWin::Toplevel *t)
569
599
{   // regardless, unmanaged windows are -yet?- not synced anyway
570
600
    Q_ASSERT(dynamic_cast<Unmanaged*>(t));
847
877
 
848
878
void EffectsHandlerImpl::activateWindow(EffectWindow* c)
849
879
{
850
 
    if (Client* cl = dynamic_cast< Client* >(static_cast<EffectWindowImpl*>(c)->window()))
 
880
    if (AbstractClient* cl = dynamic_cast< AbstractClient* >(static_cast<EffectWindowImpl*>(c)->window()))
851
881
        Workspace::self()->activateClient(cl, true);
852
882
}
853
883
 
890
920
QString EffectsHandlerImpl::currentActivity() const
891
921
{
892
922
#ifdef KWIN_BUILD_ACTIVITIES
 
923
    if (!Activities::self()) {
 
924
        return QString();
 
925
    }
893
926
    return Activities::self()->current();
894
927
#else
895
928
    return QString();
1005
1038
        return w->effectWindow();
1006
1039
    if (Unmanaged* w = Workspace::self()->findUnmanaged(id))
1007
1040
        return w->effectWindow();
 
1041
#if HAVE_WAYLAND
 
1042
    if (waylandServer()) {
 
1043
        if (ShellClient *w = waylandServer()->findClient(id)) {
 
1044
            return w->effectWindow();
 
1045
        }
 
1046
    }
 
1047
#endif
1008
1048
    return NULL;
1009
1049
}
1010
1050
 
1050
1090
{
1051
1091
#ifdef KWIN_BUILD_TABBOX
1052
1092
    EffectWindowList ret;
1053
 
    ClientList clients;
1054
 
    clients = TabBox::TabBox::self()->currentClientList();
1055
 
    for (Client * c : clients)
 
1093
    const auto clients = TabBox::TabBox::self()->currentClientList();
 
1094
    for (auto c : clients)
1056
1095
    ret.append(c->effectWindow());
1057
1096
    return ret;
1058
1097
#else
1100
1139
EffectWindow* EffectsHandlerImpl::currentTabBoxWindow() const
1101
1140
{
1102
1141
#ifdef KWIN_BUILD_TABBOX
1103
 
    if (Client* c = TabBox::TabBox::self()->currentClient())
 
1142
    if (auto c = TabBox::TabBox::self()->currentClient())
1104
1143
        return c->effectWindow();
1105
1144
#endif
1106
1145
    return NULL;
1610
1649
 
1611
1650
EffectWindow* EffectWindowImpl::findModal()
1612
1651
{
1613
 
    if (Client* c = dynamic_cast< Client* >(toplevel)) {
1614
 
        if (Client* c2 = c->findModal())
 
1652
    if (AbstractClient* c = dynamic_cast< AbstractClient* >(toplevel)) {
 
1653
        if (AbstractClient* c2 = c->findModal())
1615
1654
            return c2->effectWindow();
1616
1655
    }
1617
1656
    return NULL;