Skip to content

Commit 53d4da8

Browse files
Multimonitor fix (flameshot-org#4498)
* Rework capture system to only enter fullscreen widget on one monitor * Sort monitor previews by screen position instead of Qt index (flameshot-org#4522) The monitor selection dialog displayed monitors in Qt's default screen order (by connector name, e.g. DP-1 before DP-2), which can differ from the physical arrangement configured in the display settings. This sorts the preview widgets by their X geometry position so they match the user's actual left-to-right layout. --------- Co-authored-by: Brian J. Cohen <brianjcohen@gmail.com>
1 parent 739a809 commit 53d4da8

20 files changed

+863
-344
lines changed

PKGBUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ depends=('qt6-base' 'qt6-svg' 'hicolor-icon-theme' 'kguiaddons')
1010
makedepends=('qt6-tools' 'cmake' 'ninja')
1111
optdepends=(
1212
'gnome-shell-extension-appindicator: for system tray icon if you are using Gnome'
13-
'grim: for wlroots wayland support'
1413
'xdg-desktop-portal: for wayland support, you will need the implementation for your wayland desktop environment'
1514
'qt6-imageformats: for additional export image formats (e.g. tiff, webp, and more)'
1615
)

docs/Sway and wlroots support.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Flameshot currently supports Sway and other wlroots based Wayland compositors through [xdg-desktop-portal-wlr](https://github.com/emersion/xdg-desktop-portal-wlr). However, due to the way dbus works, there may be some extra steps required for the integration to work properly.
33

44
## Basic steps
5-
The following packages need to be installed: `xdg-desktop-portal xdg-desktop-portal-wlr grim`. Please ensure your distro packages these, or install them manually.
5+
The following packages need to be installed: `xdg-desktop-portal xdg-desktop-portal-wlr`. Please ensure your distro packages these, or install them manually.
66

77
Ensure that environment variables are set properly. If your distro does not set them automatically, use a launch script to export `XDG_CURRENT_DESKTOP=sway` or `XDG_CURRENT_DESKTOP=river` **before** Sway or River is launched.
88
```sh

flameshot.example.ini

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@
5454
;; Whether the tray icon is disabled (bool)
5555
;disabledTrayIcon=false
5656
;
57-
;; Use grim-based wayland universal screenshot adapter (bool)
58-
;useGrimAdapter=false
59-
;
60-
;; Disable Grim Warning notification (bool)
61-
;disabledGrimWarning=true
62-
;
6357
;; Automatically close daemon when it's not needed (bool)
6458
;; (This option is not available on Windows)
6559
;autoCloseIdleDaemon=false

src/config/generalconf.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ GeneralConf::GeneralConf(QWidget* parent)
3737
initAutoCloseIdleDaemon();
3838
#endif
3939
initShowTrayIcon();
40-
initUseGrimAdapter();
4140
initShowDesktopNotification();
4241
initShowAbortNotification();
4342
#if !defined(DISABLE_UPDATE_CHECKER)
@@ -124,10 +123,6 @@ void GeneralConf::_updateComponents(bool allowEmptySavePath)
124123
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
125124
m_showTray->setChecked(!config.disabledTrayIcon());
126125
#endif
127-
128-
#if defined(Q_OS_LINUX)
129-
m_useGrimAdapter->setChecked(config.useGrimAdapter());
130-
#endif
131126
}
132127

133128
void GeneralConf::updateComponents()
@@ -160,11 +155,6 @@ void GeneralConf::showAbortNotificationChanged(bool checked)
160155
ConfigHandler().setShowAbortNotification(checked);
161156
}
162157

163-
void GeneralConf::useGrimAdapter(bool checked)
164-
{
165-
ConfigHandler().useGrimAdapter(checked);
166-
}
167-
168158
#if !defined(DISABLE_UPDATE_CHECKER)
169159
void GeneralConf::checkForUpdatesChanged(bool checked)
170160
{
@@ -343,24 +333,6 @@ void GeneralConf::initShowTrayIcon()
343333
#endif
344334
}
345335

346-
void GeneralConf::initUseGrimAdapter()
347-
{
348-
#if defined(Q_OS_LINUX)
349-
m_useGrimAdapter =
350-
new QCheckBox(tr("Use grim to capture screenshots"), this);
351-
m_useGrimAdapter->setToolTip(
352-
tr("Grim is a wayland only utility to capture screens based on the "
353-
"screencopy protocol. Generally only enable on minimal wayland window "
354-
"managers like sway, hyprland, etc."));
355-
m_scrollAreaLayout->addWidget(m_useGrimAdapter);
356-
357-
connect(m_useGrimAdapter,
358-
&QCheckBox::clicked,
359-
this,
360-
&GeneralConf::useGrimAdapter);
361-
#endif
362-
}
363-
364336
void GeneralConf::initHistoryConfirmationToDelete()
365337
{
366338
m_historyConfirmationToDelete = new QCheckBox(

src/config/generalconf.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ private slots:
3838
void showSidePanelButtonChanged(bool checked);
3939
void showDesktopNotificationChanged(bool checked);
4040
void showAbortNotificationChanged(bool checked);
41-
void useGrimAdapter(bool checked);
4241
#if !defined(DISABLE_UPDATE_CHECKER)
4342
void checkForUpdatesChanged(bool checked);
4443
#endif
@@ -89,7 +88,6 @@ private slots:
8988
void initShowSidePanelButton();
9089
void initShowStartupLaunchMessage();
9190
void initShowTrayIcon();
92-
void initUseGrimAdapter();
9391
void initSquareMagnifier();
9492
void initUndoLimit();
9593
void initUploadWithoutConfirmation();
@@ -111,7 +109,6 @@ private slots:
111109
QCheckBox* m_sysNotifications;
112110
QCheckBox* m_abortNotifications;
113111
QCheckBox* m_showTray;
114-
QCheckBox* m_useGrimAdapter;
115112
QCheckBox* m_helpMessage;
116113
QCheckBox* m_sidePanelButton;
117114
#if !defined(DISABLE_UPDATE_CHECKER)

src/core/capturerequest.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ CaptureRequest::CaptureRequest(CaptureRequest::CaptureMode mode,
1818
, m_delay(delay)
1919
, m_tasks(tasks)
2020
, m_data(std::move(data))
21+
, m_selectedMonitor(-1)
22+
, m_hasSelectedMonitor(false)
2123
{
2224

2325
ConfigHandler config;
@@ -86,3 +88,19 @@ void CaptureRequest::setInitialSelection(const QRect& selection)
8688
{
8789
m_initialSelection = selection;
8890
}
91+
92+
void CaptureRequest::setSelectedMonitor(int monitorIndex)
93+
{
94+
m_selectedMonitor = monitorIndex;
95+
m_hasSelectedMonitor = true;
96+
}
97+
98+
int CaptureRequest::selectedMonitor() const
99+
{
100+
return m_selectedMonitor;
101+
}
102+
103+
bool CaptureRequest::hasSelectedMonitor() const
104+
{
105+
return m_hasSelectedMonitor;
106+
}

src/core/capturerequest.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ class CaptureRequest
4949
void addSaveTask(const QString& path = QString());
5050
void addPinTask(const QRect& pinWindowGeometry);
5151
void setInitialSelection(const QRect& selection);
52+
void setSelectedMonitor(int monitorIndex);
53+
int selectedMonitor() const;
54+
bool hasSelectedMonitor() const;
5255

5356
private:
5457
CaptureMode m_mode;
@@ -57,6 +60,8 @@ class CaptureRequest
5760
ExportTask m_tasks;
5861
QVariant m_data;
5962
QRect m_pinWindowGeometry, m_initialSelection;
63+
int m_selectedMonitor;
64+
bool m_hasSelectedMonitor;
6065

6166
CaptureRequest() {}
6267
};

src/utils/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ target_sources(
1414
PRIVATE abstractlogger.cpp
1515
filenamehandler.cpp
1616
screengrabber.cpp
17+
monitorpreview.cpp
1718
confighandler.cpp
1819
systemnotification.cpp
1920
valuehandler.cpp

src/utils/confighandler.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ static QMap<class QString, QSharedPointer<ValueHandler>>
7979
OPTION("showDesktopNotification" ,Bool ( true )),
8080
OPTION("showAbortNotification" ,Bool ( true )),
8181
OPTION("disabledTrayIcon" ,Bool ( false )),
82-
OPTION("useGrimAdapter" ,Bool ( false )),
83-
OPTION("disabledGrimWarning" ,Bool ( false )),
8482
OPTION("historyConfirmationToDelete" ,Bool ( true )),
8583
#if !defined(DISABLE_UPDATE_CHECKER)
8684
OPTION("checkForUpdates" ,Bool ( true )),

src/utils/confighandler.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ class ConfigHandler : public QObject
9090
CONFIG_GETTER_SETTER(showAbortNotification, setShowAbortNotification, bool)
9191
CONFIG_GETTER_SETTER(filenamePattern, setFilenamePattern, QString)
9292
CONFIG_GETTER_SETTER(disabledTrayIcon, setDisabledTrayIcon, bool)
93-
CONFIG_GETTER_SETTER(useGrimAdapter, useGrimAdapter, bool)
94-
CONFIG_GETTER_SETTER(disabledGrimWarning, disabledGrimWarning, bool)
9593
CONFIG_GETTER_SETTER(drawThickness, setDrawThickness, int)
9694
CONFIG_GETTER_SETTER(drawFontSize, setDrawFontSize, int)
9795
CONFIG_GETTER_SETTER(drawCircleCounterSize, setDrawCircleCounterSize, int)

0 commit comments

Comments
 (0)