Skip to content

Instantly share code, notes, and snippets.

@weoses
Created March 8, 2024 03:43
Show Gist options
  • Save weoses/cb104c99caf0ff1aea7b66ca34c8c2ac to your computer and use it in GitHub Desktop.
Save weoses/cb104c99caf0ff1aea7b66ca34c8c2ac to your computer and use it in GitHub Desktop.
Flameshot-wayland-2-screen-patch
diff --git a/src/core/flameshot.cpp b/src/core/flameshot.cpp
index c7eadcad..3be96268 100644
--- a/src/core/flameshot.cpp
+++ b/src/core/flameshot.cpp
@@ -125,7 +125,7 @@ CaptureWidget* Flameshot::gui(const CaptureRequest& req)
m_captureWindow->activateWindow();
m_captureWindow->raise();
#else
- m_captureWindow->showFullScreen();
+ m_captureWindow->show();
// m_captureWindow->show(); // For CaptureWidget Debugging under Linux
#endif
return m_captureWindow;
diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp
index 49ebff97..87f77ba0 100644
--- a/src/widgets/capture/capturewidget.cpp
+++ b/src/widgets/capture/capturewidget.cpp
@@ -104,6 +104,7 @@ CaptureWidget::CaptureWidget(const CaptureRequest& req,
m_contrastUiColor = m_config.contrastUiColor();
setMouseTracking(true);
initContext(fullScreen, req);
+ QRect wndDims = QRect();
#if (defined(Q_OS_WIN) || defined(Q_OS_MACOS))
// Top left of the whole set of screens
QPoint topLeft(0, 0);
@@ -177,12 +178,17 @@ CaptureWidget::CaptureWidget(const CaptureRequest& req,
r.moveTo(0, 0);
areas.append(r);
#else
+
for (QScreen* const screen : QGuiApplication::screens()) {
QRect r = screen->geometry();
r.moveTo(r.x() / screen->devicePixelRatio(),
r.y() / screen->devicePixelRatio());
r.moveTo(r.topLeft() - topLeftOffset);
areas.append(r);
+ wndDims.setX(qMin(r.x(), wndDims.x()));
+ wndDims.setY(qMin(r.y(), wndDims.y()));
+ wndDims.setWidth( qMax(r.x() + r.width() , wndDims.width()));
+ wndDims.setHeight(qMax(r.y() + r.height(), wndDims.height()));
}
#endif
} else {
@@ -230,7 +236,7 @@ CaptureWidget::CaptureWidget(const CaptureRequest& req,
onToolSizeSettled(m_context.toolSize);
});
- initPanel();
+ initPanel(wndDims);
m_config.checkAndHandleError();
if (m_config.hasError()) {
@@ -1059,16 +1065,14 @@ void CaptureWidget::initContext(bool fullscreen, const CaptureRequest& req)
m_context.request = req;
}
-void CaptureWidget::initPanel()
+void CaptureWidget::initPanel(QRect& panelRect)
{
- QRect panelRect = rect();
if (m_context.fullscreen) {
#if (defined(Q_OS_MACOS) || defined(Q_OS_LINUX))
QScreen* currentScreen = QGuiAppCurrentScreen().currentScreen();
- panelRect = currentScreen->geometry();
auto devicePixelRatio = currentScreen->devicePixelRatio();
- panelRect.moveTo(static_cast<int>(panelRect.x() / devicePixelRatio),
- static_cast<int>(panelRect.y() / devicePixelRatio));
+ panelRect.moveTo(static_cast<int>(panelRect.x() ),
+ static_cast<int>(panelRect.y() ));
#else
panelRect = QGuiApplication::primaryScreen()->geometry();
auto devicePixelRatio =
@@ -1113,7 +1117,7 @@ void CaptureWidget::initPanel()
m_panel->setFixedHeight(currentScreen->geometry().height());
#else
panelRect.moveTo(mapFromGlobal(panelRect.topLeft()));
- panelRect.setWidth(m_colorPicker->width() * 1.5);
+ //panelRect.setWidth(m_colorPicker->width() * 1.5);
m_panel->setGeometry(panelRect);
#endif
connect(m_panel,
diff --git a/src/widgets/capture/capturewidget.h b/src/widgets/capture/capturewidget.h
index 12087e8b..a3e7ab5e 100644
--- a/src/widgets/capture/capturewidget.h
+++ b/src/widgets/capture/capturewidget.h
@@ -116,7 +116,7 @@ private:
bool startDrawObjectTool(const QPoint& pos);
QPointer<CaptureTool> activeToolObject();
void initContext(bool fullscreen, const CaptureRequest& req);
- void initPanel();
+ void initPanel(QRect& bigWnd);
void initSelection();
void initShortcuts();
void initButtons();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment