From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54791) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrPwy-0000cn-5h for qemu-devel@nongnu.org; Mon, 02 Jun 2014 06:58:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WrPwt-0006ZK-39 for qemu-devel@nongnu.org; Mon, 02 Jun 2014 06:58:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:7444) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WrPws-0006Z6-Qe for qemu-devel@nongnu.org; Mon, 02 Jun 2014 06:58:39 -0400 From: Gerd Hoffmann Date: Mon, 2 Jun 2014 12:58:33 +0200 Message-Id: <1401706713-24909-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH] gtk: cleanup backend dependencies List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , Anthony Liguori , Richard Henderson Make configure detect gtk x11 and win32 backends. Make gtk backend specific code properly #ifdefed on the new CONFIG_GTK_{X11,WIN32} config options. Our gtk ui code should build fine on any platform now. This also fixes the linker failute due to the new XkbGetKeyboard call added by commit 3158a3482b0093e41f2b2596fba50774ea31ae08. Cc: Richard Henderson Signed-off-by: Gerd Hoffmann --- configure | 15 +++++++++++++++ ui/gtk.c | 8 +++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 0e516f9..b02f822 100755 --- a/configure +++ b/configure @@ -1986,6 +1986,8 @@ fi if test "$gtk" != "no"; then gtkpackage="gtk+-$gtkabi" + gtkx11package="gtk+-x11-$gtkabi" + gtkwin32package="gtk+-win32-$gtkabi" if test "$gtkabi" = "3.0" ; then gtkversion="3.0.0" else @@ -1996,6 +1998,13 @@ if test "$gtk" != "no"; then gtk_libs=`$pkg_config --libs $gtkpackage` libs_softmmu="$gtk_libs $libs_softmmu" gtk="yes" + if $pkg_config --exists "$gtkx11package >= $gtkversion"; then + gtkx11="yes" + gtk_libs="$gtk_libs -lX11" + fi + if $pkg_config --exists "$gtkwin32package >= $gtkversion"; then + gtkwin32="yes" + fi elif test "$gtk" = "yes"; then feature_not_found "gtk" "Install gtk2 or gtk3 devel" else @@ -4459,6 +4468,12 @@ if test "$gtk" = "yes" ; then echo "CONFIG_GTKABI=$gtkabi" >> $config_host_mak echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak fi +if test "$gtkx11" = "yes" ; then + echo "CONFIG_GTK_X11=y" >> $config_host_mak +fi +if test "$gtkwin32" = "yes" ; then + echo "CONFIG_GTK_WIN32=y" >> $config_host_mak +fi if test "$vte" = "yes" ; then echo "CONFIG_VTE=y" >> $config_host_mak echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak diff --git a/ui/gtk.c b/ui/gtk.c index 9d06df3..773a987 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -68,7 +68,7 @@ #include "keymaps.h" #include "sysemu/char.h" #include "qom/object.h" -#ifndef _WIN32 +#ifdef CONFIG_GTK_X11 #include #include #endif @@ -925,7 +925,7 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque) int gdk_keycode = key->hardware_keycode; int i; -#ifdef _WIN32 +#ifdef CONFIG_GTK_WIN32 UINT qemu_keycode = MapVirtualKey(gdk_keycode, MAPVK_VK_TO_VSC); switch (qemu_keycode) { case 103: /* alt gr */ @@ -939,12 +939,14 @@ static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque) qemu_keycode = 0; } else if (gdk_keycode < 97) { qemu_keycode = gdk_keycode - 8; +#ifdef CONFIG_GTK_X11 } else if (gdk_keycode < 158) { if (s->has_evdev) { qemu_keycode = translate_evdev_keycode(gdk_keycode - 97); } else { qemu_keycode = translate_xfree86_keycode(gdk_keycode - 97); } +#endif } else if (gdk_keycode == 208) { /* Hiragana_Katakana */ qemu_keycode = 0x70; } else if (gdk_keycode == 211) { /* backslash */ @@ -1822,7 +1824,7 @@ static void gd_create_menus(GtkDisplayState *s) static void gd_set_keycode_type(GtkDisplayState *s) { -#ifndef _WIN32 +#ifdef CONFIG_GTK_X11 char *keycodes = NULL; GdkDisplay *display = gtk_widget_get_display(s->window); Display *x11_display = gdk_x11_display_get_xdisplay(display); -- 1.8.3.1