Deskflow 1.26.0.0
Keyboard and mouse sharing utility
Loading...
Searching...
No Matches
App.h
Go to the documentation of this file.
1/*
2 * Deskflow -- mouse and keyboard sharing utility
3 * SPDX-FileCopyrightText: (C) 2026 Deskflow Developers
4 * SPDX-FileCopyrightText: (C) 2012 - 2025 Symless Ltd.
5 * SPDX-FileCopyrightText: (C) 2002 Chris Schoeneman
6 * SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
7 */
8
9#pragma once
10
11#include "base/EventQueue.h"
12#include "base/Log.h"
13#include "deskflow/IApp.h"
15
16#if SYSAPI_WIN32
18#elif SYSAPI_UNIX
20#endif
21
22#include <memory>
23#include <stdexcept>
24
25namespace deskflow {
26class Screen;
27}
28
30class IEventQueue;
32
33class App : public IApp
34{
35public:
36 class XNoEiSupport : public std::runtime_error
37 {
38 public:
39 XNoEiSupport() : std::runtime_error("libei is not supported")
40 {
41 // do nothing
42 }
43 };
44
45 App(IEventQueue *events, const QString &processName);
46 App(App const &) = delete;
47 App(App &&) = delete;
48 ~App() override;
49
50 App &operator=(App const &) = delete;
51 App &operator=(App &&) = delete;
52
53 virtual void parseArgs() = 0;
54 virtual void loadConfig() = 0;
55 virtual bool loadConfig(const QString &filename) = 0;
56
57 void setByeFunc(void (*bye)(int)) override
58 {
59 m_bye = bye;
60 }
61 void bye(int error) override
62 {
63 m_bye(error);
64 }
65 IEventQueue *getEvents() const override
66 {
67 return m_events;
68 }
69
71 {
72 return m_appUtil;
73 }
74
75 int run();
76 void setupFileLogging();
77 void loggingFilterWarning() const;
78 void initApp() override;
79
80 void setEvents(EventQueue &events)
81 {
82 m_events = &events;
83 }
84 void setSocketMultiplexer(std::unique_ptr<SocketMultiplexer> &&sm)
85 {
86 m_socketMultiplexer = std::move(sm);
87 }
88
90 {
91 return m_socketMultiplexer.get();
92 }
93
94 static App &instance()
95 {
96 assert(s_instance != nullptr);
97 return *s_instance;
98 }
99
100 QString processName() const
101 {
102 return m_pname;
103 }
104
105 void handleScreenError() const;
106
107protected:
108 void runEventsLoop(const void *);
109
110private:
111 void (*m_bye)(int);
112 IEventQueue *m_events = nullptr;
113 static App *s_instance;
114 FileLogOutputter *m_fileLog = nullptr;
115 ARCH_APP_UTIL m_appUtil;
116 std::unique_ptr<SocketMultiplexer> m_socketMultiplexer;
117 QString m_pname;
118};
119
120#if !defined(WINAPI_LIBEI) && WINAPI_XWINDOWS
121constexpr static auto s_helpNoWayland = //
122 "\nYour Linux distribution does not support Wayland EI (emulated input)\n"
123 "which is required for Wayland support. Please use a Linux distribution\n"
124 "that supports Wayland EI.\n";
125
126#else
127constexpr static auto s_helpNoWayland = "";
128#endif
#define ARCH_APP_UTIL
Definition AppUtilUnix.h:12
static constexpr auto s_helpNoWayland
Definition App.h:127
static int(PASCAL FAR *bind_winsock)(SOCKET s
XNoEiSupport()
Definition App.h:39
Definition App.h:34
IEventQueue * getEvents() const override
Definition App.h:65
virtual void loadConfig()=0
static App & instance()
Definition App.h:94
virtual bool loadConfig(const QString &filename)=0
App(App const &)=delete
SocketMultiplexer * getSocketMultiplexer() const
Definition App.h:89
App & operator=(App &&)=delete
void loggingFilterWarning() const
Definition App.cpp:114
App(IEventQueue *events, const QString &processName)
Definition App.cpp:42
void setupFileLogging()
Definition App.cpp:104
void setByeFunc(void(*bye)(int)) override
Definition App.h:57
void initApp() override
Definition App.cpp:124
int run()
Definition App.cpp:60
QString processName() const
Definition App.h:100
App(App &&)=delete
ARCH_APP_UTIL & appUtil()
Definition App.h:70
void runEventsLoop(const void *)
Definition App.cpp:151
virtual void parseArgs()=0
void bye(int error) override
Definition App.h:61
App & operator=(App const &)=delete
void setEvents(EventQueue &events)
Definition App.h:80
~App() override
Definition App.cpp:55
void setSocketMultiplexer(std::unique_ptr< SocketMultiplexer > &&sm)
Definition App.h:84
void handleScreenError() const
Definition App.cpp:145
Event queue.
Definition EventQueue.h:28
Write log to file.
Definition LogOutputters.h:57
Definition IApp.h:20
Event queue interface.
Definition IEventQueue.h:29
Socket multiplexer.
Definition SocketMultiplexer.h:24
Platform independent screen.
Definition Screen.h:30
Definition DaemonApp.h:20
Definition Config.h:28