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
26 changes: 23 additions & 3 deletions docs/Sway and wlroots support.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Flameshot currently supports Sway and other wlroots based Wayland compositors th
## Basic steps
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.

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` **before** Sway is launched.
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.
```sh
#!/bin/bash
export SDL_VIDEODRIVER=wayland
Expand All @@ -15,7 +15,20 @@ export XDG_SESSION_DESKTOP=sway
exec sway
```

You will also need to ensure that systemd/dbus is aware of these environment variables; this should be done **in your sway config** so that the DISPLAY and WAYLAND_DISPLAY variables are defined.
or


```sh
#!/bin/bash
export SDL_VIDEODRIVER=wayland
export _JAVA_AWT_WM_NONREPARENTING=1
export QT_QPA_PLATFORM=wayland
export XDG_CURRENT_DESKTOP=river
export XDG_SESSION_DESKTOP=river
exec river
```

You will also need to ensure that systemd/dbus is aware of these environment variables; this should be done **in your sway or river config** so that the DISPLAY and WAYLAND_DISPLAY variables are defined.

(taken from [Sway wiki](https://github.com/swaywm/sway/wiki#gtk-applications-take-20-seconds-to-start)):
```sh
Expand All @@ -29,6 +42,13 @@ To ensure that Flameshot is correctly positioned on multiple outputs (monitors)
for_window [app_id="flameshot"] border pixel 0, floating enable, fullscreen disable, move absolute position 0 0
```

and add the following on your River config:

```
riverctl rule-add -app-id "flameshot" float
```

Otherwise, flameshot will not take all of the screen and tiles its window instead like a normal application. Note however, that some clipboard stuff is broken so it might be good to save your screenshot as a file while having it copied to a clipboard in case if clipboard does some weird stuff like not pasting the overall screenshot.


Starting from 0.17.0 xdg-desktop-portal requires a configuration file (e.g. in ~/.config/xdg-desktop-portal/sway-portals.conf):
Expand Down Expand Up @@ -68,7 +88,7 @@ and add the following on your config such as in `$HOME/.config/river/init`
riverctl float-filter-add "flameshot"
```

Otherwise, Flameshot will not take all of the screen and tiles its window instead like a normal application. Note however, that some clipboard stuff is broken so it might be good to save your screenshot as a file while having it copied to a clipboard in case if clipboard does some weird stuff like not pasting the overall screenshot.
Otherwise, Flameshot will not take all of the screen and tiles its window instead like a normal application.

#### For more information, please refer to https://github.com/emersion/xdg-desktop-portal-wlr/wiki/%22It-doesn't-work%22-Troubleshooting-Checklist

17 changes: 17 additions & 0 deletions src/config/generalconf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ GeneralConf::GeneralConf(QWidget* parent)
initShowMagnifier();
initSquareMagnifier();
initJpegQuality();
initReverseArrow();
// this has to be at the end
initConfigButtons();
updateComponents();
Expand Down Expand Up @@ -96,6 +97,7 @@ void GeneralConf::_updateComponents(bool allowEmptySavePath)
m_showMagnifier->setChecked(config.showMagnifier());
m_squareMagnifier->setChecked(config.squareMagnifier());
m_saveLastRegion->setChecked(config.saveLastRegion());
m_reverseArrow->setChecked(config.reverseArrow());

#if !defined(Q_OS_WIN)
m_autoCloseIdleDaemon->setChecked(config.autoCloseIdleDaemon());
Expand Down Expand Up @@ -829,6 +831,16 @@ void GeneralConf::initJpegQuality()
&GeneralConf::setJpegQuality);
}

void GeneralConf::initReverseArrow()
{
m_reverseArrow = new QCheckBox(tr("Reverse arrow"), this);
m_reverseArrow->setToolTip(tr("Draw the arrow head first"));
m_scrollAreaLayout->addWidget(m_reverseArrow);

connect(
m_reverseArrow, &QCheckBox::clicked, this, &GeneralConf::setReverseArrow);
}

void GeneralConf::setSelGeoHideTime(int v)
{
ConfigHandler().setValue("showSelectionGeometryHideTime", v);
Expand Down Expand Up @@ -859,3 +871,8 @@ void GeneralConf::useJpgForClipboardChanged(bool checked)
{
ConfigHandler().setUseJpgForClipboard(checked);
}

void GeneralConf::setReverseArrow(bool checked)
{
ConfigHandler().setReverseArrow(checked);
}
3 changes: 3 additions & 0 deletions src/config/generalconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ private slots:
void setGeometryLocation(int index);
void setSelGeoHideTime(int v);
void setJpegQuality(int v);
void setReverseArrow(bool checked);

private:
const QString chooseFolder(const QString& currentPath = "");
Expand Down Expand Up @@ -95,6 +96,7 @@ private slots:
void initSaveLastRegion();
void initShowSelectionGeometry();
void initJpegQuality();
void initReverseArrow();

void _updateComponents(bool allowEmptySavePath);

Expand Down Expand Up @@ -141,4 +143,5 @@ private slots:
QComboBox* m_selectGeometryLocation;
QSpinBox* m_xywhTimeout;
QSpinBox* m_jpegQuality;
QCheckBox* m_reverseArrow;
};
10 changes: 8 additions & 2 deletions src/tools/arrow/arrowtool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-FileCopyrightText: 2017-2019 Alejandro Sirgo Rica & Contributors

#include "arrowtool.h"
#include "confighandler.h"
#include <cmath>

namespace {
Expand Down Expand Up @@ -148,10 +149,15 @@ void ArrowTool::copyParams(const ArrowTool* from, ArrowTool* to)

void ArrowTool::process(QPainter& painter, const QPixmap& pixmap)
{
bool isArrowReversed = ConfigHandler().reverseArrow();

const QPoint& head = isArrowReversed ? points().second : points().first;
const QPoint& tail = isArrowReversed ? points().first : points().second;

Q_UNUSED(pixmap)
painter.setPen(QPen(color(), size()));
painter.drawLine(getShorterLine(points().first, points().second, size()));
m_arrowPath = getArrowHead(points().first, points().second, size());
painter.drawLine(getShorterLine(head, tail, size()));
m_arrowPath = getArrowHead(head, tail, size());
painter.fillPath(m_arrowPath, QBrush(color()));
}

Expand Down
3 changes: 2 additions & 1 deletion src/utils/confighandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ static QMap<class QString, QSharedPointer<ValueHandler>>
OPTION("uploadClientSecret" ,String ( "313baf0c7b4d3ff" )),
OPTION("showSelectionGeometry" , BoundedInt (0,5,4)),
OPTION("showSelectionGeometryHideTime", LowerBoundedInt (0, 3000)),
OPTION("jpegQuality", BoundedInt (0,100,75))
OPTION("jpegQuality", BoundedInt (0,100,75)),
OPTION("reverseArrow" ,Bool ( false )),
};

static QMap<QString, QSharedPointer<KeySequence>> recognizedShortcuts = {
Expand Down
1 change: 1 addition & 0 deletions src/utils/confighandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class ConfigHandler : public QObject
CONFIG_GETTER_SETTER(saveLastRegion, setSaveLastRegion, bool)
CONFIG_GETTER_SETTER(showSelectionGeometry, setShowSelectionGeometry, int)
CONFIG_GETTER_SETTER(jpegQuality, setJpegQuality, int)
CONFIG_GETTER_SETTER(reverseArrow, setReverseArrow, bool)
CONFIG_GETTER_SETTER(showSelectionGeometryHideTime,
showSelectionGeometryHideTime,
int)
Expand Down
5 changes: 3 additions & 2 deletions src/utils/desktopinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ DesktopInfo::WM DesktopInfo::windowManager()
if (desktop.contains(QLatin1String("qtile"), Qt::CaseInsensitive)) {
return DesktopInfo::QTILE;
}
if (desktop.contains(QLatin1String("sway"), Qt::CaseInsensitive)) {
return DesktopInfo::SWAY;
if (desktop.contains(QLatin1String("sway"), Qt::CaseInsensitive) ||
desktop.contains(QLatin1String("river"), Qt::CaseInsensitive)) {
return DesktopInfo::WLROOTS;
}
if (desktop.contains(QLatin1String("Hyprland"), Qt::CaseInsensitive)) {
return DesktopInfo::HYPRLAND;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/desktopinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DesktopInfo
COSMIC,
OTHER,
QTILE,
SWAY,
WLROOTS,
HYPRLAND
};

Expand Down
2 changes: 1 addition & 1 deletion src/utils/screengrabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool& ok)
freeDesktopPortal(ok, res);
break;
case DesktopInfo::QTILE:
case DesktopInfo::SWAY:
case DesktopInfo::WLROOTS:
case DesktopInfo::HYPRLAND:
case DesktopInfo::OTHER: {
if (!ConfigHandler().useGrimAdapter()) {
Expand Down
Loading