build-scripts/emscripten-buildbot.sh
author Ryan C. Gordon
Mon, 21 Aug 2017 00:42:06 -0400
changeset 11334 749cb40916f2
parent 10958 92d837180433
child 13814 dc7142e7b47e
permissions -rwxr-xr-x
x11: specify event mask for buttons when grabbing pointer (thanks, Stas!).

This fixes a strange corner case (notes appended below), and should be
safe to do anyhow.

Fixes Bugzilla #3674.

"I did more tests.
It appears the bug only happens if there is
another window on the screen that has "always
on top" property. For me it is xawtv - it is
always opened in a screen corner. Closing
xawtv or removing "always on top" property
from it makes the problem to go away.
Plus, it doesn't appear like the buttons are
not delivered at all. It appears that instead
the button presses are delivered on some mouse
positions, but not delivered when you move the
mouse to other part of the window... So this is
really weird and is likely somewhere deep in the
Xorg.
Maybe somehow it happens that the cursor is
actually above the xawtv window, but, because
my app uses grab, it is not visible there, and
in that case the events are not delivered to
my app?
But with my patch the button events are
always delivered flawlessly, it seems.

Hmm, and that indeed seems to explain my problem:
if the mask is set properly and my app uses
grab, then, even if the mouse is above some
other window, the events would still be delivered
to the grabbing app, which is what actually wanted
because my app uses relative mouse mode, so it
doesn't know the pointer can cross some other window
(my app draws the pointer itself).
So my current theory is that my patch only enforces
the mouse grab, which otherwise can be tricked by
some other window preventing the button events
delivery (but motion events are still delivered
via xinput2, which makes it all look very obscure)."
     1 #!/bin/bash
     2 
     3 if [ -z "$SDKDIR" ]; then
     4     SDKDIR="/emsdk_portable"
     5 fi
     6 
     7 ENVSCRIPT="$SDKDIR/emsdk_env.sh"
     8 if [ ! -f "$ENVSCRIPT" ]; then
     9    echo "ERROR: This script expects the Emscripten SDK to be in '$SDKDIR'." 1>&2
    10    echo "ERROR: Set the \$SDKDIR environment variable to override this." 1>&2
    11    exit 1
    12 fi
    13 
    14 TARBALL="$1"
    15 if [ -z $1 ]; then
    16     TARBALL=sdl-emscripten.tar.xz
    17 fi
    18 
    19 cd `dirname "$0"`
    20 cd ..
    21 SDLBASE=`pwd`
    22 
    23 if [ -z "$MAKE" ]; then
    24     OSTYPE=`uname -s`
    25     if [ "$OSTYPE" == "Linux" ]; then
    26         NCPU=`cat /proc/cpuinfo |grep vendor_id |wc -l`
    27         let NCPU=$NCPU+1
    28     elif [ "$OSTYPE" = "Darwin" ]; then
    29         NCPU=`sysctl -n hw.ncpu`
    30     elif [ "$OSTYPE" = "SunOS" ]; then
    31         NCPU=`/usr/sbin/psrinfo |wc -l |sed -e 's/^ *//g;s/ *$//g'`
    32     else
    33         NCPU=1
    34     fi
    35 
    36     if [ -z "$NCPU" ]; then
    37         NCPU=1
    38     elif [ "$NCPU" = "0" ]; then
    39         NCPU=1
    40     fi
    41 
    42     MAKE="make -j$NCPU"
    43 fi
    44 
    45 echo "\$MAKE is '$MAKE'"
    46 
    47 echo "Setting up Emscripten SDK environment..."
    48 source "$ENVSCRIPT"
    49 
    50 echo "Setting up..."
    51 set -x
    52 cd "$SDLBASE"
    53 rm -rf buildbot
    54 mkdir buildbot
    55 pushd buildbot
    56 
    57 echo "Configuring..."
    58 emconfigure ../configure --host=asmjs-unknown-emscripten --disable-assembly --disable-threads --disable-cpuinfo CFLAGS="-O2 -Wno-warn-absolute-paths -Wdeclaration-after-statement -Werror=declaration-after-statement" --prefix="$PWD/emscripten-sdl2-installed" || exit $?
    59 
    60 echo "Building..."
    61 emmake $MAKE || exit $?
    62 
    63 echo "Moving things around..."
    64 emmake $MAKE install || exit $?
    65 
    66 # Fix up a few things to a real install path
    67 perl -w -pi -e "s#$PWD/emscripten-sdl2-installed#/usr/local#g;" ./emscripten-sdl2-installed/lib/libSDL2.la ./emscripten-sdl2-installed/lib/pkgconfig/sdl2.pc ./emscripten-sdl2-installed/bin/sdl2-config
    68 mkdir -p ./usr
    69 mv ./emscripten-sdl2-installed ./usr/local
    70 popd
    71 tar -cJvvf $TARBALL -C buildbot usr
    72 rm -rf buildbot
    73 
    74 exit 0
    75 
    76 # end of emscripten-buildbot.sh ...
    77