Skip to content

Commit

Permalink
Add support for MATE Desktop (fixes PCSX2#12169)
Browse files Browse the repository at this point in the history
  • Loading branch information
spixi committed Jan 8, 2025
1 parent 4dafea6 commit 411626a
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions common/Linux/LnxMisc.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team
// SPDX-FileCopyrightText: 2002-2025 PCSX2 Dev Team
// SPDX-License-Identifier: GPL-3.0+

#include "common/Pcsx2Types.h"
Expand All @@ -22,6 +22,8 @@
#include <sys/wait.h>
#include <unistd.h>
#include <dbus/dbus.h>
#include <cstdlib>
#include <cstring>

// Returns 0 on failure (not supported by the operating system).
u64 GetPhysicalMemory()
Expand Down Expand Up @@ -101,6 +103,7 @@ static bool SetScreensaverInhibitDBus(const bool inhibit_requested, const char*
DBusMessage* message = nullptr;
DBusMessage* response = nullptr;
DBusMessageIter message_itr;
char* desktop_session = nullptr;

ScopedGuard cleanup = [&]() {
if (dbus_error_is_set(&error_dbus))
Expand All @@ -122,7 +125,17 @@ static bool SetScreensaverInhibitDBus(const bool inhibit_requested, const char*
s_cookie = 0;
s_comparison_connection = connection;
}
message = dbus_message_new_method_call("org.freedesktop.ScreenSaver", "/org/freedesktop/ScreenSaver", "org.freedesktop.ScreenSaver", bus_method);

desktop_session = std::getenv("DESKTOP_SESSION");
if (desktop_session && std::strncmp(desktop_session, "mate", 4) == 0)
{
message = dbus_message_new_method_call("org.mate.ScreenSaver", "/org/mate/ScreenSaver", "org.mate.ScreenSaver", bus_method);
}
else
{
message = dbus_message_new_method_call("org.freedesktop.ScreenSaver", "/org/freedesktop/ScreenSaver", "org.freedesktop.ScreenSaver", bus_method);
}

if (!message)
return false;
// Initialize an append iterator for the message, gets freed with the message.
Expand Down

0 comments on commit 411626a

Please sign in to comment.