Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gnome-based wayland universal screenshot adapter #3215

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,20 @@
)

if (USE_WAYLAND_CLIPBOARD)
if(!USE_WAYLAND_GNOME)
message(WARNING "You have activated the USE_WAYLAND_CLIPBOARD option, but not the USE_WAYLAND_GNOME option. flameshot will use the dbus protocol to support wayland. if you are using gnome-based wayland, it is recommended that you enable USE_WAYLAND_GNOME")
endif()
if(!USE_WAYLAND_GRIM)
message(WARNING "You activated the USE_WAYLAND_CLIPBOARD option, but did not activate the USE_WAYLAND_GRIM option. Flameshot will use the dbus protocol to support wayland. If you use wlroots-based wayland, it is recommended to enable USE_WAYLAND_GRIM")
endif()
target_compile_definitions(flameshot PRIVATE USE_WAYLAND_CLIPBOARD=1)
target_link_libraries(flameshot KF5::GuiAddons)
endif()

if(USE_WAYLAND_GNOME)
target_compile_definitions(flameshot PRIVATE USE_WAYLAND_GNOME=1)
endif()

if (USE_WAYLAND_GRIM)
target_compile_definitions(flameshot PRIVATE USE_WAYLAND_GRIM=1)
endif()
Expand Down Expand Up @@ -265,7 +272,7 @@
endif ()

if (NOT USE_OPENSSL)
message(WARNING "OpenSSL is required to upload screenshots")

Check warning on line 275 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2019 x64-portable

OpenSSL is required to upload screenshots

Check warning on line 275 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2019 x86-portable

OpenSSL is required to upload screenshots

Check warning on line 275 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2019 x86-installer

OpenSSL is required to upload screenshots

Check warning on line 275 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2019 x64-installer

OpenSSL is required to upload screenshots

Check warning on line 275 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2019 x64-installer

OpenSSL is required to upload screenshots

Check warning on line 275 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2019 x86-installer

OpenSSL is required to upload screenshots

Check warning on line 275 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2019 x86-portable

OpenSSL is required to upload screenshots

Check warning on line 275 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2019 x64-portable

OpenSSL is required to upload screenshots
endif ()
endif ()

Expand Down Expand Up @@ -418,7 +425,7 @@
FILES_MATCHING
PATTERN "*.dll")
else ()
message(WARNING "Unable to find OpenSSL dlls.")

Check warning on line 428 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2019 x64-portable

Unable to find OpenSSL dlls.

Check warning on line 428 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2019 x86-portable

Unable to find OpenSSL dlls.

Check warning on line 428 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2019 x86-installer

Unable to find OpenSSL dlls.

Check warning on line 428 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2019 x64-installer

Unable to find OpenSSL dlls.

Check warning on line 428 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2019 x64-installer

Unable to find OpenSSL dlls.

Check warning on line 428 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2019 x86-installer

Unable to find OpenSSL dlls.

Check warning on line 428 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2019 x86-portable

Unable to find OpenSSL dlls.

Check warning on line 428 in src/CMakeLists.txt

View workflow job for this annotation

GitHub Actions / VS 2019 x64-portable

Unable to find OpenSSL dlls.
endif ()
endif ()

Expand Down
35 changes: 35 additions & 0 deletions src/utils/screengrabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,30 @@ ScreenGrabber::ScreenGrabber(QObject* parent)
: QObject(parent)
{}

void ScreenGrabber::generalGnomeScreenshot(bool& ok, QPixmap& res)
{
#ifdef USE_WAYLAND_GNOME
#if defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
QProcess Process;
QString program = "gnome-screenshot";
QStringList arguments;
QString tmpFileName = "/tmp/gnome_flameshot_png";
arguments << "-f" << tmpFileName;
Process.start(program, arguments);
if (Process.waitForFinished()) {
res.load(tmpFileName);
ok = true;
} else {
ok = false;
AbstractLogger::error() << tr(
"The GNOME-based Universal wayland Screen Capture Adapter requires "
"gnome-screenshot as the screen capture component of wayland. If the "
"screen capture component is missing, please install it!");
}
#endif
#endif
}

void ScreenGrabber::generalGrimScreenshot(bool& ok, QPixmap& res)
{
#ifdef USE_WAYLAND_GRIM
Expand Down Expand Up @@ -126,6 +150,17 @@ QPixmap ScreenGrabber::grabEntireDesktop(bool& ok)
// handle screenshot based on DE
switch (m_info.windowManager()) {
case DesktopInfo::GNOME:
#ifndef USE_WAYLAND_GNOME
AbstractLogger::warning() << tr(
"If the USE_WAYLAND_GNOME option is not enabled, the default "
"dbus protocol will be used directly. Note that it is not "
"recommended to use the default dbus protocol under wayland "
"in gnome environments. It is recommended to recompile with "
"the USE_WAYLAND_GNOME flag to activate the gnome-screenshot "
"based generic wayland screenshot adapter");
#else
generalGnomeScreenshot(ok, res);
#endif
case DesktopInfo::KDE:
freeDesktopPortal(ok, res);
break;
Expand Down
1 change: 1 addition & 0 deletions src/utils/screengrabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ScreenGrabber : public QObject
QPixmap grabScreen(QScreen* screenNumber, bool& ok);
void freeDesktopPortal(bool& ok, QPixmap& res);
void generalGrimScreenshot(bool& ok, QPixmap& res);
void generalGnomeScreenshot(bool& ok, QPixmap& res);
QRect desktopGeometry();

private:
Expand Down
Loading