ui: fixes for vnc, opengl and curses.

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABAgAGBQJWOIQUAAoJEEy22O7T6HE4LEsP/jegRIreUmdcbL/WKxpJO/xT
 8OO8XSiQ9s1iukKKe+a9Eh3zbntb3ALd2rLADBQq3MF32Nq5PFR6Dqkvx2+JMPRN
 jj3eV++DbOdLfhBFeaXA5AfC54xUvVXImap/tSjXewZyIoHz+2hmpqF0a1y7OXle
 NgGaFn9sAAV8ny/TwtqWAXQNOYzl5qX35/NRl0FBdn13VKmtorJPOJYtYADBUXR4
 sd0VtOyMjXiH/iSzdazqhEoHqJOoJpR75rKfyRiuzWlFyTCMZ/CXiEXtm+u869uq
 WkJSdFiS0RrqozwnJqJH65/ZJm40nCPtZpQOAkOofV4LiZ64smxr65yw0w51kd2X
 Ic2NRHhplrP/TnpEBSG66ReH14GXmoWkT6/DQFvqT2D0E+fDO8piusTBd3zg3GGw
 eHg4vYk/Vuu+Hic+92YVuBPgWme1SsJMJZDSjgqr6wenW3+Ip0g3bo9Lbsb+hZHz
 0/Kyu8ZcR5vg6EPW9w7CxpiAEsJKgPJnUJ2HVcHEV1BXdckchmZYO6dgmW+yhdFw
 jIpVHthpWfuzLZ1Fr45ySmriz7/rprhwzhq30pkvbK+p+Jwa/NlmgyvYNMROzUE7
 wdIZNvRTqodrCKpuyV6mY3L6vESvJzweOaxI4setpd9BhhYqIVHx0dNe4z/vLjfZ
 1AWQtou4nnT2FUh3Ubeb
 =aGNx
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/kraxel/tags/pull-ui-20151103-1' into staging

ui: fixes for vnc, opengl and curses.

# gpg: Signature made Tue 03 Nov 2015 09:53:24 GMT using RSA key ID D3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg:                 aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg:                 aka "Gerd Hoffmann (private) <kraxel@gmail.com>"

* remotes/kraxel/tags/pull-ui-20151103-1:
  vnc: fix bug: vnc server can't start when 'to' is specified
  vnc: allow fall back to RAW encoding
  ui/opengl: Reduce build required libraries for opengl
  ui/curses: Fix pageup/pagedown on -curses
  ui/curses: Support line graphics chars on -curses mode
  ui/curses: Fix monitor color with -curses when 256 colors

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2015-11-03 10:20:04 +00:00
commit 130d0bc659
7 changed files with 94 additions and 26 deletions

20
configure vendored
View file

@ -3286,25 +3286,11 @@ fi
libs_softmmu="$libs_softmmu $fdt_libs"
##########################################
# opengl probe (for sdl2, milkymist-tmu2)
# GLX probe, used by milkymist-tmu2
# this is temporary, code will be switched to egl mid-term.
cat > $TMPC << EOF
#include <X11/Xlib.h>
#include <GL/gl.h>
#include <GL/glx.h>
int main(void) { glBegin(0); glXQueryVersion(0,0,0); return 0; }
EOF
if compile_prog "" "-lGL -lX11" ; then
have_glx=yes
else
have_glx=no
fi
# opengl probe (for sdl2, gtk, milkymist-tmu2)
if test "$opengl" != "no" ; then
opengl_pkgs="gl glesv2 epoxy egl"
if $pkg_config $opengl_pkgs x11 && test "$have_glx" = "yes"; then
opengl_pkgs="epoxy"
if $pkg_config $opengl_pkgs x11; then
opengl_cflags="$($pkg_config --cflags $opengl_pkgs) $x11_cflags"
opengl_libs="$($pkg_config --libs $opengl_pkgs) $x11_libs"
opengl=yes

View file

@ -30,8 +30,8 @@
#include "qemu/error-report.h"
#include <X11/Xlib.h>
#include <GL/gl.h>
#include <GL/glx.h>
#include <epoxy/gl.h>
#include <epoxy/glx.h>
enum {
R_CTL = 0,

View file

@ -88,7 +88,8 @@ static inline DeviceState *milkymist_pfpu_create(hwaddr base,
#ifdef CONFIG_OPENGL
#include <X11/Xlib.h>
#include <GL/glx.h>
#include <epoxy/gl.h>
#include <epoxy/glx.h>
static const int glx_fbconfig_attr[] = {
GLX_GREEN_SIZE, 5,
GLX_GREEN_SIZE, 6,

View file

@ -321,13 +321,23 @@ static inline pixman_format_code_t surface_format(DisplaySurface *s)
#ifdef CONFIG_CURSES
#include <curses.h>
typedef chtype console_ch_t;
extern chtype vga_to_curses[];
#else
typedef unsigned long console_ch_t;
#endif
static inline void console_write_ch(console_ch_t *dest, uint32_t ch)
{
if (!(ch & 0xff))
uint8_t c = ch;
#ifdef CONFIG_CURSES
if (vga_to_curses[c]) {
ch &= ~(console_ch_t)0xff;
ch |= vga_to_curses[c];
}
#else
if (c == '\0') {
ch |= ' ';
}
#endif
*dest = ch;
}

View file

@ -42,6 +42,8 @@ static WINDOW *screenpad = NULL;
static int width, height, gwidth, gheight, invalidate;
static int px, py, sminx, sminy, smaxx, smaxy;
chtype vga_to_curses[256];
static void curses_update(DisplayChangeListener *dcl,
int x, int y, int w, int h)
{
@ -341,8 +343,55 @@ static void curses_setup(void)
nodelay(stdscr, TRUE); nonl(); keypad(stdscr, TRUE);
start_color(); raw(); scrollok(stdscr, FALSE);
for (i = 0; i < 64; i ++)
for (i = 0; i < 64; i++) {
init_pair(i, colour_default[i & 7], colour_default[i >> 3]);
}
/* Set default color for more than 64. (monitor uses 0x74xx for example) */
for (i = 64; i < COLOR_PAIRS; i++) {
init_pair(i, COLOR_WHITE, COLOR_BLACK);
}
/*
* Setup mapping for vga to curses line graphics.
* FIXME: for better font, have to use ncursesw and setlocale()
*/
#if 0
/* FIXME: map from where? */
ACS_S1;
ACS_S3;
ACS_S7;
ACS_S9;
#endif
/* ACS_* is not constant. So, we can't initialize statically. */
vga_to_curses['\0'] = ' ';
vga_to_curses[0x04] = ACS_DIAMOND;
vga_to_curses[0x0a] = ACS_RARROW;
vga_to_curses[0x0b] = ACS_LARROW;
vga_to_curses[0x18] = ACS_UARROW;
vga_to_curses[0x19] = ACS_DARROW;
vga_to_curses[0x9c] = ACS_STERLING;
vga_to_curses[0xb0] = ACS_BOARD;
vga_to_curses[0xb1] = ACS_CKBOARD;
vga_to_curses[0xb3] = ACS_VLINE;
vga_to_curses[0xb4] = ACS_RTEE;
vga_to_curses[0xbf] = ACS_URCORNER;
vga_to_curses[0xc0] = ACS_LLCORNER;
vga_to_curses[0xc1] = ACS_BTEE;
vga_to_curses[0xc2] = ACS_TTEE;
vga_to_curses[0xc3] = ACS_LTEE;
vga_to_curses[0xc4] = ACS_HLINE;
vga_to_curses[0xc5] = ACS_PLUS;
vga_to_curses[0xce] = ACS_LANTERN;
vga_to_curses[0xd8] = ACS_NEQUAL;
vga_to_curses[0xd9] = ACS_LRCORNER;
vga_to_curses[0xda] = ACS_ULCORNER;
vga_to_curses[0xdb] = ACS_BLOCK;
vga_to_curses[0xe3] = ACS_PI;
vga_to_curses[0xf1] = ACS_PLMINUS;
vga_to_curses[0xf2] = ACS_GEQUAL;
vga_to_curses[0xf3] = ACS_LEQUAL;
vga_to_curses[0xf8] = ACS_DEGREE;
vga_to_curses[0xfe] = ACS_BULLET;
}
static void curses_keyboard_setup(void)

View file

@ -29,8 +29,7 @@
#include "keymaps.h"
#define KEY_RELEASE 0x80
#define KEY_MASK 0x7f
#define KEY_MASK SCANCODE_KEYMASK
#define GREY_CODE 0xe0
#define GREY SCANCODE_GREY
#define SHIFT_CODE 0x2a
@ -60,6 +59,8 @@ static const int curses2keysym[CURSES_KEYS] = {
['\n'] = KEY_ENTER,
[27] = 27,
[KEY_BTAB] = '\t' | KEYSYM_SHIFT,
[KEY_SPREVIOUS] = KEY_PPAGE | KEYSYM_SHIFT,
[KEY_SNEXT] = KEY_NPAGE | KEYSYM_SHIFT,
};
static const int curses2keycode[CURSES_KEYS] = {
@ -149,6 +150,9 @@ static const int curses2keycode[CURSES_KEYS] = {
[KEY_IC] = 82 | GREY, /* Insert */
[KEY_DC] = 83 | GREY, /* Delete */
[KEY_SPREVIOUS] = 73 | GREY | SHIFT, /* Shift + Page Up */
[KEY_SNEXT] = 81 | GREY | SHIFT, /* Shift + Page Down */
['!'] = 2 | SHIFT,
['@'] = 3 | SHIFT,
['#'] = 4 | SHIFT,

View file

@ -840,6 +840,8 @@ int vnc_raw_send_framebuffer_update(VncState *vs, int x, int y, int w, int h)
int vnc_send_framebuffer_update(VncState *vs, int x, int y, int w, int h)
{
int n = 0;
bool encode_raw = false;
size_t saved_offs = vs->output.offset;
switch(vs->vnc_encoding) {
case VNC_ENCODING_ZLIB:
@ -862,10 +864,24 @@ int vnc_send_framebuffer_update(VncState *vs, int x, int y, int w, int h)
n = vnc_zywrle_send_framebuffer_update(vs, x, y, w, h);
break;
default:
vnc_framebuffer_update(vs, x, y, w, h, VNC_ENCODING_RAW);
n = vnc_raw_send_framebuffer_update(vs, x, y, w, h);
encode_raw = true;
break;
}
/* If the client has the same pixel format as our internal buffer and
* a RAW encoding would need less space fall back to RAW encoding to
* save bandwidth and processing power in the client. */
if (!encode_raw && vs->write_pixels == vnc_write_pixels_copy &&
12 + h * w * VNC_SERVER_FB_BYTES <= (vs->output.offset - saved_offs)) {
vs->output.offset = saved_offs;
encode_raw = true;
}
if (encode_raw) {
vnc_framebuffer_update(vs, x, y, w, h, VNC_ENCODING_RAW);
n = vnc_raw_send_framebuffer_update(vs, x, y, w, h);
}
return n;
}
@ -3556,6 +3572,8 @@ void vnc_display_open(const char *id, Error **errp)
if (to) {
saddr->u.inet->has_to = true;
saddr->u.inet->to = to;
saddr->u.inet->has_to = true;
saddr->u.inet->to = to + 5900;
}
saddr->u.inet->ipv4 = saddr->u.inet->has_ipv4 = has_ipv4;
saddr->u.inet->ipv6 = saddr->u.inet->has_ipv6 = has_ipv6;