improve panel painting for disabled compositing

pull/1/head
Michail Vourlakos 8 years ago
parent af8f844bc6
commit c61c14e9be

@ -24,6 +24,7 @@
#include "visibilitymanager.h" #include "visibilitymanager.h"
#include "panelshadows_p.h" #include "panelshadows_p.h"
#include "../liblattedock/extras.h" #include "../liblattedock/extras.h"
#include "../liblattedock/quickwindowsystem.h"
#include <QAction> #include <QAction>
#include <QQmlContext> #include <QQmlContext>
@ -38,6 +39,7 @@
#include <KLocalizedContext> #include <KLocalizedContext>
#include <KLocalizedString> #include <KLocalizedString>
#include <KWindowEffects> #include <KWindowEffects>
#include <KWindowSystem>
#include <Plasma/Containment> #include <Plasma/Containment>
#include <Plasma/ContainmentActions> #include <Plasma/ContainmentActions>
@ -53,6 +55,7 @@ DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen, bool alwaysVis
setTitle(corona->kPackage().metadata().name()); setTitle(corona->kPackage().metadata().name());
setIcon(qGuiApp->windowIcon()); setIcon(qGuiApp->windowIcon());
setResizeMode(QuickViewSharedEngine::SizeRootObjectToView); setResizeMode(QuickViewSharedEngine::SizeRootObjectToView);
setColor(QColor(Qt::transparent));
setClearBeforeRendering(true); setClearBeforeRendering(true);
if (!alwaysVisible) { if (!alwaysVisible) {
@ -75,7 +78,6 @@ DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen, bool alwaysVis
connect(this, &DockView::containmentChanged connect(this, &DockView::containmentChanged
, this, [&]() { , this, [&]() {
if (!this->containment()) if (!this->containment())
return; return;
@ -121,7 +123,6 @@ DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen, bool alwaysVis
DockView::~DockView() DockView::~DockView()
{ {
m_screenSyncTimer.stop(); m_screenSyncTimer.stop();
qDebug() << "dock view deleting..."; qDebug() << "dock view deleting...";
rootContext()->setContextProperty(QStringLiteral("dock"), nullptr); rootContext()->setContextProperty(QStringLiteral("dock"), nullptr);
this->disconnect(); this->disconnect();
@ -139,7 +140,6 @@ DockView::~DockView()
void DockView::init() void DockView::init()
{ {
connect(this, &QQuickWindow::screenChanged, this, &DockView::screenChanged); connect(this, &QQuickWindow::screenChanged, this, &DockView::screenChanged);
connect(qGuiApp, &QGuiApplication::screenAdded, this, &DockView::screenChanged); connect(qGuiApp, &QGuiApplication::screenAdded, this, &DockView::screenChanged);
connect(qGuiApp, &QGuiApplication::primaryScreenChanged, this, &DockView::screenChanged); connect(qGuiApp, &QGuiApplication::primaryScreenChanged, this, &DockView::screenChanged);
connect(this, &DockView::screenGeometryChanged, this, &DockView::syncGeometry); connect(this, &DockView::screenGeometryChanged, this, &DockView::syncGeometry);
@ -151,7 +151,6 @@ void DockView::init()
connect(this, &QQuickWindow::widthChanged, this, &DockView::updateAbsDockGeometry); connect(this, &QQuickWindow::widthChanged, this, &DockView::updateAbsDockGeometry);
connect(this, &QQuickWindow::heightChanged, this, &DockView::heightChanged); connect(this, &QQuickWindow::heightChanged, this, &DockView::heightChanged);
connect(this, &QQuickWindow::heightChanged, this, &DockView::updateAbsDockGeometry); connect(this, &QQuickWindow::heightChanged, this, &DockView::updateAbsDockGeometry);
connect(corona(), &Plasma::Corona::availableScreenRectChanged, this, [&]() { connect(corona(), &Plasma::Corona::availableScreenRectChanged, this, [&]() {
if (formFactor() == Plasma::Types::Vertical) if (formFactor() == Plasma::Types::Vertical)
syncGeometry(); syncGeometry();
@ -159,22 +158,16 @@ void DockView::init()
connect(this, &DockView::drawShadowsChanged, this, &DockView::syncGeometry); connect(this, &DockView::drawShadowsChanged, this, &DockView::syncGeometry);
connect(this, &DockView::maxLengthChanged, this, &DockView::syncGeometry); connect(this, &DockView::maxLengthChanged, this, &DockView::syncGeometry);
connect(this, &DockView::alignmentChanged, this, &DockView::updateEnabledBorders); connect(this, &DockView::alignmentChanged, this, &DockView::updateEnabledBorders);
connect(this, &DockView::onPrimaryChanged, this, &DockView::saveConfig); connect(this, &DockView::onPrimaryChanged, this, &DockView::saveConfig);
connect(this, &DockView::onPrimaryChanged, this, &DockView::reconsiderScreen); connect(this, &DockView::onPrimaryChanged, this, &DockView::reconsiderScreen);
connect(this, &DockView::sessionChanged, this, &DockView::saveConfig); connect(this, &DockView::sessionChanged, this, &DockView::saveConfig);
connect(this, &DockView::locationChanged, this, [&]() { connect(this, &DockView::locationChanged, this, [&]() {
updateFormFactor(); updateFormFactor();
syncGeometry(); syncGeometry();
}); });
connect(&m_theme, &Plasma::Theme::themeChanged, this, &DockView::themeChanged); connect(&m_theme, &Plasma::Theme::themeChanged, this, &DockView::themeChanged);
connect(this, SIGNAL(normalThicknessChanged()), corona(), SIGNAL(availableScreenRectChanged())); connect(this, SIGNAL(normalThicknessChanged()), corona(), SIGNAL(availableScreenRectChanged()));
connect(this, SIGNAL(shadowChanged()), corona(), SIGNAL(availableScreenRectChanged())); connect(this, SIGNAL(shadowChanged()), corona(), SIGNAL(availableScreenRectChanged()));
rootContext()->setContextProperty(QStringLiteral("dock"), this); rootContext()->setContextProperty(QStringLiteral("dock"), this);
setSource(corona()->kPackage().filePath("lattedockui")); setSource(corona()->kPackage().filePath("lattedockui"));
setVisible(true); setVisible(true);
@ -237,14 +230,12 @@ void DockView::setScreenToFollow(QScreen *screen, bool updateScreenId)
} }
qDebug() << "adapting to screen..."; qDebug() << "adapting to screen...";
setScreen(screen); setScreen(screen);
if (this->containment()) if (this->containment())
this->containment()->reactToScreenChange(); this->containment()->reactToScreenChange();
syncGeometry(); syncGeometry();
emit screenGeometryChanged(); emit screenGeometryChanged();
} }
@ -259,7 +250,6 @@ void DockView::reconsiderScreen()
} }
auto *dockCorona = qobject_cast<DockCorona *>(this->corona()); auto *dockCorona = qobject_cast<DockCorona *>(this->corona());
bool screenExists{false}; bool screenExists{false};
//!check if the associated screen is running //!check if the associated screen is running
@ -409,9 +399,7 @@ QRect DockView::maximumNormalGeometry()
int yPos = 0; int yPos = 0;
int maxHeight = maxLength() * screen()->geometry().height(); int maxHeight = maxLength() * screen()->geometry().height();
int maxWidth = normalThickness(); int maxWidth = normalThickness();
QRect maxGeometry; QRect maxGeometry;
maxGeometry.setRect(0, 0, maxWidth, maxHeight); maxGeometry.setRect(0, 0, maxWidth, maxHeight);
switch (location()) { switch (location()) {
@ -434,7 +422,6 @@ QRect DockView::maximumNormalGeometry()
} }
maxGeometry.setRect(xPos, yPos, maxWidth, maxHeight); maxGeometry.setRect(xPos, yPos, maxWidth, maxHeight);
break; break;
case Plasma::Types::RightEdge: case Plasma::Types::RightEdge:
@ -456,7 +443,6 @@ QRect DockView::maximumNormalGeometry()
} }
maxGeometry.setRect(xPos, yPos, maxWidth, maxHeight); maxGeometry.setRect(xPos, yPos, maxWidth, maxHeight);
break; break;
} }
@ -507,9 +493,7 @@ void DockView::setLocalGeometry(const QRect &geometry)
} }
m_localGeometry = geometry; m_localGeometry = geometry;
emit localGeometryChanged(); emit localGeometryChanged();
updateAbsDockGeometry(); updateAbsDockGeometry();
} }
@ -530,13 +514,10 @@ void DockView::updatePosition(QRect availableScreenRect)
{ {
QRect screenGeometry; QRect screenGeometry;
QPoint position; QPoint position;
position = {0, 0}; position = {0, 0};
const auto length = [&](int length) -> int { const auto length = [&](int length) -> int {
return static_cast<int>(length * (1 - maxLength()) / 2); return static_cast<int>(length * (1 - maxLength()) / 2);
}; };
int cleanThickness = normalThickness() - shadow(); int cleanThickness = normalThickness() - shadow();
switch (location()) { switch (location()) {
@ -623,14 +604,12 @@ inline void DockView::syncGeometry()
maximumRect = maximumNormalGeometry(); maximumRect = maximumNormalGeometry();
QRegion availableRegion = freeRegion.intersected(maximumRect); QRegion availableRegion = freeRegion.intersected(maximumRect);
availableScreenRect = freeRegion.intersected(maximumRect).boundingRect(); availableScreenRect = freeRegion.intersected(maximumRect).boundingRect();
float area = 0; float area = 0;
//! it is used to choose which or the availableRegion rectangles will //! it is used to choose which or the availableRegion rectangles will
//! be the one representing dock geometry //! be the one representing dock geometry
for (int i = 0; i < availableRegion.rectCount(); ++i) { for (int i = 0; i < availableRegion.rectCount(); ++i) {
QRect rect = availableRegion.rects().at(i); QRect rect = availableRegion.rects().at(i);
//! the area of each rectangle in calculated in squares of 50x50 //! the area of each rectangle in calculated in squares of 50x50
//! this is a way to avoid enourmous numbers for area value //! this is a way to avoid enourmous numbers for area value
float tempArea = (float)(rect.width() * rect.height()) / 2500; float tempArea = (float)(rect.width() * rect.height()) / 2500;
@ -649,7 +628,6 @@ inline void DockView::syncGeometry()
m_forceDrawCenteredBorders = false; m_forceDrawCenteredBorders = false;
} }
updateEnabledBorders(); updateEnabledBorders();
resizeWindow(availableScreenRect); resizeWindow(availableScreenRect);
updatePosition(availableScreenRect); updatePosition(availableScreenRect);
@ -691,7 +669,6 @@ void DockView::setNormalThickness(int thickness)
} }
m_normalThickness = thickness; m_normalThickness = thickness;
emit normalThicknessChanged(); emit normalThicknessChanged();
} }
@ -754,12 +731,10 @@ void DockView::setDrawShadows(bool draw)
} else { } else {
PanelShadows::self()->removeWindow(this); PanelShadows::self()->removeWindow(this);
m_enabledBorders = Plasma::FrameSvg::AllBorders; m_enabledBorders = Plasma::FrameSvg::AllBorders;
emit enabledBordersChanged(); emit enabledBordersChanged();
} }
themeChanged(); themeChanged();
emit drawShadowsChanged(); emit drawShadowsChanged();
} }
@ -805,7 +780,6 @@ void DockView::setMaxLength(float length)
} }
m_maxLength = length; m_maxLength = length;
emit maxLengthChanged(); emit maxLengthChanged();
} }
@ -852,7 +826,25 @@ void DockView::setMaskArea(QRect area)
return; return;
m_maskArea = area; m_maskArea = area;
setMask(m_maskArea);
if (KWindowSystem::compositingActive()) {
setMask(m_maskArea);
} 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
if (!m_background) {
m_background = new Plasma::FrameSvg(this);
m_background->setImagePath(QStringLiteral("opaque/dialogs/background"));
}
m_background->setEnabledBorders(enabledBorders());
m_background->resizeFrame(area.size());
QRegion fixedMask = m_background->mask();
fixedMask.translate(area.x(), area.y());
setMask(fixedMask);
}
//qDebug() << "dock mask set:" << m_maskArea; //qDebug() << "dock mask set:" << m_maskArea;
emit maskAreaChanged(); emit maskAreaChanged();
} }
@ -1023,7 +1015,6 @@ void DockView::mouseReleaseEvent(QMouseEvent *event)
void DockView::mousePressEvent(QMouseEvent *event) void DockView::mousePressEvent(QMouseEvent *event)
{ {
//qDebug() << "Step -1 ..."; //qDebug() << "Step -1 ...";
if (!event || !this->containment()) { if (!event || !this->containment()) {
return; return;
} }
@ -1076,7 +1067,6 @@ void DockView::mousePressEvent(QMouseEvent *event)
//Try to find applets inside a systray //Try to find applets inside a systray
if (meta.pluginId() == "org.kde.plasma.systemtray") { if (meta.pluginId() == "org.kde.plasma.systemtray") {
auto systrayId = applet->config().readEntry("SystrayContainmentId"); auto systrayId = applet->config().readEntry("SystrayContainmentId");
applet = 0; applet = 0;
inSystray = true; inSystray = true;
Plasma::Containment *cont = containmentById(systrayId.toInt()); Plasma::Containment *cont = containmentById(systrayId.toInt());
@ -1119,7 +1109,6 @@ void DockView::mousePressEvent(QMouseEvent *event)
if (this->mouseGrabberItem()) { if (this->mouseGrabberItem()) {
//workaround, this fixes for me most of the right click menu behavior //workaround, this fixes for me most of the right click menu behavior
this->mouseGrabberItem()->ungrabMouse(); this->mouseGrabberItem()->ungrabMouse();
return; return;
} }
@ -1340,7 +1329,6 @@ Plasma::FrameSvg::EnabledBorders DockView::enabledBorders() const
void DockView::updateEnabledBorders() void DockView::updateEnabledBorders()
{ {
// qDebug() << "draw shadow!!!! :" << m_drawShadows; // qDebug() << "draw shadow!!!! :" << m_drawShadows;
if (!this->screen()) { if (!this->screen()) {
return; return;
} }
@ -1381,7 +1369,6 @@ void DockView::updateEnabledBorders()
if (m_alignment == Dock::Bottom && !m_forceDrawCenteredBorders) { if (m_alignment == Dock::Bottom && !m_forceDrawCenteredBorders) {
borders &= ~Plasma::FrameSvg::BottomBorder; borders &= ~Plasma::FrameSvg::BottomBorder;
} }
} }
if (location() == Plasma::Types::TopEdge || location() == Plasma::Types::BottomEdge) { if (location() == Plasma::Types::TopEdge || location() == Plasma::Types::BottomEdge) {

@ -227,6 +227,8 @@ private:
QTimer m_screenSyncTimer; QTimer m_screenSyncTimer;
Plasma::Theme m_theme; Plasma::Theme m_theme;
//only for the mask on disabled compositing, not to actually paint
Plasma::FrameSvg *m_background{nullptr};
//only for the mask, not to actually paint //only for the mask, not to actually paint
Plasma::FrameSvg::EnabledBorders m_enabledBorders = Plasma::FrameSvg::AllBorders; Plasma::FrameSvg::EnabledBorders m_enabledBorders = Plasma::FrameSvg::AllBorders;

@ -62,9 +62,13 @@ Item{
} }
} }
property int spacing: (root.panelAlignment === Latte.Dock.Center property int spacing: {
|| plasmoid.configuration.panelPosition === Latte.Dock.Justify) ? if (root.panelAlignment === Latte.Dock.Center || plasmoid.configuration.panelPosition === Latte.Dock.Justify) {
root.panelEdgeSpacing/2 : root.panelEdgeSpacing/4 return root.panelEdgeSpacing/2;
} else {
return root.panelEdgeSpacing/4;
}
}
property int smallSize: Math.max(3.7*root.statesLineSize, 16) property int smallSize: Math.max(3.7*root.statesLineSize, 16)
Behavior on opacity{ Behavior on opacity{
@ -104,8 +108,8 @@ Item{
height: root.isVertical ? Math.min(parent.height + marginsHeight, root.height - marginsHeight) : height: root.isVertical ? Math.min(parent.height + marginsHeight, root.height - marginsHeight) :
panelSize + marginsHeight - (solidBackground.topIncreaser + solidBackground.bottomIncreaser) panelSize + marginsHeight - (solidBackground.topIncreaser + solidBackground.bottomIncreaser)
imagePath: root.drawShadowsExternal ? "" : "widgets/panel-background" imagePath: root.drawShadowsExternal || !Latte.WindowSystem.compositingActive ? "" : "widgets/panel-background"
prefix: root.drawShadowsExternal ? "" : "shadow" prefix: root.drawShadowsExternal || !Latte.WindowSystem.compositingActive ? "" : "shadow"
opacity: root.useThemePanel ? 1 : 0 opacity: root.useThemePanel ? 1 : 0
visible: (opacity == 0) ? false : true visible: (opacity == 0) ? false : true
@ -113,7 +117,7 @@ Item{
enabledBorders: dock ? dock.enabledBorders : 0 enabledBorders: dock ? dock.enabledBorders : 0
property int marginsWidth: { property int marginsWidth: {
if (root.drawShadowsExternal) { if (root.drawShadowsExternal || !Latte.WindowSystem.compositingActive) {
return 0; return 0;
} else { } else {
if (root.panelAlignment === Latte.Dock.Left) if (root.panelAlignment === Latte.Dock.Left)
@ -126,7 +130,7 @@ Item{
} }
property int marginsHeight: { property int marginsHeight: {
if (root.drawShadowsExternal) { if (root.drawShadowsExternal || !Latte.WindowSystem.compositingActive) {
return 0; return 0;
} else { } else {
if (root.panelAlignment === Latte.Dock.Top) if (root.panelAlignment === Latte.Dock.Top)
@ -196,10 +200,10 @@ Item{
PlasmaCore.FrameSvgItem{ PlasmaCore.FrameSvgItem{
id: solidBackground id: solidBackground
anchors.leftMargin: shadowsSvgItem.margins.left - leftIncreaser anchors.leftMargin: Latte.WindowSystem.compositingActive ? shadowsSvgItem.margins.left - leftIncreaser : 0
anchors.rightMargin: shadowsSvgItem.margins.right - rightIncreaser anchors.rightMargin: Latte.WindowSystem.compositingActive ? shadowsSvgItem.margins.right - rightIncreaser : 0
anchors.topMargin: shadowsSvgItem.margins.top - topIncreaser anchors.topMargin: Latte.WindowSystem.compositingActive ? shadowsSvgItem.margins.top - topIncreaser : 0
anchors.bottomMargin: shadowsSvgItem.margins.bottom - bottomIncreaser anchors.bottomMargin: Latte.WindowSystem.compositingActive ? shadowsSvgItem.margins.bottom - bottomIncreaser : 0
anchors.fill:parent anchors.fill:parent
imagePath: root.solidPanel ? "opaque/dialogs/background" : "widgets/panel-background" imagePath: root.solidPanel ? "opaque/dialogs/background" : "widgets/panel-background"
@ -251,8 +255,6 @@ Item{
else if (plasmoid.location === PlasmaCore.Types.TopEdge) else if (plasmoid.location === PlasmaCore.Types.TopEdge)
return solidBackground.margins.bottom; return solidBackground.margins.bottom;
} }
} else {
return 0;
} }
} }
} }

@ -178,8 +178,21 @@ Item{
var tempLength = root.isHorizontal ? width : height; var tempLength = root.isHorizontal ? width : height;
var tempThickness = root.isHorizontal ? height : width; var tempThickness = root.isHorizontal ? height : width;
var space = root.useThemePanel ? (plasmoid.configuration.panelPosition === Latte.Dock.Justify) ? var space = 0;
root.panelEdgeSpacing + 2*root.panelShadow : root.panelEdgeSpacing + 2*root.panelShadow : 2;
if (Latte.WindowSystem.compositingActive) {
if (root.useThemePanel){
space = root.panelEdgeSpacing + 2*root.panelShadow;
} else {
space = 2;
}
} else {
if (root.panelAlignment === Latte.Dock.Center || plasmoid.configuration.panelPosition === Latte.Dock.Justify) {
space = root.panelEdgeSpacing/2;
} else {
space = root.panelEdgeSpacing/4;
}
}
if (normalState) { if (normalState) {
//console.log("entered normal state..."); //console.log("entered normal state...");

@ -62,7 +62,7 @@ DragDrop.DropArea {
property bool normalState : false property bool normalState : false
property bool onlyAddingStarup: true //is used for the initialization phase in startup where there arent removals, this variable provides a way to grow icon size property bool onlyAddingStarup: true //is used for the initialization phase in startup where there arent removals, this variable provides a way to grow icon size
property bool shrinkThickMargins: plasmoid.configuration.shrinkThickMargins property bool shrinkThickMargins: plasmoid.configuration.shrinkThickMargins
property bool solidPanel: plasmoid.configuration.solidPanel property bool solidPanel: Latte.WindowSystem.compositingActive ? plasmoid.configuration.solidPanel : true
//FIXME: possibly this is going to be the default behavior, this user choice //FIXME: possibly this is going to be the default behavior, this user choice
//has been dropped from the Dock Configuration Window //has been dropped from the Dock Configuration Window
//property bool smallAutomaticIconJumps: plasmoid.configuration.smallAutomaticIconJumps //property bool smallAutomaticIconJumps: plasmoid.configuration.smallAutomaticIconJumps
@ -110,7 +110,7 @@ DragDrop.DropArea {
var panelBase = root.statesLineSize + root.panelMargin; var panelBase = root.statesLineSize + root.panelMargin;
var margin = latteApplet ? thickMargin : 0; var margin = latteApplet ? thickMargin : 0;
var maxPanelSize = (root.statesLineSize + iconSize + margin + 1) - panelBase; var maxPanelSize = (root.statesLineSize + iconSize + margin + 1) - panelBase;
var percentage = plasmoid.configuration.panelSize/100; var percentage = Latte.WindowSystem.compositingActive ? plasmoid.configuration.panelSize/100 : 1;
return Math.max(panelBase, panelBase + percentage*maxPanelSize); return Math.max(panelBase, panelBase + percentage*maxPanelSize);
} }
@ -184,7 +184,7 @@ DragDrop.DropArea {
layoutsContainer.height + 0.5*iconMargin : mainLayout.height + iconMargin) : layoutsContainer.height + 0.5*iconMargin : mainLayout.height + iconMargin) :
Screen.height //on unlocked state use the maximum*/ Screen.height //on unlocked state use the maximum*/
Plasmoid.backgroundHints: Latte.WindowSystem.compositingActive ? PlasmaCore.Types.NoBackground : PlasmaCore.Types.DefaultBackground Plasmoid.backgroundHints: PlasmaCore.Types.NoBackground
//// BEGIN properties in functions //// BEGIN properties in functions
property int noApplets: { property int noApplets: {
@ -1133,23 +1133,14 @@ DragDrop.DropArea {
EditModeVisual{ EditModeVisual{
id:editModeVisual id:editModeVisual
z: root.drawShadowsExternal ? 1 : 0 z: root.drawShadowsExternal || !Latte.WindowSystem.compositingActive ? 1 : 0
} }
Item{ Item{
anchors.fill:layoutsContainer anchors.fill:layoutsContainer
z: root.drawShadowsExternal ? 0 : 1 z: root.drawShadowsExternal || !Latte.WindowSystem.compositingActive ? 0 : 1
Loader{ PanelBox{}
width: parent.width
height: parent.height
// FIX IT && TEST IT: it is crashing Plasma with two Now Docks one of which has only
// task manager (small)
//active: root.useThemePanel
active: Latte.WindowSystem.compositingActive
sourceComponent: PanelBox{}
}
} }
Item { Item {

Loading…
Cancel
Save