Changeset View
Changeset View
Standalone View
Standalone View
effects.cpp
Show First 20 Lines • Show All 1640 Lines • ▼ Show 20 Line(s) | |||||
1641 | 1641 | | |||
1642 | EffectWindowImpl::~EffectWindowImpl() | 1642 | EffectWindowImpl::~EffectWindowImpl() | ||
1643 | { | 1643 | { | ||
1644 | QVariant cachedTextureVariant = data(LanczosCacheRole); | 1644 | QVariant cachedTextureVariant = data(LanczosCacheRole); | ||
1645 | if (cachedTextureVariant.isValid()) { | 1645 | if (cachedTextureVariant.isValid()) { | ||
1646 | GLTexture *cachedTexture = static_cast< GLTexture*>(cachedTextureVariant.value<void*>()); | 1646 | GLTexture *cachedTexture = static_cast< GLTexture*>(cachedTextureVariant.value<void*>()); | ||
1647 | delete cachedTexture; | 1647 | delete cachedTexture; | ||
1648 | } | 1648 | } | ||
1649 | } | 1649 | } | ||
zzag: Because we're inside of KWin, we can just use qobject_cast. :-) | |||||
1650 | 1650 | | |||
1651 | bool EffectWindowImpl::isPaintingEnabled() | 1651 | bool EffectWindowImpl::isPaintingEnabled() | ||
1652 | { | 1652 | { | ||
1653 | return sceneWindow()->isPaintingEnabled(); | 1653 | return sceneWindow()->isPaintingEnabled(); | ||
1654 | } | 1654 | } | ||
1655 | 1655 | | |||
1656 | void EffectWindowImpl::enablePainting(int reason) | 1656 | void EffectWindowImpl::enablePainting(int reason) | ||
1657 | { | 1657 | { | ||
1658 | sceneWindow()->enablePainting(reason); | 1658 | sceneWindow()->enablePainting(reason); | ||
1659 | } | 1659 | } | ||
1660 | 1660 | | |||
1661 | void EffectWindowImpl::disablePainting(int reason) | 1661 | void EffectWindowImpl::disablePainting(int reason) | ||
1662 | { | 1662 | { | ||
1663 | sceneWindow()->disablePainting(reason); | 1663 | sceneWindow()->disablePainting(reason); | ||
1664 | } | 1664 | } | ||
1665 | 1665 | | |||
1666 | const EffectWindowGroup* EffectWindowImpl::group() const | 1666 | const EffectWindowGroup* EffectWindowImpl::group() const | ||
1667 | { | 1667 | { | ||
1668 | if (Client* c = dynamic_cast< Client* >(toplevel)) | 1668 | if (Client* c = dynamic_cast< Client* >(toplevel)) | ||
1669 | return c->group()->effectGroup(); | 1669 | return c->group()->effectGroup(); | ||
1670 | return NULL; // TODO | 1670 | return nullptr; // TODO | ||
1671 | } | 1671 | } | ||
1672 | 1672 | | |||
1673 | void EffectWindowImpl::refWindow() | 1673 | void EffectWindowImpl::refWindow() | ||
1674 | { | 1674 | { | ||
1675 | if (Deleted* d = dynamic_cast< Deleted* >(toplevel)) | 1675 | if (Deleted* d = dynamic_cast< Deleted* >(toplevel)) | ||
1676 | return d->refWindow(); | 1676 | return d->refWindow(); | ||
1677 | abort(); // TODO | 1677 | abort(); // TODO | ||
1678 | } | 1678 | } | ||
1679 | 1679 | | |||
1680 | void EffectWindowImpl::unrefWindow() | 1680 | void EffectWindowImpl::unrefWindow() | ||
1681 | { | 1681 | { | ||
1682 | if (Deleted* d = dynamic_cast< Deleted* >(toplevel)) | 1682 | if (Deleted* d = dynamic_cast< Deleted* >(toplevel)) | ||
1683 | return d->unrefWindow(); // delays deletion in case | 1683 | return d->unrefWindow(); // delays deletion in case | ||
1684 | abort(); // TODO | 1684 | abort(); // TODO | ||
1685 | } | 1685 | } | ||
1686 | 1686 | | |||
1687 | #define WINDOW_HELPER( rettype, prototype, toplevelPrototype) \ | ||||
1688 | rettype EffectWindowImpl::prototype ( ) const \ | ||||
1689 | { \ | ||||
1690 | return toplevel->toplevelPrototype(); \ | ||||
1691 | } | ||||
1692 | | ||||
1693 | WINDOW_HELPER(double, opacity, opacity) | ||||
1694 | WINDOW_HELPER(bool, hasAlpha, hasAlpha) | ||||
1695 | WINDOW_HELPER(int, x, x) | ||||
1696 | WINDOW_HELPER(int, y, y) | ||||
1697 | WINDOW_HELPER(int, width, width) | ||||
1698 | WINDOW_HELPER(int, height, height) | ||||
1699 | WINDOW_HELPER(QPoint, pos, pos) | ||||
1700 | WINDOW_HELPER(QSize, size, size) | ||||
1701 | WINDOW_HELPER(int, screen, screen) | ||||
1702 | WINDOW_HELPER(QRect, geometry, geometry) | ||||
1703 | WINDOW_HELPER(QRect, expandedGeometry, visibleRect) | ||||
1704 | WINDOW_HELPER(QRect, rect, rect) | ||||
1705 | WINDOW_HELPER(int, desktop, desktop) | ||||
1706 | WINDOW_HELPER(bool, isDesktop, isDesktop) | ||||
1707 | WINDOW_HELPER(bool, isDock, isDock) | ||||
1708 | WINDOW_HELPER(bool, isToolbar, isToolbar) | ||||
1709 | WINDOW_HELPER(bool, isMenu, isMenu) | ||||
1710 | WINDOW_HELPER(bool, isNormalWindow, isNormalWindow) | ||||
1711 | WINDOW_HELPER(bool, isDialog, isDialog) | ||||
1712 | WINDOW_HELPER(bool, isSplash, isSplash) | ||||
1713 | WINDOW_HELPER(bool, isUtility, isUtility) | ||||
1714 | WINDOW_HELPER(bool, isDropdownMenu, isDropdownMenu) | ||||
1715 | WINDOW_HELPER(bool, isPopupMenu, isPopupMenu) | ||||
1716 | WINDOW_HELPER(bool, isTooltip, isTooltip) | ||||
1717 | WINDOW_HELPER(bool, isNotification, isNotification) | ||||
1718 | WINDOW_HELPER(bool, isOnScreenDisplay, isOnScreenDisplay) | ||||
1719 | WINDOW_HELPER(bool, isComboBox, isComboBox) | ||||
1720 | WINDOW_HELPER(bool, isDNDIcon, isDNDIcon) | ||||
1721 | WINDOW_HELPER(bool, isDeleted, isDeleted) | ||||
1722 | WINDOW_HELPER(bool, hasOwnShape, shape) | ||||
1723 | WINDOW_HELPER(QString, windowRole, windowRole) | ||||
1724 | WINDOW_HELPER(QStringList, activities, activities) | ||||
1725 | WINDOW_HELPER(bool, skipsCloseAnimation, skipsCloseAnimation) | ||||
1726 | WINDOW_HELPER(KWayland::Server::SurfaceInterface *, surface, surface) | ||||
1727 | WINDOW_HELPER(QString, caption, caption); | ||||
1728 | WINDOW_HELPER(bool, isMinimized, isMinimized) | ||||
zzag: ```lang=cpp
#undef TOPLEVEL_HELPER
``` | |||||
1729 | WINDOW_HELPER(bool, keepAbove, keepAbove) | ||||
1730 | WINDOW_HELPER(bool, keepBelow, keepBelow) | ||||
1731 | WINDOW_HELPER(bool, isModal, isModal) | ||||
1732 | WINDOW_HELPER(bool, isFullScreen, isFullScreen) | ||||
1733 | WINDOW_HELPER(bool, isCurrentTab, isCurrentTab) | ||||
1734 | | ||||
1735 | //windowClass | ||||
zzag: We probably don't need this comment. | |||||
1736 | QString EffectWindowImpl::windowClass() const | ||||
1737 | { | ||||
1738 | return toplevel->resourceName() + QLatin1Char(' ') + toplevel->resourceClass(); | ||||
1739 | } | ||||
1740 | | ||||
1741 | QRect EffectWindowImpl::contentsRect() const | ||||
1742 | { | ||||
1743 | return QRect(toplevel->clientPos(), toplevel->clientSize()); | ||||
1744 | } | ||||
1745 | | ||||
1746 | NET::WindowType EffectWindowImpl::windowType() const | ||||
1747 | { | ||||
1748 | return toplevel->windowType(); | ||||
1749 | } | ||||
1750 | | ||||
1751 | #define WINDOW_HELPER_DEFAULT( rettype, prototype, propertyname, defaultValue ) \ | ||||
1752 | rettype EffectWindowImpl::prototype ( ) const \ | ||||
zzag: Please delete this comment when you're about to push this change. | |||||
1753 | { \ | ||||
1754 | auto client = qobject_cast<AbstractClient*>(toplevel); \ | ||||
1755 | if (!client) { \ | ||||
1756 | return defaultValue; \ | ||||
1757 | } \ | ||||
1758 | return client->propertyname(); \ | ||||
1759 | } | ||||
1760 | | ||||
1761 | WINDOW_HELPER_DEFAULT(bool, isMovable, isMovable, false) | ||||
1762 | WINDOW_HELPER_DEFAULT(bool, isMovableAcrossScreens, isMovableAcrossScreens, false) | ||||
1763 | WINDOW_HELPER_DEFAULT(bool, isUserMove, isMove, false) | ||||
1764 | WINDOW_HELPER_DEFAULT(bool, isUserResize, isResize, false) | ||||
1765 | WINDOW_HELPER_DEFAULT(QRect, iconGeometry, iconGeometry, QRect()) | ||||
1766 | WINDOW_HELPER_DEFAULT(bool, isSpecialWindow, isSpecialWindow, true) | ||||
1767 | WINDOW_HELPER_DEFAULT(bool, acceptsFocus, wantsInput, true) // We don't actually know... | ||||
1768 | WINDOW_HELPER_DEFAULT(QIcon, icon, icon, QIcon()) | ||||
1769 | WINDOW_HELPER_DEFAULT(bool, isSkipSwitcher, skipSwitcher, false) | ||||
1770 | WINDOW_HELPER_DEFAULT(bool, decorationHasAlpha, decorationHasAlpha, false) | ||||
1771 | WINDOW_HELPER_DEFAULT(bool, isUnresponsive, unresponsive, false) | ||||
1772 | | ||||
1773 | QSize EffectWindowImpl::basicUnit() const | ||||
1774 | { | ||||
1775 | if (auto client = qobject_cast<Client*>(toplevel)){ | ||||
zzag: Missing whitespace between the type and "*". | |||||
1776 | return client->basicUnit(); | ||||
1777 | } | ||||
1778 | return QSize(1,1); | ||||
1779 | } | ||||
1780 | | ||||
1687 | void EffectWindowImpl::setWindow(Toplevel* w) | 1781 | void EffectWindowImpl::setWindow(Toplevel* w) | ||
1688 | { | 1782 | { | ||
1689 | toplevel = w; | 1783 | toplevel = w; | ||
1690 | setParent(w); | 1784 | setParent(w); | ||
1691 | } | 1785 | } | ||
1692 | 1786 | | |||
1693 | void EffectWindowImpl::setSceneWindow(Scene::Window* w) | 1787 | void EffectWindowImpl::setSceneWindow(Scene::Window* w) | ||
1694 | { | 1788 | { | ||
▲ Show 20 Lines • Show All 193 Lines • ▼ Show 20 Line(s) | 1971 | { | |||
1888 | m_sceneFrame = Compositor::self()->scene()->createEffectFrame(this); | 1982 | m_sceneFrame = Compositor::self()->scene()->createEffectFrame(this); | ||
1889 | } | 1983 | } | ||
1890 | 1984 | | |||
1891 | EffectFrameImpl::~EffectFrameImpl() | 1985 | EffectFrameImpl::~EffectFrameImpl() | ||
1892 | { | 1986 | { | ||
1893 | delete m_sceneFrame; | 1987 | delete m_sceneFrame; | ||
1894 | } | 1988 | } | ||
1895 | 1989 | | |||
1896 | const QFont& EffectFrameImpl::font() const | 1990 | const QFont EffectFrameImpl::font() const | ||
1897 | { | 1991 | { | ||
1898 | return m_font; | 1992 | return m_font; | ||
1899 | } | 1993 | } | ||
1900 | 1994 | | |||
1901 | void EffectFrameImpl::setFont(const QFont& font) | 1995 | void EffectFrameImpl::setFont(const QFont& font) | ||
1902 | { | 1996 | { | ||
1903 | if (m_font == font) { | 1997 | if (m_font == font) { | ||
1904 | return; | 1998 | return; | ||
Show All 9 Lines | |||||
1914 | } | 2008 | } | ||
1915 | } | 2009 | } | ||
1916 | 2010 | | |||
1917 | void EffectFrameImpl::free() | 2011 | void EffectFrameImpl::free() | ||
1918 | { | 2012 | { | ||
1919 | m_sceneFrame->free(); | 2013 | m_sceneFrame->free(); | ||
1920 | } | 2014 | } | ||
1921 | 2015 | | |||
1922 | const QRect& EffectFrameImpl::geometry() const | 2016 | const QRect EffectFrameImpl::geometry() const | ||
1923 | { | 2017 | { | ||
1924 | return m_geometry; | 2018 | return m_geometry; | ||
1925 | } | 2019 | } | ||
1926 | 2020 | | |||
1927 | void EffectFrameImpl::setGeometry(const QRect& geometry, bool force) | 2021 | void EffectFrameImpl::setGeometry(const QRect& geometry, bool force) | ||
1928 | { | 2022 | { | ||
1929 | QRect oldGeom = m_geometry; | 2023 | QRect oldGeom = m_geometry; | ||
1930 | m_geometry = geometry; | 2024 | m_geometry = geometry; | ||
Show All 10 Lines | 2034 | if (m_style == EffectFrameStyled) { | |||
1941 | qreal left, top, right, bottom; | 2035 | qreal left, top, right, bottom; | ||
1942 | m_frame.getMargins(left, top, right, bottom); // m_geometry is the inner geometry | 2036 | m_frame.getMargins(left, top, right, bottom); // m_geometry is the inner geometry | ||
1943 | m_frame.resizeFrame(m_geometry.adjusted(-left, -top, right, bottom).size()); | 2037 | m_frame.resizeFrame(m_geometry.adjusted(-left, -top, right, bottom).size()); | ||
1944 | } | 2038 | } | ||
1945 | 2039 | | |||
1946 | free(); | 2040 | free(); | ||
1947 | } | 2041 | } | ||
1948 | 2042 | | |||
1949 | const QIcon& EffectFrameImpl::icon() const | 2043 | const QIcon EffectFrameImpl::icon() const | ||
1950 | { | 2044 | { | ||
1951 | return m_icon; | 2045 | return m_icon; | ||
1952 | } | 2046 | } | ||
1953 | 2047 | | |||
1954 | void EffectFrameImpl::setIcon(const QIcon& icon) | 2048 | void EffectFrameImpl::setIcon(const QIcon& icon) | ||
1955 | { | 2049 | { | ||
1956 | m_icon = icon; | 2050 | m_icon = icon; | ||
1957 | if (isCrossFade()) { | 2051 | if (isCrossFade()) { | ||
1958 | m_sceneFrame->crossFadeIcon(); | 2052 | m_sceneFrame->crossFadeIcon(); | ||
1959 | } | 2053 | } | ||
1960 | if (m_iconSize.isEmpty() && !m_icon.availableSizes().isEmpty()) { // Set a size if we don't already have one | 2054 | if (m_iconSize.isEmpty() && !m_icon.availableSizes().isEmpty()) { // Set a size if we don't already have one | ||
1961 | setIconSize(m_icon.availableSizes().first()); | 2055 | setIconSize(m_icon.availableSizes().first()); | ||
1962 | } | 2056 | } | ||
1963 | m_sceneFrame->freeIconFrame(); | 2057 | m_sceneFrame->freeIconFrame(); | ||
1964 | } | 2058 | } | ||
1965 | 2059 | | |||
1966 | const QSize& EffectFrameImpl::iconSize() const | 2060 | const QSize EffectFrameImpl::iconSize() const | ||
1967 | { | 2061 | { | ||
1968 | return m_iconSize; | 2062 | return m_iconSize; | ||
1969 | } | 2063 | } | ||
1970 | 2064 | | |||
1971 | void EffectFrameImpl::setIconSize(const QSize& size) | 2065 | void EffectFrameImpl::setIconSize(const QSize& size) | ||
1972 | { | 2066 | { | ||
1973 | if (m_iconSize == size) { | 2067 | if (m_iconSize == size) { | ||
1974 | return; | 2068 | return; | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | |||||
2034 | void EffectFrameImpl::setPosition(const QPoint& point) | 2128 | void EffectFrameImpl::setPosition(const QPoint& point) | ||
2035 | { | 2129 | { | ||
2036 | m_point = point; | 2130 | m_point = point; | ||
2037 | QRect geometry = m_geometry; // this is important, setGeometry need call repaint for old & new geometry | 2131 | QRect geometry = m_geometry; // this is important, setGeometry need call repaint for old & new geometry | ||
2038 | align(geometry); | 2132 | align(geometry); | ||
2039 | setGeometry(geometry); | 2133 | setGeometry(geometry); | ||
2040 | } | 2134 | } | ||
2041 | 2135 | | |||
2042 | const QString& EffectFrameImpl::text() const | 2136 | const QString EffectFrameImpl::text() const | ||
2043 | { | 2137 | { | ||
2044 | return m_text; | 2138 | return m_text; | ||
2045 | } | 2139 | } | ||
2046 | 2140 | | |||
2047 | void EffectFrameImpl::setText(const QString& text) | 2141 | void EffectFrameImpl::setText(const QString& text) | ||
2048 | { | 2142 | { | ||
2049 | if (m_text == text) { | 2143 | if (m_text == text) { | ||
2050 | return; | 2144 | return; | ||
▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines |
Because we're inside of KWin, we can just use qobject_cast. :-)