Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion panels/dock/tray/frame/util/dockpopupwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "dockpopupwindow.h"
#include <dwindowmanagerhelper.h>
#include "utils.h"
#include "dbusutil.h"
#include "dockscreen.h"
Expand All @@ -15,13 +16,16 @@
#include <QAccessibleEvent>
#include <QCursor>

#include <DStyleHelper>

DWIDGET_USE_NAMESPACE

#define DOCK_SCREEN DockScreen::instance()
#define DIS_INS DisplayManager::instance()

DockPopupWindow::DockPopupWindow(QWidget *parent)
: DBlurEffectWidget(parent)
, m_radius(-1)
, m_model(false)
, m_eventMonitor(new XEventMonitor(xEventMonitorService, xEventMonitorPath, QDBusConnection::sessionBus(), this))
, m_enableMouseRelease(true)
Expand All @@ -30,6 +34,9 @@ DockPopupWindow::DockPopupWindow(QWidget *parent)
{
setContentsMargins(0, 0, 0, 0);
m_wmHelper = DWindowManagerHelper::instance();
m_windowHandle = new DPlatformWindowHandle(this);

connect(m_wmHelper, &DWindowManagerHelper::hasCompositeChanged, this, &DockPopupWindow::updateRadius);

setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint);
if (Utils::IS_WAYLAND_DISPLAY) {
Expand Down Expand Up @@ -59,8 +66,16 @@ QWidget *DockPopupWindow::getContent()
return m_lastWidget;
}

void DockPopupWindow::setContent(QWidget *content)
void DockPopupWindow::setContent(QWidget *content, int radius)
{
if (radius != -1) {
setRadius(radius);
}
else {
DStyleHelper dstyle;
setRadius(dstyle.pixelMetric(DStyle::PM_FrameRadius));
}

if (m_lastWidget)
m_lastWidget->removeEventFilter(this);
content->installEventFilter(this);
Expand Down Expand Up @@ -93,6 +108,17 @@ QWidget *DockPopupWindow::extendWidget() const
return m_extendWidget;
}

void DockPopupWindow::setRadius(int radius)
{
if (m_radius == radius) {
return;
}

m_radius = radius;

updateRadius();
}

void DockPopupWindow::show(const QPoint &pos, const bool model)
{
m_model = model;
Expand Down Expand Up @@ -211,6 +237,14 @@ bool DockPopupWindow::eventFilter(QObject *o, QEvent *e)
return false;
}

void DockPopupWindow::updateRadius()
{
const bool hasComposite = m_wmHelper->hasComposite();
m_windowHandle->setEnableBlurWindow(hasComposite);
m_windowHandle->setTranslucentBackground(hasComposite);
m_windowHandle->setWindowRadius((hasComposite ? m_radius : 0) * devicePixelRatioF());
}

void DockPopupWindow::ensureRaised()
{
if (isVisible())
Expand Down
7 changes: 6 additions & 1 deletion panels/dock/tray/frame/util/dockpopupwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <DBlurEffectWidget>
#include <dregionmonitor.h>
#include <DWindowManagerHelper>
#include <DPlatformWindowHandle>

#include <QVBoxLayout>
#include <QPainter>
Expand All @@ -33,10 +34,11 @@ class DockPopupWindow : public Dtk::Widget::DBlurEffectWidget
bool model() const;

QWidget *getContent();
void setContent(QWidget *content);
void setContent(QWidget *content, int radius = -1);
void setExtendWidget(QWidget *widget);
void setPosition(Dock::Position position);
QWidget *extendWidget() const;
void setRadius(int radius);

public slots:
void show(const QPoint &pos, const bool model = false);
Expand All @@ -61,15 +63,18 @@ public slots:
private slots:
void ensureRaised();
void onButtonPress(int type, int x, int y, const QString &key);
void updateRadius();

private:
int m_radius;
bool m_model;
QPoint m_lastPoint;
Dock::Position m_position;

XEventMonitor *m_eventMonitor;
QString m_eventKey;
DWindowManagerHelper *m_wmHelper;
DPlatformWindowHandle *m_windowHandle;
bool m_enableMouseRelease;
QWidget *m_extendWidget;
QPointer<QWidget> m_lastWidget;
Expand Down
2 changes: 1 addition & 1 deletion panels/dock/tray/frame/window/quickpluginwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ void QuickDockItem::enterEvent(QEnterEvent *event)

m_popupWindow->setPosition(m_position);
m_popupWindow->resize(tipWidget->sizeHint());
m_popupWindow->setContent(tipWidget);
m_popupWindow->setContent(tipWidget, 4);

m_popupWindow->show(popupMarkPoint());
}
Expand Down