build-scripts/androidbuildlibs.sh
author Ryan C. Gordon
Mon, 21 Aug 2017 00:42:06 -0400
changeset 11334 749cb40916f2
parent 11262 8e5441ab6c63
child 11836 a42b155124a3
permissions -rw-r--r--
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/sh
     2 #
     3 # Build the Android libraries without needing a project
     4 # (AndroidManifest.xml, jni/{Application,Android}.mk, etc.)
     5 #
     6 # Usage: androidbuildlibs.sh [arg for ndk-build ...]"
     7 #
     8 # Useful NDK arguments:
     9 #
    10 #  NDK_DEBUG=1          - build debug version
    11 #  NDK_LIBS_OUT=<dest>  - specify alternate destination for installable
    12 #                         modules.
    13 #
    14 # Note that SDLmain is not an installable module (.so) so libSDLmain.a
    15 # can be found in $obj/local/<abi> along with the unstripped libSDL.so.
    16 #
    17 
    18 
    19 # Android.mk is in srcdir
    20 srcdir=`dirname $0`/..
    21 srcdir=`cd $srcdir && pwd`
    22 cd $srcdir
    23 
    24 
    25 #
    26 # Create the build directories
    27 #
    28 
    29 build=build
    30 buildandroid=$build/android
    31 obj=
    32 lib=
    33 ndk_args=
    34 
    35 # Allow an external caller to specify locations.
    36 for arg in $*
    37 do
    38   if [ "${arg:0:8}" == "NDK_OUT=" ]; then
    39 	obj=${arg#NDK_OUT=}
    40   elif [ "${arg:0:13}" == "NDK_LIBS_OUT=" ]; then
    41 	lib=${arg#NDK_LIBS_OUT=}
    42   else
    43     ndk_args="$ndk_args $arg"
    44   fi
    45 done
    46 
    47 if [ -z $obj ]; then
    48   obj=$buildandroid/obj
    49 fi
    50 if [ -z $lib ]; then
    51   lib=$buildandroid/lib
    52 fi
    53 
    54 for dir in $build $buildandroid $obj $lib; do
    55     if test -d $dir; then
    56         :
    57     else
    58         mkdir $dir || exit 1
    59     fi
    60 done
    61 
    62 
    63 # APP_* variables set in the environment here will not be seen by the
    64 # ndk-build makefile segments that use them, e.g., default-application.mk.
    65 # For consistency, pass all values on the command line.
    66 ndk-build \
    67   NDK_PROJECT_PATH=null \
    68   NDK_OUT=$obj \
    69   NDK_LIBS_OUT=$lib \
    70   APP_BUILD_SCRIPT=Android.mk \
    71   APP_ABI="all" \
    72   APP_PLATFORM=android-12 \
    73   APP_MODULES="SDL2 SDL2_main" \
    74   $ndk_args