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

« back to all changes in this revision

Viewing changes to layers.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:
92
92
#include "effects.h"
93
93
#include "composite.h"
94
94
#include "screenedge.h"
 
95
#if HAVE_WAYLAND
 
96
#include "shell_client.h"
 
97
#include "wayland_server.h"
 
98
#endif
95
99
 
96
100
#include <QDebug>
97
101
 
102
106
// Workspace
103
107
//*******************************
104
108
 
105
 
void Workspace::updateClientLayer(Client* c)
 
109
void Workspace::updateClientLayer(AbstractClient* c)
106
110
{
107
111
    if (c)
108
112
        c->updateLayer();
281
285
    return NULL;
282
286
}
283
287
 
284
 
void Workspace::raiseOrLowerClient(Client *c)
 
288
void Workspace::raiseOrLowerClient(AbstractClient *c)
285
289
{
286
290
    if (!c) return;
287
 
    Client* topmost = NULL;
 
291
    AbstractClient* topmost = NULL;
288
292
// TODO    Q_ASSERT( block_stacking_updates == 0 );
289
293
    if (most_recently_raised && stacking_order.contains(most_recently_raised) &&
290
294
            most_recently_raised->isShown(true) && c->isOnCurrentDesktop())
300
304
}
301
305
 
302
306
 
303
 
void Workspace::lowerClient(Client* c, bool nogroup)
 
307
void Workspace::lowerClient(AbstractClient* c, bool nogroup)
304
308
{
305
309
    if (!c)
306
310
        return;
313
317
    unconstrained_stacking_order.prepend(c);
314
318
    if (!nogroup && c->isTransient()) {
315
319
        // lower also all windows in the group, in their reversed stacking order
316
 
        ClientList wins = ensureStackingOrder(c->group()->members());
 
320
        ClientList wins = ensureStackingOrder(static_cast<Client*>(c)->group()->members());
317
321
        for (int i = wins.size() - 1;
318
322
                i >= 0;
319
323
                --i) {
356
360
    // ignore mainwindows
357
361
}
358
362
 
359
 
void Workspace::raiseClient(Client* c, bool nogroup)
 
363
void Workspace::raiseClient(AbstractClient* c, bool nogroup)
360
364
{
361
365
    if (!c)
362
366
        return;
367
371
 
368
372
    if (!nogroup && c->isTransient()) {
369
373
        ClientList transients;
370
 
        Client *transient_parent = c;
 
374
        Client *transient_parent = static_cast<Client*>(c);
371
375
        while ((transient_parent = transient_parent->transientFor()))
372
376
            transients << transient_parent;
373
377
        foreach (transient_parent, transients)
431
435
}
432
436
 
433
437
 
434
 
void Workspace::restack(Client* c, Client* under, bool force)
 
438
void Workspace::restack(AbstractClient* c, AbstractClient* under, bool force)
435
439
{
436
440
    assert(unconstrained_stacking_order.contains(under));
437
 
    if (!force && !Client::belongToSameApplication(under, c)) {
 
441
    if (!force && !AbstractClient::belongToSameApplication(under, c)) {
438
442
         // put in the stacking order below _all_ windows belonging to the active application
439
443
        for (int i = 0; i < unconstrained_stacking_order.size(); ++i) {
440
 
            Client *other = qobject_cast<Client*>(unconstrained_stacking_order.at(i));
441
 
            if (other && other->layer() == c->layer() && Client::belongToSameApplication(under, other)) {
 
444
            AbstractClient *other = qobject_cast<AbstractClient*>(unconstrained_stacking_order.at(i));
 
445
            if (other && other->layer() == c->layer() && AbstractClient::belongToSameApplication(under, other)) {
442
446
                under = (c == other) ? 0 : other;
443
447
                break;
444
448
            }
454
458
    updateStackingOrder();
455
459
}
456
460
 
457
 
void Workspace::restackClientUnderActive(Client* c)
 
461
void Workspace::restackClientUnderActive(AbstractClient* c)
458
462
{
459
463
    if (!active_client || active_client == c || active_client->layer() != c->layer()) {
460
464
        raiseClient(c);
688
692
            }
689
693
        }
690
694
    }
 
695
#if HAVE_WAYLAND
 
696
    if (waylandServer()) {
 
697
        const auto clients = waylandServer()->internalClients();
 
698
        for (auto c: clients) {
 
699
            x_stacking << c;
 
700
        }
 
701
    }
 
702
#endif
691
703
    if (m_compositor) {
692
704
        const_cast< Workspace* >(this)->m_compositor->checkUnredirect();
693
705
    }
773
785
        sendSyntheticConfigureNotify();
774
786
}
775
787
 
776
 
void Client::setKeepAbove(bool b)
 
788
void Client::doSetKeepAbove()
777
789
{
778
 
    b = rules()->checkKeepAbove(b);
779
 
    if (b && !rules()->checkKeepBelow(false))
780
 
        setKeepBelow(false);
781
 
    if (b == keepAbove()) {
782
 
        // force hint change if different
783
 
        if (bool(info->state() & NET::KeepAbove) != keepAbove())
784
 
            info->setState(keepAbove() ? NET::KeepAbove : NET::States(0), NET::KeepAbove);
785
 
        return;
786
 
    }
787
 
    keep_above = b;
788
 
    info->setState(keepAbove() ? NET::KeepAbove : NET::States(0), NET::KeepAbove);
789
 
    workspace()->updateClientLayer(this);
790
 
    updateWindowRules(Rules::Above);
791
 
 
792
790
    // Update states of all other windows in this group
793
791
    if (tabGroup())
794
792
        tabGroup()->updateStates(this, TabGroup::Layer);
795
 
    emit keepAboveChanged(keep_above);
796
793
}
797
794
 
798
 
void Client::setKeepBelow(bool b)
 
795
void Client::doSetKeepBelow()
799
796
{
800
 
    b = rules()->checkKeepBelow(b);
801
 
    if (b && !rules()->checkKeepAbove(false))
802
 
        setKeepAbove(false);
803
 
    if (b == keepBelow()) {
804
 
        // force hint change if different
805
 
        if (bool(info->state() & NET::KeepBelow) != keepBelow())
806
 
            info->setState(keepBelow() ? NET::KeepBelow : NET::States(0), NET::KeepBelow);
807
 
        return;
808
 
    }
809
 
    keep_below = b;
810
 
    info->setState(keepBelow() ? NET::KeepBelow : NET::States(0), NET::KeepBelow);
811
 
    workspace()->updateClientLayer(this);
812
 
    updateWindowRules(Rules::Below);
813
 
 
814
797
    // Update states of all other windows in this group
815
798
    if (tabGroup())
816
799
        tabGroup()->updateStates(this, TabGroup::Layer);
817
 
    emit keepBelowChanged(keep_below);
818
800
}
819
801
 
820
802
Layer Client::layer() const
893
875
    if (!isFullScreen())
894
876
        return false;
895
877
 
896
 
    const Client* ac = workspace()->mostRecentlyActivatedClient(); // instead of activeClient() - avoids flicker
 
878
    const Client* ac = dynamic_cast<Client*>(workspace()->mostRecentlyActivatedClient()); // instead of activeClient() - avoids flicker
897
879
    // according to NETWM spec implementation notes suggests
898
880
    // "focused windows having state _NET_WM_STATE_FULLSCREEN" to be on the highest layer.
899
881
    // we'll also take the screen into account