aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb/SMsgWriter.cxx
diff options
context:
space:
mode:
authorAdam Halim <adaha@cendio.se>2024-09-24 15:55:21 +0200
committerAdam Halim <adaha@cendio.se>2024-10-22 14:52:31 +0200
commit63327145959e26193682e2b691a6027e26c1ce16 (patch)
tree772dcd8cc872bf7da5482cfaee33639cee924db4 /common/rfb/SMsgWriter.cxx
parent2fe9dca45f7d0a519fef5053ba61e2db7c1ff2b1 (diff)
downloadtigervnc-63327145959e26193682e2b691a6027e26c1ce16.tar.gz
tigervnc-63327145959e26193682e2b691a6027e26c1ce16.zip
Add server support for forward/back mouse buttons
This commit adds support for the pseudo-encoding ExtendedMouseButtons in Xvnc and x0vncserver, which makes it possible to use to use the back/forward mouse buttons. This commit contains work originally done by PixelSmith <manny33@frontbuffer.com>.
Diffstat (limited to 'common/rfb/SMsgWriter.cxx')
-rw-r--r--common/rfb/SMsgWriter.cxx33
1 files changed, 32 insertions, 1 deletions
diff --git a/common/rfb/SMsgWriter.cxx b/common/rfb/SMsgWriter.cxx
index 0c03b51d..d1218c11 100644
--- a/common/rfb/SMsgWriter.cxx
+++ b/common/rfb/SMsgWriter.cxx
@@ -49,7 +49,7 @@ SMsgWriter::SMsgWriter(ClientParams* client_, rdr::OutStream* os_)
nRectsInUpdate(0), nRectsInHeader(0),
needSetDesktopName(false), needCursor(false),
needCursorPos(false), needLEDState(false),
- needQEMUKeyEvent(false)
+ needQEMUKeyEvent(false), needExtMouseButtonsEvent(false)
{
}
@@ -303,6 +303,14 @@ void SMsgWriter::writeQEMUKeyEvent()
needQEMUKeyEvent = true;
}
+void SMsgWriter::writeExtendedMouseButtonsSupport()
+{
+ if (!client->supportsEncoding(pseudoEncodingExtendedMouseButtons))
+ throw Exception("Client does not support Extended Mouse Buttons");
+
+ needExtMouseButtonsEvent = true;
+}
+
bool SMsgWriter::needFakeUpdate()
{
if (needSetDesktopName)
@@ -315,6 +323,8 @@ bool SMsgWriter::needFakeUpdate()
return true;
if (needQEMUKeyEvent)
return true;
+ if (needExtMouseButtonsEvent)
+ return true;
if (needNoDataUpdate())
return true;
@@ -363,6 +373,8 @@ void SMsgWriter::writeFramebufferUpdateStart(int nRects)
nRects++;
if (needQEMUKeyEvent)
nRects++;
+ if (needExtMouseButtonsEvent)
+ nRects++;
}
os->writeU16(nRects);
@@ -502,6 +514,11 @@ void SMsgWriter::writePseudoRects()
writeQEMUKeyEventRect();
needQEMUKeyEvent = false;
}
+
+ if (needExtMouseButtonsEvent) {
+ writeExtendedMouseButtonsRect();
+ needExtMouseButtonsEvent = false;
+ }
}
void SMsgWriter::writeNoDataRects()
@@ -734,3 +751,17 @@ void SMsgWriter::writeQEMUKeyEventRect()
os->writeU16(0);
os->writeU32(pseudoEncodingQEMUKeyEvent);
}
+
+void SMsgWriter::writeExtendedMouseButtonsRect()
+{
+ if (!client->supportsEncoding(pseudoEncodingExtendedMouseButtons))
+ throw Exception("Client does not support extended mouse button events");
+ if (++nRectsInUpdate > nRectsInHeader && nRectsInHeader)
+ throw Exception("SMsgWriter::writeExtendedMouseButtonsRect: nRects out of sync");
+
+ os->writeS16(0);
+ os->writeS16(0);
+ os->writeU16(0);
+ os->writeU16(0);
+ os->writeU32(pseudoEncodingExtendedMouseButtons);
+}