octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [changeset] Missing ScreenSize & ScreenPixelsPerInch properties


From: Thomas Treichl
Subject: Re: [changeset] Missing ScreenSize & ScreenPixelsPerInch properties
Date: Sun, 25 Jan 2009 21:54:41 +0100
User-agent: Thunderbird 2.0.0.19 (Macintosh/20081209)

Thomas Treichl schrieb:
Build time option?

Good question, and my last question to John here before I prepare a changeset tomorrow: Do we need a configure test to check for the LDFLAGS '-framework Carbon' or can I just add this to the '*-*-darwin*)' flags of the canonical_host_system in configure.in?

Hi,

I've adjusted display.cc and I'd like to introduce the m4 macro "OCTAVE_HAVE_FRAMEWORK". This script allows me to check for the compiler option "-framework NAME" and take further arguments $2 and $3 as file prologue and file body if some deeper tests should be performed. However, here is my output from the ./configure run

  checking whether ld accepts -framework Carbon... yes
  configure: adding -Wl,-framework -Wl,Carbon to LDFLAGS

Compilation is successful and I also checked if the part HAVE_FRAMEWORK_CARBON in display.cc is compiled (and not the X11 part). The output before was

  bash$ octave --quiet --eval 'get (0, "ScreenSize")'
  ans = 0   0   0   0

The correct new output is

  bash$ octave --quiet --eval 'get (0, "ScreenSize")'
  ans = 1      1   1680   1050

Ben can you please check if this works on your 10.5 system? If it works, can it be included into the sources? Thanks,

  Thomas
# HG changeset patch
# User Thomas Treichl <address@hidden>
# Date 1232912397 -3600
# Node ID 5ce72d54fb692fd8d8c2746020307f49725178bd
# Parent  79845b1793cf079861840b800a51b1b399b2dd63
Use Carbon framework to determine ScreenSize on Mac.

diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,12 @@
+2009-01-25  John W. Eaton  <address@hidden>
+
+       * aclocal.m4: Introduce new macro OCTAVE_HAVE_FRAMEWORK.
+        * configure.in: Include OCTAVE_HAVE_FRAMEWORK for Carbon.
+
 2009-01-22  John W. Eaton  <address@hidden>
 
        * 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  <address@hidden>
 
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
@@ -268,6 +268,15 @@
 
   AC_CHECK_LIB(X11, XrmInitialize, [X11_LIBS=-lX11], [X11_LIBS=])
   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
diff --git a/src/ChangeLog b/src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2009-01-25  Thomas Treichl  <address@hidden>
+
+       * display.cc: CGSize is a struct of 2 floats on older Macs.
+
 2009-01-24  Jaroslav Hajek  <address@hidden>
 
        * pt-cell.cc (tree_cell::rvalue): Optimize the single row case.
diff --git a/src/display.cc b/src/display.cc
--- a/src/display.cc
+++ b/src/display.cc
@@ -28,9 +28,8 @@
 
 #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
@@ -65,7 +64,7 @@
   else
     warning ("no graphical display found");
 
-#elif defined (OCTAVE_USE_OS_X_API)
+#elif defined (HAVE_FRAMEWORK_CARBON)
 
   CGDirectDisplayID display = CGMainDisplayID ();
 
@@ -78,8 +77,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 (typedef float CGFloat), on older systems (<=
+      // 10.4.11) it is a struct of two float values.
+      float ht_mm = sz_mm.height;
+      float wd_mm = sz_mm.width;
 
       rx = wd * 25.4 / wd_mm;
       ry = ht * 25.4 / ht_mm;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]