|
3 | 3 | #include <QGraphicsDropShadowEffect> |
4 | 4 | #include <QGraphicsOpacityEffect> |
5 | 5 | #include <QPinchGesture> |
| 6 | +#include <QWindow> |
6 | 7 |
|
7 | 8 | #include "pinwidget.h" |
8 | 9 | #include "qguiappcurrentscreen.h" |
@@ -34,12 +35,11 @@ PinWidget::PinWidget(const QPixmap& pixmap, |
34 | 35 | , m_shadowEffect(new QGraphicsDropShadowEffect(this)) |
35 | 36 | { |
36 | 37 | setWindowIcon(QIcon(GlobalValues::iconPath())); |
37 | | - setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint); |
| 38 | + setWindowFlags(Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint | |
| 39 | + Qt::Dialog); |
38 | 40 | setFocusPolicy(Qt::StrongFocus); |
39 | | - // set the bottom widget background transparent |
40 | 41 | setAttribute(Qt::WA_TranslucentBackground); |
41 | 42 | setAttribute(Qt::WA_DeleteOnClose); |
42 | | - setWindowTitle("flameshot-pin"); |
43 | 43 | ConfigHandler conf; |
44 | 44 | m_baseColor = conf.uiColor(); |
45 | 45 | m_hoverColor = conf.contrastUiColor(); |
@@ -69,10 +69,6 @@ PinWidget::PinWidget(const QPixmap& pixmap, |
69 | 69 | static_cast<int>(static_cast<double>(MARGIN) * devicePixelRatio); |
70 | 70 | QRect adjusted_pos = geometry + QMargins(margin, margin, margin, margin); |
71 | 71 | setGeometry(adjusted_pos); |
72 | | -#if defined(Q_OS_LINUX) |
73 | | - setWindowFlags(Qt::X11BypassWindowManagerHint); |
74 | | -#endif |
75 | | - |
76 | 72 | #if defined(Q_OS_MACOS) || defined(Q_OS_LINUX) |
77 | 73 | if (currentScreen != nullptr) { |
78 | 74 | QPoint topLeft = currentScreen->geometry().topLeft(); |
@@ -152,19 +148,13 @@ void PinWidget::mouseDoubleClickEvent(QMouseEvent*) |
152 | 148 |
|
153 | 149 | void PinWidget::mousePressEvent(QMouseEvent* e) |
154 | 150 | { |
155 | | - m_dragStart = e->globalPosition(); |
156 | | - m_offsetX = e->position().x() / width(); |
157 | | - m_offsetY = e->position().y() / height(); |
| 151 | + if (QWindow* window = windowHandle(); window != nullptr) { |
| 152 | + window->startSystemMove(); |
| 153 | + return; |
| 154 | + } |
158 | 155 | } |
159 | 156 |
|
160 | | -void PinWidget::mouseMoveEvent(QMouseEvent* e) |
161 | | -{ |
162 | | - const QPointF delta = e->globalPosition() - m_dragStart; |
163 | | - const int offsetW = width() * m_offsetX; |
164 | | - const int offsetH = height() * m_offsetY; |
165 | | - move(m_dragStart.x() + delta.x() - offsetW, |
166 | | - m_dragStart.y() + delta.y() - offsetH); |
167 | | -} |
| 157 | +void PinWidget::mouseMoveEvent(QMouseEvent* e) {} |
168 | 158 |
|
169 | 159 | void PinWidget::keyPressEvent(QKeyEvent* event) |
170 | 160 | { |
|
0 commit comments