Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
Use EI screen when XDG_SESSION_TYPE is "wayland" (deskflow#7455)
Browse files Browse the repository at this point in the history
* Use EI screen when XDG_SESSION_TYPE is wayland

* Log when using EI vs X

* Update ChangeLog
  • Loading branch information
nbolton authored Aug 30, 2024
1 parent 88cc3b5 commit 1ebfe2a
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 59 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Enhancements:
- #7448 Only add PR comments for internal PR
- #7445 Update `config.yaml` to support Linux Mint build target
- #7453 Change default value for dev thanks message
- #7455 Use EI screen when XDG_SESSION_TYPE is "wayland"

# 1.15.1

Expand Down
29 changes: 29 additions & 0 deletions src/lib/platform/wayland.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2024 Symless Ltd.
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file LICENSE that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include <string>

namespace synergy::platform {

inline bool isWayland() {
const std::string session = getenv("XDG_SESSION_TYPE");
return session == "wayland";
}

} // namespace synergy::platform
13 changes: 1 addition & 12 deletions src/lib/synergy/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,24 +219,13 @@ class MinimalApp : public App {
" reading error messages that occur on exit.\n"
#endif

#if WINAPI_LIBEI

const auto kNoWaylandEiArg =
" --no-wayland-ei do not use EI (emulated input) for\n"
" Wayland and instead use the legacy\n"
" X Window System.\n";
const auto kHelpNoWayland = "";

#elif WINAPI_XWINDOWS

const auto kNoWaylandEiArg = "";
#if !defined(WINAPI_LIBEI) && WINAPI_XWINDOWS
const auto kHelpNoWayland =
"\n"
"Your Linux distribution does not support Wayland EI (emulated input)\n"
"which is required for Wayland support. Please use a Linux distribution\n"
"that supports Wayland EI.\n";

#else
const auto kNoWaylandEiArg = "";
const auto kHelpNoWayland = "";
#endif
10 changes: 0 additions & 10 deletions src/lib/synergy/ArgParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,6 @@ bool ArgParser::parsePlatformArgs(
argsBase.m_disableXInitThreads = true;
}

#if WINAPI_LIBEI
else if (isArg(i, argc, argv, nullptr, "--no-wayland-ei")) {
argsBase.m_disableWaylandEi = true;
}

else if (!isServer && isArg(i, argc, argv, nullptr, "--no-wayland-portal")) {
argsBase.m_disableWaylandPortal = true;
}
#endif

else {
// option not supported here
return false;
Expand Down
18 changes: 0 additions & 18 deletions src/lib/synergy/ArgsBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,6 @@

namespace synergy {

#if WINAPI_LIBEI
const auto kDisableEiDefault = false;
#else
const auto kDisableEiDefault = true;
#endif

#if WINAPI_LIBPORTAL
const auto kDisablePortalDefault = false;
#else
const auto kDisablePortalDefault = true;
#endif

/**
* @brief This is the base Argument class that will store the generic
* arguments passed into the applications this will be derived
Expand Down Expand Up @@ -106,12 +94,6 @@ class ArgsBase {
/// @brief Stop this computer from sleeping
bool m_preventSleep = false;

/// @brief Disable EI (Emulated Input) for Wayland support
bool m_disableWaylandEi = kDisableEiDefault;

/// @brief Disable Portal for Wayland support (use EI sockets instead)
bool m_disableWaylandPortal = kDisablePortalDefault;

#if SYSAPI_WIN32
bool m_debugServiceWait = false;
bool m_pauseOnExit = false;
Expand Down
18 changes: 7 additions & 11 deletions src/lib/synergy/ClientApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "net/SocketMultiplexer.h"
#include "net/TCPSocketFactory.h"
#include "net/XSocket.h"
#include "platform/wayland.h"
#include "synergy/ArgParser.h"
#include "synergy/ClientArgs.h"
#include "synergy/Screen.h"
Expand Down Expand Up @@ -139,15 +140,9 @@ void ClientApp::help() {
<< " --host act as a host; invert server/client mode\n"
<< " and listen instead of connecting.\n"
#if WINAPI_XWINDOWS
<< " --display <display> connect to the X server at <display>\n"
<< " --display <display> when in X mode, connect to the X server\n"
<< " at <display>\n."
<< " --no-xinitthreads do not call XInitThreads()\n"
#endif
#if defined(WINAPI_XWINDOWS) && defined(WINAPI_LIBEI)
<< kNoWaylandEiArg
#endif
#if defined(WINAPI_LIBPORTAL) && defined(WINAPI_LIBEI)
<< " --no-wayland-portal do not use Portal for Wayland and \n"
<< " connect to EI socket instead.\n"
#endif
<< HELP_COMMON_INFO_2 << "\n"
<< "* marks defaults.\n"
Expand Down Expand Up @@ -188,13 +183,14 @@ synergy::Screen *ClientApp::createScreen() {
m_events);
#endif
#if WINAPI_LIBEI
if (!args().m_disableWaylandEi) {
if (synergy::platform::isWayland()) {
LOG((CLOG_INFO "using ei screen for wayland"));
return new synergy::Screen(
new synergy::EiScreen(false, m_events, !args().m_disableWaylandPortal),
m_events);
new synergy::EiScreen(false, m_events, true), m_events);
}
#endif
#if WINAPI_XWINDOWS
LOG((CLOG_INFO "using legacy x windows screen"));
return new synergy::Screen(
new XWindowsScreen(
args().m_display, false, args().m_disableXInitThreads,
Expand Down
15 changes: 7 additions & 8 deletions src/lib/synergy/ServerApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "net/SocketMultiplexer.h"
#include "net/TCPSocketFactory.h"
#include "net/XSocket.h"
#include "platform/wayland.h"
#include "server/ClientListener.h"
#include "server/ClientProxy.h"
#include "server/PrimaryClient.h"
Expand Down Expand Up @@ -139,14 +140,11 @@ void ServerApp::help() {
<< "instead.\n" HELP_COMMON_INFO_1

#if WINAPI_XWINDOWS
<< " --display <display> connect to the X server at <display>\n"
<< " --display <display> when in X mode, connect to the X server\n"
<< " at <display>\n."
<< " --no-xinitthreads do not call XInitThreads()\n"
#endif

#if defined(WINAPI_XWINDOWS) && defined(WINAPI_LIBEI)
<< kNoWaylandEiArg
#endif

<< HELP_SYS_INFO HELP_COMMON_INFO_2 "\n"
<< "* marks defaults.\n"

Expand Down Expand Up @@ -552,14 +550,15 @@ synergy::Screen *ServerApp::createScreen() {
#endif

#if WINAPI_LIBEI
if (!args().m_disableWaylandEi) {
if (synergy::platform::isWayland()) {
LOG((CLOG_INFO "using ei screen for wayland"));
return new synergy::Screen(
new synergy::EiScreen(true, m_events, !args().m_disableWaylandPortal),
m_events);
new synergy::EiScreen(true, m_events, true), m_events);
}
#endif

#if WINAPI_XWINDOWS
LOG((CLOG_INFO "using legacy x windows screen"));
return new synergy::Screen(
new XWindowsScreen(
args().m_display, true, args().m_disableXInitThreads, 0, m_events),
Expand Down

0 comments on commit 1ebfe2a

Please sign in to comment.