From 9e2c567908b1be08fc8930ba0ae7d02301773cdd Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Tue, 13 Feb 2018 16:56:36 +0100 Subject: [PATCH] xwayland and xvfb-run fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit xwayland: avoid race condition on new keymap xwayland: Keep separate variables for pointer and tablet foci xvfb-run: Add support for “ --auto-display” command line option --- ...parate-variables-for-pointer-and-tab.patch | 135 ++++++++++++++++++ ...d-avoid-race-condition-on-new-keymap.patch | 41 ++++++ xorg-x11-server.spec | 11 +- xvfb-run.sh | 31 ++-- 4 files changed, 209 insertions(+), 9 deletions(-) create mode 100644 0001-xwayland-Keep-separate-variables-for-pointer-and-tab.patch create mode 100644 0001-xwayland-avoid-race-condition-on-new-keymap.patch diff --git a/0001-xwayland-Keep-separate-variables-for-pointer-and-tab.patch b/0001-xwayland-Keep-separate-variables-for-pointer-and-tab.patch new file mode 100644 index 0000000..571fc93 --- /dev/null +++ b/0001-xwayland-Keep-separate-variables-for-pointer-and-tab.patch @@ -0,0 +1,135 @@ +From 60f4646ae10f0b57790fce46682baa531512b53e Mon Sep 17 00:00:00 2001 +From: Carlos Garnacho +Date: Mon, 4 Dec 2017 16:55:13 +0100 +Subject: [PATCH xserver] xwayland: Keep separate variables for pointer and + tablet foci + +The tablet/stylus interfaces reused xwl_seat->focus_window, which +would leave a somewhat inconsistent state of that variable for +wl_pointer purposes (basically, everything) if the pointer happened +to lay on the same surface than the stylus while proximity_out +happens. + +We just want the stylus xwl_window to correctly determine we have +stylus focus, and to correctly translate surface-local coordinates +to root coordinates, this can be done using a different variable. + +Signed-off-by: Carlos Garnacho +Acked-by: Jason Gerecke +Tested-by: Olivier Fourdan +--- + hw/xwayland/xwayland-input.c | 20 ++++++++++---------- + hw/xwayland/xwayland.c | 2 ++ + hw/xwayland/xwayland.h | 1 + + 3 files changed, 13 insertions(+), 10 deletions(-) + +diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c +index 68e365051..439903032 100644 +--- a/hw/xwayland/xwayland-input.c ++++ b/hw/xwayland/xwayland-input.c +@@ -1514,7 +1514,7 @@ tablet_tool_proximity_in(void *data, struct zwp_tablet_tool_v2 *tool, + return; + + xwl_tablet_tool->proximity_in_serial = serial; +- xwl_seat->focus_window = wl_surface_get_user_data(wl_surface); ++ xwl_seat->tablet_focus_window = wl_surface_get_user_data(wl_surface); + + xwl_tablet_tool_set_cursor(xwl_tablet_tool); + } +@@ -1526,7 +1526,7 @@ tablet_tool_proximity_out(void *data, struct zwp_tablet_tool_v2 *tool) + struct xwl_seat *xwl_seat = xwl_tablet_tool->seat; + + xwl_tablet_tool->proximity_in_serial = 0; +- xwl_seat->focus_window = NULL; ++ xwl_seat->tablet_focus_window = NULL; + + xwl_tablet_tool->pressure = 0; + xwl_tablet_tool->tilt_x = 0; +@@ -1568,11 +1568,11 @@ tablet_tool_motion(void *data, struct zwp_tablet_tool_v2 *tool, + int sx = wl_fixed_to_int(x); + int sy = wl_fixed_to_int(y); + +- if (!xwl_seat->focus_window) ++ if (!xwl_seat->tablet_focus_window) + return; + +- dx = xwl_seat->focus_window->window->drawable.x; +- dy = xwl_seat->focus_window->window->drawable.y; ++ dx = xwl_seat->tablet_focus_window->window->drawable.x; ++ dy = xwl_seat->tablet_focus_window->window->drawable.y; + + xwl_tablet_tool->x = dx + sx; + xwl_tablet_tool->y = dy + sy; +@@ -1585,7 +1585,7 @@ tablet_tool_pressure(void *data, struct zwp_tablet_tool_v2 *tool, + struct xwl_tablet_tool *xwl_tablet_tool = data; + struct xwl_seat *xwl_seat = xwl_tablet_tool->seat; + +- if (!xwl_seat->focus_window) ++ if (!xwl_seat->tablet_focus_window) + return; + + /* normalized to 65535 already */ +@@ -1605,7 +1605,7 @@ tablet_tool_tilt(void *data, struct zwp_tablet_tool_v2 *tool, + struct xwl_tablet_tool *xwl_tablet_tool = data; + struct xwl_seat *xwl_seat = xwl_tablet_tool->seat; + +- if (!xwl_seat->focus_window) ++ if (!xwl_seat->tablet_focus_window) + return; + + xwl_tablet_tool->tilt_x = wl_fixed_to_double(tilt_x); +@@ -1620,7 +1620,7 @@ tablet_tool_rotation(void *data, struct zwp_tablet_tool_v2 *tool, + struct xwl_seat *xwl_seat = xwl_tablet_tool->seat; + double rotation = wl_fixed_to_double(angle); + +- if (!xwl_seat->focus_window) ++ if (!xwl_seat->tablet_focus_window) + return; + + /* change origin (buttons facing right [libinput +90 degrees]) and +@@ -1639,7 +1639,7 @@ tablet_tool_slider(void *data, struct zwp_tablet_tool_v2 *tool, + struct xwl_seat *xwl_seat = xwl_tablet_tool->seat; + float position = position_raw / 65535.0; + +- if (!xwl_seat->focus_window) ++ if (!xwl_seat->tablet_focus_window) + return; + + xwl_tablet_tool->slider = (position * 1799.0f) - 900.0f; +@@ -1652,7 +1652,7 @@ tablet_tool_wheel(void *data, struct zwp_tablet_tool_v2 *tool, + struct xwl_tablet_tool *xwl_tablet_tool = data; + struct xwl_seat *xwl_seat = xwl_tablet_tool->seat; + +- if (!xwl_seat->focus_window) ++ if (!xwl_seat->tablet_focus_window) + return; + + xwl_tablet_tool->wheel_clicks = clicks; +diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c +index 79deead8d..638022180 100644 +--- a/hw/xwayland/xwayland.c ++++ b/hw/xwayland/xwayland.c +@@ -545,6 +545,8 @@ xwl_unrealize_window(WindowPtr window) + xorg_list_for_each_entry(xwl_seat, &xwl_screen->seat_list, link) { + if (xwl_seat->focus_window && xwl_seat->focus_window->window == window) + xwl_seat->focus_window = NULL; ++ if (xwl_seat->tablet_focus_window && xwl_seat->tablet_focus_window->window == window) ++ xwl_seat->tablet_focus_window = NULL; + if (xwl_seat->last_xwindow == window) + xwl_seat->last_xwindow = NullWindow; + if (xwl_seat->cursor_confinement_window && +diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h +index 3adee82fa..e6eb37bec 100644 +--- a/hw/xwayland/xwayland.h ++++ b/hw/xwayland/xwayland.h +@@ -154,6 +154,7 @@ struct xwl_seat { + struct zwp_tablet_seat_v2 *tablet_seat; + struct wl_array keys; + struct xwl_window *focus_window; ++ struct xwl_window *tablet_focus_window; + uint32_t id; + uint32_t pointer_enter_serial; + struct xorg_list link; +-- +2.14.3 + diff --git a/0001-xwayland-avoid-race-condition-on-new-keymap.patch b/0001-xwayland-avoid-race-condition-on-new-keymap.patch new file mode 100644 index 0000000..3acf65c --- /dev/null +++ b/0001-xwayland-avoid-race-condition-on-new-keymap.patch @@ -0,0 +1,41 @@ +From 170c95978530f6373bdf4488116902b273f3abf4 Mon Sep 17 00:00:00 2001 +From: Olivier Fourdan +Date: Fri, 15 Dec 2017 16:43:47 +0100 +Subject: [PATCH xserver] xwayland: avoid race condition on new keymap +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When the Wayland compositor notifies of a new keymap, for the first X11 +client using the keyboard, the last slave keyboard used might still not +be set (i.e. “lastSlave” is still NULL). + +As a result, the new keymap is not applied, and the first X11 window +will have the wrong keymap set initially. + +Apply the new keymap to the master keyboard as long as there's one. + +Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=791383 +Signed-off-by: Olivier Fourdan +Reviewed-by: Peter Hutterer +Signed-off-by: Peter Hutterer +--- + hw/xwayland/xwayland-input.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c +index 439903032..c613690cd 100644 +--- a/hw/xwayland/xwayland-input.c ++++ b/hw/xwayland/xwayland-input.c +@@ -710,7 +710,7 @@ keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, + XkbDeviceApplyKeymap(xwl_seat->keyboard, xkb); + + master = GetMaster(xwl_seat->keyboard, MASTER_KEYBOARD); +- if (master && master->lastSlave == xwl_seat->keyboard) ++ if (master) + XkbDeviceApplyKeymap(master, xkb); + + XkbFreeKeyboard(xkb, XkbAllComponentsMask, TRUE); +-- +2.14.3 + diff --git a/xorg-x11-server.spec b/xorg-x11-server.spec index d642338..2169679 100644 --- a/xorg-x11-server.spec +++ b/xorg-x11-server.spec @@ -46,7 +46,7 @@ Summary: X.Org X11 X server Name: xorg-x11-server Version: 1.19.6 -Release: 4%{?gitdate:.%{gitdate}}%{dist} +Release: 5%{?gitdate:.%{gitdate}}%{dist} URL: http://www.x.org License: MIT Group: User Interface/X @@ -107,6 +107,10 @@ Patch9912: 0012-xwayland-Implement-tablet_tool_wheel-for-scrolling.patch # Upstream commit fe46cbe for Xwayland - Not in server-1.19-branch Patch9950: 0001-xwayland-Give-up-cleanly-on-Wayland-socket-errors.patch +# Upstream commit 60f4646a for Xwayland - Not in xorg-server-1.19.6 +Patch9951: 0001-xwayland-Keep-separate-variables-for-pointer-and-tab.patch +# Upstream commit 16fd1847 for Xwayland - Not in xorg-server-1.19.6 +Patch9952: 0001-xwayland-avoid-race-condition-on-new-keymap.patch # From Debian use intel ddx driver only for gen4 and older chipsets %if 0%{?fedora} > 25 || 0%{?rhel} > 7 @@ -624,6 +628,11 @@ find %{inst_srcdir}/hw/xfree86 -name \*.c -delete %changelog +* Tue Feb 13 2018 Olivier Fourdan 1.19.6-5 +- xwayland: avoid race condition on new keymap +- xwayland: Keep separate variables for pointer and tablet foci (rhbz#1519961) +- xvfb-run now support command line option “--auto-display” + * Fri Feb 09 2018 Fedora Release Engineering - 1.19.6-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild diff --git a/xvfb-run.sh b/xvfb-run.sh index de5fa39..473688c 100644 --- a/xvfb-run.sh +++ b/xvfb-run.sh @@ -64,7 +64,10 @@ Usage: $PROGNAME [OPTION ...] COMMAND Run COMMAND (usually an X client) in a virtual X server environment. Options: -a --auto-servernum try to get a free server number, starting at - --server-num + --server-num (deprecated, use --auto-display + instead) +-d --auto-display use the X server to find a display number + automatically -e FILE --error-file=FILE file used to store xauth errors and Xvfb output (default: $ERRORFILE) -f FILE --auth-file=FILE file used to store auth cookie @@ -97,7 +100,7 @@ find_free_servernum() { } # Parse the command line. -ARGS=$(getopt --options +ae:f:hn:lp:s:w: \ +ARGS=$(getopt --options +ade:f:hn:lp:s:w: \ --long auto-servernum,error-file:auth-file:,help,server-num:,listen-tcp,xauth-protocol:,server-args:,wait: \ --name "$PROGNAME" -- "$@") GETOPT_STATUS=$? @@ -112,6 +115,7 @@ eval set -- "$ARGS" while :; do case "$1" in -a|--auto-servernum) SERVERNUM=$(find_free_servernum) ;; + -d|--auto-display) AUTO_DISPLAY=1 ;; -e|--error-file) ERRORFILE="$2"; shift ;; -f|--auth-file) AUTHFILE="$2"; shift ;; -h|--help) SHOWHELP="yes" ;; @@ -138,28 +142,39 @@ if [ -z "$*" ]; then exit 2 fi -if ! type xauth >/dev/null; then +if ! which xauth >/dev/null; then error "xauth command not found" exit 3 fi +# Set up the temp dir for the pid and X authorization file +XVFB_RUN_TMPDIR="$(mktemp --directory --tmpdir $PROGNAME.XXXXXX)" # If the user did not specify an X authorization file to use, set up a temporary # directory to house one. if [ -z "$AUTHFILE" ]; then - XVFB_RUN_TMPDIR="$(mktemp --directory --tmpdir $PROGNAME.XXXXXX)" AUTHFILE=$(mktemp -p "$XVFB_RUN_TMPDIR" Xauthority.XXXXXX) fi # Start Xvfb. MCOOKIE=$(mcookie) +if [ -z "$AUTO_DISPLAY" ]; then + # Old style using a pre-computed SERVERNUM + XAUTHORITY=$AUTHFILE Xvfb ":$SERVERNUM" $XVFBARGS $LISTENTCP >>"$ERRORFILE" \ + 2>&1 & + XVFBPID=$! +else + # New style using Xvfb to provide a free display + PIDFILE=$(mktemp -p "$XVFB_RUN_TMPDIR" pid.XXXXXX) + SERVERNUM=$(XAUTHORITY=$AUTHFILE Xvfb -displayfd 1 $XVFBARGS $LISTENTCP \ + 2>"$ERRORFILE" & echo $! > $PIDFILE) + XVFBPID=$(cat $PIDFILE) +fi +sleep "$STARTWAIT" + XAUTHORITY=$AUTHFILE xauth source - << EOF >>"$ERRORFILE" 2>&1 add :$SERVERNUM $XAUTHPROTO $MCOOKIE EOF -XAUTHORITY=$AUTHFILE Xvfb ":$SERVERNUM" $XVFBARGS $LISTENTCP >>"$ERRORFILE" \ - 2>&1 & -XVFBPID=$! -sleep "$STARTWAIT" # Start the command and save its exit status. set +e