Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
dcommander committed Nov 7, 2024
2 parents 03701d2 + 2132a83 commit 10bd9b8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ automatic WebSocket detection code if an ill-behaved client sent 3 or fewer
bytes of data immediately after connecting. Certain versions of Apache
Guacamole were known to trigger this issue sporadically.

8. The TurboVNC Viewer now works around an issue that prevented keyboard
grabbing from working when running the viewer in a GNOME/Wayland session.


3.1.2
=====
Expand Down
2 changes: 1 addition & 1 deletion unix/Xvnc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ boolean_number(TVNC_DRI3 PARENT_SCOPE)
report_option(TVNC_DRI3 "DRI3 extension")

set(OpenGL_GL_PREFERENCE LEGACY)
include(FindOpenGL)
find_package(OpenGL REQUIRED)

add_subdirectory(lib)
add_subdirectory(programs/Xserver)
26 changes: 25 additions & 1 deletion unix/vncviewer/turbovnchelper.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* Copyright (C) 2015-2019, 2021-2022 D. R. Commander. All Rights Reserved.
/* Copyright (C) 2015-2019, 2021-2022, 2024 D. R. Commander.
* All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -227,6 +228,28 @@ JNIEXPORT void JNICALL Java_com_turbovnc_vncviewer_Viewport_x11FullScreen
}


/*
* Allow/disallow keyboard grabbing when using GNOME/Wayland.
*/

static void xwayland_grab_keyboard(Display *dpy, Window win, int on)
{
XEvent e;
Atom _XWAYLAND_MAY_GRAB_KEYBOARD =
XInternAtom(dpy, "_XWAYLAND_MAY_GRAB_KEYBOARD", False);

memset(&e, 0, sizeof(e));
e.xclient.type = ClientMessage;
e.xclient.message_type = _XWAYLAND_MAY_GRAB_KEYBOARD;
e.xclient.display = dpy;
e.xclient.window = win;
e.xclient.format = 32;
e.xclient.data.l[0] = on;

XSendEvent(dpy, DefaultRootWindow(dpy), False, SubstructureRedirectMask, &e);
}


JNIEXPORT void JNICALL Java_com_turbovnc_vncviewer_Viewport_grabKeyboard
(JNIEnv *env, jobject obj, jboolean on, jboolean pointer)
{
Expand Down Expand Up @@ -261,6 +284,7 @@ JNIEXPORT void JNICALL Java_com_turbovnc_vncviewer_Viewport_grabKeyboard
THROW("Could not get X11 drawing surface info");

XSync(x11dsi->display, False);
xwayland_grab_keyboard(x11dsi->display, x11dsi->drawable, on);
if (on) {
int count = 5;

Expand Down

0 comments on commit 10bd9b8

Please sign in to comment.