# HG changeset patch # User Thomas Treichl # Date 1233029229 18000 # Node ID dee5d60257e47855bbe56bd00c385d79de04f572 # Parent 756b0ba61350998cce4540634476e1292b9109ed Use Carbon framework to determine ScreenSize on Mac. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,12 @@ +2009-01-26 Thomas Treichl + + * aclocal.m4 (OCTAVE_HAVE_FRAMEWORK): New macro. + * configure.in: Use it. + 2009-01-22 John W. Eaton * 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 diff --git a/aclocal.m4 b/aclocal.m4 --- 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 +]) diff --git a/configure.in b/configure.in --- 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 ], [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. ### diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2009-01-26 Thomas Treichl + + * 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 * load-path.cc (load_path::do_find_fcn): Handle @foo/bar. diff --git a/src/display.cc b/src/display.cc --- a/src/display.cc +++ b/src/display.cc @@ -28,15 +28,12 @@ #if defined (OCTAVE_USE_WINDOWS_API) #include -#elif defined (OCTAVE_USE_OS_X_API) -#include -#include +#elif defined (HAVE_FRAMEWORK_CARBON) +#include #elif defined (HAVE_X_WINDOWS) #include #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;