diff --git a/app/view/effects.cpp b/app/view/effects.cpp index c0843265..5b4f56fe 100644 --- a/app/view/effects.cpp +++ b/app/view/effects.cpp @@ -1,522 +1,509 @@ /* * Copyright 2018 Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "effects.h" // local #include "panelshadows_p.h" #include "view.h" #include "settings/primaryconfigview.h" #include "../../liblatte2/types.h" // Qt #include // KDE #include #include namespace Latte { namespace ViewPart { Effects::Effects(Latte::View *parent) : QObject(parent), m_view(parent) { init(); } Effects::~Effects() { } void Effects::init() { connect(this, &Effects::backgroundOpacityChanged, this, &Effects::updateEffects); connect(this, &Effects::drawEffectsChanged, this, &Effects::updateEffects); connect(this, &Effects::rectChanged, this, &Effects::updateEffects); connect(this, &Effects::settingsMaskSubtractedChanged, this, &Effects::updateMask); connect(this, &Effects::drawShadowsChanged, this, [&]() { if (m_view->behaveAsPlasmaPanel()) { updateEnabledBorders(); } }); connect(m_view, &Latte::View::alignmentChanged, this, &Effects::updateEnabledBorders); connect(m_view, &Latte::View::behaveAsPlasmaPanelChanged, this, &Effects::updateEffects); connect(m_view, &Latte::View::behaveAsPlasmaPanelChanged, this, &Effects::updateShadows); connect(m_view, &Latte::View::configWindowGeometryChanged, this, &Effects::updateMask); } bool Effects::animationsBlocked() const { return m_animationsBlocked; } void Effects::setAnimationsBlocked(bool blocked) { if (m_animationsBlocked == blocked) { return; } m_animationsBlocked = blocked; emit animationsBlockedChanged(); } bool Effects::drawShadows() const { return m_drawShadows; } void Effects::setDrawShadows(bool draw) { if (m_drawShadows == draw) { return; } m_drawShadows = draw; if (m_view->behaveAsPlasmaPanel() && m_drawShadows) { PanelShadows::self()->addWindow(m_view, m_enabledBorders); } else { PanelShadows::self()->removeWindow(m_view); } emit drawShadowsChanged(); } bool Effects::drawEffects() const { return m_drawEffects; } void Effects::setDrawEffects(bool draw) { if (m_drawEffects == draw) { return; } m_drawEffects = draw; emit drawEffectsChanged(); } bool Effects::forceDrawCenteredBorders() const { return m_forceDrawCenteredBorders; } void Effects::setForceDrawCenteredBorders(bool draw) { if (m_forceDrawCenteredBorders == draw) { return; } m_forceDrawCenteredBorders = draw; } int Effects::backgroundOpacity() const { return m_backgroundOpacity; } void Effects::setBackgroundOpacity(int opacity) { if (m_backgroundOpacity == opacity) { return; } m_backgroundOpacity = opacity; emit backgroundOpacityChanged(); } int Effects::editShadow() const { return m_editShadow; } void Effects::setEditShadow(int shadow) { if (m_editShadow == shadow) { return; } m_editShadow = shadow; emit editShadowChanged(); } int Effects::innerShadow() const { return m_innerShadow; } void Effects::setInnerShadow(int shadow) { if (m_innerShadow == shadow) return; m_innerShadow = shadow; emit innerShadowChanged(); } bool Effects::settingsMaskSubtracted() const { return m_settingsMaskSubtracted; } void Effects::setSettingsMaskSubtracted(bool enabled) { if (m_settingsMaskSubtracted == enabled) { return; } m_settingsMaskSubtracted = enabled; emit settingsMaskSubtractedChanged(); } QRegion Effects::subtrackedMaskFromWindow(QRegion initialRegion, QQuickView *window) { QRegion subtractedMask = initialRegion; int start; int length; if (m_view->formFactor() == Plasma::Types::Horizontal) { if (KWindowSystem::isPlatformX11()) { start = window->x(); length = window->width(); } else { start = m_view->x(); length = m_view->width(); } } else { if (KWindowSystem::isPlatformX11()) { start = window->y(); length = window->height(); } else { start = m_view->y(); length = m_view->height(); } } if (m_settingsMaskSubtracted && window) { QRect windowMask; //! we need to subtrack the mask areas that overlap with underlying window switch (m_view->location()) { - case Plasma::Types::TopEdge: - windowMask.setTopLeft(QPoint(start - m_view->x(), m_mask.y() + m_mask.height() - m_editShadow)); - windowMask.setSize(QSize(length, m_editShadow)); - break; - - case Plasma::Types::LeftEdge: - windowMask.setTopLeft(QPoint(m_mask.right() + 1 - m_editShadow, start - m_view->y())); - windowMask.setSize(QSize(m_editShadow, length)); - break; - - case Plasma::Types::RightEdge: - windowMask.setTopLeft(QPoint(m_mask.x(), start - m_view->y())); - windowMask.setSize(QSize(m_editShadow, length)); - break; - - case Plasma::Types::BottomEdge: - windowMask.setTopLeft(QPoint(start - m_view->x(), m_mask.y())); - windowMask.setSize(QSize(length, m_editShadow)); - break; - - default: - break; + case Plasma::Types::TopEdge: + windowMask.setTopLeft(QPoint(start - m_view->x(), m_mask.y() + m_mask.height() - m_editShadow)); + windowMask.setSize(QSize(length, m_editShadow)); + break; + + case Plasma::Types::LeftEdge: + windowMask.setTopLeft(QPoint(m_mask.right() + 1 - m_editShadow, start - m_view->y())); + windowMask.setSize(QSize(m_editShadow, length)); + break; + + case Plasma::Types::RightEdge: + windowMask.setTopLeft(QPoint(m_mask.x(), start - m_view->y())); + windowMask.setSize(QSize(m_editShadow, length)); + break; + + case Plasma::Types::BottomEdge: + windowMask.setTopLeft(QPoint(start - m_view->x(), m_mask.y())); + windowMask.setSize(QSize(length, m_editShadow)); + break; + + default: + break; } subtractedMask = subtractedMask.subtracted(windowMask); } return subtractedMask; } QRegion Effects::subtractedMask() { QRegion subMask = m_mask; if (m_settingsMaskSubtracted && m_view->configView()) { subMask = subtrackedMaskFromWindow(subMask, m_view->configView()); ViewPart::PrimaryConfigView *primaryConfig = qobject_cast(m_view->configView()); if (primaryConfig && m_view->formFactor() == Plasma::Types::Horizontal && primaryConfig->secondaryWindow()) { subMask = subtrackedMaskFromWindow(subMask, primaryConfig->secondaryWindow()); } } return subMask; } QRect Effects::rect() const { return m_rect; } void Effects::setRect(QRect area) { if (KWindowSystem::compositingActive()) { QRect inWindowRect = area.intersected(QRect(0, 0, m_view->width(), m_view->height())); if (m_rect == inWindowRect) { return; } m_rect = inWindowRect; } else { if (m_rect == area) { return; } m_rect = area; } emit rectChanged(); } QRect Effects::mask() const { return m_mask; } void Effects::setMask(QRect area) { if (m_mask == area) return; m_mask = area; updateMask(); // qDebug() << "dock mask set:" << m_mask; emit maskChanged(); } void Effects::forceMaskRedraw() { if (m_background) { delete m_background; } m_background = new Plasma::FrameSvg(this); m_background->setImagePath(QStringLiteral("widgets/panel-background")); m_background->setEnabledBorders(m_enabledBorders); updateMask(); } void Effects::updateMask() { if (KWindowSystem::compositingActive()) { if (m_view->behaveAsPlasmaPanel()) { m_view->setMask(QRect()); } else { m_view->setMask(subtractedMask()); } } else { //! this is used when compositing is disabled and provides //! the correct way for the mask to be painted in order for //! rounded corners to be shown correctly //! the enabledBorders check was added because there was cases //! that the mask region wasn't calculated correctly after location changes if (!m_background) { if (m_background && m_background->enabledBorders() != m_enabledBorders) { delete m_background; } m_background = new Plasma::FrameSvg(this); } if (m_background->imagePath() != "widgets/panel-background") { m_background->setImagePath(QStringLiteral("widgets/panel-background")); } m_background->setEnabledBorders(m_enabledBorders); m_background->resizeFrame(m_mask.size()); QRegion fixedMask = m_background->mask(); fixedMask.translate(m_mask.x(), m_mask.y()); //! fix for KF5.32 that return empty QRegion's for the mask if (fixedMask.isEmpty()) { fixedMask = QRegion(m_mask); } m_view->setMask(fixedMask); } } void Effects::clearShadows() { PanelShadows::self()->removeWindow(m_view); } void Effects::updateShadows() { if (m_view->behaveAsPlasmaPanel() && drawShadows()) { PanelShadows::self()->addWindow(m_view, enabledBorders()); } else { PanelShadows::self()->removeWindow(m_view); } } void Effects::updateEffects() { //! Don't apply any effect before the wayland surface is created under wayland //! https://bugs.kde.org/show_bug.cgi?id=392890 if (KWindowSystem::isPlatformWayland() && !m_view->surface()) { return; } - if (!m_view->behaveAsPlasmaPanel()) { - if (m_drawEffects && !m_rect.isNull() && !m_rect.isEmpty()) { - //! this is used when compositing is disabled and provides - //! the correct way for the mask to be painted in order for - //! rounded corners to be shown correctly - if (!m_background) { - m_background = new Plasma::FrameSvg(this); - } - - if (m_background->imagePath() != "widgets/panel-background") { - m_background->setImagePath(QStringLiteral("widgets/panel-background")); - } + if (m_drawEffects && !m_rect.isNull() && !m_rect.isEmpty()) { + //! this is used when compositing is disabled and provides + //! the correct way for the mask to be painted in order for + //! rounded corners to be shown correctly + if (!m_background) { + m_background = new Plasma::FrameSvg(this); + } - m_background->setEnabledBorders(m_enabledBorders); - m_background->resizeFrame(m_rect.size()); - QRegion fixedMask = m_background->mask(); - fixedMask.translate(m_rect.x(), m_rect.y()); + if (m_background->imagePath() != "widgets/panel-background") { + m_background->setImagePath(QStringLiteral("widgets/panel-background")); + } - //! fix1, for KF5.32 that return empty QRegion's for the mask - if (fixedMask.isEmpty()) { - fixedMask = QRegion(m_rect); - } + m_background->setEnabledBorders(m_enabledBorders); + m_background->resizeFrame(m_rect.size()); + QRegion fixedMask = m_background->mask(); + fixedMask.translate(m_rect.x(), m_rect.y()); - KWindowEffects::enableBlurBehind(m_view->winId(), true, fixedMask); - - bool drawBackgroundEffect = m_theme.backgroundContrastEnabled() && (m_backgroundOpacity == 100); - //based on Breeze Dark theme behavior the enableBackgroundContrast even though it does accept - //a QRegion it uses only the first rect. The bug was that for Breeze Dark there was a line - //at the dock bottom that was distinguishing it from other themes - KWindowEffects::enableBackgroundContrast(m_view->winId(), drawBackgroundEffect, - m_theme.backgroundContrast(), - m_theme.backgroundIntensity(), - m_theme.backgroundSaturation(), - fixedMask.boundingRect()); - } else { - KWindowEffects::enableBlurBehind(m_view->winId(), false); - KWindowEffects::enableBackgroundContrast(m_view->winId(), false); + //! fix1, for KF5.32 that return empty QRegion's for the mask + if (fixedMask.isEmpty()) { + fixedMask = QRegion(m_rect); } - } else if (m_view->behaveAsPlasmaPanel() && m_drawEffects) { - KWindowEffects::enableBlurBehind(m_view->winId(), true); - bool drawBackgroundEffect = m_theme.backgroundContrastEnabled() && (m_backgroundOpacity == 100); + KWindowEffects::enableBlurBehind(m_view->winId(), true, fixedMask); - KWindowEffects::enableBackgroundContrast(m_view->winId(), drawBackgroundEffect, - m_theme.backgroundContrast(), - m_theme.backgroundIntensity(), - m_theme.backgroundSaturation()); + bool drawBackgroundEffect = m_theme.backgroundContrastEnabled() && (m_backgroundOpacity == 100); + //based on Breeze Dark theme behavior the enableBackgroundContrast even though it does accept + //a QRegion it uses only the first rect. The bug was that for Breeze Dark there was a line + //at the dock bottom that was distinguishing it from other themes + KWindowEffects::enableBackgroundContrast(m_view->winId(), + drawBackgroundEffect, + m_theme.backgroundContrast(), + m_theme.backgroundIntensity(), + m_theme.backgroundSaturation(), + fixedMask); } else { KWindowEffects::enableBlurBehind(m_view->winId(), false); KWindowEffects::enableBackgroundContrast(m_view->winId(), false); } } //!BEGIN draw panel shadows outside the dock window Plasma::FrameSvg::EnabledBorders Effects::enabledBorders() const { return m_enabledBorders; } void Effects::updateEnabledBorders() { if (!m_view->screen()) { return; } Plasma::FrameSvg::EnabledBorders borders = Plasma::FrameSvg::AllBorders; switch (m_view->location()) { - case Plasma::Types::TopEdge: - borders &= ~Plasma::FrameSvg::TopBorder; - break; + case Plasma::Types::TopEdge: + borders &= ~Plasma::FrameSvg::TopBorder; + break; - case Plasma::Types::LeftEdge: - borders &= ~Plasma::FrameSvg::LeftBorder; - break; + case Plasma::Types::LeftEdge: + borders &= ~Plasma::FrameSvg::LeftBorder; + break; - case Plasma::Types::RightEdge: - borders &= ~Plasma::FrameSvg::RightBorder; - break; + case Plasma::Types::RightEdge: + borders &= ~Plasma::FrameSvg::RightBorder; + break; - case Plasma::Types::BottomEdge: - borders &= ~Plasma::FrameSvg::BottomBorder; - break; + case Plasma::Types::BottomEdge: + borders &= ~Plasma::FrameSvg::BottomBorder; + break; - default: - break; + default: + break; } if ((m_view->location() == Plasma::Types::LeftEdge || m_view->location() == Plasma::Types::RightEdge)) { if (m_view->maxLength() == 1 && m_view->alignment() == Latte::Types::Justify && !m_forceDrawCenteredBorders) { borders &= ~Plasma::FrameSvg::TopBorder; borders &= ~Plasma::FrameSvg::BottomBorder; } if (m_view->alignment() == Latte::Types::Top && !m_forceDrawCenteredBorders && m_view->offset() == 0) { borders &= ~Plasma::FrameSvg::TopBorder; } if (m_view->alignment() == Latte::Types::Bottom && !m_forceDrawCenteredBorders && m_view->offset() == 0) { borders &= ~Plasma::FrameSvg::BottomBorder; } } if (m_view->location() == Plasma::Types::TopEdge || m_view->location() == Plasma::Types::BottomEdge) { if (m_view->maxLength() == 1 && m_view->alignment() == Latte::Types::Justify) { borders &= ~Plasma::FrameSvg::LeftBorder; borders &= ~Plasma::FrameSvg::RightBorder; } if (m_view->alignment() == Latte::Types::Left && m_view->offset() == 0) { borders &= ~Plasma::FrameSvg::LeftBorder; } if (m_view->alignment() == Latte::Types::Right && m_view->offset() == 0) { borders &= ~Plasma::FrameSvg::RightBorder; } } if (m_enabledBorders != borders) { m_enabledBorders = borders; emit enabledBordersChanged(); } if (!m_view->behaveAsPlasmaPanel() || !m_drawShadows) { PanelShadows::self()->removeWindow(m_view); } else { PanelShadows::self()->setEnabledBorders(m_view, borders); } } //!END draw panel shadows outside the dock window } } diff --git a/app/wm/xwindowinterface.cpp b/app/wm/xwindowinterface.cpp index d68fc9b8..40351bd4 100644 --- a/app/wm/xwindowinterface.cpp +++ b/app/wm/xwindowinterface.cpp @@ -1,674 +1,669 @@ /* * Copyright 2016 Smith AR * Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "xwindowinterface.h" // local #include "tasktools.h" #include "view/screenedgeghostwindow.h" #include "view/view.h" #include "../liblatte2/extras.h" // Qt #include #include #include // KDE #include #include #include #include // X11 #include #include namespace Latte { namespace WindowSystem { XWindowInterface::XWindowInterface(QObject *parent) : AbstractWindowInterface(parent) { m_currentDesktop = QString(KWindowSystem::self()->currentDesktop()); connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged, this, &AbstractWindowInterface::activeWindowChanged); connect(KWindowSystem::self(), &KWindowSystem::windowAdded, this, &AbstractWindowInterface::windowAdded); connect(KWindowSystem::self(), &KWindowSystem::windowRemoved, this, &AbstractWindowInterface::windowRemoved); connect(KWindowSystem::self(), &KWindowSystem::currentDesktopChanged, this, [&](int desktop) { m_currentDesktop = QString(desktop); emit currentDesktopChanged(); }); connect(KWindowSystem::self() , static_cast (&KWindowSystem::windowChanged) , this, &XWindowInterface::windowChangedProxy); } XWindowInterface::~XWindowInterface() { } void XWindowInterface::setViewExtraFlags(QWindow &view) { NETWinInfo winfo(QX11Info::connection() , static_cast(view.winId()) , static_cast(view.winId()) , 0, 0); winfo.setAllowedActions(NET::ActionChangeDesktop); KWindowSystem::setType(view.winId(), NET::Dock); KWindowSystem::setState(view.winId(), NET::SkipTaskbar | NET::SkipPager); KWindowSystem::setOnAllDesktops(view.winId(), true); } void XWindowInterface::setViewStruts(QWindow &view, const QRect &rect , Plasma::Types::Location location) { NETExtendedStrut strut; const auto screen = view.screen(); const QRect currentScreen {screen->geometry()}; const QRect wholeScreen {{0, 0}, screen->virtualSize()}; - //! WORKAROUND in order to fix KWin faulty behavior concerning struts - //! under !compositing mode. Under !compositing mode, kwin removes 1px. - //! from the struts - const int strutsGap = KWindowSystem::compositingActive ? 1 : 2; - switch (location) { case Plasma::Types::TopEdge: { const int topOffset {screen->geometry().top()}; strut.top_width = rect.height() + topOffset; strut.top_start = rect.x(); - strut.top_end = rect.x() + rect.width() - strutsGap; + strut.top_end = rect.x() + rect.width() - 1; break; } case Plasma::Types::BottomEdge: { const int bottomOffset {wholeScreen.bottom() - currentScreen.bottom()}; strut.bottom_width = rect.height() + bottomOffset; strut.bottom_start = rect.x(); - strut.bottom_end = rect.x() + rect.width() - strutsGap; + strut.bottom_end = rect.x() + rect.width() - 1; break; } case Plasma::Types::LeftEdge: { const int leftOffset = {screen->geometry().left()}; strut.left_width = rect.width() + leftOffset; strut.left_start = rect.y(); - strut.left_end = rect.y() + rect.height() - strutsGap; + strut.left_end = rect.y() + rect.height() - 1; break; } case Plasma::Types::RightEdge: { const int rightOffset = {wholeScreen.right() - currentScreen.right()}; strut.right_width = rect.width() + rightOffset; strut.right_start = rect.y(); - strut.right_end = rect.y() + rect.height() - strutsGap; + strut.right_end = rect.y() + rect.height() - 1; break; } default: qWarning() << "wrong location:" << qEnumToStr(location); return; } KWindowSystem::setExtendedStrut(view.winId(), strut.left_width, strut.left_start, strut.left_end, strut.right_width, strut.right_start, strut.right_end, strut.top_width, strut.top_start, strut.top_end, strut.bottom_width, strut.bottom_start, strut.bottom_end ); } void XWindowInterface::switchToNextVirtualDesktop() const { int desktops = KWindowSystem::numberOfDesktops(); if (desktops <= 1) { return; } int curPos = KWindowSystem::currentDesktop(); int nextPos = curPos + 1; if (curPos == desktops) { nextPos = 1; } KWindowSystem::setCurrentDesktop(nextPos); } void XWindowInterface::switchToPreviousVirtualDesktop() const { int desktops = KWindowSystem::numberOfDesktops(); if (desktops <= 1) { return; } int curPos = KWindowSystem::currentDesktop(); int nextPos = curPos - 1; if (curPos == 1) { nextPos = desktops; } KWindowSystem::setCurrentDesktop(nextPos); } void XWindowInterface::setWindowOnActivities(QWindow &window, const QStringList &activities) { KWindowSystem::setOnActivities(window.winId(), activities); } void XWindowInterface::removeViewStruts(QWindow &view) const { KWindowSystem::setStrut(view.winId(), 0, 0, 0, 0); } WindowId XWindowInterface::activeWindow() const { return KWindowSystem::self()->activeWindow(); } void XWindowInterface::setKeepAbove(const QDialog &dialog, bool above) const { if (above) { KWindowSystem::setState(dialog.winId(), NET::KeepAbove); } else { KWindowSystem::clearState(dialog.winId(), NET::KeepAbove); } } void XWindowInterface::skipTaskBar(const QDialog &dialog) const { KWindowSystem::setState(dialog.winId(), NET::SkipTaskbar); } void XWindowInterface::slideWindow(QWindow &view, AbstractWindowInterface::Slide location) const { auto slideLocation = KWindowEffects::NoEdge; switch (location) { case Slide::Top: slideLocation = KWindowEffects::TopEdge; break; case Slide::Bottom: slideLocation = KWindowEffects::BottomEdge; break; case Slide::Left: slideLocation = KWindowEffects::LeftEdge; break; case Slide::Right: slideLocation = KWindowEffects::RightEdge; break; default: break; } KWindowEffects::slideWindow(view.winId(), slideLocation, -1); } void XWindowInterface::enableBlurBehind(QWindow &view) const { KWindowEffects::enableBlurBehind(view.winId()); } void XWindowInterface::setEdgeStateFor(QWindow *view, bool active) const { ViewPart::ScreenEdgeGhostWindow *window = qobject_cast(view); if (!window) { return; } xcb_connection_t *c = QX11Info::connection(); const QByteArray effectName = QByteArrayLiteral("_KDE_NET_WM_SCREEN_EDGE_SHOW"); xcb_intern_atom_cookie_t atomCookie = xcb_intern_atom_unchecked(c, false, effectName.length(), effectName.constData()); QScopedPointer atom(xcb_intern_atom_reply(c, atomCookie, nullptr)); if (!atom) { return; } if (!active) { xcb_delete_property(c, window->winId(), atom->atom); window->hideWithMask(); return; } window->showWithMask(); uint32_t value = 0; switch (window->location()) { case Plasma::Types::TopEdge: value = 0; break; case Plasma::Types::RightEdge: value = 1; break; case Plasma::Types::BottomEdge: value = 2; break; case Plasma::Types::LeftEdge: value = 3; break; case Plasma::Types::Floating: default: value = 4; break; } int hideType = 0; value |= hideType << 8; xcb_change_property(c, XCB_PROP_MODE_REPLACE, window->winId(), atom->atom, XCB_ATOM_CARDINAL, 32, 1, &value); } WindowInfoWrap XWindowInterface::requestInfoActive() const { return requestInfo(KWindowSystem::activeWindow()); } WindowInfoWrap XWindowInterface::requestInfo(WindowId wid) const { const KWindowInfo winfo{wid.value(), NET::WMFrameExtents | NET::WMWindowType | NET::WMGeometry | NET::WMDesktop | NET::WMState | NET::WMName | NET::WMVisibleName, NET::WM2WindowClass | NET::WM2Activities}; //! update desktop id bool isPlasmaDesktop{false}; if (winfo.windowClassName() == "plasmashell" && hasScreenGeometry(winfo)) { isPlasmaDesktop = true; windowsTracker()->setPlasmaDesktop(wid); } WindowInfoWrap winfoWrap; if (isValidWindow(winfo) && !isPlasmaDesktop) { winfoWrap.setIsValid(true); winfoWrap.setWid(wid); winfoWrap.setIsActive(KWindowSystem::activeWindow() == wid.value()); winfoWrap.setIsMinimized(winfo.hasState(NET::Hidden)); winfoWrap.setIsMaxVert(winfo.hasState(NET::MaxVert)); winfoWrap.setIsMaxHoriz(winfo.hasState(NET::MaxHoriz)); winfoWrap.setIsFullscreen(winfo.hasState(NET::FullScreen)); winfoWrap.setIsShaded(winfo.hasState(NET::Shaded)); winfoWrap.setIsOnAllDesktops(winfo.onAllDesktops()); winfoWrap.setIsOnAllActivities(winfo.activities().empty()); winfoWrap.setGeometry(winfo.frameGeometry()); winfoWrap.setIsKeepAbove(winfo.hasState(NET::KeepAbove)); winfoWrap.setHasSkipTaskbar(winfo.hasState(NET::SkipTaskbar)); winfoWrap.setDisplay(winfo.visibleName()); winfoWrap.setDesktops({QString(winfo.desktop())}); winfoWrap.setActivities(winfo.activities()); } else if (m_desktopId == wid) { winfoWrap.setIsValid(true); winfoWrap.setIsPlasmaDesktop(true); winfoWrap.setWid(wid); winfoWrap.setHasSkipTaskbar(true); } return winfoWrap; } AppData XWindowInterface::appDataFor(WindowId wid) const { return appDataFromUrl(windowUrl(wid)); } QUrl XWindowInterface::windowUrl(WindowId wid) const { const KWindowInfo info(wid.value(), 0, NET::WM2WindowClass | NET::WM2DesktopFileName); QString desktopFile = QString::fromUtf8(info.desktopFileName()); if (!desktopFile.isEmpty()) { KService::Ptr service = KService::serviceByStorageId(desktopFile); if (service) { const QString &menuId = service->menuId(); // applications: URLs are used to refer to applications by their KService::menuId // (i.e. .desktop file name) rather than the absolute path to a .desktop file. if (!menuId.isEmpty()) { return QUrl(QStringLiteral("applications:") + menuId); } return QUrl::fromLocalFile(service->entryPath()); } if (!desktopFile.endsWith(QLatin1String(".desktop"))) { desktopFile.append(QLatin1String(".desktop")); } if (KDesktopFile::isDesktopFile(desktopFile) && QFile::exists(desktopFile)) { return QUrl::fromLocalFile(desktopFile); } } return windowUrlFromMetadata(info.windowClassClass(), NETWinInfo(QX11Info::connection(), wid.value(), QX11Info::appRootWindow(), NET::WMPid, NET::Properties2()).pid(), rulesConfig, info.windowClassName()); } bool XWindowInterface::windowCanBeDragged(WindowId wid) const { WindowInfoWrap winfo = requestInfo(wid); return (winfo.isValid() && !winfo.isMinimized() && !winfo.isPlasmaDesktop()); } void XWindowInterface::releaseMouseEventFor(WindowId wid) const { auto connection = QX11Info::connection(); xcb_button_release_event_t releaseEvent; memset(&releaseEvent, 0, sizeof(releaseEvent)); releaseEvent.response_type = XCB_BUTTON_RELEASE; releaseEvent.event = wid.toInt(); releaseEvent.child = XCB_WINDOW_NONE; releaseEvent.root = QX11Info::appRootWindow(); releaseEvent.event_x = -1; releaseEvent.event_y = -1; releaseEvent.root_x = -1; releaseEvent.root_y = -1; releaseEvent.detail = XCB_BUTTON_INDEX_1; releaseEvent.state = XCB_BUTTON_MASK_1; releaseEvent.time = XCB_CURRENT_TIME; releaseEvent.same_screen = true; xcb_send_event( connection, false, wid.toInt(), XCB_EVENT_MASK_BUTTON_RELEASE, reinterpret_cast(&releaseEvent)); } void XWindowInterface::requestActivate(WindowId wid) const { KWindowSystem::activateWindow(wid.toInt()); } QIcon XWindowInterface::iconFor(WindowId wid) const { QIcon icon; icon.addPixmap(KWindowSystem::icon(wid.value(), KIconLoader::SizeSmall, KIconLoader::SizeSmall, false)); icon.addPixmap(KWindowSystem::icon(wid.value(), KIconLoader::SizeSmallMedium, KIconLoader::SizeSmallMedium, false)); icon.addPixmap(KWindowSystem::icon(wid.value(), KIconLoader::SizeMedium, KIconLoader::SizeMedium, false)); icon.addPixmap(KWindowSystem::icon(wid.value(), KIconLoader::SizeLarge, KIconLoader::SizeLarge, false)); return icon; } WindowId XWindowInterface::winIdFor(QString appId, QRect geometry) const { return activeWindow(); } void XWindowInterface::requestClose(WindowId wid) const { WindowInfoWrap wInfo = requestInfo(wid); if (!wInfo.isValid() || wInfo.isPlasmaDesktop()) { return; } NETRootInfo ri(QX11Info::connection(), NET::CloseWindow); ri.closeWindowRequest(wInfo.wid().toUInt()); } void XWindowInterface::requestMoveWindow(WindowId wid, QPoint from) const { WindowInfoWrap wInfo = requestInfo(wid); if (!wInfo.isValid() || wInfo.isPlasmaDesktop()) { return; } int borderX{wInfo.geometry().width() > 120 ? 60 : 10}; int borderY{10}; //! find min/max values for x,y based on active window geometry int minX = wInfo.geometry().x() + borderX; int maxX = wInfo.geometry().x() + wInfo.geometry().width() - borderX; int minY = wInfo.geometry().y() + borderY; int maxY = wInfo.geometry().y() + wInfo.geometry().height() - borderY; //! set the point from which this window will be moved, //! make sure that it is in window boundaries int validX = qBound(minX, from.x(), maxX); int validY = qBound(minY, from.y(), maxY); NETRootInfo ri(QX11Info::connection(), NET::WMMoveResize); ri.moveResizeRequest(wInfo.wid().toUInt(), validX, validY, NET::Move); } void XWindowInterface::requestToggleIsOnAllDesktops(WindowId wid) const { WindowInfoWrap wInfo = requestInfo(wid); if (!wInfo.isValid() || wInfo.isPlasmaDesktop()) { return; } if (KWindowSystem::numberOfDesktops() <= 1) { return; } if (wInfo.isOnAllDesktops()) { KWindowSystem::setOnDesktop(wid.toUInt(), KWindowSystem::currentDesktop()); KWindowSystem::forceActiveWindow(wid.toUInt()); } else { KWindowSystem::setOnAllDesktops(wid.toUInt(), true); } } void XWindowInterface::requestToggleKeepAbove(WindowId wid) const { WindowInfoWrap wInfo = requestInfo(wid); if (!wInfo.isValid() || wInfo.isPlasmaDesktop()) { return; } NETWinInfo ni(QX11Info::connection(), wid.toUInt(), QX11Info::appRootWindow(), NET::WMState, NET::Properties2()); if (wInfo.isKeepAbove()) { ni.setState(NET::States(), NET::StaysOnTop); } else { ni.setState(NET::StaysOnTop, NET::StaysOnTop); } } void XWindowInterface::requestToggleMinimized(WindowId wid) const { WindowInfoWrap wInfo = requestInfo(wid); if (!wInfo.isValid() || wInfo.isPlasmaDesktop()) { return; } if (wInfo.isMinimized()) { bool onCurrent = wInfo.isOnDesktop(m_currentDesktop); KWindowSystem::unminimizeWindow(wid.toUInt()); if (onCurrent) { KWindowSystem::forceActiveWindow(wid.toUInt()); } } else { KWindowSystem::minimizeWindow(wid.toUInt()); } } void XWindowInterface::requestToggleMaximized(WindowId wid) const { WindowInfoWrap wInfo = requestInfo(wid); bool restore = wInfo.isMaxHoriz() && wInfo.isMaxVert(); if (wInfo.isMinimized()) { KWindowSystem::unminimizeWindow(wid.toUInt()); } NETWinInfo ni(QX11Info::connection(), wid.toInt(), QX11Info::appRootWindow(), NET::WMState, NET::Properties2()); if (restore) { ni.setState(NET::States(), NET::Max); } else { ni.setState(NET::Max, NET::Max); } } bool XWindowInterface::isValidWindow(WindowId wid) const { if (windowsTracker()->isValidFor(wid)) { return true; } const KWindowInfo winfo{wid.value(), NET::WMWindowType}; return isValidWindow(winfo); } bool XWindowInterface::isValidWindow(const KWindowInfo &winfo) const { if (windowsTracker()->isValidFor(winfo.win())) { return true; } constexpr auto types = NET::DockMask | NET::MenuMask | NET::SplashMask | NET::PopupMenuMask | NET::NormalMask | NET::DialogMask; NET::WindowType winType = winfo.windowType(types); const auto winClass = KWindowInfo(winfo.win(), 0, NET::WM2WindowClass).windowClassName(); //! ignore latte related windows from tracking if (winClass == "latte-dock") { return false; } if (m_desktopId == winfo.win()) { return false; } if (winType == -1) { // Trying to get more types for verify if the window have any other type winType = winfo.windowType(~types & NET::AllTypesMask); if (winType == -1) { qWarning() << KWindowInfo(winfo.win(), 0, NET::WM2WindowClass).windowClassName() << "doesn't have any WindowType, assuming as NET::Normal"; return true; } } bool isMenu = ((winType & NET::Menu) == true); bool isDock = ((winType & NET::Dock) == true); bool isPopup = ((winType & NET::PopupMenu) == true); bool isSplash = ((winType & NET::Splash) == true); //! GTK2+ dialogs case e.g. inkscape, gimp2, etc... //! are both Popups and Splash types, this is why //! we can not black list them here return !(isMenu || isDock); } bool XWindowInterface::hasScreenGeometry(const KWindowInfo &winfo) const { bool hasScreenGeometry{false}; for (const auto scr : qGuiApp->screens()) { if (!winfo.geometry().isEmpty() && winfo.geometry() == scr->geometry()) { hasScreenGeometry = true; break; } } return hasScreenGeometry; } void XWindowInterface::windowChangedProxy(WId wid, NET::Properties prop1, NET::Properties2 prop2) { const KWindowInfo info(wid, NET::WMGeometry, NET::WM2WindowClass); const auto winClass = info.windowClassName(); //! ignore latte related windows from tracking if (winClass == "latte-dock") { return; } //! update desktop id if (winClass == "plasmashell" && hasScreenGeometry(info)) { m_desktopId = wid; windowsTracker()->setPlasmaDesktop(wid); considerWindowChanged(wid); return; } //! accept only NET::Properties events, //! ignore when the user presses a key, or a window is sending X events etc. //! without needing to (e.g. Firefox, https://bugzilla.mozilla.org/show_bug.cgi?id=1389953) //! NET::WM2UserTime, NET::WM2IconPixmap etc.... if (prop1 == 0 && !(prop2 & NET::WM2Activities)) { return; } //! accept only the following NET:Properties changed signals //! NET::WMState, NET::WMGeometry, NET::ActiveWindow if ( !(prop1 & NET::WMState) && !(prop1 & NET::WMGeometry) && !(prop1 & NET::ActiveWindow) && !(prop1 & NET::WMDesktop) && !(prop1 & (NET::WMName | NET::WMVisibleName) && !(prop2 & NET::WM2Activities)) ) { return; } //! ignore windows that do not respect normal windows types if (!isValidWindow(wid)) { return; } considerWindowChanged(wid); } } } diff --git a/containment/package/contents/ui/PanelBox.qml b/containment/package/contents/ui/PanelBox.qml index b75926fc..d0ffc3a6 100644 --- a/containment/package/contents/ui/PanelBox.qml +++ b/containment/package/contents/ui/PanelBox.qml @@ -1,825 +1,828 @@ /* * Copyright 2016 Smith AR * Michail Vourlakos * * This file is part of Latte-Dock * * Latte-Dock is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * Latte-Dock is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.1 import QtQuick.Layouts 1.1 import QtQuick.Window 2.2 import QtGraphicalEffects 1.0 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.kquickcontrolsaddons 2.0 import "colorizer" as Colorizer import org.kde.latte 0.2 as Latte Item{ id:barLine width: root.isHorizontal ? panelWidth : smallSize height: root.isVertical ? panelHeight : smallSize opacity: root.useThemePanel ? 1 : 0 property int animationTime: 6*root.durationTime*units.shortDuration property int lengthMargins: { return root.isVertical ? shadowsSvgItem.marginsHeight : shadowsSvgItem.marginsWidth } property int panelWidth: { if (root.behaveAsPlasmaPanel && Latte.WindowSystem.compositingActive && !root.editMode) { return root.width; } else { if ((root.panelAlignment === Latte.Types.Justify) && root.isHorizontal) { return root.maxLength; } else { return layoutsContainerItem.mainLayout.width + spacing; } } } property int panelHeight: { if (root.behaveAsPlasmaPanel && Latte.WindowSystem.compositingActive && !root.editMode) { return root.height; } else { if ((root.panelAlignment === Latte.Types.Justify) && root.isVertical) { return root.maxLength; } else { return layoutsContainerItem.mainLayout.height + spacing; } } } property int spacing: { if (root.panelAlignment === Latte.Types.Justify && plasmoid.configuration.maxLength === 100) { return 0; } else if (!Latte.WindowSystem.compositingActive) { return root.panelEdgeSpacing/2; } else if (root.panelAlignment === Latte.Types.Center || root.panelAlignment === Latte.Types.Justify || root.offset!==0) { return root.panelEdgeSpacing/2; } else { return root.panelEdgeSpacing/4; } } property int smallSize: 16 //Math.max(3.7*root.statesLineSize, 16) Behavior on opacity{ enabled: Latte.WindowSystem.compositingActive NumberAnimation { duration: barLine.animationTime } } Behavior on opacity{ enabled: !Latte.WindowSystem.compositingActive NumberAnimation { duration: 0 } } Binding{ target: root property: "currentPanelTransparency" value: overlayedBackground.opacity>0 ? overlayedBackground.opacity*100 : solidBackground.opacity*100 } Binding { target: root property: "realPanelLength" value: root.isVertical ? barLine.height : barLine.width } Binding { target: root property: "totalPanelEdgeSpacing" value: spacing } onXChanged: solidBackground.updateEffectsArea(); onYChanged: solidBackground.updateEffectsArea(); /// plasmoid's default panel /* BorderImage{ anchors.fill:parent source: "../images/panel-west.png" border { left:8; right:8; top:8; bottom:8 } opacity: (!root.useThemePanel) ? 1 : 0 visible: (opacity == 0) ? false : true horizontalTileMode: BorderImage.Stretch verticalTileMode: BorderImage.Stretch Behavior on opacity{ NumberAnimation { duration: 200 } } }*/ /// the current theme's panel PlasmaCore.FrameSvgItem{ id: shadowsSvgItem width: root.isVertical ? panelSize + marginsWidth : Math.min(parent.width + marginsWidth, root.width - marginsWidth) height: root.isVertical ? Math.min(parent.height + marginsHeight, root.height - marginsHeight) : panelSize + marginsHeight imagePath: hideShadow ? "" : "widgets/panel-background" prefix: hideShadow ? "" : "shadow" visible: (opacity == 0) ? false : true opacity: { if ((root.forceTransparentPanel && !root.forcePanelForBusyBackground) || !root.useThemePanel) return 0; else return 1; } enabledBorders: latteView && latteView.effects ? latteView.effects.enabledBorders : PlasmaCore.FrameSvg.NoBorder //! set true by default in order to avoid crash on startup because imagePath is set to "" readonly property bool themeHasShadow: themeExtended ? themeExtended.hasShadow : true readonly property bool hideShadow: (root.behaveAsPlasmaPanel && !root.editMode) || !Latte.WindowSystem.compositingActive || !root.panelShadowsActive || !themeHasShadow Behavior on opacity { enabled: Latte.WindowSystem.compositingActive NumberAnimation { duration: barLine.animationTime } } Behavior on opacity{ enabled: !Latte.WindowSystem.compositingActive NumberAnimation { duration: 0 } } property int marginsWidth: { if (imagePath === "") { return 0; } else { if (root.panelAlignment === Latte.Types.Left && root.offset===0) return margins.right; else if (root.panelAlignment === Latte.Types.Right && root.offset===0) return margins.left; else return margins.left+margins.right; } } property int marginsHeight: { if (imagePath === "") { return 0; } else { if (root.panelAlignment === Latte.Types.Top && root.offset===0) return margins.bottom; else if (root.panelAlignment === Latte.Types.Bottom && root.offset===0) return margins.top; else return margins.top + margins.bottom; } } property int panelSize: automaticPanelSize property int automaticPanelSize: { if (root.behaveAsPlasmaPanel) { return root.iconSize + root.thickMargins;// + 2; } else { var icons = root.iconSize + root.thickMargins;// + 2; var panelt = root.themePanelThickness;// + 2; root.realPanelThickness = icons; return Math.min(icons, panelt); } } property int shadowsSize: 0 Binding{ target: shadowsSvgItem property: "shadowsSize" value:{ if (shadowsSvgItem && !root.behaveAsPlasmaPanel && root.useThemePanel && root.panelShadowsActive){ if (root.isVertical){ if (plasmoid.location === PlasmaCore.Types.LeftEdge) return shadowsSvgItem.margins.right; else if (plasmoid.location === PlasmaCore.Types.RightEdge) return shadowsSvgItem.margins.left; } else { if (plasmoid.location === PlasmaCore.Types.BottomEdge) return shadowsSvgItem.margins.top; else if (plasmoid.location === PlasmaCore.Types.TopEdge) return shadowsSvgItem.margins.bottom; } } else { return 0; } } } Behavior on opacity{ enabled: Latte.WindowSystem.compositingActive NumberAnimation { duration: barLine.animationTime } } Behavior on opacity{ enabled: !Latte.WindowSystem.compositingActive NumberAnimation { duration: 0 } } Binding { target: root property: "panelShadow" when: shadowsSvgItem value: shadowsSvgItem.shadowsSize } Binding { target: root property: "realPanelSize" when: shadowsSvgItem value: shadowsSvgItem.panelSize } Binding { target: root property: "panelMarginLength" when: shadowsSvgItem value: root.isVertical ? shadowsSvgItem.marginsHeight : shadowsSvgItem.marginsWidth } //! Show a fake blurness under panel background for editMode visual feedback Loader { anchors.fill: solidBackground active: editModeVisual.inEditMode && root.userShowPanelBackground && plasmoid.configuration.blurEnabled sourceComponent: Item{ Image{ id: backTiler anchors.fill: parent visible: false fillMode: Image.Tile source: hasBackground ? latteView.layout.background : "../icons/"+editModeVisual.layoutColor+"print.jpg" readonly property bool hasBackground: (latteView && latteView.layout && latteView.layout.background.startsWith("/")) ? true : false } ShaderEffectSource { id: effectSource anchors.fill: backTiler visible: false sourceItem: backTiler sourceRect: Qt.rect(0,0, width, height) } FastBlur{ id: blur anchors.fill: effectSource opacity: editModeVisual.appliedOpacity * 1.4 source: effectSource radius: 50 } } } //! This is used to provide real solidness Colorizer.CustomBackground { id: backgroundLowestRectangle anchors.fill: solidBackground opacity: normalizedOpacity backgroundColor: colorizerManager.backgroundColor roundness: overlayedBackground.roundness visible: Latte.WindowSystem.compositingActive && solidBackground.exceedsThemeOpacityLimits readonly property real normalizedOpacity: visible ? Math.min(1, (appliedOpacity - solidBackground.themeMaxOpacity)/(1-solidBackground.themeMaxOpacity)) : 0 readonly property real appliedOpacity: visible ? solidBackground.appliedOpacity : 0 Behavior on opacity{ enabled: Latte.WindowSystem.compositingActive NumberAnimation { duration: barLine.animationTime } } Behavior on opacity{ enabled: !Latte.WindowSystem.compositingActive NumberAnimation { duration: 0 } } } PlasmaCore.FrameSvgItem{ id: solidBackground anchors.leftMargin: Latte.WindowSystem.compositingActive ? shadowsSvgItem.margins.left : 0 anchors.rightMargin: Latte.WindowSystem.compositingActive ? shadowsSvgItem.margins.right : 0 anchors.topMargin: Latte.WindowSystem.compositingActive ? shadowsSvgItem.margins.top : 0 anchors.bottomMargin: Latte.WindowSystem.compositingActive ? shadowsSvgItem.margins.bottom : 0 anchors.fill:parent opacity: normalizedOpacity readonly property bool exceedsThemeOpacityLimits: appliedOpacity > themeMaxOpacity readonly property bool forceSolidness: root.forceSolidPanel || !Latte.WindowSystem.compositingActive //! must be normalized to plasma theme maximum opacity readonly property real normalizedOpacity: Math.min(1, appliedOpacity / themeMaxOpacity) readonly property real appliedOpacity: overlayedBackground.opacity > 0 ? 0 : overlayedBackground.midOpacity readonly property real themeMaxOpacity: { if (themeExtended) { switch(plasmoid.location) { case PlasmaCore.Types.BottomEdge: return themeExtended.bottomEdgeMaxOpacity; case PlasmaCore.Types.LeftEdge: return themeExtended.leftEdgeMaxOpacity; case PlasmaCore.Types.TopEdge: return themeExtended.topEdgeMaxOpacity; case PlasmaCore.Types.RightEdge: return themeExtended.rightEdgeMaxOpacity; default: return 0; } } return 1; } property rect efGeometry: Qt.rect(-1,-1,0,0) imagePath: "widgets/panel-background" onWidthChanged: updateEffectsArea(); onHeightChanged: updateEffectsArea(); Component.onCompleted: { root.updateEffectsArea.connect(updateEffectsArea); adjustPrefix(); } Component.onDestruction: { root.updateEffectsArea.disconnect(updateEffectsArea); } onImagePathChanged: solidBackground.adjustPrefix(); Connections{ target: root onEditModeChanged: { if (!root.editMode){ solidBackground.updateEffectsArea(); } } } //! Fix for FrameSvgItem QML version not updating its margins after a theme change //! with this hack we enforce such update. I could use the repaintNeeded signal but //! it is called more often than the themeChanged one. Connections{ target: themeExtended onThemeChanged: { solidBackground.adjustPrefix(); plasmoid.configuration.panelShadows = !plasmoid.configuration.panelShadows; plasmoid.configuration.panelShadows = !plasmoid.configuration.panelShadows; updateEffectsArea(); } } Connections{ target: plasmoid onLocationChanged: solidBackground.adjustPrefix(); } function updateEffectsArea(){ if (!latteView) return; var rootGeometry = mapToItem(root, 0, 0); efGeometry.x = rootGeometry.x; efGeometry.y = rootGeometry.y; efGeometry.width = width; efGeometry.height = height; latteView.effects.rect = efGeometry; if (!Latte.WindowSystem.compositingActive) { visibilityManager.updateMaskArea(); } } Binding { target: root property: "panelThickMarginHigh" value: { if (root.useThemePanel){ if (root.isVertical){ if (plasmoid.location === PlasmaCore.Types.LeftEdge) return solidBackground.margins.right; else if (plasmoid.location === PlasmaCore.Types.RightEdge) return solidBackground.margins.left; } else { if (plasmoid.location === PlasmaCore.Types.BottomEdge) return solidBackground.margins.top; else if (plasmoid.location === PlasmaCore.Types.TopEdge) return solidBackground.margins.bottom; } } } } onRepaintNeeded: { if (root.behaveAsPlasmaPanel) adjustPrefix(); } enabledBorders: latteView && latteView.effects ? latteView.effects.enabledBorders : PlasmaCore.FrameSvg.NoBorder Behavior on opacity{ enabled: Latte.WindowSystem.compositingActive NumberAnimation { duration: barLine.animationTime } } Behavior on opacity{ enabled: !Latte.WindowSystem.compositingActive NumberAnimation { duration: 0 } } function adjustPrefix() { if (!plasmoid) { return ""; } var pre; switch (plasmoid.location) { case PlasmaCore.Types.LeftEdge: pre = "west"; break; case PlasmaCore.Types.TopEdge: pre = "north"; break; case PlasmaCore.Types.RightEdge: pre = "east"; break; case PlasmaCore.Types.BottomEdge: pre = "south"; break; default: prefix = ""; } prefix = [pre, ""]; } } Colorizer.CustomBackground { id: overlayedBackground anchors.fill: solidBackground opacity: { if (root.forcePanelForBusyBackground && solidBackground.opacity === 0) { return plasmoid.configuration.panelTransparency / 100; } if (colorizerManager.mustBeShown && colorizerManager.applyTheme !== theme) { return midOpacity; } return 0; } backgroundColor: { if (colorizerManager.mustBeShown && colorizerManager.applyTheme !== theme) { return colorizerManager.backgroundColor; } return "transparent"; } + borderWidth: 1 + borderColor: backgroundColor + roundness: { if (themeExtended) { switch(plasmoid.location) { case PlasmaCore.Types.BottomEdge: return themeExtended.bottomEdgeRoundness; case PlasmaCore.Types.LeftEdge: return themeExtended.leftEdgeRoundness; case PlasmaCore.Types.TopEdge: return themeExtended.topEdgeRoundness; case PlasmaCore.Types.RightEdge: return themeExtended.rightEdgeRoundness; default: return 0; } } return 0; } property real midOpacity: { if (forceSolidness) { return 1; } else if (!root.userShowPanelBackground || root.forcePanelForBusyBackground || root.forceTransparentPanel) { return 0; } else { return plasmoid.configuration.panelTransparency / 100; } } readonly property bool forceSolidness: root.forceSolidPanel || !Latte.WindowSystem.compositingActive Behavior on opacity{ enabled: Latte.WindowSystem.compositingActive NumberAnimation { duration: barLine.animationTime } } Behavior on opacity{ enabled: !Latte.WindowSystem.compositingActive NumberAnimation { duration: 0 } } } //! Outline drawing Loader{ anchors.fill: solidBackground active: root.panelOutline sourceComponent: Colorizer.CustomBackground{ backgroundColor: "transparent" borderColor: colorizerManager.outlineColor borderWidth: themeExtended ? themeExtended.outlineWidth : 1 roundness: overlayedBackground.roundness } } //! CustomBackground debugger /*Colorizer.CustomBackground { anchors.fill: solidBackground backgroundColor: "transparent" borderWidth: 1 borderColor: "red" roundness: overlayedBackground.roundness }*/ } transitions: Transition { enabled: editModeVisual.plasmaEditMode AnchorAnimation { duration: 0.8 * root.animationTime easing.type: Easing.OutCubic } } //BEGIN states //user set Panel Positions //0-Center, 1-Left, 2-Right, 3-Top, 4-Bottom states: [ ///Left State { name: "leftCenterOrJustify" when: (plasmoid.location === PlasmaCore.Types.LeftEdge)&&(root.panelAlignment === Latte.Types.Center || root.panelAlignment === Latte.Types.Justify) AnchorChanges { target: barLine anchors{ top:undefined; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:parent.verticalCenter} } AnchorChanges { target: shadowsSvgItem anchors{ top:undefined; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:parent.verticalCenter} } PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: (root.panelAlignment === Latte.Types.Center ? root.offset : 0); } }, ///Left State { name: "leftTop" when: (plasmoid.location === PlasmaCore.Types.LeftEdge)&&(root.panelAlignment === Latte.Types.Top) AnchorChanges { target: barLine anchors{ top:parent.top; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined} } AnchorChanges { target: shadowsSvgItem anchors{ top:parent.top; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined} } PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:root.offset; anchors.bottomMargin:0; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, ///Left State { name: "leftBottom" when: (plasmoid.location === PlasmaCore.Types.LeftEdge)&&(root.panelAlignment === Latte.Types.Bottom) AnchorChanges { target: barLine anchors{ top:undefined; bottom:parent.bottom; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined} } AnchorChanges { target: shadowsSvgItem anchors{ top:undefined; bottom:parent.bottom; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined} } PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:root.offset; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, ///Right State { name: "rightCenterOrJustify" when: (plasmoid.location === PlasmaCore.Types.RightEdge)&&(root.panelAlignment === Latte.Types.Center || root.panelAlignment === Latte.Types.Justify) AnchorChanges { target: barLine anchors{ top:undefined; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:parent.verticalCenter} } AnchorChanges { target: shadowsSvgItem anchors{ top:undefined; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:parent.verticalCenter} } PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: (root.panelAlignment === Latte.Types.Center ? root.offset : 0); } }, State { name: "rightTop" when: (plasmoid.location === PlasmaCore.Types.RightEdge)&&(root.panelAlignment === Latte.Types.Top) AnchorChanges { target: barLine anchors{ top:parent.top; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined} } AnchorChanges { target: shadowsSvgItem anchors{ top:parent.top; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined} } PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:root.offset; anchors.bottomMargin:0; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, State { name: "rightBottom" when: (plasmoid.location === PlasmaCore.Types.RightEdge)&&(root.panelAlignment === Latte.Types.Bottom) AnchorChanges { target: barLine anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined } } AnchorChanges { target: shadowsSvgItem anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined} } PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:root.offset; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, ///Bottom State { name: "bottomCenterOrJustify" when: (plasmoid.location === PlasmaCore.Types.BottomEdge)&&(root.panelAlignment === Latte.Types.Center || root.panelAlignment === Latte.Types.Justify) AnchorChanges { target: barLine anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined} } AnchorChanges { target: shadowsSvgItem anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined} } PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0; anchors.horizontalCenterOffset: (root.panelAlignment === Latte.Types.Center ? root.offset : 0); anchors.verticalCenterOffset: 0; } }, State { name: "bottomLeft" when: (plasmoid.location === PlasmaCore.Types.BottomEdge) &&(((root.panelAlignment === Latte.Types.Left)&&(Qt.application.layoutDirection !== Qt.RightToLeft)) || ((root.panelAlignment === Latte.Types.Right)&&(Qt.application.layoutDirection === Qt.RightToLeft))) AnchorChanges { target: barLine anchors{ top:undefined; bottom:parent.bottom; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined} } AnchorChanges { target: shadowsSvgItem anchors{ top:undefined; bottom:parent.bottom; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined} } PropertyChanges{ target: barLine anchors.leftMargin: root.offset; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, State { name: "bottomRight" when: (plasmoid.location === PlasmaCore.Types.BottomEdge) &&(((root.panelAlignment === Latte.Types.Right)&&(Qt.application.layoutDirection !== Qt.RightToLeft)) ||((root.panelAlignment === Latte.Types.Left)&&(Qt.application.layoutDirection === Qt.RightToLeft))) AnchorChanges { target: barLine anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined} } AnchorChanges { target: shadowsSvgItem anchors{ top:undefined; bottom:parent.bottom; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined} } PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin:root.offset; anchors.topMargin:0; anchors.bottomMargin:0; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, ///Top State { name: "topCenterOrJustify" when: (plasmoid.location === PlasmaCore.Types.TopEdge)&&(root.panelAlignment === Latte.Types.Center || root.panelAlignment === Latte.Types.Justify) AnchorChanges { target: barLine anchors{ top:parent.top; bottom:undefined; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined} } AnchorChanges { target: shadowsSvgItem anchors{ top:parent.top; bottom:undefined; left:undefined; right:undefined; horizontalCenter:parent.horizontalCenter; verticalCenter:undefined} } PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0; anchors.horizontalCenterOffset: (root.panelAlignment === Latte.Types.Center ? root.offset : 0); anchors.verticalCenterOffset: 0; } }, State { name: "topLeft" when: (plasmoid.location === PlasmaCore.Types.TopEdge) &&(((root.panelAlignment === Latte.Types.Left)&&(Qt.application.layoutDirection !== Qt.RightToLeft)) || ((root.panelAlignment === Latte.Types.Right)&&(Qt.application.layoutDirection === Qt.RightToLeft))) AnchorChanges { target: barLine anchors{ top:parent.top; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined} } AnchorChanges { target: shadowsSvgItem anchors{ top:parent.top; bottom:undefined; left:parent.left; right:undefined; horizontalCenter:undefined; verticalCenter:undefined} } PropertyChanges{ target: barLine anchors.leftMargin: root.offset; anchors.rightMargin:0; anchors.topMargin:0; anchors.bottomMargin:0; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } }, State { name: "topRight" when: (plasmoid.location === PlasmaCore.Types.TopEdge) &&(((root.panelAlignment === Latte.Types.Right)&&(Qt.application.layoutDirection !== Qt.RightToLeft)) ||((root.panelAlignment === Latte.Types.Left)&&(Qt.application.layoutDirection === Qt.RightToLeft))) AnchorChanges { target: barLine anchors{ top:parent.top; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined} } AnchorChanges { target: shadowsSvgItem anchors{ top:parent.top; bottom:undefined; left:undefined; right:parent.right; horizontalCenter:undefined; verticalCenter:undefined} } PropertyChanges{ target: barLine anchors.leftMargin: 0; anchors.rightMargin:root.offset; anchors.topMargin:0; anchors.bottomMargin:0; anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; } } ] //END states }