Wayland: Support classical indicators too

The Indicator Window is top-level, but on Wayland that can't do,
as we have no way to position it. So parent it. The indicators
are now under the window being dragged, but that's no so bad, as it's
smi-transparent, so you still see the indicator.
This commit is contained in:
Sergio Martins
2020-10-17 10:56:30 +01:00
parent ba04c70d5a
commit 5872c2fbe3
4 changed files with 21 additions and 10 deletions

View File

@@ -91,12 +91,6 @@ FloatingWindow *DefaultWidgetFactory::createFloatingWindow(Frame *frame, MainWin
DropIndicatorOverlayInterface *DefaultWidgetFactory::createDropIndicatorOverlay(DropArea *dropArea) const
{
if (isWayland() && s_dropIndicatorType == DropIndicatorType::Classic) {
qWarning() << Q_FUNC_INFO << "Classical indicators aren't supported on Wayland yet."
<< "Falling back to Segmented Indicators";
s_dropIndicatorType = DropIndicatorType::Segmented;
}
switch (s_dropIndicatorType) {
case DropIndicatorType::Classic:
return new ClassicIndicators(dropArea);

View File

@@ -221,7 +221,7 @@ QPixmap WindowBeingDraggedWayland::pixmap() const
{
QPixmap pixmap(size());
QPainter p(&pixmap);
p.setOpacity(0.8);
p.setOpacity(0.7);
if (m_floatingWindow) {
m_floatingWindow->render(&p);

View File

@@ -197,7 +197,10 @@ void ClassicIndicators::setDropLocation(ClassicIndicators::DropLocation location
void ClassicIndicators::updateWindowPosition()
{
QRect rect = this->rect();
QPoint pos = mapToGlobal(QPoint(0, 0));
rect.moveTo(pos);
if (m_indicatorWindow->isWindow()) {
// On all non-wayland platforms it's a top-level.
QPoint pos = mapToGlobal(QPoint(0, 0));
rect.moveTo(pos);
}
m_indicatorWindow->setGeometry(rect);
}

View File

@@ -101,8 +101,22 @@ QString Indicator::iconFileName(bool active) const
: QStringLiteral(":/img/classic_indicators/opaque/%1.png").arg(name);
}
static QWidgetAdapter* parentForIndicatorWindow(ClassicIndicators *classicIndicators_)
{
// On Wayland it can't be a top-level, as we have no way of positioning it
return isWayland() ? classicIndicators_
: nullptr;
}
static Qt::WindowFlags flagsForIndicatorWindow()
{
return isWayland() ? Qt::Widget
: (Qt::Tool | Qt::BypassWindowManagerHint);
}
IndicatorWindow::IndicatorWindow(ClassicIndicators *classicIndicators_)
: QWidget(nullptr, Qt::Tool | Qt::BypassWindowManagerHint)
: QWidget(parentForIndicatorWindow(classicIndicators_), flagsForIndicatorWindow())
, classicIndicators(classicIndicators_)
, m_center(new Indicator(classicIndicators, this, DropIndicatorOverlayInterface::DropLocation_Center)) // Each indicator is not a top-level. Otherwise there's noticeable delay.
, m_left(new Indicator(classicIndicators, this, DropIndicatorOverlayInterface::DropLocation_Left))