build-scripts/g++-fat.sh
author Sam Lantinga <slouken@libsdl.org>
Sun, 17 Aug 2014 14:57:52 -0700
changeset 9086 c5e33f9a0d03
parent 7507 885b4aab4190
child 9221 0702f9d6e2b1
permissions -rwxr-xr-x
Fixed bug 2655 - OSX: Window position and global mouse coord spaces are different

Tim McDaniel

On OSX, with revision 8729, the coordinate space for window position and the coordinate space for global mouse position don't match. For a non-fullscreen window, the window position is global relative to the bottom of the menubar. The global mouse position is relative to the top of the screen. This affects Cocoa_WarpMouse and potentially other things as well. Further, the coordinate system for window position is now affected by what screen it is on. For example, if I have two equal size screens oriented side by side such that the tops of the screens are equal in global space, with the menubar on one screen, and a window straddles the two screens, the window's y position makes no sense. The window's y position depends on what screen "most" of the window is on. So if I move the window horizontally just a bit, the y position of my window is now different by the size of the menubar, even though the window was not moved vertically.

I'd like to reiterate that this was a fairly fundamental change (and a breaking change for us). If SDL OSX is to really support multi-display configurations, this is especially problematic.

If the real concern is preventing windows from going under the menubar, then perhaps a solution involving something like overriding [NSWindow constrainFrameRect] would be less problematic than redefining the global window coord space for the main display.
slouken@7255
     1
#!/bin/sh
slouken@7255
     2
#
slouken@7255
     3
# Build Universal binaries on Mac OS X, thanks Ryan!
slouken@7255
     4
#
slouken@7255
     5
# Usage: ./configure CXX="sh g++-fat.sh" && make && rm -rf x86 x64
slouken@7255
     6
slouken@7255
     7
DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer"
slouken@7255
     8
slouken@7255
     9
# Intel 32-bit compiler flags (10.6 runtime compatibility)
jorgen@7507
    10
GCC_COMPILE_X86="g++ -arch i386 -mmacosx-version-min=10.5 \
slouken@7255
    11
-I/usr/local/include"
slouken@7255
    12
jorgen@7507
    13
GCC_LINK_X86="-mmacosx-version-min=10.5"
slouken@7255
    14
slouken@7255
    15
# Intel 64-bit compiler flags (10.6 runtime compatibility)
slouken@7255
    16
GCC_COMPILE_X64="g++ -arch x86_64 -mmacosx-version-min=10.6 \
slouken@7255
    17
-I/usr/local/include"
slouken@7255
    18
slouken@7255
    19
GCC_LINK_X64="-mmacosx-version-min=10.6"
slouken@7255
    20
slouken@7255
    21
# Output both PowerPC and Intel object files
slouken@7255
    22
args="$*"
slouken@7255
    23
compile=yes
slouken@7255
    24
link=yes
slouken@7255
    25
while test x$1 != x; do
slouken@7255
    26
    case $1 in
slouken@7255
    27
        --version) exec g++ $1;;
slouken@7255
    28
        -v) exec g++ $1;;
slouken@7255
    29
        -V) exec g++ $1;;
slouken@7255
    30
        -print-prog-name=*) exec g++ $1;;
slouken@7255
    31
        -print-search-dirs) exec g++ $1;;
slouken@7255
    32
        -E) GCC_COMPILE_X86="$GCC_COMPILE_X86 -E"
slouken@7255
    33
            GCC_COMPILE_X64="$GCC_COMPILE_X64 -E"
slouken@7255
    34
            compile=no; link=no;;
slouken@7255
    35
        -c) link=no;;
slouken@7255
    36
        -o) output=$2;;
slouken@7255
    37
        *.c|*.cc|*.cpp|*.S) source=$1;;
slouken@7255
    38
    esac
slouken@7255
    39
    shift
slouken@7255
    40
done
slouken@7255
    41
if test x$link = xyes; then
slouken@7255
    42
    GCC_COMPILE_X86="$GCC_COMPILE_X86 $GCC_LINK_X86"
slouken@7255
    43
    GCC_COMPILE_X64="$GCC_COMPILE_X64 $GCC_LINK_X64"
slouken@7255
    44
fi
slouken@7255
    45
if test x"$output" = x; then
slouken@7255
    46
    if test x$link = xyes; then
slouken@7255
    47
        output=a.out
slouken@7255
    48
    elif test x$compile = xyes; then
slouken@7255
    49
        output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o
slouken@7255
    50
    fi
slouken@7255
    51
fi
slouken@7255
    52
slouken@7255
    53
# Compile X86 32-bit
slouken@7255
    54
if test x"$output" != x; then
slouken@7255
    55
    dir=x86/`dirname $output`
slouken@7255
    56
    if test -d $dir; then
slouken@7255
    57
        :
slouken@7255
    58
    else
slouken@7255
    59
        mkdir -p $dir
slouken@7255
    60
    fi
slouken@7255
    61
fi
slouken@7255
    62
set -- $args
slouken@7255
    63
while test x$1 != x; do
slouken@7255
    64
    if test -f "x86/$1" && test "$1" != "$output"; then
slouken@7255
    65
        x86_args="$x86_args x86/$1"
slouken@7255
    66
    else
slouken@7255
    67
        x86_args="$x86_args $1"
slouken@7255
    68
    fi
slouken@7255
    69
    shift
slouken@7255
    70
done
slouken@7255
    71
$GCC_COMPILE_X86 $x86_args || exit $?
slouken@7255
    72
if test x"$output" != x; then
slouken@7255
    73
    cp $output x86/$output
slouken@7255
    74
fi
slouken@7255
    75
slouken@7255
    76
# Compile X86 32-bit
slouken@7255
    77
if test x"$output" != x; then
slouken@7255
    78
    dir=x64/`dirname $output`
slouken@7255
    79
    if test -d $dir; then
slouken@7255
    80
        :
slouken@7255
    81
    else
slouken@7255
    82
        mkdir -p $dir
slouken@7255
    83
    fi
slouken@7255
    84
fi
slouken@7255
    85
set -- $args
slouken@7255
    86
while test x$1 != x; do
slouken@7255
    87
    if test -f "x64/$1" && test "$1" != "$output"; then
slouken@7255
    88
        x64_args="$x64_args x64/$1"
slouken@7255
    89
    else
slouken@7255
    90
        x64_args="$x64_args $1"
slouken@7255
    91
    fi
slouken@7255
    92
    shift
slouken@7255
    93
done
slouken@7255
    94
$GCC_COMPILE_X64 $x64_args || exit $?
slouken@7255
    95
if test x"$output" != x; then
slouken@7255
    96
    cp $output x64/$output
slouken@7255
    97
fi
slouken@7255
    98
slouken@7255
    99
if test x"$output" != x; then
slouken@7255
   100
    lipo -create -o $output x86/$output x64/$output
slouken@7255
   101
fi