3#include <QLoggingCategory> 
    8    #include "Windows/HookWindows.h" 
    9#elif defined(Q_OS_ANDROID) 
   10#elif defined(Q_OS_MACOS) 
   11#elif defined(Q_OS_LINUX) 
   12    #include "Unix/NativeEventFilterUnix.h" 
   15QAbstractNativeEventFilter* g_pNativeEventFilter = 
nullptr;
 
   16static Q_LOGGING_CATEGORY(log, 
"Client.Hook")
 
   20    , m_pParameterPlugin(pPara)
 
   22    qDebug(log) << 
"CHook::~CHook()";
 
   27    qDebug(log) << 
"CHook::~CHook()";
 
   35#elif defined(Q_OS_LINUX) 
   36    p = 
new CHook(pPara, parent);
 
   41int CHook::RegisterKeyboard()
 
   44#if defined(Q_OS_MACOS) || defined(Q_OS_ANDROID) || defined(Q_OS_MACOS) 
   45    qApp->installEventFilter(
this);
 
   46#elif defined(Q_OS_LINUX) 
   47    if(!g_pNativeEventFilter)
 
   49    if(g_pNativeEventFilter)
 
   50        qApp->installNativeEventFilter(g_pNativeEventFilter);
 
   52    qApp->installEventFilter(
this);
 
   57int CHook::UnRegisterKeyboard()
 
   60    if(g_pNativeEventFilter) {
 
   61        qApp->removeNativeEventFilter(g_pNativeEventFilter);
 
   62        delete g_pNativeEventFilter;
 
   63        g_pNativeEventFilter = 
nullptr;
 
   66    if(m_pParameterPlugin)
 
   67        qApp->removeEventFilter(
this);
 
   72bool CHook::eventFilter(QObject *watched, QEvent *event)
 
   74    if(QEvent::KeyPress == event->type() || QEvent::KeyRelease == event->type())
 
   76        if(m_pParameterPlugin && !m_pParameterPlugin->GetNativeWindowReceiveKeyboard()) {
 
   78            bool bProcess = 
false;
 
   79            QKeyEvent *keyEvent = 
static_cast<QKeyEvent *
>(event);
 
   80            int key = keyEvent->key();
 
   91            CFrmViewer* focus = qobject_cast<CFrmViewer*>(QApplication::focusWidget());
 
   92            qDebug(log) << 
"eventFilter:" << keyEvent
 
   93                        << watched << focus << bProcess;
 
   95                if(focus == watched) {
 
  107                switch(keyEvent->type())
 
  109                case QKeyEvent::KeyPress:
 
  110                    emit focus->sigKeyPressEvent(keyEvent);
 
  112                case QKeyEvent::KeyRelease:
 
  113                    emit focus->sigKeyReleaseEvent(keyEvent);
 
A widget which displays output image from a CConnectDesktop and sends input keypresses and mouse acti...
 
The class is the HOOK abstract class.
 
Global parameters of plugins.