Mercurial > hg > octave-kai
changeset 8595:dee5d60257e4
Use Carbon framework to determine ScreenSize on Mac.
author | Thomas Treichl <Thomas.Treichl@gmx.net> |
---|---|
date | Mon, 26 Jan 2009 23:07:09 -0500 |
parents | 756b0ba61350 |
children | 8833c0b18eb2 |
files | ChangeLog aclocal.m4 configure.in src/ChangeLog src/display.cc |
diffstat | 5 files changed, 54 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,12 @@ +2009-01-26 Thomas Treichl <Thomas.Treichl@gmx.net> + + * aclocal.m4 (OCTAVE_HAVE_FRAMEWORK): New macro. + * configure.in: Use it. + 2009-01-22 John W. Eaton <jwe@octave.org> * configure.in (AH_BOTTOM): Define OCTAVE_USE_OS_X_API if - __APPLE__ and __MACK__ are defined. + __APPLE__ and __MACH__ are defined. 2009-01-22 Jaroslav Hajek <highegg@gmail.com>
--- a/aclocal.m4 +++ b/aclocal.m4 @@ -1270,4 +1270,29 @@ AC_DEFINE(HAVE_FAST_INT_OPS,1,[Define if signed integers use two's complement])], [AC_MSG_RESULT([no])]) AC_LANG_POP(C++)]) - +dnl +dnl Check to see if the compiler and the linker can handle the flags +dnl "-framework $1" for the given prologue $2 and the given body $3 +dnl of a source file. Arguments 2 and 3 optionally can also be empty. +dnl If this test is dnl successful then perform $4, otherwise do $5. +dnl +dnl OCTAVE_HAVE_FRAMEWORK +AC_DEFUN(OCTAVE_HAVE_FRAMEWORK, [ + ac_safe=`echo "$1" | sed 'y%./+-:=%__p___%'` + AC_MSG_CHECKING(whether ${LD-ld} accepts -framework $1) + AC_CACHE_VAL(octave_cv_framework_$ac_safe, [ + XLDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -framework $1" + AC_LINK_IFELSE([AC_LANG_PROGRAM([$2], [$3])], + eval "octave_cv_framework_$ac_safe=yes", + eval "octave_cv_framework_$ac_safe=no") + LDFLAGS="$XLDFLAGS" + ]) + if eval "test \"`echo '$octave_cv_framework_'$ac_safe`\" = yes"; then + AC_MSG_RESULT(yes) + [$4] + else + AC_MSG_RESULT(no) + [$5] + fi +])
--- a/configure.in +++ b/configure.in @@ -270,6 +270,15 @@ AC_SUBST(X11_LIBS) fi +### On MacOSX system the Carbon framework is used to determine ScreenSize +OCTAVE_HAVE_FRAMEWORK(Carbon, [#include <Carbon/Carbon.h>], [CGMainDisplayID ()], + [have_carbon="yes"], [have_carbon="no"]) +if test $have_carbon = "yes"; then + AC_DEFINE(HAVE_FRAMEWORK_CARBON, 1, [Define if framework CARBON is available.]) + LDFLAGS="$LDFLAGS -Wl,-framework -Wl,Carbon" + AC_MSG_NOTICE([adding -Wl,-framework -Wl,Carbon to LDFLAGS]) +fi + ### On Intel systems with gcc, we may need to compile with -mieee-fp ### and -ffloat-store to get full support for IEEE floating point. ###
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2009-01-26 Thomas Treichl <Thomas.Treichl@gmx.net> + + * display.cc (display_info::init): Use double instead of CGFloat. + Use HAVE_FRAMEWORK_CARBON instead of OCTAVE_USE_OS_X_API. + 2009-01-26 John W. Eaton <jwe@octave.org> * load-path.cc (load_path::do_find_fcn): Handle @foo/bar.
--- a/src/display.cc +++ b/src/display.cc @@ -28,15 +28,12 @@ #if defined (OCTAVE_USE_WINDOWS_API) #include <Windows.h> -#elif defined (OCTAVE_USE_OS_X_API) -#include <CGDirectDisplay.h> -#include <CGDisplayConfiguration.h> +#elif defined (HAVE_FRAMEWORK_CARBON) +#include <Carbon/Carbon.h> #elif defined (HAVE_X_WINDOWS) #include <X11/Xlib.h> #endif - - #include "display.h" #include "error.h" @@ -65,7 +62,7 @@ else warning ("no graphical display found"); -#elif defined (OCTAVE_USE_OS_X_API) +#elif defined (HAVE_FRAMEWORK_CARBON) CGDirectDisplayID display = CGMainDisplayID (); @@ -78,8 +75,11 @@ CGSize sz_mm = CGDisplayScreenSize (display); - CGFloat ht_mm = sz_mm.height; - CGFloat wd_mm = sz_mm.width; + // On modern Mac systems (>= 10.5) CGSize is a struct keeping 2 + // CGFloat values, but the CGFloat typedef is not present on + // older systems, so use double instead. + double ht_mm = sz_mm.height; + double wd_mm = sz_mm.width; rx = wd * 25.4 / wd_mm; ry = ht * 25.4 / ht_mm;