1
0
mirror of https://github.com/KDE/krfb synced 2026-07-01 07:41:17 -07:00

Format project

Command used to format: git ls-files | grep -E '\.(cpp|h|hpp|c)$' | xargs clang-format -i --style file
This commit is contained in:
Antti Savolainen
2026-04-24 11:36:02 +03:00
parent 88f1636fef
commit c521740404
48 changed files with 704 additions and 679 deletions

View File

@@ -13,13 +13,13 @@
#include <QtGui/private/qtx11extras_p.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <X11/extensions/XTest.h>
#include <X11/keysym.h>
enum {
LEFTSHIFT = 1,
RIGHTSHIFT = 2,
ALTGR = 4
ALTGR = 4,
};
class EventData
@@ -27,7 +27,7 @@ class EventData
public:
EventData();
//keyboard
// keyboard
Display *dpy = nullptr;
signed char modifiers[0x100] = {};
KeyCode keycodes[0x100] = {};
@@ -36,7 +36,7 @@ public:
KeyCode altGrCode = 0;
char modifierState = 0;
//mouse
// mouse
int buttonMask = 0;
int x = 0;
int y = 0;
@@ -57,7 +57,7 @@ void EventData::init()
buttonMask = 0;
dpy = QX11Info::display();
//initialize keycodes
// initialize keycodes
KeySym key, *keymap;
int i, j, minkey, maxkey, syms_per_keycode;
@@ -66,14 +66,14 @@ void EventData::init()
XDisplayKeycodes(dpy, &minkey, &maxkey);
Q_ASSERT(minkey >= 8);
Q_ASSERT(maxkey < 256);
keymap = (KeySym *) XGetKeyboardMapping(dpy, minkey,
(maxkey - minkey + 1),
&syms_per_keycode);
keymap = (KeySym *)XGetKeyboardMapping(dpy, minkey,
(maxkey - minkey + 1),
&syms_per_keycode);
Q_ASSERT(keymap);
for (i = minkey; i <= maxkey; i++) {
for (j = 0; j < syms_per_keycode; j++) {
key = keymap[(i-minkey)*syms_per_keycode+j];
key = keymap[(i - minkey) * syms_per_keycode + j];
if (key >= ' ' && key < 0x100 && i == XKeysymToKeycode(dpy, key)) {
keycodes[key] = i;
@@ -128,8 +128,13 @@ static void tweakModifiers(signed char mod, bool down)
void X11EventHandler::handleKeyboard(bool down, rfbKeySym keySym)
{
#define ADJUSTMOD(sym,state) \
if(keySym==sym) { if(down) data->modifierState|=state; else data->modifierState&=~state; }
#define ADJUSTMOD(sym, state) \
if (keySym == sym) { \
if (down) \
data->modifierState |= state; \
else \
data->modifierState &= ~state; \
}
if (QX11Info::isPlatformX11()) {
ADJUSTMOD(XK_Shift_L, LEFTSHIFT);
@@ -160,11 +165,11 @@ void X11EventHandler::handleKeyboard(bool down, rfbKeySym keySym)
}
}
}
/*
// Wayland platform and pipweire plugin in use
if (KrfbConfig::preferredFrameBufferPlugin() == QStringLiteral("pw")) {
/*
// Wayland platform and pipweire plugin in use
if (KrfbConfig::preferredFrameBufferPlugin() == QStringLiteral("pw")) {
}*/
}*/
}
void X11EventHandler::handlePointer(int buttonMask, int x, int y)
@@ -173,11 +178,11 @@ void X11EventHandler::handlePointer(int buttonMask, int x, int y)
XTestFakeMotionEvent(data->dpy, 0, x, y, CurrentTime);
for (int i = 0; i < 5; i++) {
if ((data->buttonMask&(1 << i)) != (buttonMask&(1 << i))) {
if ((data->buttonMask & (1 << i)) != (buttonMask & (1 << i))) {
XTestFakeButtonEvent(data->dpy,
i + 1,
(buttonMask&(1 << i)) ? True : False,
CurrentTime);
i + 1,
(buttonMask & (1 << i)) ? True : False,
CurrentTime);
}
}

View File

@@ -14,15 +14,15 @@
class X11EventHandler : public EventHandler
{
Q_OBJECT
public:
explicit X11EventHandler(QObject *parent = nullptr)
: EventHandler(parent)
{
};
}
void handleKeyboard(bool down, rfbKeySym key) override;
void handlePointer(int buttonMask, int x, int y) override;
};
#endif

View File

@@ -22,11 +22,11 @@ X11EventsPlugin::X11EventsPlugin(QObject *parent, const QVariantList &args)
EventHandler *X11EventsPlugin::eventHandler()
{
// works only under X11
if(!QX11Info::isPlatformX11())
if (!QX11Info::isPlatformX11()) {
return nullptr;
}
return new X11EventHandler();
}
#include "x11eventsplugin.moc"

View File

@@ -16,6 +16,7 @@ class EventHandler;
class X11EventsPlugin : public EventsPlugin
{
Q_OBJECT
public:
X11EventsPlugin(QObject *parent, const QVariantList &args);
@@ -25,5 +26,4 @@ private:
Q_DISABLE_COPY(X11EventsPlugin)
};
#endif // Header guard
#endif // Header guard

View File

@@ -21,7 +21,7 @@ class EventData
public:
EventData();
//mouse
// mouse
int buttonMask = 0;
int x = 0;
int y = 0;
@@ -42,7 +42,7 @@ EventData::EventData()
void EventData::init()
{
dbusXdpRemoteDesktopService.reset(new OrgFreedesktopPortalRemoteDesktopInterface(QStringLiteral("org.freedesktop.portal.Desktop"),
QStringLiteral("/org/freedesktop/portal/desktop"), QDBusConnection::sessionBus()));
QStringLiteral("/org/freedesktop/portal/desktop"), QDBusConnection::sessionBus()));
}
void XdpEventHandler::handleKeyboard(bool down, rfbKeySym keySym)
@@ -68,7 +68,7 @@ void XdpEventHandler::handlePointer(int buttonMask, int x, int y)
if (buttonMask != data->buttonMask) {
int i = 0;
QList<int> buttons = { BTN_LEFT, BTN_MIDDLE, BTN_RIGHT, 0, 0, 0, 0, BTN_SIDE, BTN_EXTRA };
QList<int> buttons = {BTN_LEFT, BTN_MIDDLE, BTN_RIGHT, 0, 0, 0, 0, BTN_SIDE, BTN_EXTRA};
for (auto it = buttons.constBegin(); it != buttons.constEnd(); ++it) {
int prevButtonState = (data->buttonMask >> i) & 0x01;
int currentButtonState = (buttonMask >> i) & 0x01;
@@ -81,22 +81,22 @@ void XdpEventHandler::handlePointer(int buttonMask, int x, int y)
int steps = 0;
switch (i) {
case 3:
axis = 0; // Vertical
axis = 0; // Vertical
steps = -1;
break;
case 4:
axis = 0; // Vertical
axis = 0; // Vertical
steps = 1;
break;
case 5:
axis = 1; // Horizontal
axis = 1; // Horizontal
steps = -1;
break;
case 6:
axis = 1; // Horizontal
axis = 1; // Horizontal
steps = 1;
break;
}
}
data->dbusXdpRemoteDesktopService->NotifyPointerAxisDiscrete(sessionHandle, QVariantMap(), axis, steps);
}

View File

@@ -14,11 +14,10 @@
class XdpEventHandler : public EventHandler
{
Q_OBJECT
public:
void handleKeyboard(bool down, rfbKeySym key) override;
void handlePointer(int buttonMask, int x, int y) override;
};
#endif

View File

@@ -26,4 +26,3 @@ EventHandler *XdpEventsPlugin::eventHandler()
}
#include "xdpeventsplugin.moc"

View File

@@ -18,6 +18,7 @@ class EventHandler;
class XdpEventsPlugin : public EventsPlugin
{
Q_OBJECT
public:
XdpEventsPlugin(QObject *parent, const QVariantList &args);
@@ -27,6 +28,4 @@ private:
Q_DISABLE_COPY(XdpEventsPlugin)
};
#endif // Header guard
#endif // Header guard