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