Changeset View
Changeset View
Standalone View
Standalone View
workspace.cpp
1 | /******************************************************************** | 1 | /******************************************************************** | ||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | 2 | KWin - the KDE window manager | ||
3 | This file is part of the KDE project. | 3 | This file is part of the KDE project. | ||
4 | 4 | | |||
5 | Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org> | 5 | Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org> | ||
6 | Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org> | 6 | Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org> | ||
7 | Copyright (C) 2019 Vlad Zagorodniy <vladzzag@gmail.com> | ||||
7 | 8 | | |||
8 | This program is free software; you can redistribute it and/or modify | 9 | 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 | 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 | the Free Software Foundation; either version 2 of the License, or | ||
11 | (at your option) any later version. | 12 | (at your option) any later version. | ||
12 | 13 | | |||
13 | This program is distributed in the hope that it will be useful, | 14 | This program is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
Show All 17 Lines | |||||
32 | #include "composite.h" | 33 | #include "composite.h" | ||
33 | #include "cursor.h" | 34 | #include "cursor.h" | ||
34 | #include "dbusinterface.h" | 35 | #include "dbusinterface.h" | ||
35 | #include "deleted.h" | 36 | #include "deleted.h" | ||
36 | #include "effects.h" | 37 | #include "effects.h" | ||
37 | #include "focuschain.h" | 38 | #include "focuschain.h" | ||
38 | #include "group.h" | 39 | #include "group.h" | ||
39 | #include "input.h" | 40 | #include "input.h" | ||
41 | #include "internal_client.h" | ||||
40 | #include "logind.h" | 42 | #include "logind.h" | ||
41 | #include "moving_client_x11_filter.h" | 43 | #include "moving_client_x11_filter.h" | ||
42 | #include "killwindow.h" | 44 | #include "killwindow.h" | ||
43 | #include "netinfo.h" | 45 | #include "netinfo.h" | ||
44 | #include "outline.h" | 46 | #include "outline.h" | ||
45 | #include "placement.h" | 47 | #include "placement.h" | ||
46 | #include "rules.h" | 48 | #include "rules.h" | ||
47 | #include "screenedge.h" | 49 | #include "screenedge.h" | ||
▲ Show 20 Lines • Show All 509 Lines • ▼ Show 20 Line(s) | 535 | { | |||
557 | } | 559 | } | ||
558 | Client::cleanupX11(); | 560 | Client::cleanupX11(); | ||
559 | 561 | | |||
560 | if (waylandServer()) { | 562 | if (waylandServer()) { | ||
561 | const QList<ShellClient *> shellClients = waylandServer()->clients(); | 563 | const QList<ShellClient *> shellClients = waylandServer()->clients(); | ||
562 | for (ShellClient *shellClient : shellClients) { | 564 | for (ShellClient *shellClient : shellClients) { | ||
563 | shellClient->destroyClient(); | 565 | shellClient->destroyClient(); | ||
564 | } | 566 | } | ||
565 | | ||||
566 | const QList<ShellClient *> internalClients = waylandServer()->internalClients(); | | |||
567 | for (ShellClient *internalClient : internalClients) { | | |||
568 | internalClient->destroyClient(); | | |||
569 | } | | |||
570 | } | 567 | } | ||
571 | 568 | | |||
572 | for (UnmanagedList::iterator it = unmanaged.begin(), end = unmanaged.end(); it != end; ++it) | 569 | for (UnmanagedList::iterator it = unmanaged.begin(), end = unmanaged.end(); it != end; ++it) | ||
573 | (*it)->release(ReleaseReason::KWinShutsDown); | 570 | (*it)->release(ReleaseReason::KWinShutsDown); | ||
574 | 571 | | |||
572 | for (InternalClient *client : m_internalClients) { | ||||
573 | client->destroyClient(); | ||||
574 | } | ||||
575 | | ||||
575 | if (auto c = kwinApp()->x11Connection()) { | 576 | if (auto c = kwinApp()->x11Connection()) { | ||
576 | xcb_delete_property(c, kwinApp()->x11RootWindow(), atoms->kwin_running); | 577 | xcb_delete_property(c, kwinApp()->x11RootWindow(), atoms->kwin_running); | ||
577 | } | 578 | } | ||
578 | 579 | | |||
579 | for (auto it = deleted.begin(); it != deleted.end();) { | 580 | for (auto it = deleted.begin(); it != deleted.end();) { | ||
580 | emit deletedRemoved(*it); | 581 | emit deletedRemoved(*it); | ||
581 | it = deleted.erase(it); | 582 | it = deleted.erase(it); | ||
582 | } | 583 | } | ||
▲ Show 20 Lines • Show All 1079 Lines • ▼ Show 20 Line(s) | |||||
1662 | AbstractClient *Workspace::findAbstractClient(std::function<bool (const AbstractClient*)> func) const | 1663 | AbstractClient *Workspace::findAbstractClient(std::function<bool (const AbstractClient*)> func) const | ||
1663 | { | 1664 | { | ||
1664 | if (AbstractClient *ret = Toplevel::findInList(m_allClients, func)) { | 1665 | if (AbstractClient *ret = Toplevel::findInList(m_allClients, func)) { | ||
1665 | return ret; | 1666 | return ret; | ||
1666 | } | 1667 | } | ||
1667 | if (Client *ret = Toplevel::findInList(desktops, func)) { | 1668 | if (Client *ret = Toplevel::findInList(desktops, func)) { | ||
1668 | return ret; | 1669 | return ret; | ||
1669 | } | 1670 | } | ||
1670 | if (waylandServer()) { | 1671 | if (InternalClient *ret = Toplevel::findInList(m_internalClients, func)) { | ||
1671 | if (AbstractClient *ret = Toplevel::findInList(waylandServer()->internalClients(), func)) { | | |||
1672 | return ret; | 1672 | return ret; | ||
1673 | } | 1673 | } | ||
1674 | } | | |||
1675 | return nullptr; | 1674 | return nullptr; | ||
1676 | } | 1675 | } | ||
1677 | 1676 | | |||
1678 | Unmanaged *Workspace::findUnmanaged(std::function<bool (const Unmanaged*)> func) const | 1677 | Unmanaged *Workspace::findUnmanaged(std::function<bool (const Unmanaged*)> func) const | ||
1679 | { | 1678 | { | ||
1680 | return Toplevel::findInList(unmanaged, func); | 1679 | return Toplevel::findInList(unmanaged, func); | ||
1681 | } | 1680 | } | ||
1682 | 1681 | | |||
Show All 33 Lines | 1714 | if (Client *ret = Toplevel::findInList(clients, func)) { | |||
1716 | return ret; | 1715 | return ret; | ||
1717 | } | 1716 | } | ||
1718 | if (Client *ret = Toplevel::findInList(desktops, func)) { | 1717 | if (Client *ret = Toplevel::findInList(desktops, func)) { | ||
1719 | return ret; | 1718 | return ret; | ||
1720 | } | 1719 | } | ||
1721 | if (Unmanaged *ret = Toplevel::findInList(unmanaged, func)) { | 1720 | if (Unmanaged *ret = Toplevel::findInList(unmanaged, func)) { | ||
1722 | return ret; | 1721 | return ret; | ||
1723 | } | 1722 | } | ||
1724 | return nullptr; | 1723 | if (InternalClient *ret = Toplevel::findInList(m_internalClients, func)) { | ||
1724 | return ret; | ||||
1725 | } | 1725 | } | ||
1726 | | ||||
1727 | Toplevel *Workspace::findToplevel(QWindow *w) const | | |||
1728 | { | | |||
1729 | if (!w) { | | |||
1730 | return nullptr; | 1726 | return nullptr; | ||
1731 | } | 1727 | } | ||
1732 | if (waylandServer()) { | | |||
1733 | if (auto c = waylandServer()->findClient(w)) { | | |||
1734 | return c; | | |||
1735 | } | | |||
1736 | } | | |||
1737 | return findUnmanaged(w->winId()); | | |||
1738 | } | | |||
1739 | 1728 | | |||
1740 | bool Workspace::hasClient(const AbstractClient *c) | 1729 | bool Workspace::hasClient(const AbstractClient *c) | ||
1741 | { | 1730 | { | ||
1742 | if (auto cc = dynamic_cast<const Client*>(c)) { | 1731 | if (auto cc = dynamic_cast<const Client*>(c)) { | ||
1743 | return hasClient(cc); | 1732 | return hasClient(cc); | ||
1744 | } else { | 1733 | } else { | ||
1745 | return findAbstractClient([c](const AbstractClient *test) { | 1734 | return findAbstractClient([c](const AbstractClient *test) { | ||
1746 | return test == c; | 1735 | return test == c; | ||
1747 | }) != nullptr; | 1736 | }) != nullptr; | ||
1748 | } | 1737 | } | ||
1749 | return false; | 1738 | return false; | ||
1750 | } | 1739 | } | ||
1751 | 1740 | | |||
1752 | void Workspace::forEachAbstractClient(std::function< void (AbstractClient*) > func) | 1741 | void Workspace::forEachAbstractClient(std::function< void (AbstractClient*) > func) | ||
1753 | { | 1742 | { | ||
1754 | std::for_each(m_allClients.constBegin(), m_allClients.constEnd(), func); | 1743 | std::for_each(m_allClients.constBegin(), m_allClients.constEnd(), func); | ||
1755 | std::for_each(desktops.constBegin(), desktops.constEnd(), func); | 1744 | std::for_each(desktops.constBegin(), desktops.constEnd(), func); | ||
1745 | std::for_each(m_internalClients.constBegin(), m_internalClients.constEnd(), func); | ||||
1756 | } | 1746 | } | ||
1757 | 1747 | | |||
1758 | Toplevel *Workspace::findInternal(QWindow *w) const | 1748 | Toplevel *Workspace::findInternal(QWindow *w) const | ||
1759 | { | 1749 | { | ||
1760 | if (!w) { | 1750 | if (!w) { | ||
1761 | return nullptr; | 1751 | return nullptr; | ||
1762 | } | 1752 | } | ||
1763 | if (kwinApp()->operationMode() == Application::OperationModeX11) { | 1753 | if (kwinApp()->operationMode() == Application::OperationModeX11) { | ||
1764 | return findUnmanaged(w->winId()); | 1754 | return findUnmanaged(w->winId()); | ||
1765 | } else { | | |||
1766 | return waylandServer()->findClient(w); | | |||
1767 | } | 1755 | } | ||
1756 | for (InternalClient *client : m_internalClients) { | ||||
1757 | if (client->internalWindow() == w) { | ||||
1758 | return client; | ||||
1759 | } | ||||
1760 | } | ||||
1761 | return nullptr; | ||||
1768 | } | 1762 | } | ||
1769 | 1763 | | |||
1770 | bool Workspace::compositing() const | 1764 | bool Workspace::compositing() const | ||
1771 | { | 1765 | { | ||
1772 | return m_compositor && m_compositor->scene(); | 1766 | return m_compositor && m_compositor->scene(); | ||
1773 | } | 1767 | } | ||
1774 | 1768 | | |||
1775 | void Workspace::markXStackingOrderAsDirty() | 1769 | void Workspace::markXStackingOrderAsDirty() | ||
Show All 23 Lines | |||||
1799 | #ifdef KWIN_BUILD_TABBOX | 1793 | #ifdef KWIN_BUILD_TABBOX | ||
1800 | TabBox::TabBox *tabBox = TabBox::TabBox::self(); | 1794 | TabBox::TabBox *tabBox = TabBox::TabBox::self(); | ||
1801 | if (tabBox && tabBox->isDisplayed()) { | 1795 | if (tabBox && tabBox->isDisplayed()) { | ||
1802 | tabBox->reset(true); | 1796 | tabBox->reset(true); | ||
1803 | } | 1797 | } | ||
1804 | #endif | 1798 | #endif | ||
1805 | } | 1799 | } | ||
1806 | 1800 | | |||
1807 | } // namespace | 1801 | void Workspace::addInternalClient(InternalClient *client) | ||
1802 | { | ||||
1803 | m_internalClients.append(client); | ||||
1804 | | ||||
1805 | setupClientConnections(client); | ||||
1806 | client->updateLayer(); | ||||
1807 | | ||||
1808 | if (client->isDecorated()) { | ||||
1809 | client->keepInArea(clientArea(FullScreenArea, client)); | ||||
1810 | } | ||||
1808 | 1811 | | |||
1812 | markXStackingOrderAsDirty(); | ||||
1813 | updateStackingOrder(true); | ||||
1814 | updateClientArea(); | ||||
1815 | | ||||
1816 | emit internalClientAdded(client); | ||||
1817 | } | ||||
1818 | | ||||
1819 | void Workspace::removeInternalClient(InternalClient *client) | ||||
1820 | { | ||||
1821 | m_internalClients.removeOne(client); | ||||
1822 | | ||||
1823 | markXStackingOrderAsDirty(); | ||||
1824 | updateStackingOrder(true); | ||||
1825 | updateClientArea(); | ||||
1826 | | ||||
1827 | emit internalClientRemoved(client); | ||||
1828 | } | ||||
1829 | | ||||
1830 | } // namespace |