build-scripts/mkinstalldirs
author Ryan C. Gordon
Mon, 21 Aug 2017 00:42:06 -0400
changeset 11334 749cb40916f2
parent 1361 19418e4422cb
child 12335 5e68900d2232
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/sh
     2 # mkinstalldirs --- make directory hierarchy
     3 # Author: Noah Friedman <friedman@prep.ai.mit.edu>
     4 # Created: 1993-05-16
     5 # Public domain
     6 
     7 errstatus=0
     8 dirmode=""
     9 
    10 usage="\
    11 Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..."
    12 
    13 # process command line arguments
    14 while test $# -gt 0 ; do
    15    case "${1}" in
    16      -h | --help | --h* )			# -h for help
    17 	echo "${usage}" 1>&2; exit 0 ;;
    18      -m )					# -m PERM arg
    19 	shift
    20 	test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; }
    21 	dirmode="${1}"
    22 	shift ;;
    23      -- ) shift; break ;;			# stop option processing
    24      -* ) echo "${usage}" 1>&2; exit 1 ;;	# unknown option
    25      * )  break ;;				# first non-opt arg
    26    esac
    27 done
    28 
    29 for file
    30 do
    31   if test -d "$file"; then
    32     shift
    33   else
    34     break
    35   fi
    36 done
    37 
    38 case $# in
    39 0) exit 0 ;;
    40 esac
    41 
    42 case $dirmode in
    43 '')
    44   if mkdir -p -- . 2>/dev/null; then
    45     echo "mkdir -p -- $*"
    46     exec mkdir -p -- "$@"
    47   fi ;;
    48 *)
    49   if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
    50     echo "mkdir -m $dirmode -p -- $*"
    51     exec mkdir -m "$dirmode" -p -- "$@"
    52   fi ;;
    53 esac
    54 
    55 for file
    56 do
    57    set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
    58    shift
    59 
    60    pathcomp=
    61    for d
    62    do
    63      pathcomp="$pathcomp$d"
    64      case "$pathcomp" in
    65        -* ) pathcomp=./$pathcomp ;;
    66      esac
    67 
    68      if test ! -d "$pathcomp"; then
    69 	echo "mkdir $pathcomp"
    70 
    71 	mkdir "$pathcomp" || lasterr=$?
    72 
    73 	if test ! -d "$pathcomp"; then
    74 	  errstatus=$lasterr
    75 	else
    76 	  if test ! -z "$dirmode"; then
    77 	     echo "chmod $dirmode $pathcomp"
    78 
    79 	     lasterr=""
    80 	     chmod "$dirmode" "$pathcomp" || lasterr=$?
    81 
    82 	     if test ! -z "$lasterr"; then
    83 	       errstatus=$lasterr
    84 	     fi
    85 	  fi
    86 	fi
    87      fi
    88 
    89      pathcomp="$pathcomp/"
    90    done
    91 done
    92 
    93 exit $errstatus
    94 
    95 # Local Variables:
    96 # mode: shell-script
    97 # sh-indentation: 3
    98 # End:
    99 # mkinstalldirs ends here