ui: fixes for sdl, curses, vnc, input-linux.

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.22 (GNU/Linux)
 
 iQIcBAABCgAGBQJfhrUPAAoJEEy22O7T6HE40KsQAJzFApqnGiFeWpLeUTIHsiQ5
 hClieasK4ISBTlCx75EX6czVocBUokATkCy2f0rvXftDyXppnhuJIUHN/suq4uZ/
 +QKgv4r9iOw4zUd1UTn1mOCqBR2zslx2stvlC0BNzC5RxpbA2nmkd3waINTIHIaX
 3j2vA/c3eiyaV5mx/fvyuMl6rbtqGsIqNYHoE8vB0Ijs7mHNEAkif9/yjxZ7cC1H
 7qp2Lx6+PJWCktLS0Y/WGYnkfoWDSvo2UMAFz2WdW19vTF3LZzXyUzjICiQVoRi3
 SQBKs5j7mRUZfdurIfPLtXyOo+gu0U21RPIqC7A9ZPzQgCudl0TvN3CN2dryBoZq
 /BfB0weTj7V56esN6LhwLSGEKV3xrm2NVjy7Kiuyl/KtXOVHL1c2GI8e4tOFtIhT
 XbbkTzFVA01rlfmw2gdvoLgvPrCovHiRhMr02MiCvnfjvOukaZm7PcM4WJ6/dRU0
 sggZWNpTt8NQqJawQK8JFC4xHeQbcnYBXwDLHEJhKiwbhItOs+fDEUSQs+LqA8rX
 Tk4G0WZoFGpTq0vBsT7e3H++6Nzl2oAWJ7Bc/3Ifjc3vefGOCAPza8Q4bmIvOddF
 O6xGToBG2SzSRokKMTGA1S2fdpEIlNXYLuDAmgehJFrwWnWVKApIAM67JR4rj4gJ
 dZD8106jvd7VRAMFEdyt
 =mHP7
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/kraxel/tags/ui-20201014-pull-request' into staging

ui: fixes for sdl, curses, vnc, input-linux.

# gpg: Signature made Wed 14 Oct 2020 09:21:35 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-20201014-pull-request:
  ui: Fix default window_id value
  input-linux: Reset il->fd handler before closing it
  SDL: enable OpenGL context creation
  vnc-stubs: Allow -vnc none
  configure: Fixes ncursesw detection under msys2/mingw by convert them to meson
  win32: Simplify gmtime_r detection not depends on if _POSIX_C_SOURCE are defined on msys2/mingw
  curses: Fixes curses compiling errors.
  curses: Fixes compiler error that complain don't have langinfo.h on msys2/mingw
  qemu-edid: drop cast

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2020-10-14 13:56:06 +01:00
commit 57c98ea9ac
12 changed files with 105 additions and 173 deletions

155
configure vendored
View File

@ -295,7 +295,8 @@ unset target_list_exclude
brlapi=""
curl=""
curses=""
iconv="auto"
curses="auto"
docs=""
fdt="auto"
netmap="no"
@ -1173,13 +1174,13 @@ for opt do
;;
--disable-safe-stack) safe_stack="no"
;;
--disable-curses) curses="no"
--disable-curses) curses="disabled"
;;
--enable-curses) curses="yes"
--enable-curses) curses="enabled"
;;
--disable-iconv) iconv="no"
--disable-iconv) iconv="disabled"
;;
--enable-iconv) iconv="yes"
--enable-iconv) iconv="enabled"
;;
--disable-curl) curl="no"
;;
@ -2386,37 +2387,6 @@ if test "$vhost_net" = ""; then
test "$vhost_kernel" = "yes" && vhost_net=yes
fi
##########################################
# MinGW / Mingw-w64 localtime_r/gmtime_r check
if test "$mingw32" = "yes"; then
# Some versions of MinGW / Mingw-w64 lack localtime_r
# and gmtime_r entirely.
#
# Some versions of Mingw-w64 define a macro for
# localtime_r/gmtime_r.
#
# Some versions of Mingw-w64 will define functions
# for localtime_r/gmtime_r, but only if you have
# _POSIX_THREAD_SAFE_FUNCTIONS defined. For fun
# though, unistd.h and pthread.h both define
# that for you.
#
# So this #undef localtime_r and #include <unistd.h>
# are not in fact redundant.
cat > $TMPC << EOF
#include <unistd.h>
#include <time.h>
#undef localtime_r
int main(void) { localtime_r(NULL, NULL); return 0; }
EOF
if compile_prog "" "" ; then
localtime_r="yes"
else
localtime_r="no"
fi
fi
##########################################
# pkg-config probe
@ -3471,105 +3441,6 @@ EOF
fi
fi
##########################################
# iconv probe
if test "$iconv" != "no" ; then
cat > $TMPC << EOF
#include <iconv.h>
int main(void) {
iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
return conv != (iconv_t) -1;
}
EOF
iconv_prefix_list="/usr/local:/usr"
iconv_lib_list=":-liconv"
IFS=:
for iconv_prefix in $iconv_prefix_list; do
IFS=:
iconv_cflags="-I$iconv_prefix/include"
iconv_ldflags="-L$iconv_prefix/lib"
for iconv_link in $iconv_lib_list; do
unset IFS
iconv_lib="$iconv_ldflags $iconv_link"
echo "looking at iconv in '$iconv_cflags' '$iconv_lib'" >> config.log
if compile_prog "$iconv_cflags" "$iconv_lib" ; then
iconv_found=yes
break
fi
done
if test "$iconv_found" = yes ; then
break
fi
done
if test "$iconv_found" = "yes" ; then
iconv=yes
else
if test "$iconv" = "yes" ; then
feature_not_found "iconv" "Install iconv devel"
fi
iconv=no
fi
fi
##########################################
# curses probe
if test "$iconv" = "no" ; then
# curses will need iconv
curses=no
fi
if test "$curses" != "no" ; then
if test "$mingw32" = "yes" ; then
curses_inc_list="$($pkg_config --cflags ncurses 2>/dev/null):"
curses_lib_list="$($pkg_config --libs ncurses 2>/dev/null):-lpdcurses"
else
curses_inc_list="$($pkg_config --cflags ncursesw 2>/dev/null):-I/usr/include/ncursesw:"
curses_lib_list="$($pkg_config --libs ncursesw 2>/dev/null):-lncursesw:-lcursesw"
fi
curses_found=no
cat > $TMPC << EOF
#include <locale.h>
#include <curses.h>
#include <wchar.h>
#include <langinfo.h>
int main(void) {
const char *codeset;
wchar_t wch = L'w';
setlocale(LC_ALL, "");
resize_term(0, 0);
addwstr(L"wide chars\n");
addnwstr(&wch, 1);
add_wch(WACS_DEGREE);
codeset = nl_langinfo(CODESET);
return codeset != 0;
}
EOF
IFS=:
for curses_inc in $curses_inc_list; do
# Make sure we get the wide character prototypes
curses_inc="-DNCURSES_WIDECHAR $curses_inc"
IFS=:
for curses_lib in $curses_lib_list; do
unset IFS
if compile_prog "$curses_inc" "$curses_lib" ; then
curses_found=yes
break
fi
done
if test "$curses_found" = yes ; then
break
fi
done
unset IFS
if test "$curses_found" = "yes" ; then
curses=yes
else
if test "$curses" = "yes" ; then
feature_not_found "curses" "Install ncurses devel"
fi
curses=no
fi
fi
##########################################
# curl probe
if test "$curl" != "no" ; then
@ -6234,16 +6105,6 @@ if test "$have_x11" = "yes" && test "$need_x11" = "yes"; then
echo "X11_CFLAGS=$x11_cflags" >> $config_host_mak
echo "X11_LIBS=$x11_libs" >> $config_host_mak
fi
if test "$iconv" = "yes" ; then
echo "CONFIG_ICONV=y" >> $config_host_mak
echo "ICONV_CFLAGS=$iconv_cflags" >> $config_host_mak
echo "ICONV_LIBS=$iconv_lib" >> $config_host_mak
fi
if test "$curses" = "yes" ; then
echo "CONFIG_CURSES=y" >> $config_host_mak
echo "CURSES_CFLAGS=$curses_inc" >> $config_host_mak
echo "CURSES_LIBS=$curses_lib" >> $config_host_mak
fi
if test "$pipe2" = "yes" ; then
echo "CONFIG_PIPE2=y" >> $config_host_mak
fi
@ -6613,9 +6474,6 @@ if [ "$bsd" = "yes" ] ; then
echo "CONFIG_BSD=y" >> $config_host_mak
fi
if test "$localtime_r" = "yes" ; then
echo "CONFIG_LOCALTIME_R=y" >> $config_host_mak
fi
if test "$qom_cast_debug" = "yes" ; then
echo "CONFIG_QOM_CAST_DEBUG=y" >> $config_host_mak
fi
@ -7218,6 +7076,7 @@ NINJA=${ninja:-$PWD/ninjatool} $meson setup \
-Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
-Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f \
-Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt \
-Diconv=$iconv -Dcurses=$curses \
$cross_arg \
"$PWD" "$source_path"

View File

@ -48,12 +48,12 @@
#define siglongjmp(env, val) longjmp(env, val)
/* Missing POSIX functions. Don't use MinGW-w64 macros. */
#ifndef CONFIG_LOCALTIME_R
#ifndef _POSIX_THREAD_SAFE_FUNCTIONS
#undef gmtime_r
struct tm *gmtime_r(const time_t *timep, struct tm *result);
#undef localtime_r
struct tm *localtime_r(const time_t *timep, struct tm *result);
#endif /* CONFIG_LOCALTIME_R */
#endif /* _POSIX_THREAD_SAFE_FUNCTIONS */
static inline void os_setup_signal_handling(void) {}
static inline void os_daemonize(void) {}

View File

@ -426,6 +426,74 @@ if targetos == 'linux' and have_tools and not get_option('mpath').disabled()
endif
endif
iconv = not_found
if not get_option('iconv').disabled()
libiconv = cc.find_library('iconv',
required: false,
static: enable_static)
if libiconv.found()
if cc.links('''
#include <iconv.h>
int main(void) {
iconv_t conv = iconv_open("WCHAR_T", "UCS-2");
return conv != (iconv_t) -1;
}''', dependencies: [libiconv])
iconv = declare_dependency(dependencies: [libiconv])
endif
endif
endif
if get_option('iconv').enabled() and not iconv.found()
error('Cannot detect iconv API')
endif
curses = not_found
if iconv.found() and not get_option('curses').disabled()
curses_libname_list = ['ncursesw', 'ncurses', 'cursesw', 'pdcurses']
curses_test = '''
#include <locale.h>
#include <curses.h>
#include <wchar.h>
int main(void) {
wchar_t wch = L'w';
setlocale(LC_ALL, "");
resize_term(0, 0);
addwstr(L"wide chars\n");
addnwstr(&wch, 1);
add_wch(WACS_DEGREE);
return 0;
}'''
foreach curses_libname : curses_libname_list
libcurses = dependency(curses_libname,
required: false,
method: 'pkg-config',
static: enable_static)
if not libcurses.found()
dirs = ['/usr/include/ncursesw']
if targetos == 'windows'
dirs = []
endif
libcurses = cc.find_library(curses_libname,
required: false,
dirs: dirs,
static: enable_static)
endif
if libcurses.found()
if cc.links(curses_test, dependencies: [libcurses])
curses = declare_dependency(compile_args: '-DNCURSES_WIDECHAR', dependencies: [libcurses])
break
endif
endif
endforeach
endif
if get_option('curses').enabled() and not curses.found()
if not iconv.found()
error('Cannot detect iconv API')
else
error('Cannot detect curses API')
endif
endif
brlapi = not_found
if 'CONFIG_BRLAPI' in config_host
brlapi = declare_dependency(link_args: config_host['BRLAPI_LIBS'].split())
@ -504,16 +572,6 @@ if 'CONFIG_X11' in config_host
x11 = declare_dependency(compile_args: config_host['X11_CFLAGS'].split(),
link_args: config_host['X11_LIBS'].split())
endif
curses = not_found
if 'CONFIG_CURSES' in config_host
curses = declare_dependency(compile_args: config_host['CURSES_CFLAGS'].split(),
link_args: config_host['CURSES_LIBS'].split())
endif
iconv = not_found
if 'CONFIG_ICONV' in config_host
iconv = declare_dependency(compile_args: config_host['ICONV_CFLAGS'].split(),
link_args: config_host['ICONV_LIBS'].split())
endif
vnc = not_found
png = not_found
jpeg = not_found
@ -622,6 +680,7 @@ config_host_data.set('CONFIG_COCOA', cocoa.found())
config_host_data.set('CONFIG_LIBUDEV', libudev.found())
config_host_data.set('CONFIG_MPATH', mpathpersist.found())
config_host_data.set('CONFIG_MPATH_NEW_API', mpathpersist_new_api)
config_host_data.set('CONFIG_CURSES', curses.found())
config_host_data.set('CONFIG_SDL', sdl.found())
config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
config_host_data.set('CONFIG_VNC', vnc.found())
@ -1905,8 +1964,8 @@ if config_host.has_key('CONFIG_NETTLE')
endif
summary_info += {'libtasn1': config_host.has_key('CONFIG_TASN1')}
summary_info += {'PAM': config_host.has_key('CONFIG_AUTH_PAM')}
summary_info += {'iconv support': config_host.has_key('CONFIG_ICONV')}
summary_info += {'curses support': config_host.has_key('CONFIG_CURSES')}
summary_info += {'iconv support': iconv.found()}
summary_info += {'curses support': curses.found()}
# TODO: add back version
summary_info += {'virgl support': config_host.has_key('CONFIG_VIRGL')}
summary_info += {'curl support': config_host.has_key('CONFIG_CURL')}

View File

@ -32,6 +32,10 @@ option('cocoa', type : 'feature', value : 'auto',
description: 'Cocoa user interface (macOS only)')
option('mpath', type : 'feature', value : 'auto',
description: 'Multipath persistent reservation passthrough')
option('iconv', type : 'feature', value : 'auto',
description: 'Font glyph conversion support')
option('curses', type : 'feature', value : 'auto',
description: 'curses UI')
option('sdl', type : 'feature', value : 'auto',
description: 'SDL user interface')
option('sdl_image', type : 'feature', value : 'auto',

View File

@ -9,7 +9,7 @@
#include "qemu/cutils.h"
#include "hw/display/edid.h"
static qemu_edid_info info = (qemu_edid_info) {
static qemu_edid_info info = {
.prefx = 1024,
.prefy = 768,
};

View File

@ -1310,6 +1310,7 @@ static QemuConsole *new_console(DisplayState *ds, console_type_t console_type,
}
s->ds = ds;
s->console_type = console_type;
s->window_id = -1;
if (QTAILQ_EMPTY(&consoles)) {
s->index = 0;

View File

@ -30,7 +30,6 @@
#endif
#include <locale.h>
#include <wchar.h>
#include <langinfo.h>
#include <iconv.h>
#include "qapi/error.h"
@ -263,7 +262,7 @@ static int curses2foo(const int _curses2foo[], const int _curseskey2foo[],
static void curses_refresh(DisplayChangeListener *dcl)
{
int chr, keysym, keycode, keycode_alt;
enum maybe_keycode maybe_keycode;
enum maybe_keycode maybe_keycode = CURSES_KEYCODE;
curses_winch_check();
@ -300,7 +299,7 @@ static void curses_refresh(DisplayChangeListener *dcl)
/* alt or esc key */
if (keycode == 1) {
enum maybe_keycode next_maybe_keycode;
enum maybe_keycode next_maybe_keycode = CURSES_KEYCODE;
int nextchr = console_getch(&next_maybe_keycode);
if (nextchr != -1) {
@ -526,6 +525,7 @@ static void font_setup(void)
iconv_t nativecharset_to_ucs2;
iconv_t font_conv;
int i;
g_autofree gchar *local_codeset = g_get_codeset();
/*
* Control characters are normally non-printable, but VGA does have
@ -566,14 +566,14 @@ static void font_setup(void)
0x25bc
};
ucs2_to_nativecharset = iconv_open(nl_langinfo(CODESET), "UCS-2");
ucs2_to_nativecharset = iconv_open(local_codeset, "UCS-2");
if (ucs2_to_nativecharset == (iconv_t) -1) {
fprintf(stderr, "Could not convert font glyphs from UCS-2: '%s'\n",
strerror(errno));
exit(1);
}
nativecharset_to_ucs2 = iconv_open("UCS-2", nl_langinfo(CODESET));
nativecharset_to_ucs2 = iconv_open("UCS-2", local_codeset);
if (nativecharset_to_ucs2 == (iconv_t) -1) {
iconv_close(ucs2_to_nativecharset);
fprintf(stderr, "Could not convert font glyphs to UCS-2: '%s'\n",
@ -581,7 +581,7 @@ static void font_setup(void)
exit(1);
}
font_conv = iconv_open(nl_langinfo(CODESET), font_charset);
font_conv = iconv_open(local_codeset, font_charset);
if (font_conv == (iconv_t) -1) {
iconv_close(ucs2_to_nativecharset);
iconv_close(nativecharset_to_ucs2);
@ -602,7 +602,7 @@ static void font_setup(void)
/* DEL */
convert_ucs(0x7F, 0x2302, ucs2_to_nativecharset);
if (strcmp(nl_langinfo(CODESET), "UTF-8")) {
if (strcmp(local_codeset, "UTF-8")) {
/* Non-Unicode capable, use termcap equivalents for those available */
for (i = 0; i <= 0xFF; i++) {
wchar_t wch[CCHARW_MAX];

View File

@ -418,6 +418,7 @@ static void input_linux_instance_finalize(Object *obj)
if (il->initialized) {
QTAILQ_REMOVE(&inputs, il, next);
qemu_set_fd_handler(il->fd, NULL, NULL, NULL);
close(il->fd);
}
g_free(il->evdev);

View File

@ -39,7 +39,7 @@ specific_ss.add(when: ['CONFIG_SOFTMMU'], if_true: opengl)
ui_modules = {}
if config_host.has_key('CONFIG_CURSES')
if curses.found()
curses_ss = ss.source_set()
curses_ss.add(when: [curses, iconv], if_true: [files('curses.c'), pixman])
ui_modules += {'curses' : curses_ss}

View File

@ -84,6 +84,11 @@ void sdl2_window_create(struct sdl2_console *scon)
if (scon->hidden) {
flags |= SDL_WINDOW_HIDDEN;
}
#ifdef CONFIG_OPENGL
if (scon->opengl) {
flags |= SDL_WINDOW_OPENGL;
}
#endif
scon->real_window = SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,

View File

@ -12,6 +12,9 @@ int vnc_display_pw_expire(const char *id, time_t expires)
};
QemuOpts *vnc_parse(const char *str, Error **errp)
{
if (strcmp(str, "none") == 0) {
return NULL;
}
error_setg(errp, "VNC support is disabled");
return NULL;
}

View File

@ -106,7 +106,7 @@ void qemu_anon_ram_free(void *ptr, size_t size)
}
}
#ifndef CONFIG_LOCALTIME_R
#ifndef _POSIX_THREAD_SAFE_FUNCTIONS
/* FIXME: add proper locking */
struct tm *gmtime_r(const time_t *timep, struct tm *result)
{
@ -130,7 +130,7 @@ struct tm *localtime_r(const time_t *timep, struct tm *result)
}
return p;
}
#endif /* CONFIG_LOCALTIME_R */
#endif /* _POSIX_THREAD_SAFE_FUNCTIONS */
static int socket_error(void)
{