diff --git a/src/tools/pin/pinwidget.cpp b/src/tools/pin/pinwidget.cpp index 6b4128d3..04623504 100644 --- a/src/tools/pin/pinwidget.cpp +++ b/src/tools/pin/pinwidget.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "pinwidget.h" #include "qguiappcurrentscreen.h" @@ -34,12 +35,11 @@ PinWidget::PinWidget(const QPixmap& pixmap, , m_shadowEffect(new QGraphicsDropShadowEffect(this)) { setWindowIcon(QIcon(GlobalValues::iconPath())); - setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint); + setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | + Qt::Dialog); setFocusPolicy(Qt::StrongFocus); - // set the bottom widget background transparent setAttribute(Qt::WA_TranslucentBackground); setAttribute(Qt::WA_DeleteOnClose); - setWindowTitle("flameshot-pin"); ConfigHandler conf; m_baseColor = conf.uiColor(); m_hoverColor = conf.contrastUiColor(); @@ -69,10 +69,6 @@ PinWidget::PinWidget(const QPixmap& pixmap, static_cast(static_cast(MARGIN) * devicePixelRatio); QRect adjusted_pos = geometry + QMargins(margin, margin, margin, margin); setGeometry(adjusted_pos); -#if defined(Q_OS_LINUX) - setWindowFlags(Qt::X11BypassWindowManagerHint); -#endif - #if defined(Q_OS_MACOS) || defined(Q_OS_LINUX) if (currentScreen != nullptr) { QPoint topLeft = currentScreen->geometry().topLeft(); @@ -152,19 +148,13 @@ void PinWidget::mouseDoubleClickEvent(QMouseEvent*) void PinWidget::mousePressEvent(QMouseEvent* e) { - m_dragStart = e->globalPosition(); - m_offsetX = e->position().x() / width(); - m_offsetY = e->position().y() / height(); + if (QWindow* window = windowHandle(); window != nullptr) { + window->startSystemMove(); + return; + } } -void PinWidget::mouseMoveEvent(QMouseEvent* e) -{ - const QPointF delta = e->globalPosition() - m_dragStart; - const int offsetW = width() * m_offsetX; - const int offsetH = height() * m_offsetY; - move(m_dragStart.x() + delta.x() - offsetW, - m_dragStart.y() + delta.y() - offsetH); -} +void PinWidget::mouseMoveEvent(QMouseEvent* e) {} void PinWidget::keyPressEvent(QKeyEvent* event) { diff --git a/src/tools/pin/pinwidget.h b/src/tools/pin/pinwidget.h index 860ffbf0..54ea92bd 100644 --- a/src/tools/pin/pinwidget.h +++ b/src/tools/pin/pinwidget.h @@ -45,8 +45,6 @@ private: QPixmap m_pixmap; QVBoxLayout* m_layout; QLabel* m_label; - QPointF m_dragStart; - qreal m_offsetX{}, m_offsetY{}; QGraphicsDropShadowEffect* m_shadowEffect; QColor m_baseColor, m_hoverColor;