Commit f58946e3 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winewayland.drv: Basic handling of Wayland keyboard events.

Handle Wayland keyboard events and translate them to Windows events, currently using a hardcoded US key mapping.
parent 677868a0
......@@ -702,6 +702,8 @@ INOTIFY_LIBS
INOTIFY_CFLAGS
PCSCLITE_LIBS
PCAP_LIBS
XKBCOMMON_LIBS
XKBCOMMON_CFLAGS
WAYLAND_SCANNER
WAYLAND_CLIENT_LIBS
WAYLAND_CLIENT_CFLAGS
......@@ -1793,6 +1795,8 @@ XMKMF
CPP
WAYLAND_CLIENT_CFLAGS
WAYLAND_CLIENT_LIBS
XKBCOMMON_CFLAGS
XKBCOMMON_LIBS
INOTIFY_CFLAGS
INOTIFY_LIBS
DBUS_CFLAGS
......@@ -2612,6 +2616,10 @@ Some influential environment variables:
C compiler flags for wayland-client, overriding pkg-config
WAYLAND_CLIENT_LIBS
Linker flags for wayland-client, overriding pkg-config
XKBCOMMON_CFLAGS
C compiler flags for xkbcommon, overriding pkg-config
XKBCOMMON_LIBS
Linker flags for xkbcommon, overriding pkg-config
INOTIFY_CFLAGS
C compiler flags for libinotify, overriding pkg-config
INOTIFY_LIBS
......@@ -11078,6 +11086,7 @@ CFLAGS="$CFLAGS -nostdlib -nodefaultlibs -Wmicrosoft-enum-forward-reference"
ac_exeext=".exe"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
void *__os_arm64x_dispatch_ret = 0;
int __cdecl mainCRTStartup(void) { return 0; }
_ACEOF
if ac_fn_c_try_link "$LINENO"
......@@ -15825,8 +15834,86 @@ fi
CPPFLAGS=$ac_save_CPPFLAGS
rm -f conftest.err
if ${XKBCOMMON_CFLAGS:+false} :
then :
if test ${PKG_CONFIG+y}
then :
XKBCOMMON_CFLAGS=`$PKG_CONFIG --cflags xkbcommon 2>conftest.err`
fi
fi
if ${XKBCOMMON_LIBS:+false} :
then :
if test ${PKG_CONFIG+y}
then :
XKBCOMMON_LIBS=`$PKG_CONFIG --libs xkbcommon 2>/dev/null`
fi
fi
printf "%s\n" "$as_me:${as_lineno-$LINENO}: xkbcommon cflags: $XKBCOMMON_CFLAGS" >&5
printf "%s\n" "$as_me:${as_lineno-$LINENO}: xkbcommon libs: $XKBCOMMON_LIBS" >&5
if test -s conftest.err; then
printf %s "$as_me:${as_lineno-$LINENO}: xkbcommon errors: " >&5
cat conftest.err >&5
fi
rm -f conftest.err
ac_save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS $XKBCOMMON_CFLAGS"
ac_fn_c_check_header_compile "$LINENO" "xkbcommon/xkbcommon.h" "ac_cv_header_xkbcommon_xkbcommon_h" "$ac_includes_default"
if test "x$ac_cv_header_xkbcommon_xkbcommon_h" = xyes
then :
printf "%s\n" "#define HAVE_XKBCOMMON_XKBCOMMON_H 1" >>confdefs.h
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for xkb_context_new in -lxkbcommon" >&5
printf %s "checking for xkb_context_new in -lxkbcommon... " >&6; }
if test ${ac_cv_lib_xkbcommon_xkb_context_new+y}
then :
printf %s "(cached) " >&6
else $as_nop
ac_check_lib_save_LIBS=$LIBS
LIBS="-lxkbcommon $XKBCOMMON_LIBS $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
char xkb_context_new ();
int
main (void)
{
return xkb_context_new ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
ac_cv_lib_xkbcommon_xkb_context_new=yes
else $as_nop
ac_cv_lib_xkbcommon_xkb_context_new=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_xkbcommon_xkb_context_new" >&5
printf "%s\n" "$ac_cv_lib_xkbcommon_xkb_context_new" >&6; }
if test "x$ac_cv_lib_xkbcommon_xkb_context_new" = xyes
then :
:
else $as_nop
XKBCOMMON_LIBS=""
fi
CPPFLAGS=$ac_save_CPPFLAGS
fi
if test -z "$WAYLAND_CLIENT_LIBS" -o -z "$WAYLAND_SCANNER" -o "$ac_cv_header_linux_input_h" = "no"
if test -z "$WAYLAND_CLIENT_LIBS" -o -z "$WAYLAND_SCANNER" -o -z "$XKBCOMMON_LIBS" -o "$ac_cv_header_linux_input_h" = "no"
then :
case "x$with_wayland" in
x) as_fn_append wine_notices "|Wayland ${notice_platform}development files not found, the Wayland driver won't be supported." ;;
......@@ -23410,6 +23497,8 @@ X_EXTRA_LIBS = $X_EXTRA_LIBS
WAYLAND_CLIENT_CFLAGS = $WAYLAND_CLIENT_CFLAGS
WAYLAND_CLIENT_LIBS = $WAYLAND_CLIENT_LIBS
WAYLAND_SCANNER = $WAYLAND_SCANNER
XKBCOMMON_CFLAGS = $XKBCOMMON_CFLAGS
XKBCOMMON_LIBS = $XKBCOMMON_LIBS
PCAP_LIBS = $PCAP_LIBS
PCSCLITE_LIBS = $PCSCLITE_LIBS
INOTIFY_CFLAGS = $INOTIFY_CFLAGS
......
......@@ -1368,8 +1368,11 @@ then
[AC_PATH_PROG(WAYLAND_SCANNER,wayland-scanner,
[`test -n "$PKG_CONFIG" && $PKG_CONFIG --variable=wayland_scanner wayland-scanner 2>/dev/null`])],
[WAYLAND_CLIENT_LIBS=""],[$WAYLAND_CLIENT_LIBS])])])
WINE_PACKAGE_FLAGS(XKBCOMMON,[xkbcommon],,,,
[AC_CHECK_HEADERS([xkbcommon/xkbcommon.h])
AC_CHECK_LIB(xkbcommon,xkb_context_new,[:],[XKBCOMMON_LIBS=""],[$XKBCOMMON_LIBS])])
fi
WINE_NOTICE_WITH(wayland, [test -z "$WAYLAND_CLIENT_LIBS" -o -z "$WAYLAND_SCANNER" -o "$ac_cv_header_linux_input_h" = "no"],
WINE_NOTICE_WITH(wayland, [test -z "$WAYLAND_CLIENT_LIBS" -o -z "$WAYLAND_SCANNER" -o -z "$XKBCOMMON_LIBS" -o "$ac_cv_header_linux_input_h" = "no"],
[Wayland ${notice_platform}development files not found, the Wayland driver won't be supported.],
[enable_winewayland_drv])
......
MODULE = winewayland.drv
UNIXLIB = winewayland.so
UNIX_CFLAGS = $(WAYLAND_CLIENT_CFLAGS)
UNIX_LIBS = -lwin32u $(WAYLAND_CLIENT_LIBS) $(PTHREAD_LIBS) -lm
UNIX_CFLAGS = $(WAYLAND_CLIENT_CFLAGS) $(XKBCOMMON_CFLAGS)
UNIX_LIBS = -lwin32u $(WAYLAND_CLIENT_LIBS) $(XKBCOMMON_LIBS) $(PTHREAD_LIBS) -lm
SOURCES = \
display.c \
dllmain.c \
version.rc \
wayland.c \
wayland_keyboard.c \
wayland_output.c \
wayland_pointer.c \
wayland_surface.c \
......
......@@ -35,6 +35,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(waylanddrv);
struct wayland process_wayland =
{
.seat.mutex = PTHREAD_MUTEX_INITIALIZER,
.keyboard.mutex = PTHREAD_MUTEX_INITIALIZER,
.pointer.mutex = PTHREAD_MUTEX_INITIALIZER,
.output_list = {&process_wayland.output_list, &process_wayland.output_list},
.output_mutex = PTHREAD_MUTEX_INITIALIZER
......@@ -66,6 +67,11 @@ static void wl_seat_handle_capabilities(void *data, struct wl_seat *seat,
wayland_pointer_init(wl_seat_get_pointer(seat));
else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && process_wayland.pointer.wl_pointer)
wayland_pointer_deinit();
if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !process_wayland.keyboard.wl_keyboard)
wayland_keyboard_init(wl_seat_get_keyboard(seat));
else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && process_wayland.keyboard.wl_keyboard)
wayland_keyboard_deinit();
}
static void wl_seat_handle_name(void *data, struct wl_seat *seat, const char *name)
......
......@@ -181,6 +181,11 @@ void wayland_surface_destroy(struct wayland_surface *surface)
}
pthread_mutex_unlock(&process_wayland.pointer.mutex);
pthread_mutex_lock(&process_wayland.keyboard.mutex);
if (process_wayland.keyboard.focused_hwnd == surface->hwnd)
process_wayland.keyboard.focused_hwnd = NULL;
pthread_mutex_unlock(&process_wayland.keyboard.mutex);
pthread_mutex_lock(&surface->mutex);
if (surface->xdg_toplevel)
......
......@@ -27,6 +27,7 @@
#include <pthread.h>
#include <wayland-client.h>
#include <xkbcommon/xkbcommon.h>
#include "xdg-output-unstable-v1-client-protocol.h"
#include "xdg-shell-client-protocol.h"
......@@ -65,6 +66,14 @@ enum wayland_surface_config_state
WAYLAND_SURFACE_CONFIG_STATE_FULLSCREEN = (1 << 3)
};
struct wayland_keyboard
{
struct wl_keyboard *wl_keyboard;
struct xkb_context *xkb_context;
HWND focused_hwnd;
pthread_mutex_t mutex;
};
struct wayland_cursor
{
struct wayland_shm_buffer *shm_buffer;
......@@ -100,6 +109,7 @@ struct wayland
struct xdg_wm_base *xdg_wm_base;
struct wl_shm *wl_shm;
struct wayland_seat seat;
struct wayland_keyboard keyboard;
struct wayland_pointer pointer;
struct wl_list output_list;
/* Protects the output_list and the wayland_output.current states. */
......@@ -224,6 +234,13 @@ void wayland_window_surface_update_wayland_surface(struct window_surface *surfac
void wayland_window_flush(HWND hwnd) DECLSPEC_HIDDEN;
/**********************************************************************
* Wayland Keyboard
*/
void wayland_keyboard_init(struct wl_keyboard *wl_keyboard) DECLSPEC_HIDDEN;
void wayland_keyboard_deinit(void) DECLSPEC_HIDDEN;
/**********************************************************************
* Wayland pointer
*/
......
......@@ -672,6 +672,9 @@
/* Define to 1 if `callback' is a member of `XICCallback'. */
#undef HAVE_XICCALLBACK_CALLBACK
/* Define to 1 if you have the <xkbcommon/xkbcommon.h> header file. */
#undef HAVE_XKBCOMMON_XKBCOMMON_H
/* Define if Xrender has the XRenderCreateLinearGradient function */
#undef HAVE_XRENDERCREATELINEARGRADIENT
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment