* Add libei and libportal
* Port libei and libportal code by Peter Hutterer and Olivier Fourdan
* Add Peter Hutterer and Olivier Fourdan to important devs list
* Improve error handling for libei and libportal builds
* Checkout libportal tags/0.7.1
* Hack out the gi-docgen clone
* Remove new submodules in favor of using ExternalProject_Add
* Remove submodule dirs
* Use ExternalProject_Add instead of submodules
* Fixed namespace
* Hack to work around type libportal causing type conflicts
* Add log helper functions
* Use original log functions
* Switch to FetchContent, use libportal a1530a9 (unreleased) and use camelCase member names for consistency
* Restore a few events (much more work required)
* Add TODOs for supporting multiple lib versions
* Revert "Switch to FetchContent, use libportal a1530a9 (unreleased) and use camelCase member names for consistency"
This reverts commit 610cebb5b6a08282eee68f4424fcdbe9eaab4bf9.
* Simplify cmake config by removing builds for libei and libportal (will do this in `install_deps.py` instead)
* Remove submodules
* Remove .gitmodules
* Use meson to build subprojects
* Update copyright with Peter Hutterer's guidance
* Use meson for installing deps
* Fixed typo in tag name
* Remove submodules
* Remove old submodules
* Fixed libei name
* Defaults for pugixml and gtest depending on whether source exists in subprojects
* Ignore some subproject dirs
* Make deps OS-specific
* Move python deps to pyproject
* Only compile and install on Linux with Meson
* Revert "Move python deps to pyproject"
This reverts commit 92c8a287b8376a4d166058c85f1d6081f6fdb423.
* Add ninja to brewfile
* Add python3-attr
* Restore original coverage config
* Add ninja for meson
* Include meson in same try-except
* Fixed ninja dep name
* Move libs to correct oS
* Fixed include for wintoast
* Disable docs for libportal
* More options for libei and libportal
* Fixed option for libei
* Use ninja directly to install
* Revert "Use ninja directly to install"
This reverts commit c926d78ba483406a55acd10fb157c39e13f90b71.
* Meson install verbose
* Prints stdout/stderr
* Remove `from None`
* Remove submodules that somehow crept back in?!
* Prepend sudo if exists
* Add libei deps for all distros
* Fixed Fedora package name
* Add more deps for other distros
* Add more libs (including pugixml)
* Fix lib name
* Drop -u from pacman
* Add vala to rhel
* Make libportal optional
* Make portal link optional
* Remove example code
* Always use system pugixml
* Disable interactive apt through install_deps.py
* Revert "Disable interactive apt through install_deps.py"
This reverts commit 5bbc8fd689182447c79b81db16c961b98361a292.
* Set DEBIAN_FRONTEND in workflows
* Set DEBIAN_FRONTEND in CodeQL workflow
* Add gtest dep
* Add bundled libei dep
* Add libei dep to Arch
* Use `googletest` on openSUSE
* Add gmock dep
* Remove gtest dep from openSUSE
* Add libei on Fedora
* Bundle libei for older Linux distros
* Disable libei dep for RPM
* Also bundle symlink to .so
* Use ${CMAKE_INSTALL_LIBDIR}
* Rename libei to fix openSUSE
* List installed files
* Add libei-devel to openSUSE
* Add googletest-devel to openSUSE
* Remove manual deps (probably resolved automatically)
* Remove googletest from openSUSE (doesn't provide google mock)
* Only add Portal* if libportal found
* WIP - Partial work on using old events system :'(
* Add deps install commands for subprojects
* Solved more compile issues related to events system, threads, etc
* Fixed bad config for adding x, ei, portal sources
* Remove redundant deps
* Remove (another) redundant dep
* Fixed pacman command
* Add Ubuntu and Linux Mint libei deps
* Fixed Ubuntu and Linux Mint libei deps aliases
* Only iterate subprojects if not None
* Add rhel, rocky, and alma for libei
* Make rhel-like deps same as fedora again
* Build libportal on rhel-like
* Re-enable meson rhel-like for libportal
* Remove dbus-python
* Make libportal optional (for rhel-like)
* Handle ei event queue results
* Re-introduce libportal
* Print libei and libportal versions
* Add ei/portal args and client screen
* Switch --use args to --no
* Don't build libei/libportal on older distros as it's pointless
* Make libei and libportal optional
* Add Debian 13 runner
* Make some packages optional
* Remove subprojects
* Improve comment
* Add comment for libportal
* Improve comment
* Add Debian 13 runner
* Make optional... optional
* Change continuation stripper to remove newline and continuation char
* Make command strip more uniform
* Fixed help var syntax
* Fixed libei linking
* Ensure `kHelpNoWayland` is always defined
* Improve help message
* Fixed Debian 13 runner name
* Include sstream and use const var
* Update ChangeLog
* Remove Wayland block
* Return new timer
* Make tray icon logging verbose
* Fixed arg parser for wayland args
* Fixed init of EI screen
* Fixed lint issues
* Update README to indicate Wayland support in GNOME 46
* Add missing word
* Fixed comment positions
* Automate CI env
* Tone down debug log messages
* Add missing comma
* Remove redundant log line
201 lines
6 KiB
C++
201 lines
6 KiB
C++
/*
|
|
* synergy -- mouse and keyboard sharing utility
|
|
* Copyright (C) 2022 Red Hat, Inc.
|
|
* 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 "config.h"
|
|
#include "synergy/KeyMap.h"
|
|
#include "synergy/PlatformScreen.h"
|
|
|
|
#include <libei.h>
|
|
#include <mutex>
|
|
#include <set>
|
|
#include <vector>
|
|
|
|
struct ei;
|
|
struct ei_event;
|
|
struct ei_seat;
|
|
struct ei_device;
|
|
|
|
namespace synergy {
|
|
|
|
class EiClipboard;
|
|
class EiKeyState;
|
|
class PortalRemoteDesktop;
|
|
#if HAVE_LIBPORTAL_INPUTCAPTURE
|
|
class PortalInputCapture;
|
|
#endif
|
|
|
|
//! Implementation of IPlatformScreen for X11
|
|
class EiScreen : public PlatformScreen {
|
|
public:
|
|
EiScreen(bool is_primary, IEventQueue *events, bool use_portal);
|
|
~EiScreen();
|
|
|
|
// IScreen overrides
|
|
void *getEventTarget() const override;
|
|
bool getClipboard(ClipboardID id, IClipboard *) const override;
|
|
void getShape(
|
|
std::int32_t &x, std::int32_t &y, std::int32_t &width,
|
|
std::int32_t &height) const override;
|
|
void getCursorPos(std::int32_t &x, std::int32_t &y) const override;
|
|
|
|
// IPrimaryScreen overrides
|
|
void reconfigure(std::uint32_t activeSides) override;
|
|
void warpCursor(std::int32_t x, std::int32_t y) override;
|
|
std::uint32_t registerHotKey(KeyID key, KeyModifierMask mask) override;
|
|
void unregisterHotKey(std::uint32_t id) override;
|
|
void fakeInputBegin() override;
|
|
void fakeInputEnd() override;
|
|
std::int32_t getJumpZoneSize() const override;
|
|
bool isAnyMouseButtonDown(std::uint32_t &buttonID) const override;
|
|
void getCursorCenter(std::int32_t &x, std::int32_t &y) const override;
|
|
|
|
// ISecondaryScreen overrides
|
|
void fakeMouseButton(ButtonID id, bool press) override;
|
|
void fakeMouseMove(std::int32_t x, std::int32_t y) override;
|
|
void fakeMouseRelativeMove(std::int32_t dx, std::int32_t dy) const override;
|
|
void fakeMouseWheel(std::int32_t xDelta, std::int32_t yDelta) const override;
|
|
void fakeKey(std::uint32_t keycode, bool is_down) const;
|
|
|
|
// IPlatformScreen overrides
|
|
void enable() override;
|
|
void disable() override;
|
|
void enter() override;
|
|
bool leave() override;
|
|
bool setClipboard(ClipboardID, const IClipboard *) override;
|
|
void checkClipboards() override;
|
|
void openScreensaver(bool notify) override;
|
|
void closeScreensaver() override;
|
|
void screensaver(bool activate) override;
|
|
void resetOptions() override;
|
|
void setOptions(const OptionsList &options) override;
|
|
void setSequenceNumber(std::uint32_t) override;
|
|
bool isPrimary() const override;
|
|
|
|
protected:
|
|
// IPlatformScreen overrides
|
|
void handleSystemEvent(const Event &event, void *) override;
|
|
void updateButtons() override;
|
|
IKeyState *getKeyState() const override;
|
|
String getSecureInputApp() const override;
|
|
|
|
void update_shape();
|
|
void add_device(ei_device *device);
|
|
void remove_device(ei_device *device);
|
|
|
|
private:
|
|
void init_ei();
|
|
void cleanup_ei();
|
|
void sendEvent(Event::Type type, void *data);
|
|
ButtonID map_button_from_evdev(ei_event *event) const;
|
|
void on_key_event(ei_event *event);
|
|
void on_button_event(ei_event *event);
|
|
void send_wheel_events(
|
|
ei_device *device, const int threshold, double dx, double dy,
|
|
bool is_discrete);
|
|
void on_pointer_scroll_event(ei_event *event);
|
|
void on_pointer_scroll_discrete_event(ei_event *event);
|
|
void on_motion_event(ei_event *event);
|
|
void on_abs_motion_event(ei_event *event);
|
|
bool on_hotkey(KeyID key, bool is_press, KeyModifierMask mask);
|
|
void handle_ei_log_event(
|
|
ei *ei, ei_log_priority priority, const char *message,
|
|
ei_log_context *context);
|
|
void handle_connected_to_eis_event(const Event &event, void *);
|
|
void handle_portal_session_closed(const Event &event, void *);
|
|
|
|
static void cb_handle_ei_log_event(
|
|
ei *ei, ei_log_priority priority, const char *message,
|
|
ei_log_context *context) {
|
|
auto screen = reinterpret_cast<EiScreen *>(ei_get_user_data(ei));
|
|
screen->handle_ei_log_event(ei, priority, message, context);
|
|
}
|
|
|
|
private:
|
|
// true if screen is being used as a primary screen, false otherwise
|
|
bool is_primary_ = false;
|
|
IEventQueue *events_ = nullptr;
|
|
|
|
// keyboard stuff
|
|
EiKeyState *key_state_ = nullptr;
|
|
|
|
std::vector<ei_device *> ei_devices_;
|
|
|
|
ei *ei_ = nullptr;
|
|
ei_seat *ei_seat_ = nullptr;
|
|
ei_device *ei_pointer_ = nullptr;
|
|
ei_device *ei_keyboard_ = nullptr;
|
|
ei_device *ei_abs_ = nullptr;
|
|
|
|
std::uint32_t sequence_number_ = 0;
|
|
|
|
std::uint32_t x_ = 0;
|
|
std::uint32_t y_ = 0;
|
|
std::uint32_t w_ = 0;
|
|
std::uint32_t h_ = 0;
|
|
|
|
// true if mouse has entered the screen
|
|
bool is_on_screen_;
|
|
|
|
// server: last pointer position
|
|
// client: position sent before enter()
|
|
std::int32_t cursor_x_ = 0;
|
|
std::int32_t cursor_y_ = 0;
|
|
|
|
double buffer_dx = 0;
|
|
double buffer_dy = 0;
|
|
|
|
mutable std::mutex mutex_;
|
|
|
|
PortalRemoteDesktop *portal_remote_desktop_ = nullptr;
|
|
#if HAVE_LIBPORTAL_INPUTCAPTURE
|
|
PortalInputCapture *portal_input_capture_ = nullptr;
|
|
#endif
|
|
|
|
struct HotKeyItem {
|
|
public:
|
|
HotKeyItem(std::uint32_t mask, std::uint32_t id);
|
|
bool operator<(const HotKeyItem &other) const {
|
|
return mask_ < other.mask_;
|
|
};
|
|
|
|
public:
|
|
std::uint32_t mask_ = 0;
|
|
std::uint32_t id_ = 0; // for registering the hotkey
|
|
};
|
|
|
|
class HotKeySet {
|
|
public:
|
|
HotKeySet(KeyID keyid);
|
|
KeyID keyid() const { return id_; };
|
|
bool remove_by_id(std::uint32_t id);
|
|
void add_item(HotKeyItem item);
|
|
std::uint32_t find_by_mask(std::uint32_t mask) const;
|
|
|
|
private:
|
|
KeyID id_ = 0;
|
|
std::vector<HotKeyItem> set_;
|
|
};
|
|
|
|
using HotKeyMap = std::map<KeyID, HotKeySet>;
|
|
|
|
HotKeyMap hotkeys_;
|
|
};
|
|
|
|
} // namespace synergy
|