diff --git a/gui/drv_glx.c b/gui/drv_glx.c index 1d94c591f..f066aa8f0 100644 --- a/gui/drv_glx.c +++ b/gui/drv_glx.c @@ -672,15 +672,49 @@ GLX_GetNextEvent(void *_Nullable drvCaller, AG_DriverEvent *_Nonnull dev) AG_MutexUnlock(&agDisplayLock); return (0); } + if (XLookupString(&xev.xkey, xkbBuf, sizeof(xkbBuf), NULL, &xkbCompStatus) >= 1) { + ch = (AG_Char)xkbBuf[0]; + } else { + ch = 0; + } + if (!LookupKeyCode(xev.xkey.keycode, &ks)) { + AG_SetError("KeyRelease: Unknown keycode: %d", (int)xev.xkey.keycode); + AG_MutexUnlock(&agDisplayLock); + return (-1); + } AG_MutexUnlock(&agDisplayLock); - /* FALLTHROUGH */ + + if ((win = LookupWindowByID(xev.xkey.window)) == NULL) { + return (-1); + } +#ifdef DEBUG_XEVENTS + Debug(win, "KeyRelease(%u)\n", (Uint)xev.xkey.keycode); +#endif + AG_KeyboardUpdate(WIDGET(win)->drv->kbd, AG_KEY_RELEASED, ks); + + dev->type = AG_DRIVER_KEY_UP; + dev->win = win; + dev->key.ks = ks; + dev->key.ucs = ch; + break; case KeyPress: AG_MutexLock(&agDisplayLock); #ifdef AG_UNICODE if (agXIC) { - XwcLookupString(agXIC, &xev.xkey, - (wchar_t *)&ch, 1, - NULL, NULL); + wchar_t wch; + Status status; + + if (XwcLookupString(agXIC, &xev.xkey, &wch, 1, + NULL, &status) == 0) { + ch = (AG_Char)xkbBuf[0]; + } else { + if (status != XBufferOverflow && + status != XLookupNone) { + ch = (AG_Char)wch; + } else { + ch = (AG_Char)xkbBuf[0]; + } + } } else #endif /* AG_UNICODE */ { @@ -693,8 +727,7 @@ GLX_GetNextEvent(void *_Nullable drvCaller, AG_DriverEvent *_Nonnull dev) } if (!LookupKeyCode(xev.xkey.keycode, &ks)) { - AG_SetError(_("Keyboard event: Unknown keycode: %d"), - (int)xev.xkey.keycode); + AG_SetError("KeyPress: Unknown keycode: %d", (int)xev.xkey.keycode); AG_MutexUnlock(&agDisplayLock); return (-1); } @@ -704,14 +737,11 @@ GLX_GetNextEvent(void *_Nullable drvCaller, AG_DriverEvent *_Nonnull dev) return (-1); } #ifdef DEBUG_XEVENTS - Debug(win, "Key%s(%u)\n", (xev.type == KeyPress) ? "Press" : "Release", (Uint)xev.xkey.keycode); + Debug(win, "KeyPress(%u)\n", (Uint)xev.xkey.keycode); #endif - AG_KeyboardUpdate(WIDGET(win)->drv->kbd, - (xev.type == KeyPress) ? AG_KEY_PRESSED : AG_KEY_RELEASED, - ks); + AG_KeyboardUpdate(WIDGET(win)->drv->kbd, AG_KEY_PRESSED, ks); - dev->type = (xev.type == KeyPress) ? AG_DRIVER_KEY_DOWN : - AG_DRIVER_KEY_UP; + dev->type = AG_DRIVER_KEY_DOWN; dev->win = win; dev->key.ks = ks; dev->key.ucs = ch; diff --git a/mk/build.lib.mk b/mk/build.lib.mk index 0e54eec01..e8ab29f5f 100644 --- a/mk/build.lib.mk +++ b/mk/build.lib.mk @@ -429,14 +429,10 @@ lib${LIB}.so: ${SRCS_GENERATED} _lib_objs ${OBJS} echo "${CXX} -shared -o $$_libout -Wl,-soname,lib${LIB}.so.${LIB_CURRENT} -Wl,-rpath,${LIBDIR} ${LDFLAGS} $$_objs"; \ ${CXX} -shared -o $$_libout -Wl,-soname,lib${LIB}.so.${LIB_CURRENT} -Wl,-rpath ${LIBDIR} ${LDFLAGS} $$_objs; \ ;; \ - *-linux*) \ + *) \ echo "${CXX} -shared -o $$_libout -Wl,-soname,lib${LIB}.so.${LIB_CURRENT} ${LDFLAGS} $$_objs ${LIBS}"; \ ${CXX} -shared -o $$_libout -Wl,-soname,lib${LIB}.so.${LIB_CURRENT} ${LDFLAGS} $$_objs ${LIBS}; \ ;; \ - *) \ - echo "${CXX} -shared -o $$_libout -Wl,-rpath,${LIBDIR} ${LDFLAGS} $$_objs"; \ - ${CXX} -shared -o $$_libout -Wl,-rpath ${LIBDIR} ${LDFLAGS} $$_objs; \ - ;; \ esac; \ else \ case "${HOST}" in \ @@ -452,14 +448,10 @@ lib${LIB}.so: ${SRCS_GENERATED} _lib_objs ${OBJS} echo "${CC} -shared -o $$_libout -Wl,-soname,lib${LIB}.so.${LIB_CURRENT} -Wl,-rpath,${LIBDIR} ${LDFLAGS} $$_objs"; \ ${CC} -shared -o $$_libout -Wl,-soname,lib${LIB}.so.${LIB_CURRENT} -Wl,-rpath ${LIBDIR} ${LDFLAGS} $$_objs; \ ;; \ - *-linux*) \ + *) \ echo "${CC} -shared -o $$_libout -Wl,-soname,lib${LIB}.so.${LIB_CURRENT} ${LDFLAGS} $$_objs ${LIBS}"; \ ${CC} -shared -o $$_libout -Wl,-soname,lib${LIB}.so.${LIB_CURRENT} ${LDFLAGS} $$_objs ${LIBS}; \ ;; \ - *) \ - echo "${CC} -shared -o $$_libout -Wl,-rpath,${LIBDIR} ${LDFLAGS} $$_objs"; \ - ${CC} -shared -o $$_libout -Wl,-rpath ${LIBDIR} ${LDFLAGS} $$_objs; \ - ;; \ esac; \ fi; \ \ @@ -882,7 +874,7 @@ install-lib: check-libtool done; \ fi @case "${HOST}" in \ - *-linux*) \ + *-linux* | *-haiku*) \ if [ "${EUID}" = "0" -o "${USER}" = "root" ]; then \ if [ -x "/sbin/ldconfig" ]; then \ echo "/sbin/ldconfig"; \