mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge remote-tracking branch 'remotes/kraxel/tags/ui-20190919-pull-request' into staging
ui: add barrier client. ui: bugfixes for vnc & egl. # gpg: Signature made Thu 19 Sep 2019 08:09:05 BST # gpg: using RSA key 4CB6D8EED3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full] # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" [full] # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full] # Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138 * remotes/kraxel/tags/ui-20190919-pull-request: vnc: fix memory leak when vnc disconnect ui: add an embedded Barrier client vnc: fix websocket field in events ui/egl: fix framebuffer reads Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
@@ -0,0 +1,370 @@
|
||||
QEMU Barrier Client
|
||||
|
||||
|
||||
* About
|
||||
|
||||
Barrier is a KVM (Keyboard-Video-Mouse) software forked from Symless's
|
||||
synergy 1.9 codebase.
|
||||
|
||||
See https://github.com/debauchee/barrier
|
||||
|
||||
* QEMU usage
|
||||
|
||||
Generally, mouse and keyboard are grabbed through the QEMU video
|
||||
interface emulation.
|
||||
|
||||
But when we want to use a video graphic adapter via a PCI passthrough
|
||||
there is no way to provide the keyboard and mouse inputs to the VM
|
||||
except by plugging a second set of mouse and keyboard to the host
|
||||
or by installing a KVM software in the guest OS.
|
||||
|
||||
The QEMU Barrier client avoids this by implementing directly the Barrier
|
||||
protocol into QEMU.
|
||||
|
||||
This protocol is enabled by adding an input-barrier object to QEMU.
|
||||
|
||||
Syntax: input-barrier,id=<object-id>,name=<guest display name>
|
||||
[,server=<barrier server address>][,port=<barrier server port>]
|
||||
[,x-origin=<x-origin>][,y-origin=<y-origin>]
|
||||
[,width=<width>][,height=<height>]
|
||||
|
||||
The object can be added on the QEMU command line, for instance with:
|
||||
|
||||
... -object input-barrier,id=barrier0,name=VM-1 ...
|
||||
|
||||
where VM-1 is the name the display configured int the Barrier server
|
||||
on the host providing the mouse and the keyboard events.
|
||||
|
||||
by default <barrier server address> is "localhost", port is 24800,
|
||||
<x-origin> and <y-origin> are set to 0, <width> and <height> to
|
||||
1920 and 1080.
|
||||
|
||||
If Barrier server is stopped QEMU needs to be reconnected manually,
|
||||
by removing and re-adding the input-barrier object, for instance
|
||||
with the help of the HMP monitor:
|
||||
|
||||
(qemu) object_del barrier0
|
||||
(qemu) object_add input-barrier,id=barrier0,name=VM-1
|
||||
|
||||
* Message format
|
||||
|
||||
Message format between the server and client is in two parts:
|
||||
|
||||
1- the payload length is a 32bit integer in network endianness,
|
||||
2- the payload
|
||||
|
||||
The payload starts with a 4byte string (without NUL) which is the
|
||||
command. The first command between the server and the client
|
||||
is the only command not encoded on 4 bytes ("Barrier").
|
||||
The remaining part of the payload is decoded according to the command.
|
||||
|
||||
* Protocol Description (from barrier/src/lib/barrier/protocol_types.h)
|
||||
|
||||
- barrierCmdHello "Barrier"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: { int16_t minor, int16_t major }
|
||||
Description:
|
||||
|
||||
Say hello to client
|
||||
minor = protocol major version number supported by server
|
||||
major = protocol minor version number supported by server
|
||||
|
||||
- barrierCmdHelloBack "Barrier"
|
||||
|
||||
Direction: client ->server
|
||||
Parameters: { int16_t minor, int16_t major, char *name}
|
||||
Description:
|
||||
|
||||
Respond to hello from server
|
||||
minor = protocol major version number supported by client
|
||||
major = protocol minor version number supported by client
|
||||
name = client name
|
||||
|
||||
- barrierCmdDInfo "DINF"
|
||||
|
||||
Direction: client ->server
|
||||
Parameters: { int16_t x_origin, int16_t y_origin, int16_t width, int16_t height, int16_t x, int16_t y}
|
||||
Description:
|
||||
|
||||
The client screen must send this message in response to the
|
||||
barrierCmdQInfo message. It must also send this message when the
|
||||
screen's resolution changes. In this case, the client screen should
|
||||
ignore any barrierCmdDMouseMove messages until it receives a
|
||||
barrierCmdCInfoAck in order to prevent attempts to move the mouse off
|
||||
the new screen area.
|
||||
|
||||
- barrierCmdCNoop "CNOP"
|
||||
|
||||
Direction: client -> server
|
||||
Parameters: None
|
||||
Description:
|
||||
|
||||
No operation
|
||||
|
||||
- barrierCmdCClose "CBYE"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: None
|
||||
Description:
|
||||
|
||||
Close connection
|
||||
|
||||
- barrierCmdCEnter "CINN"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: { int16_t x, int16_t y, int32_t seq, int16_t modifier }
|
||||
Description:
|
||||
|
||||
Enter screen.
|
||||
x,y = entering screen absolute coordinates
|
||||
seq = sequence number, which is used to order messages between
|
||||
screens. the secondary screen must return this number
|
||||
with some messages
|
||||
modifier = modifier key mask. this will have bits set for each
|
||||
toggle modifier key that is activated on entry to the
|
||||
screen. the secondary screen should adjust its toggle
|
||||
modifiers to reflect that state.
|
||||
|
||||
- barrierCmdCLeave "COUT"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: None
|
||||
Description:
|
||||
|
||||
Leaving screen. the secondary screen should send clipboard data in
|
||||
response to this message for those clipboards that it has grabbed
|
||||
(i.e. has sent a barrierCmdCClipboard for and has not received a
|
||||
barrierCmdCClipboard for with a greater sequence number) and that
|
||||
were grabbed or have changed since the last leave.
|
||||
|
||||
- barrierCmdCClipboard "CCLP"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: { int8_t id, int32_t seq }
|
||||
Description:
|
||||
|
||||
Grab clipboard. Sent by screen when some other app on that screen
|
||||
grabs a clipboard.
|
||||
id = the clipboard identifier
|
||||
seq = sequence number. Client must use the sequence number passed in
|
||||
the most recent barrierCmdCEnter. the server always sends 0.
|
||||
|
||||
- barrierCmdCScreenSaver "CSEC"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: { int8_t started }
|
||||
Description:
|
||||
|
||||
Screensaver change.
|
||||
started = Screensaver on primary has started (1) or closed (0)
|
||||
|
||||
- barrierCmdCResetOptions "CROP"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: None
|
||||
Description:
|
||||
|
||||
Reset options. Client should reset all of its options to their
|
||||
defaults.
|
||||
|
||||
- barrierCmdCInfoAck "CIAK"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: None
|
||||
Description:
|
||||
|
||||
Resolution change acknowledgment. Sent by server in response to a
|
||||
client screen's barrierCmdDInfo. This is sent for every
|
||||
barrierCmdDInfo, whether or not the server had sent a barrierCmdQInfo.
|
||||
|
||||
- barrierCmdCKeepAlive "CALV"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: None
|
||||
Description:
|
||||
|
||||
Keep connection alive. Sent by the server periodically to verify
|
||||
that connections are still up and running. clients must reply in
|
||||
kind on receipt. if the server gets an error sending the message or
|
||||
does not receive a reply within a reasonable time then the server
|
||||
disconnects the client. if the client doesn't receive these (or any
|
||||
message) periodically then it should disconnect from the server. the
|
||||
appropriate interval is defined by an option.
|
||||
|
||||
- barrierCmdDKeyDown "DKDN"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: { int16_t keyid, int16_t modifier [,int16_t button] }
|
||||
Description:
|
||||
|
||||
Key pressed.
|
||||
keyid = X11 key id
|
||||
modified = modified mask
|
||||
button = X11 Xkb keycode (optional)
|
||||
|
||||
- barrierCmdDKeyRepeat "DKRP"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: { int16_t keyid, int16_t modifier, int16_t repeat [,int16_t button] }
|
||||
Description:
|
||||
|
||||
Key auto-repeat.
|
||||
keyid = X11 key id
|
||||
modified = modified mask
|
||||
repeat = number of repeats
|
||||
button = X11 Xkb keycode (optional)
|
||||
|
||||
- barrierCmdDKeyUp "DKUP"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: { int16_t keyid, int16_t modifier [,int16_t button] }
|
||||
Description:
|
||||
|
||||
Key released.
|
||||
keyid = X11 key id
|
||||
modified = modified mask
|
||||
button = X11 Xkb keycode (optional)
|
||||
|
||||
- barrierCmdDMouseDown "DMDN"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: { int8_t button }
|
||||
Description:
|
||||
|
||||
Mouse button pressed.
|
||||
button = button id
|
||||
|
||||
- barrierCmdDMouseUp "DMUP"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: { int8_t button }
|
||||
Description:
|
||||
|
||||
Mouse button release.
|
||||
button = button id
|
||||
|
||||
- barrierCmdDMouseMove "DMMV"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: { int16_t x, int16_t y }
|
||||
Description:
|
||||
|
||||
Absolute mouse moved.
|
||||
x,y = absolute screen coordinates
|
||||
|
||||
- barrierCmdDMouseRelMove "DMRM"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: { int16_t x, int16_t y }
|
||||
Description:
|
||||
|
||||
Relative mouse moved.
|
||||
x,y = r relative screen coordinates
|
||||
|
||||
- barrierCmdDMouseWheel "DMWM"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: { int16_t x , int16_t y } or { int16_t y }
|
||||
Description:
|
||||
|
||||
Mouse scroll. The delta should be +120 for one tick forward (away
|
||||
from the user) or right and -120 for one tick backward (toward the
|
||||
user) or left.
|
||||
x = x delta
|
||||
y = y delta
|
||||
|
||||
- barrierCmdDClipboard "DCLP"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: { int8_t id, int32_t seq, int8_t mark, char *data }
|
||||
Description:
|
||||
|
||||
Clipboard data.
|
||||
id = clipboard id
|
||||
seq = sequence number. The sequence number is 0 when sent by the
|
||||
server. Client screens should use the/ sequence number from
|
||||
the most recent barrierCmdCEnter.
|
||||
|
||||
- barrierCmdDSetOptions "DSOP"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: { int32 t nb, { int32_t id, int32_t val }[] }
|
||||
Description:
|
||||
|
||||
Set options. Client should set the given option/value pairs.
|
||||
nb = numbers of { id, val } entries
|
||||
id = option id
|
||||
val = option new value
|
||||
|
||||
- barrierCmdDFileTransfer "DFTR"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: { int8_t mark, char *content }
|
||||
Description:
|
||||
|
||||
Transfer file data.
|
||||
mark = 0 means the content followed is the file size
|
||||
1 means the content followed is the chunk data
|
||||
2 means the file transfer is finished
|
||||
|
||||
- barrierCmdDDragInfo "DDRG" int16_t char *
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: { int16_t nb, char *content }
|
||||
Description:
|
||||
|
||||
Drag information.
|
||||
nb = number of dragging objects
|
||||
content = object's directory
|
||||
|
||||
- barrierCmdQInfo "QINF"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: None
|
||||
Description:
|
||||
|
||||
Query screen info
|
||||
Client should reply with a barrierCmdDInfo
|
||||
|
||||
- barrierCmdEIncompatible "EICV"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: { int16_t nb, major *minor }
|
||||
Description:
|
||||
|
||||
Incompatible version.
|
||||
major = major version
|
||||
minor = minor version
|
||||
|
||||
- barrierCmdEBusy "EBSY"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: None
|
||||
Description:
|
||||
|
||||
Name provided when connecting is already in use.
|
||||
|
||||
- barrierCmdEUnknown "EUNK"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: None
|
||||
Description:
|
||||
|
||||
Unknown client. Name provided when connecting is not in primary's
|
||||
screen configuration map.
|
||||
|
||||
- barrierCmdEBad "EBAD"
|
||||
|
||||
Direction: server -> client
|
||||
Parameters: None
|
||||
Description:
|
||||
|
||||
Protocol violation. Server should disconnect after sending this
|
||||
message.
|
||||
|
||||
* TO DO
|
||||
|
||||
- Enable SSL
|
||||
- Manage SetOptions/ResetOptions commands
|
||||
|
||||
@@ -25,7 +25,7 @@ void egl_fb_setup_for_tex(egl_fb *fb, int width, int height,
|
||||
GLuint texture, bool delete);
|
||||
void egl_fb_setup_new_tex(egl_fb *fb, int width, int height);
|
||||
void egl_fb_blit(egl_fb *dst, egl_fb *src, bool flip);
|
||||
void egl_fb_read(void *dst, egl_fb *src);
|
||||
void egl_fb_read(DisplaySurface *dst, egl_fb *src);
|
||||
|
||||
void egl_texture_blit(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip);
|
||||
void egl_texture_blend(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip,
|
||||
|
||||
@@ -9,6 +9,7 @@ vnc-obj-y += vnc-jobs.o
|
||||
|
||||
common-obj-y += keymaps.o console.o cursor.o qemu-pixman.o
|
||||
common-obj-y += input.o input-keymap.o input-legacy.o kbd-state.o
|
||||
common-obj-y += input-barrier.o
|
||||
common-obj-$(CONFIG_LINUX) += input-linux.o
|
||||
common-obj-$(CONFIG_SPICE) += spice-core.o spice-input.o spice-display.o
|
||||
common-obj-$(CONFIG_COCOA) += cocoa.o
|
||||
|
||||
+1
-3
@@ -133,8 +133,6 @@ static void egl_scanout_flush(DisplayChangeListener *dcl,
|
||||
if (!edpy->guest_fb.texture || !edpy->ds) {
|
||||
return;
|
||||
}
|
||||
assert(surface_width(edpy->ds) == edpy->guest_fb.width);
|
||||
assert(surface_height(edpy->ds) == edpy->guest_fb.height);
|
||||
assert(surface_format(edpy->ds) == PIXMAN_x8r8g8b8);
|
||||
|
||||
if (edpy->cursor_fb.texture) {
|
||||
@@ -149,7 +147,7 @@ static void egl_scanout_flush(DisplayChangeListener *dcl,
|
||||
egl_fb_blit(&edpy->blit_fb, &edpy->guest_fb, edpy->y_0_top);
|
||||
}
|
||||
|
||||
egl_fb_read(surface_data(edpy->ds), &edpy->blit_fb);
|
||||
egl_fb_read(edpy->ds, &edpy->blit_fb);
|
||||
dpy_gfx_update(edpy->dcl.con, x, y, w, h);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -102,12 +102,12 @@ void egl_fb_blit(egl_fb *dst, egl_fb *src, bool flip)
|
||||
GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
}
|
||||
|
||||
void egl_fb_read(void *dst, egl_fb *src)
|
||||
void egl_fb_read(DisplaySurface *dst, egl_fb *src)
|
||||
{
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, src->framebuffer);
|
||||
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
|
||||
glReadPixels(0, 0, src->width, src->height,
|
||||
GL_BGRA, GL_UNSIGNED_BYTE, dst);
|
||||
glReadPixels(0, 0, surface_width(dst), surface_height(dst),
|
||||
GL_BGRA, GL_UNSIGNED_BYTE, surface_data(dst));
|
||||
}
|
||||
|
||||
void egl_texture_blit(QemuGLShader *gls, egl_fb *dst, egl_fb *src, bool flip)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*
|
||||
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
||||
* See the COPYING file in the top-level directory.
|
||||
*/
|
||||
|
||||
#ifndef UI_INPUT_BARRIER_H
|
||||
#define UI_INPUT_BARRIER_H
|
||||
|
||||
/* Barrier protocol */
|
||||
#define BARRIER_VERSION_MAJOR 1
|
||||
#define BARRIER_VERSION_MINOR 6
|
||||
|
||||
enum barrierCmd {
|
||||
barrierCmdCNoop,
|
||||
barrierCmdCClose,
|
||||
barrierCmdCEnter,
|
||||
barrierCmdCLeave,
|
||||
barrierCmdCClipboard,
|
||||
barrierCmdCScreenSaver,
|
||||
barrierCmdCResetOptions,
|
||||
barrierCmdCInfoAck,
|
||||
barrierCmdCKeepAlive,
|
||||
barrierCmdDKeyDown,
|
||||
barrierCmdDKeyRepeat,
|
||||
barrierCmdDKeyUp,
|
||||
barrierCmdDMouseDown,
|
||||
barrierCmdDMouseUp,
|
||||
barrierCmdDMouseMove,
|
||||
barrierCmdDMouseRelMove,
|
||||
barrierCmdDMouseWheel,
|
||||
barrierCmdDClipboard,
|
||||
barrierCmdDInfo,
|
||||
barrierCmdDSetOptions,
|
||||
barrierCmdDFileTransfer,
|
||||
barrierCmdDDragInfo,
|
||||
barrierCmdQInfo,
|
||||
barrierCmdEIncompatible,
|
||||
barrierCmdEBusy,
|
||||
barrierCmdEUnknown,
|
||||
barrierCmdEBad,
|
||||
/* connection sequence */
|
||||
barrierCmdHello,
|
||||
barrierCmdHelloBack,
|
||||
};
|
||||
|
||||
enum {
|
||||
barrierButtonNone,
|
||||
barrierButtonLeft,
|
||||
barrierButtonMiddle,
|
||||
barrierButtonRight,
|
||||
barrierButtonExtra0
|
||||
};
|
||||
|
||||
struct barrierVersion {
|
||||
int16_t major;
|
||||
int16_t minor;
|
||||
};
|
||||
|
||||
struct barrierMouseButton {
|
||||
int8_t buttonid;
|
||||
};
|
||||
|
||||
struct barrierEnter {
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
int32_t seqn;
|
||||
int16_t modifier;
|
||||
};
|
||||
|
||||
struct barrierMousePos {
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
};
|
||||
|
||||
struct barrierKey {
|
||||
int16_t keyid;
|
||||
int16_t modifier;
|
||||
int16_t button;
|
||||
};
|
||||
|
||||
struct barrierRepeat {
|
||||
int16_t keyid;
|
||||
int16_t modifier;
|
||||
int16_t repeat;
|
||||
int16_t button;
|
||||
};
|
||||
|
||||
#define BARRIER_MAX_OPTIONS 32
|
||||
struct barrierSet {
|
||||
int nb;
|
||||
struct {
|
||||
int id;
|
||||
char nul;
|
||||
int value;
|
||||
} option[BARRIER_MAX_OPTIONS];
|
||||
};
|
||||
|
||||
struct barrierMsg {
|
||||
enum barrierCmd cmd;
|
||||
union {
|
||||
struct barrierVersion version;
|
||||
struct barrierMouseButton mousebutton;
|
||||
struct barrierMousePos mousepos;
|
||||
struct barrierEnter enter;
|
||||
struct barrierKey key;
|
||||
struct barrierRepeat repeat;
|
||||
struct barrierSet set;
|
||||
};
|
||||
};
|
||||
#endif
|
||||
+111
-108
File diff suppressed because it is too large
Load Diff
+6
-5
@@ -76,7 +76,8 @@ static int vnc_zlib_stop(VncState *vs)
|
||||
zstream->zalloc = vnc_zlib_zalloc;
|
||||
zstream->zfree = vnc_zlib_zfree;
|
||||
|
||||
err = deflateInit2(zstream, vs->tight.compression, Z_DEFLATED, MAX_WBITS,
|
||||
err = deflateInit2(zstream, vs->tight->compression, Z_DEFLATED,
|
||||
MAX_WBITS,
|
||||
MAX_MEM_LEVEL, Z_DEFAULT_STRATEGY);
|
||||
|
||||
if (err != Z_OK) {
|
||||
@@ -84,16 +85,16 @@ static int vnc_zlib_stop(VncState *vs)
|
||||
return -1;
|
||||
}
|
||||
|
||||
vs->zlib.level = vs->tight.compression;
|
||||
vs->zlib.level = vs->tight->compression;
|
||||
zstream->opaque = vs;
|
||||
}
|
||||
|
||||
if (vs->tight.compression != vs->zlib.level) {
|
||||
if (deflateParams(zstream, vs->tight.compression,
|
||||
if (vs->tight->compression != vs->zlib.level) {
|
||||
if (deflateParams(zstream, vs->tight->compression,
|
||||
Z_DEFAULT_STRATEGY) != Z_OK) {
|
||||
return -1;
|
||||
}
|
||||
vs->zlib.level = vs->tight.compression;
|
||||
vs->zlib.level = vs->tight->compression;
|
||||
}
|
||||
|
||||
// reserve memory in output buffer
|
||||
|
||||
+34
-34
@@ -37,18 +37,18 @@ static const int bits_per_packed_pixel[] = {
|
||||
|
||||
static void vnc_zrle_start(VncState *vs)
|
||||
{
|
||||
buffer_reset(&vs->zrle.zrle);
|
||||
buffer_reset(&vs->zrle->zrle);
|
||||
|
||||
/* make the output buffer be the zlib buffer, so we can compress it later */
|
||||
vs->zrle.tmp = vs->output;
|
||||
vs->output = vs->zrle.zrle;
|
||||
vs->zrle->tmp = vs->output;
|
||||
vs->output = vs->zrle->zrle;
|
||||
}
|
||||
|
||||
static void vnc_zrle_stop(VncState *vs)
|
||||
{
|
||||
/* switch back to normal output/zlib buffers */
|
||||
vs->zrle.zrle = vs->output;
|
||||
vs->output = vs->zrle.tmp;
|
||||
vs->zrle->zrle = vs->output;
|
||||
vs->output = vs->zrle->tmp;
|
||||
}
|
||||
|
||||
static void *zrle_convert_fb(VncState *vs, int x, int y, int w, int h,
|
||||
@@ -56,24 +56,24 @@ static void *zrle_convert_fb(VncState *vs, int x, int y, int w, int h,
|
||||
{
|
||||
Buffer tmp;
|
||||
|
||||
buffer_reset(&vs->zrle.fb);
|
||||
buffer_reserve(&vs->zrle.fb, w * h * bpp + bpp);
|
||||
buffer_reset(&vs->zrle->fb);
|
||||
buffer_reserve(&vs->zrle->fb, w * h * bpp + bpp);
|
||||
|
||||
tmp = vs->output;
|
||||
vs->output = vs->zrle.fb;
|
||||
vs->output = vs->zrle->fb;
|
||||
|
||||
vnc_raw_send_framebuffer_update(vs, x, y, w, h);
|
||||
|
||||
vs->zrle.fb = vs->output;
|
||||
vs->zrle->fb = vs->output;
|
||||
vs->output = tmp;
|
||||
return vs->zrle.fb.buffer;
|
||||
return vs->zrle->fb.buffer;
|
||||
}
|
||||
|
||||
static int zrle_compress_data(VncState *vs, int level)
|
||||
{
|
||||
z_streamp zstream = &vs->zrle.stream;
|
||||
z_streamp zstream = &vs->zrle->stream;
|
||||
|
||||
buffer_reset(&vs->zrle.zlib);
|
||||
buffer_reset(&vs->zrle->zlib);
|
||||
|
||||
if (zstream->opaque != vs) {
|
||||
int err;
|
||||
@@ -93,13 +93,13 @@ static int zrle_compress_data(VncState *vs, int level)
|
||||
}
|
||||
|
||||
/* reserve memory in output buffer */
|
||||
buffer_reserve(&vs->zrle.zlib, vs->zrle.zrle.offset + 64);
|
||||
buffer_reserve(&vs->zrle->zlib, vs->zrle->zrle.offset + 64);
|
||||
|
||||
/* set pointers */
|
||||
zstream->next_in = vs->zrle.zrle.buffer;
|
||||
zstream->avail_in = vs->zrle.zrle.offset;
|
||||
zstream->next_out = vs->zrle.zlib.buffer + vs->zrle.zlib.offset;
|
||||
zstream->avail_out = vs->zrle.zlib.capacity - vs->zrle.zlib.offset;
|
||||
zstream->next_in = vs->zrle->zrle.buffer;
|
||||
zstream->avail_in = vs->zrle->zrle.offset;
|
||||
zstream->next_out = vs->zrle->zlib.buffer + vs->zrle->zlib.offset;
|
||||
zstream->avail_out = vs->zrle->zlib.capacity - vs->zrle->zlib.offset;
|
||||
zstream->data_type = Z_BINARY;
|
||||
|
||||
/* start encoding */
|
||||
@@ -108,8 +108,8 @@ static int zrle_compress_data(VncState *vs, int level)
|
||||
return -1;
|
||||
}
|
||||
|
||||
vs->zrle.zlib.offset = vs->zrle.zlib.capacity - zstream->avail_out;
|
||||
return vs->zrle.zlib.offset;
|
||||
vs->zrle->zlib.offset = vs->zrle->zlib.capacity - zstream->avail_out;
|
||||
return vs->zrle->zlib.offset;
|
||||
}
|
||||
|
||||
/* Try to work out whether to use RLE and/or a palette. We do this by
|
||||
@@ -259,14 +259,14 @@ static int zrle_send_framebuffer_update(VncState *vs, int x, int y,
|
||||
size_t bytes;
|
||||
int zywrle_level;
|
||||
|
||||
if (vs->zrle.type == VNC_ENCODING_ZYWRLE) {
|
||||
if (!vs->vd->lossy || vs->tight.quality == (uint8_t)-1
|
||||
|| vs->tight.quality == 9) {
|
||||
if (vs->zrle->type == VNC_ENCODING_ZYWRLE) {
|
||||
if (!vs->vd->lossy || vs->tight->quality == (uint8_t)-1
|
||||
|| vs->tight->quality == 9) {
|
||||
zywrle_level = 0;
|
||||
vs->zrle.type = VNC_ENCODING_ZRLE;
|
||||
} else if (vs->tight.quality < 3) {
|
||||
vs->zrle->type = VNC_ENCODING_ZRLE;
|
||||
} else if (vs->tight->quality < 3) {
|
||||
zywrle_level = 3;
|
||||
} else if (vs->tight.quality < 6) {
|
||||
} else if (vs->tight->quality < 6) {
|
||||
zywrle_level = 2;
|
||||
} else {
|
||||
zywrle_level = 1;
|
||||
@@ -337,30 +337,30 @@ static int zrle_send_framebuffer_update(VncState *vs, int x, int y,
|
||||
|
||||
vnc_zrle_stop(vs);
|
||||
bytes = zrle_compress_data(vs, Z_DEFAULT_COMPRESSION);
|
||||
vnc_framebuffer_update(vs, x, y, w, h, vs->zrle.type);
|
||||
vnc_framebuffer_update(vs, x, y, w, h, vs->zrle->type);
|
||||
vnc_write_u32(vs, bytes);
|
||||
vnc_write(vs, vs->zrle.zlib.buffer, vs->zrle.zlib.offset);
|
||||
vnc_write(vs, vs->zrle->zlib.buffer, vs->zrle->zlib.offset);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int vnc_zrle_send_framebuffer_update(VncState *vs, int x, int y, int w, int h)
|
||||
{
|
||||
vs->zrle.type = VNC_ENCODING_ZRLE;
|
||||
vs->zrle->type = VNC_ENCODING_ZRLE;
|
||||
return zrle_send_framebuffer_update(vs, x, y, w, h);
|
||||
}
|
||||
|
||||
int vnc_zywrle_send_framebuffer_update(VncState *vs, int x, int y, int w, int h)
|
||||
{
|
||||
vs->zrle.type = VNC_ENCODING_ZYWRLE;
|
||||
vs->zrle->type = VNC_ENCODING_ZYWRLE;
|
||||
return zrle_send_framebuffer_update(vs, x, y, w, h);
|
||||
}
|
||||
|
||||
void vnc_zrle_clear(VncState *vs)
|
||||
{
|
||||
if (vs->zrle.stream.opaque) {
|
||||
deflateEnd(&vs->zrle.stream);
|
||||
if (vs->zrle->stream.opaque) {
|
||||
deflateEnd(&vs->zrle->stream);
|
||||
}
|
||||
buffer_free(&vs->zrle.zrle);
|
||||
buffer_free(&vs->zrle.fb);
|
||||
buffer_free(&vs->zrle.zlib);
|
||||
buffer_free(&vs->zrle->zrle);
|
||||
buffer_free(&vs->zrle->fb);
|
||||
buffer_free(&vs->zrle->zlib);
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ static void ZRLE_ENCODE(VncState *vs, int x, int y, int w, int h,
|
||||
static void ZRLE_ENCODE_TILE(VncState *vs, ZRLE_PIXEL *data, int w, int h,
|
||||
int zywrle_level)
|
||||
{
|
||||
VncPalette *palette = &vs->zrle.palette;
|
||||
VncPalette *palette = &vs->zrle->palette;
|
||||
|
||||
int runs = 0;
|
||||
int single_pixels = 0;
|
||||
|
||||
@@ -278,6 +278,7 @@ static void vnc_client_cache_addr(VncState *client)
|
||||
vnc_init_basic_info_from_remote_addr(client->sioc,
|
||||
qapi_VncClientInfo_base(client->info),
|
||||
&err);
|
||||
client->info->websocket = client->websocket;
|
||||
if (err) {
|
||||
qapi_free_VncClientInfo(client->info);
|
||||
client->info = NULL;
|
||||
@@ -1306,6 +1307,8 @@ void vnc_disconnect_finish(VncState *vs)
|
||||
object_unref(OBJECT(vs->sioc));
|
||||
vs->sioc = NULL;
|
||||
vs->magic = 0;
|
||||
g_free(vs->zrle);
|
||||
g_free(vs->tight);
|
||||
g_free(vs);
|
||||
}
|
||||
|
||||
@@ -2057,8 +2060,8 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings)
|
||||
|
||||
vs->features = 0;
|
||||
vs->vnc_encoding = 0;
|
||||
vs->tight.compression = 9;
|
||||
vs->tight.quality = -1; /* Lossless by default */
|
||||
vs->tight->compression = 9;
|
||||
vs->tight->quality = -1; /* Lossless by default */
|
||||
vs->absolute = -1;
|
||||
|
||||
/*
|
||||
@@ -2126,11 +2129,11 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings)
|
||||
vs->features |= VNC_FEATURE_LED_STATE_MASK;
|
||||
break;
|
||||
case VNC_ENCODING_COMPRESSLEVEL0 ... VNC_ENCODING_COMPRESSLEVEL0 + 9:
|
||||
vs->tight.compression = (enc & 0x0F);
|
||||
vs->tight->compression = (enc & 0x0F);
|
||||
break;
|
||||
case VNC_ENCODING_QUALITYLEVEL0 ... VNC_ENCODING_QUALITYLEVEL0 + 9:
|
||||
if (vs->vd->lossy) {
|
||||
vs->tight.quality = (enc & 0x0F);
|
||||
vs->tight->quality = (enc & 0x0F);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -3033,6 +3036,8 @@ static void vnc_connect(VncDisplay *vd, QIOChannelSocket *sioc,
|
||||
int i;
|
||||
|
||||
trace_vnc_client_connect(vs, sioc);
|
||||
vs->zrle = g_new0(VncZrle, 1);
|
||||
vs->tight = g_new0(VncTight, 1);
|
||||
vs->magic = VNC_MAGIC;
|
||||
vs->sioc = sioc;
|
||||
object_ref(OBJECT(vs->sioc));
|
||||
@@ -3044,19 +3049,19 @@ static void vnc_connect(VncDisplay *vd, QIOChannelSocket *sioc,
|
||||
buffer_init(&vs->output, "vnc-output/%p", sioc);
|
||||
buffer_init(&vs->jobs_buffer, "vnc-jobs_buffer/%p", sioc);
|
||||
|
||||
buffer_init(&vs->tight.tight, "vnc-tight/%p", sioc);
|
||||
buffer_init(&vs->tight.zlib, "vnc-tight-zlib/%p", sioc);
|
||||
buffer_init(&vs->tight.gradient, "vnc-tight-gradient/%p", sioc);
|
||||
buffer_init(&vs->tight->tight, "vnc-tight/%p", sioc);
|
||||
buffer_init(&vs->tight->zlib, "vnc-tight-zlib/%p", sioc);
|
||||
buffer_init(&vs->tight->gradient, "vnc-tight-gradient/%p", sioc);
|
||||
#ifdef CONFIG_VNC_JPEG
|
||||
buffer_init(&vs->tight.jpeg, "vnc-tight-jpeg/%p", sioc);
|
||||
buffer_init(&vs->tight->jpeg, "vnc-tight-jpeg/%p", sioc);
|
||||
#endif
|
||||
#ifdef CONFIG_VNC_PNG
|
||||
buffer_init(&vs->tight.png, "vnc-tight-png/%p", sioc);
|
||||
buffer_init(&vs->tight->png, "vnc-tight-png/%p", sioc);
|
||||
#endif
|
||||
buffer_init(&vs->zlib.zlib, "vnc-zlib/%p", sioc);
|
||||
buffer_init(&vs->zrle.zrle, "vnc-zrle/%p", sioc);
|
||||
buffer_init(&vs->zrle.fb, "vnc-zrle-fb/%p", sioc);
|
||||
buffer_init(&vs->zrle.zlib, "vnc-zrle-zlib/%p", sioc);
|
||||
buffer_init(&vs->zrle->zrle, "vnc-zrle/%p", sioc);
|
||||
buffer_init(&vs->zrle->fb, "vnc-zrle-fb/%p", sioc);
|
||||
buffer_init(&vs->zrle->zlib, "vnc-zrle-zlib/%p", sioc);
|
||||
|
||||
if (skipauth) {
|
||||
vs->auth = VNC_AUTH_NONE;
|
||||
|
||||
@@ -338,10 +338,10 @@ struct VncState
|
||||
/* Encoding specific, if you add something here, don't forget to
|
||||
* update vnc_async_encoding_start()
|
||||
*/
|
||||
VncTight tight;
|
||||
VncTight *tight;
|
||||
VncZlib zlib;
|
||||
VncHextile hextile;
|
||||
VncZrle zrle;
|
||||
VncZrle *zrle;
|
||||
VncZywrle zywrle;
|
||||
|
||||
Notifier mouse_mode_notifier;
|
||||
|
||||
Reference in New Issue
Block a user