Changeset View
Changeset View
Standalone View
Standalone View
effects.cpp
Show First 20 Lines • Show All 1652 Lines • ▼ Show 20 Line(s) | |||||
1653 | 1653 | | |||
1654 | //**************************************** | 1654 | //**************************************** | ||
1655 | // EffectWindowImpl | 1655 | // EffectWindowImpl | ||
1656 | //**************************************** | 1656 | //**************************************** | ||
1657 | 1657 | | |||
1658 | EffectWindowImpl::EffectWindowImpl(Toplevel *toplevel) | 1658 | EffectWindowImpl::EffectWindowImpl(Toplevel *toplevel) | ||
1659 | : EffectWindow(toplevel) | 1659 | : EffectWindow(toplevel) | ||
1660 | , toplevel(toplevel) | 1660 | , toplevel(toplevel) | ||
1661 | , sw(NULL) | 1661 | , sw(nullptr) | ||
1662 | { | 1662 | { | ||
1663 | // Deleted windows are not managed. So, when windowClosed signal is | ||||
1664 | // emitted, effects can't distinguish managed windows from unmanaged | ||||
1665 | // windows(e.g. combo box popups, popup menus, etc). Save value of the | ||||
1666 | // managed property during construction of EffectWindow. At that time, | ||||
1667 | // parent can be Client, ShellClient, or Unmanaged. So, later on, when | ||||
1668 | // an instance of Deleted becomes parent of the EffectWindow, effects | ||||
1669 | // can still figure out whether it is/was a managed window. | ||||
1670 | managed = toplevel->isClient(); | ||||
1671 | | ||||
1672 | waylandClient = toplevel->inherits("KWin::ShellClient"); | ||||
zzag: Because we're inside of KWin, we can just use qobject_cast. :-) | |||||
1673 | x11Client = !waylandClient; | ||||
1663 | } | 1674 | } | ||
1664 | 1675 | | |||
1665 | EffectWindowImpl::~EffectWindowImpl() | 1676 | EffectWindowImpl::~EffectWindowImpl() | ||
1666 | { | 1677 | { | ||
1667 | QVariant cachedTextureVariant = data(LanczosCacheRole); | 1678 | QVariant cachedTextureVariant = data(LanczosCacheRole); | ||
1668 | if (cachedTextureVariant.isValid()) { | 1679 | if (cachedTextureVariant.isValid()) { | ||
1669 | GLTexture *cachedTexture = static_cast< GLTexture*>(cachedTextureVariant.value<void*>()); | 1680 | GLTexture *cachedTexture = static_cast< GLTexture*>(cachedTextureVariant.value<void*>()); | ||
1670 | delete cachedTexture; | 1681 | delete cachedTexture; | ||
Show All 14 Lines | |||||
1685 | { | 1696 | { | ||
1686 | sceneWindow()->disablePainting(reason); | 1697 | sceneWindow()->disablePainting(reason); | ||
1687 | } | 1698 | } | ||
1688 | 1699 | | |||
1689 | const EffectWindowGroup* EffectWindowImpl::group() const | 1700 | const EffectWindowGroup* EffectWindowImpl::group() const | ||
1690 | { | 1701 | { | ||
1691 | if (Client* c = dynamic_cast< Client* >(toplevel)) | 1702 | if (Client* c = dynamic_cast< Client* >(toplevel)) | ||
1692 | return c->group()->effectGroup(); | 1703 | return c->group()->effectGroup(); | ||
1693 | return NULL; // TODO | 1704 | return nullptr; // TODO | ||
1694 | } | 1705 | } | ||
1695 | 1706 | | |||
1696 | void EffectWindowImpl::refWindow() | 1707 | void EffectWindowImpl::refWindow() | ||
1697 | { | 1708 | { | ||
1698 | if (Deleted* d = dynamic_cast< Deleted* >(toplevel)) | 1709 | if (Deleted* d = dynamic_cast< Deleted* >(toplevel)) | ||
1699 | return d->refWindow(); | 1710 | return d->refWindow(); | ||
1700 | abort(); // TODO | 1711 | abort(); // TODO | ||
1701 | } | 1712 | } | ||
1702 | 1713 | | |||
1703 | void EffectWindowImpl::unrefWindow() | 1714 | void EffectWindowImpl::unrefWindow() | ||
1704 | { | 1715 | { | ||
1705 | if (Deleted* d = dynamic_cast< Deleted* >(toplevel)) | 1716 | if (Deleted* d = dynamic_cast< Deleted* >(toplevel)) | ||
1706 | return d->unrefWindow(); // delays deletion in case | 1717 | return d->unrefWindow(); // delays deletion in case | ||
1707 | abort(); // TODO | 1718 | abort(); // TODO | ||
1708 | } | 1719 | } | ||
1709 | 1720 | | |||
1721 | #define TOPLEVEL_HELPER( rettype, prototype, toplevelPrototype) \ | ||||
1722 | rettype EffectWindowImpl::prototype ( ) const \ | ||||
1723 | { \ | ||||
1724 | return toplevel->toplevelPrototype(); \ | ||||
1725 | } | ||||
1726 | | ||||
1727 | TOPLEVEL_HELPER(double, opacity, opacity) | ||||
1728 | TOPLEVEL_HELPER(bool, hasAlpha, hasAlpha) | ||||
1729 | TOPLEVEL_HELPER(int, x, x) | ||||
1730 | TOPLEVEL_HELPER(int, y, y) | ||||
1731 | TOPLEVEL_HELPER(int, width, width) | ||||
1732 | TOPLEVEL_HELPER(int, height, height) | ||||
1733 | TOPLEVEL_HELPER(QPoint, pos, pos) | ||||
1734 | TOPLEVEL_HELPER(QSize, size, size) | ||||
1735 | TOPLEVEL_HELPER(int, screen, screen) | ||||
1736 | TOPLEVEL_HELPER(QRect, geometry, geometry) | ||||
1737 | TOPLEVEL_HELPER(QRect, expandedGeometry, visibleRect) | ||||
1738 | TOPLEVEL_HELPER(QRect, rect, rect) | ||||
1739 | TOPLEVEL_HELPER(int, desktop, desktop) | ||||
1740 | TOPLEVEL_HELPER(bool, isDesktop, isDesktop) | ||||
1741 | TOPLEVEL_HELPER(bool, isDock, isDock) | ||||
1742 | TOPLEVEL_HELPER(bool, isToolbar, isToolbar) | ||||
1743 | TOPLEVEL_HELPER(bool, isMenu, isMenu) | ||||
1744 | TOPLEVEL_HELPER(bool, isNormalWindow, isNormalWindow) | ||||
1745 | TOPLEVEL_HELPER(bool, isDialog, isDialog) | ||||
1746 | TOPLEVEL_HELPER(bool, isSplash, isSplash) | ||||
1747 | TOPLEVEL_HELPER(bool, isUtility, isUtility) | ||||
1748 | TOPLEVEL_HELPER(bool, isDropdownMenu, isDropdownMenu) | ||||
1749 | TOPLEVEL_HELPER(bool, isPopupMenu, isPopupMenu) | ||||
1750 | TOPLEVEL_HELPER(bool, isTooltip, isTooltip) | ||||
1751 | TOPLEVEL_HELPER(bool, isNotification, isNotification) | ||||
1752 | TOPLEVEL_HELPER(bool, isOnScreenDisplay, isOnScreenDisplay) | ||||
1753 | TOPLEVEL_HELPER(bool, isComboBox, isComboBox) | ||||
1754 | TOPLEVEL_HELPER(bool, isDNDIcon, isDNDIcon) | ||||
1755 | TOPLEVEL_HELPER(bool, isDeleted, isDeleted) | ||||
1756 | TOPLEVEL_HELPER(bool, hasOwnShape, shape) | ||||
1757 | TOPLEVEL_HELPER(QString, windowRole, windowRole) | ||||
1758 | TOPLEVEL_HELPER(QStringList, activities, activities) | ||||
1759 | TOPLEVEL_HELPER(bool, skipsCloseAnimation, skipsCloseAnimation) | ||||
1760 | TOPLEVEL_HELPER(KWayland::Server::SurfaceInterface *, surface, surface) | ||||
1761 | TOPLEVEL_HELPER(bool, isPopupWindow, isPopupWindow) | ||||
1762 | | ||||
zzag: ```lang=cpp
#undef TOPLEVEL_HELPER
``` | |||||
1763 | #undef TOPLEVEL_HELPER | ||||
1764 | | ||||
1765 | #define CLIENT_HELPER_WITH_DELETED( rettype, prototype, propertyname, defaultValue ) \ | ||||
1766 | rettype EffectWindowImpl::prototype ( ) const \ | ||||
1767 | { \ | ||||
1768 | auto client = qobject_cast<AbstractClient*>(toplevel); \ | ||||
1769 | if (client) { \ | ||||
zzag: We probably don't need this comment. | |||||
1770 | return client->propertyname(); \ | ||||
1771 | } \ | ||||
1772 | auto deleted = qobject_cast<Deleted*>(toplevel); \ | ||||
1773 | if (deleted) { \ | ||||
1774 | return deleted->propertyname(); \ | ||||
1775 | } \ | ||||
1776 | return defaultValue; \ | ||||
1777 | } | ||||
1778 | | ||||
1779 | CLIENT_HELPER_WITH_DELETED(bool, isMinimized, isMinimized, false) | ||||
1780 | CLIENT_HELPER_WITH_DELETED(bool, isModal, isModal, false) | ||||
1781 | CLIENT_HELPER_WITH_DELETED(bool, isFullScreen, isFullScreen, false) | ||||
1782 | CLIENT_HELPER_WITH_DELETED(bool, isCurrentTab, isCurrentTab, false) | ||||
1783 | CLIENT_HELPER_WITH_DELETED(bool, keepAbove, keepAbove, false) | ||||
1784 | CLIENT_HELPER_WITH_DELETED(bool, keepBelow, keepBelow, false) | ||||
1785 | CLIENT_HELPER_WITH_DELETED(QString, caption, caption, QString()); | ||||
1786 | CLIENT_HELPER_WITH_DELETED(QVector<uint>, desktops, x11DesktopIds, QVector<uint>()); | ||||
zzag: Please delete this comment when you're about to push this change. | |||||
1787 | | ||||
1788 | #undef CLIENT_HELPER_WITH_DELETED | ||||
1789 | | ||||
1790 | QString EffectWindowImpl::windowClass() const | ||||
1791 | { | ||||
1792 | return toplevel->resourceName() + QLatin1Char(' ') + toplevel->resourceClass(); | ||||
1793 | } | ||||
1794 | | ||||
1795 | QRect EffectWindowImpl::contentsRect() const | ||||
1796 | { | ||||
1797 | return QRect(toplevel->clientPos(), toplevel->clientSize()); | ||||
1798 | } | ||||
1799 | | ||||
1800 | NET::WindowType EffectWindowImpl::windowType() const | ||||
1801 | { | ||||
1802 | return toplevel->windowType(); | ||||
1803 | } | ||||
1804 | | ||||
1805 | #define CLIENT_HELPER( rettype, prototype, propertyname, defaultValue ) \ | ||||
1806 | rettype EffectWindowImpl::prototype ( ) const \ | ||||
1807 | { \ | ||||
1808 | auto client = qobject_cast<AbstractClient*>(toplevel); \ | ||||
1809 | if (client) { \ | ||||
zzag: Missing whitespace between the type and "*". | |||||
1810 | return client->propertyname(); \ | ||||
1811 | } \ | ||||
1812 | return defaultValue; \ | ||||
1813 | } | ||||
1814 | | ||||
1815 | CLIENT_HELPER(bool, isMovable, isMovable, false) | ||||
1816 | CLIENT_HELPER(bool, isMovableAcrossScreens, isMovableAcrossScreens, false) | ||||
1817 | CLIENT_HELPER(bool, isUserMove, isMove, false) | ||||
1818 | CLIENT_HELPER(bool, isUserResize, isResize, false) | ||||
1819 | CLIENT_HELPER(QRect, iconGeometry, iconGeometry, QRect()) | ||||
1820 | CLIENT_HELPER(bool, isSpecialWindow, isSpecialWindow, true) | ||||
1821 | CLIENT_HELPER(bool, acceptsFocus, wantsInput, true) // We don't actually know... | ||||
1822 | CLIENT_HELPER(QIcon, icon, icon, QIcon()) | ||||
1823 | CLIENT_HELPER(bool, isSkipSwitcher, skipSwitcher, false) | ||||
1824 | CLIENT_HELPER(bool, decorationHasAlpha, decorationHasAlpha, false) | ||||
1825 | CLIENT_HELPER(bool, isUnresponsive, unresponsive, false) | ||||
1826 | | ||||
1827 | #undef CLIENT_HELPER | ||||
1828 | | ||||
1829 | QSize EffectWindowImpl::basicUnit() const | ||||
1830 | { | ||||
1831 | if (auto client = qobject_cast<Client*>(toplevel)){ | ||||
1832 | return client->basicUnit(); | ||||
1833 | } | ||||
1834 | return QSize(1,1); | ||||
1835 | } | ||||
1836 | | ||||
1710 | void EffectWindowImpl::setWindow(Toplevel* w) | 1837 | void EffectWindowImpl::setWindow(Toplevel* w) | ||
1711 | { | 1838 | { | ||
1712 | toplevel = w; | 1839 | toplevel = w; | ||
1713 | setParent(w); | 1840 | setParent(w); | ||
1714 | } | 1841 | } | ||
1715 | 1842 | | |||
1716 | void EffectWindowImpl::setSceneWindow(Scene::Window* w) | 1843 | void EffectWindowImpl::setSceneWindow(Scene::Window* w) | ||
1717 | { | 1844 | { | ||
▲ Show 20 Lines • Show All 145 Lines • ▼ Show 20 Line(s) | |||||
1863 | 1990 | | |||
1864 | void EffectWindowImpl::unreferencePreviousWindowPixmap() | 1991 | void EffectWindowImpl::unreferencePreviousWindowPixmap() | ||
1865 | { | 1992 | { | ||
1866 | if (sw) { | 1993 | if (sw) { | ||
1867 | sw->unreferencePreviousPixmap(); | 1994 | sw->unreferencePreviousPixmap(); | ||
1868 | } | 1995 | } | ||
1869 | } | 1996 | } | ||
1870 | 1997 | | |||
1998 | bool EffectWindowImpl::isManaged() const | ||||
1999 | { | ||||
2000 | return managed; | ||||
2001 | } | ||||
2002 | | ||||
2003 | bool EffectWindowImpl::isWaylandClient() const | ||||
2004 | { | ||||
2005 | return waylandClient; | ||||
2006 | } | ||||
2007 | | ||||
2008 | bool EffectWindowImpl::isX11Client() const | ||||
2009 | { | ||||
2010 | return x11Client; | ||||
2011 | } | ||||
2012 | | ||||
2013 | | ||||
1871 | //**************************************** | 2014 | //**************************************** | ||
1872 | // EffectWindowGroupImpl | 2015 | // EffectWindowGroupImpl | ||
1873 | //**************************************** | 2016 | //**************************************** | ||
1874 | 2017 | | |||
1875 | 2018 | | |||
1876 | EffectWindowList EffectWindowGroupImpl::members() const | 2019 | EffectWindowList EffectWindowGroupImpl::members() const | ||
1877 | { | 2020 | { | ||
1878 | const auto memberList = group->members(); | 2021 | const auto memberList = group->members(); | ||
▲ Show 20 Lines • Show All 248 Lines • Show Last 20 Lines |
Because we're inside of KWin, we can just use qobject_cast. :-)