Compare commits

..

6 Commits

Author SHA1 Message Date
Justin
617210e063 Synced submodule 2021-05-11 19:19:55 -04:00
Justin
aaef2012bd Switched to upstream toggle-game-mode branch 2021-05-11 19:09:30 -04:00
matt
551164b425 update noVNC submodule 2021-05-07 05:29:19 -04:00
matt
1518575982 Update NoVNC commit 2021-05-06 05:21:46 -04:00
matt
fda877dd72 WIP: update novnc commit 2021-05-04 15:46:26 -04:00
Lauri Kasanen
c0f107a83e Add server-side support for relative mouse motion, kasm-only hack 2021-05-03 13:52:58 +03:00
19 changed files with 104 additions and 61 deletions

2
.gitmodules vendored
View File

@@ -1,4 +1,4 @@
[submodule "kasmweb"] [submodule "kasmweb"]
path = kasmweb path = kasmweb
url = https://github.com/kasmtech/noVNC.git url = https://github.com/kasmtech/noVNC.git
branch = master branch = toggle-game-mode

View File

@@ -34,11 +34,6 @@ RUN apt-get purge -y pm-utils xscreensaver*
RUN apt-get update && apt-get install -y vim less RUN apt-get update && apt-get install -y vim less
RUN apt-get update && apt-get -y install lsb-release RUN apt-get update && apt-get -y install lsb-release
RUN apt-get update && apt-get -y install xdg-desktop-portal firefox-esr
COPY ./xdg-desktop-portal-gtk_1.2.0-1_amd64.deb /tmp
RUN apt-get install -y /tmp/xdg-*.deb
# RUN apt-get install -y xdg-desktop-portal-gtk
RUN echo 'source $STARTUPDIR/generate_container_user' >> $HOME/.bashrc RUN echo 'source $STARTUPDIR/generate_container_user' >> $HOME/.bashrc
RUN mkdir -p $STARTUPDIR RUN mkdir -p $STARTUPDIR
@@ -52,12 +47,8 @@ RUN dpkg -i /tmp/*.deb; apt-get -yf install
### END CUSTOM STUFF ### ### END CUSTOM STUFF ###
RUN sed -i -e 's/about:home/postimages.org/' /usr/lib/firefox-esr/browser/defaults/preferences/firefox.js
RUN sed -i -e '/browser.startup.firstrunSkipsHomepage/d' /usr/lib/firefox-esr/browser/defaults/preferences/firefox.js
RUN echo 'pref("browser.startup.firstrunSkipsHomepage", false);' >> /usr/lib/firefox-esr/browser/defaults/preferences/firefox.js
RUN chown -R 1000:0 $HOME RUN chown -R 1000:0 $HOME
USER 1000:ssl-cert USER 1000:ssl-cert
WORKDIR $HOME WORKDIR $HOME
ENV GTK_USE_PORTAL=1
ENTRYPOINT [ "/dockerstartup/vnc_startup.sh" ] ENTRYPOINT [ "/dockerstartup/vnc_startup.sh" ]

View File

@@ -33,7 +33,6 @@ RUN apt-get update && apt-get install -y supervisor xfce4 xfce4-terminal xterm l
RUN apt-get purge -y pm-utils xscreensaver* RUN apt-get purge -y pm-utils xscreensaver*
RUN apt-get update && apt-get install -y vim less RUN apt-get update && apt-get install -y vim less
RUN apt-get update && apt-get -y install lsb-release RUN apt-get update && apt-get -y install lsb-release
RUN apt-get update && apt-get -y install xdg-desktop-portal xdg-desktop-portal-gtk firefox
RUN echo 'source $STARTUPDIR/generate_container_user' >> $HOME/.bashrc RUN echo 'source $STARTUPDIR/generate_container_user' >> $HOME/.bashrc
@@ -48,12 +47,8 @@ RUN dpkg -i /tmp/*.deb; apt-get -yf install
### END CUSTOM STUFF ### ### END CUSTOM STUFF ###
RUN echo 'pref("browser.startup.firstrunSkipsHomepage", false);' >> /usr/lib/firefox/browser/defaults/preferences/syspref.js
RUN echo 'pref("browser.startup.homepage", "postimages.org");' >> /usr/lib/firefox/browser/defaults/preferences/syspref.js
RUN chown -R 1000:0 $HOME RUN chown -R 1000:0 $HOME
USER 1000:ssl-cert USER 1000:ssl-cert
WORKDIR $HOME WORKDIR $HOME
ENV GTK_USE_PORTAL=1
ENTRYPOINT [ "/dockerstartup/vnc_startup.sh" ] ENTRYPOINT [ "/dockerstartup/vnc_startup.sh" ]

View File

@@ -88,8 +88,6 @@ detect_www_dir
detect_cert_location detect_cert_location
[ -n "$KASMVNC_VERBOSE_LOGGING" ] && verbose_logging_option="-log *:stderr:100" [ -n "$KASMVNC_VERBOSE_LOGGING" ] && verbose_logging_option="-log *:stderr:100"
# dbus-daemon --session --address=systemd: --nofork --nopidfile --syslog-only &
echo -e "start vncserver with param: VNC_COL_DEPTH=$VNC_COL_DEPTH, VNC_RESOLUTION=$VNC_RESOLUTION\n..." echo -e "start vncserver with param: VNC_COL_DEPTH=$VNC_COL_DEPTH, VNC_RESOLUTION=$VNC_RESOLUTION\n..."
vncserver $DISPLAY -depth $VNC_COL_DEPTH -geometry $VNC_RESOLUTION -FrameRate=$MAX_FRAME_RATE -websocketPort $VNC_PORT $cert_option -sslOnly -interface 0.0.0.0 $VNCOPTIONS $package_www_dir_option $verbose_logging_option #&> $STARTUPDIR/no_vnc_startup.log vncserver $DISPLAY -depth $VNC_COL_DEPTH -geometry $VNC_RESOLUTION -FrameRate=$MAX_FRAME_RATE -websocketPort $VNC_PORT $cert_option -sslOnly -interface 0.0.0.0 $VNCOPTIONS $package_www_dir_option $verbose_logging_option #&> $STARTUPDIR/no_vnc_startup.log

View File

@@ -20,7 +20,6 @@
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/time.h>
#include "websocket.h" #include "websocket.h"
/* /*
@@ -228,13 +227,9 @@ void proxy_handler(ws_ctx_t *ws_ctx) {
strcpy(addr.sun_path, ".KasmVNCSock"); strcpy(addr.sun_path, ".KasmVNCSock");
addr.sun_path[0] = '\0'; addr.sun_path[0] = '\0';
struct timeval tv;
gettimeofday(&tv, NULL);
struct sockaddr_un myaddr; struct sockaddr_un myaddr;
myaddr.sun_family = AF_UNIX; myaddr.sun_family = AF_UNIX;
sprintf(myaddr.sun_path, ".%s@%s_%lu.%lu", ws_ctx->user, ws_ctx->ip, sprintf(myaddr.sun_path, ".%s@%s", ws_ctx->user, ws_ctx->ip);
tv.tv_sec, tv.tv_usec);
myaddr.sun_path[0] = '\0'; myaddr.sun_path[0] = '\0';
int tsock = socket(AF_UNIX, SOCK_STREAM, 0); int tsock = socket(AF_UNIX, SOCK_STREAM, 0);

View File

@@ -50,7 +50,7 @@ namespace rfb {
int w, int h, int w, int h,
const ScreenSet& layout); const ScreenSet& layout);
virtual void setCursor(int width, int height, const Point& hotspot, virtual void setCursor(int width, int height, const Point& hotspot,
const rdr::U8* data, const bool resizing = false) = 0; const rdr::U8* data) = 0;
virtual void setPixelFormat(const PixelFormat& pf); virtual void setPixelFormat(const PixelFormat& pf);
virtual void setName(const char* name); virtual void setName(const char* name);
virtual void fence(rdr::U32 flags, unsigned len, const char data[]); virtual void fence(rdr::U32 flags, unsigned len, const char data[]);

View File

@@ -36,6 +36,7 @@ namespace rfb {
rdr::U32 __unused_attr keycode, rdr::U32 __unused_attr keycode,
bool __unused_attr down) { } bool __unused_attr down) { }
virtual void pointerEvent(const Point& __unused_attr pos, virtual void pointerEvent(const Point& __unused_attr pos,
const Point& __unused_attr abspos,
int __unused_attr buttonMask, int __unused_attr buttonMask,
const bool __unused_attr skipClick, const bool __unused_attr skipClick,
const bool __unused_attr skipRelease) { } const bool __unused_attr skipRelease) { }

View File

@@ -252,7 +252,4 @@ namespace rfb {
bool hasLocalClipboard; bool hasLocalClipboard;
}; };
} }
#define WRITER_PERMS (AccessKeyEvents | AccessPtrEvents | AccessCutText | AccessSetDesktopSize)
#endif #endif

View File

@@ -220,7 +220,7 @@ void SMsgReader::readPointerEvent()
int mask = is->readU8(); int mask = is->readU8();
int x = is->readU16(); int x = is->readU16();
int y = is->readU16(); int y = is->readU16();
handler->pointerEvent(Point(x, y), mask, false, false); handler->pointerEvent(Point(x, y), Point(0, 0), mask, false, false);
} }

View File

@@ -86,9 +86,8 @@ VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
} }
bool write, owner; bool write, owner;
if (!getPerms(write, owner) || !write) { if (!getPerms(write, owner) || !write)
accessRights &= ~WRITER_PERMS; accessRights = (accessRights & ~(AccessPtrEvents | AccessKeyEvents | AccessSetDesktopSize));
}
// Configure the socket // Configure the socket
setSocketTimeouts(); setSocketTimeouts();
@@ -682,14 +681,52 @@ void VNCSConnectionST::setPixelFormat(const PixelFormat& pf)
setCursor(); setCursor();
} }
void VNCSConnectionST::pointerEvent(const Point& pos, int buttonMask, const bool skipClick, const bool skipRelease) void VNCSConnectionST::pointerEvent(const Point& pos, const Point& abspos, int buttonMask, const bool skipClick, const bool skipRelease)
{ {
pointerEventTime = lastEventTime = time(0); pointerEventTime = lastEventTime = time(0);
server->lastUserInputTime = lastEventTime; server->lastUserInputTime = lastEventTime;
if (!(accessRights & AccessPtrEvents)) return; if (!(accessRights & AccessPtrEvents)) return;
if (!rfb::Server::acceptPointerEvents) return; if (!rfb::Server::acceptPointerEvents) return;
if (!server->pointerClient || server->pointerClient == this) { if (!server->pointerClient || server->pointerClient == this) {
pointerEventPos = pos; Point newpos = pos;
if (pos.x & 0x4000) {
newpos.x &= ~0x4000;
newpos.y &= ~0x4000;
if (newpos.x & 0x8000) {
newpos.x &= ~0x8000;
newpos.x = -newpos.x;
}
if (newpos.y & 0x8000) {
newpos.y &= ~0x8000;
newpos.y = -newpos.y;
}
if (newpos.x < 0) {
if (pointerEventPos.x + newpos.x >= 0)
pointerEventPos.x += newpos.x;
else
pointerEventPos.x = 0;
} else {
pointerEventPos.x += newpos.x;
if (pointerEventPos.x >= cp.width)
pointerEventPos.x = cp.width;
}
if (newpos.y < 0) {
if (pointerEventPos.y + newpos.y >= 0)
pointerEventPos.y += newpos.y;
else
pointerEventPos.y = 0;
} else {
pointerEventPos.y += newpos.y;
if (pointerEventPos.y >= cp.height)
pointerEventPos.y = cp.height;
}
} else {
pointerEventPos = pos;
}
if (buttonMask) if (buttonMask)
server->pointerClient = this; server->pointerClient = this;
else else
@@ -710,7 +747,7 @@ void VNCSConnectionST::pointerEvent(const Point& pos, int buttonMask, const bool
} }
} }
server->desktop->pointerEvent(pointerEventPos, buttonMask, skipclick, skiprelease); server->desktop->pointerEvent(newpos, pointerEventPos, buttonMask, skipclick, skiprelease);
} }
} }
@@ -1217,9 +1254,9 @@ void VNCSConnectionST::writeFramebufferUpdate()
close("User was deleted"); close("User was deleted");
return; return;
} else if (!write) { } else if (!write) {
accessRights &= ~WRITER_PERMS; accessRights = (accessRights & ~(AccessPtrEvents | AccessKeyEvents | AccessSetDesktopSize));
} else { } else {
accessRights |= WRITER_PERMS; accessRights |= AccessPtrEvents | AccessKeyEvents | AccessSetDesktopSize;
} }
} }

View File

@@ -175,7 +175,7 @@ namespace rfb {
virtual void queryConnection(const char* userName); virtual void queryConnection(const char* userName);
virtual void clientInit(bool shared); virtual void clientInit(bool shared);
virtual void setPixelFormat(const PixelFormat& pf); virtual void setPixelFormat(const PixelFormat& pf);
virtual void pointerEvent(const Point& pos, int buttonMask, const bool skipClick, const bool skipRelease); virtual void pointerEvent(const Point& pos, const Point& abspos, int buttonMask, const bool skipClick, const bool skipRelease);
virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down); virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
virtual void framebufferUpdateRequest(const Rect& r, bool incremental); virtual void framebufferUpdateRequest(const Rect& r, bool incremental);
virtual void setDesktopSize(int fb_width, int fb_height, virtual void setDesktopSize(int fb_width, int fb_height,
@@ -206,7 +206,7 @@ namespace rfb {
bool write, owner; bool write, owner;
if (!getPerms(write, owner) || !write) if (!getPerms(write, owner) || !write)
accessRights &= ~WRITER_PERMS; accessRights = (accessRights & ~(AccessPtrEvents | AccessKeyEvents));
needsPermCheck = false; needsPermCheck = false;
} }

View File

@@ -79,7 +79,7 @@ namespace rfb {
// cursorData argument contains width*height rgba quadruplets with // cursorData argument contains width*height rgba quadruplets with
// non-premultiplied alpha. // non-premultiplied alpha.
virtual void setCursor(int width, int height, const Point& hotspot, virtual void setCursor(int width, int height, const Point& hotspot,
const rdr::U8* cursorData, const bool resizing = false) = 0; const rdr::U8* cursorData) = 0;
// setCursorPos() tells the server the current position of the cursor, and // setCursorPos() tells the server the current position of the cursor, and
// whether the server initiated that change (e.g. through another X11 // whether the server initiated that change (e.g. through another X11

View File

@@ -579,7 +579,7 @@ void VNCServerST::add_copied(const Region& dest, const Point& delta)
} }
void VNCServerST::setCursor(int width, int height, const Point& newHotspot, void VNCServerST::setCursor(int width, int height, const Point& newHotspot,
const rdr::U8* data, const bool resizing) const rdr::U8* data)
{ {
delete cursor; delete cursor;
cursor = new Cursor(width, height, newHotspot, data); cursor = new Cursor(width, height, newHotspot, data);
@@ -587,13 +587,6 @@ void VNCServerST::setCursor(int width, int height, const Point& newHotspot,
renderedCursorInvalid = true; renderedCursorInvalid = true;
// If an app has an animated cursor on the resized edge, X internals
// will call for it to be rendered. Unlucky for us, the VNC screen
// is currently pointing to freed memory, and a cursor change
// would want to send a screen update. So, don't do that.
if (resizing)
return;
std::list<VNCSConnectionST*>::iterator ci, ci_next; std::list<VNCSConnectionST*>::iterator ci, ci_next;
for (ci = clients.begin(); ci != clients.end(); ci = ci_next) { for (ci = clients.begin(); ci != clients.end(); ci = ci_next) {
ci_next = ci; ci_next++; ci_next = ci; ci_next++;

View File

@@ -102,7 +102,7 @@ namespace rfb {
virtual void add_changed(const Region &region); virtual void add_changed(const Region &region);
virtual void add_copied(const Region &dest, const Point &delta); virtual void add_copied(const Region &dest, const Point &delta);
virtual void setCursor(int width, int height, const Point& hotspot, virtual void setCursor(int width, int height, const Point& hotspot,
const rdr::U8* data, const bool resizing = false); const rdr::U8* data);
virtual void setCursorPos(const Point& p, bool warped); virtual void setCursorPos(const Point& p, bool warped);
virtual void setLEDState(unsigned state); virtual void setLEDState(unsigned state);

Submodule kasmweb updated: 67466077c0...33066b89b3

View File

@@ -234,6 +234,40 @@ void vncPointerMove(int x, int y)
cursorPosY = y; cursorPosY = y;
} }
void vncPointerMoveRelative(int x, int y, int absx, int absy)
{
int valuators[2];
#if XORG < 111
int n;
#endif
#if XORG >= 110
ValuatorMask mask;
#endif
// if (cursorPosX == absx && cursorPosY == absy)
// return;
valuators[0] = x;
valuators[1] = y;
#if XORG < 110
n = GetPointerEvents(eventq, vncPointerDev, MotionNotify, 0,
POINTER_RELATIVE, 0, 2, valuators);
enqueueEvents(vncPointerDev, n);
#elif XORG < 111
valuator_mask_set_range(&mask, 0, 2, valuators);
n = GetPointerEvents(eventq, vncPointerDev, MotionNotify, 0,
POINTER_RELATIVE, &mask);
enqueueEvents(vncPointerDev, n);
#else
valuator_mask_set_range(&mask, 0, 2, valuators);
QueuePointerEvents(vncPointerDev, MotionNotify, 0,
POINTER_RELATIVE, &mask);
#endif
cursorPosX = absx;
cursorPosY = absy;
}
void vncGetPointerPos(int *x, int *y) void vncGetPointerPos(int *x, int *y)
{ {
if (vncPointerDev != NULL) { if (vncPointerDev != NULL) {

View File

@@ -35,6 +35,7 @@ void vncInitInputDevice(void);
void vncPointerButtonAction(int buttonMask, const unsigned char skipclick, void vncPointerButtonAction(int buttonMask, const unsigned char skipclick,
const unsigned char skiprelease); const unsigned char skiprelease);
void vncPointerMove(int x, int y); void vncPointerMove(int x, int y);
void vncPointerMoveRelative(int x, int y, int absx, int absy);
void vncGetPointerPos(int *x, int *y); void vncGetPointerPos(int *x, int *y);
void vncKeyboardEvent(KeySym keysym, unsigned xtcode, int down); void vncKeyboardEvent(KeySym keysym, unsigned xtcode, int down);

View File

@@ -74,7 +74,7 @@ XserverDesktop::XserverDesktop(int screenIndex_,
: screenIndex(screenIndex_), : screenIndex(screenIndex_),
server(0), listeners(listeners_), server(0), listeners(listeners_),
directFbptr(true), directFbptr(true),
queryConnectId(0), queryConnectTimer(this), resizing(false) queryConnectId(0), queryConnectTimer(this)
{ {
format = pf; format = pf;
@@ -251,7 +251,7 @@ void XserverDesktop::setCursor(int width, int height, int hotX, int hotY,
} }
try { try {
server->setCursor(width, height, Point(hotX, hotY), cursorData, resizing); server->setCursor(width, height, Point(hotX, hotY), cursorData);
} catch (rdr::Exception& e) { } catch (rdr::Exception& e) {
vlog.error("XserverDesktop::setCursor: %s",e.str()); vlog.error("XserverDesktop::setCursor: %s",e.str());
} }
@@ -445,11 +445,17 @@ void XserverDesktop::approveConnection(uint32_t opaqueId, bool accept,
// SDesktop callbacks // SDesktop callbacks
void XserverDesktop::pointerEvent(const Point& pos, int buttonMask, void XserverDesktop::pointerEvent(const Point& pos, const Point& abspos, int buttonMask,
const bool skipClick, const bool skipRelease) const bool skipClick, const bool skipRelease)
{ {
vncPointerMove(pos.x + vncGetScreenX(screenIndex), if (pos.equals(abspos)) {
pos.y + vncGetScreenY(screenIndex)); vncPointerMove(pos.x + vncGetScreenX(screenIndex),
pos.y + vncGetScreenY(screenIndex));
} else {
vncPointerMoveRelative(pos.x, pos.y,
abspos.x + vncGetScreenX(screenIndex),
abspos.y + vncGetScreenY(screenIndex));
}
vncPointerButtonAction(buttonMask, skipClick, skipRelease); vncPointerButtonAction(buttonMask, skipClick, skipRelease);
} }
@@ -462,11 +468,8 @@ unsigned int XserverDesktop::setScreenLayout(int fb_width, int fb_height,
layout.print(buffer, sizeof(buffer)); layout.print(buffer, sizeof(buffer));
vlog.debug("%s", buffer); vlog.debug("%s", buffer);
resizing = true;
vncSetGlueContext(screenIndex); vncSetGlueContext(screenIndex);
const unsigned int ret = ::setScreenLayout(fb_width, fb_height, layout, &outputIdMap); return ::setScreenLayout(fb_width, fb_height, layout, &outputIdMap);
resizing = false;
return ret;
} }
void XserverDesktop::handleClipboardRequest() void XserverDesktop::handleClipboardRequest()

View File

@@ -89,7 +89,7 @@ public:
const char* rejectMsg=0); const char* rejectMsg=0);
// rfb::SDesktop callbacks // rfb::SDesktop callbacks
virtual void pointerEvent(const rfb::Point& pos, int buttonMask, virtual void pointerEvent(const rfb::Point& pos, const rfb::Point& abspos, int buttonMask,
const bool skipClick, const bool skipRelease); const bool skipClick, const bool skipRelease);
virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down); virtual void keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down);
virtual unsigned int setScreenLayout(int fb_width, int fb_height, virtual unsigned int setScreenLayout(int fb_width, int fb_height,
@@ -132,7 +132,5 @@ private:
OutputIdMap outputIdMap; OutputIdMap outputIdMap;
rfb::Point oldCursorPos; rfb::Point oldCursorPos;
bool resizing;
}; };
#endif #endif