aboutsummaryrefslogtreecommitdiffstats
path: root/android
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@google.com>2009-06-04 16:07:01 +0200
committerDavid 'Digit' Turner <digit@google.com>2009-06-08 17:43:17 +0200
commit46be48730333120a7b939116cef075e61c12c703 (patch)
tree92bde033dd93fc14e0e2565a52293b59787b8859 /android
parentb72269abe4a75736c09b0ee8797b736f49c058c8 (diff)
downloadexternal_qemu-46be48730333120a7b939116cef075e61c12c703.zip
external_qemu-46be48730333120a7b939116cef075e61c12c703.tar.gz
external_qemu-46be48730333120a7b939116cef075e61c12c703.tar.bz2
Add our modified SDL sources under distrib/sdl-1.2.12
Fix distrib/make-distrib.sh script to work with git Fix distrib/build-emulator.sh to accomodate for new SDL configure script Handle Tiger SDK usage in SDL configure script
Diffstat (limited to 'android')
-rw-r--r--android/build/common.sh515
-rw-r--r--android/build/definitions.make20
-rw-r--r--android/main.c3
-rw-r--r--android/skin/window.c16
-rw-r--r--android/utils/display-quartz.m111
-rw-r--r--android/utils/display.c245
-rw-r--r--android/utils/display.h31
7 files changed, 545 insertions, 396 deletions
diff --git a/android/build/common.sh b/android/build/common.sh
new file mode 100644
index 0000000..b22ef7d
--- /dev/null
+++ b/android/build/common.sh
@@ -0,0 +1,515 @@
+# Copyright (C) 2008 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# This file is included by other shell scripts; do not execute it directly.
+# It contains common definitions.
+#
+PROGNAME=`basename $0`
+
+## Logging support
+##
+VERBOSE=yes
+VERBOSE2=no
+
+log ()
+{
+ if [ "$VERBOSE" = "yes" ] ; then
+ echo "$1"
+ fi
+}
+
+log2 ()
+{
+ if [ "$VERBOSE2" = "yes" ] ; then
+ echo "$1"
+ fi
+}
+
+## Utilities
+##
+
+# return the value of a given named variable
+# $1: variable name
+#
+var_value ()
+{
+ # find a better way to do that ?
+ local result
+ eval result="$`echo $1`"
+ echo $result
+}
+
+# convert to uppercase
+to_uppercase ()
+{
+ echo $1 | tr "[:lower:]" "[:upper:]"
+}
+
+## Normalize OS and CPU
+##
+
+CPU=`uname -m`
+case "$CPU" in
+ i?86) CPU=x86
+ ;;
+ amd64) CPU=x86_64
+ ;;
+ powerpc) CPU=ppc
+ ;;
+esac
+
+log2 "CPU=$CPU"
+
+# at this point, the supported values for CPU are:
+# x86
+# x86_64
+# ppc
+#
+# other values may be possible but haven't been tested
+#
+
+EXE=""
+OS=`uname -s`
+case "$OS" in
+ Darwin)
+ OS=darwin-$CPU
+ ;;
+ Linux)
+ # note that building 32-bit binaries on x86_64 is handled later
+ OS=linux-$CPU
+ ;;
+ CYGWIN*|*_NT-*)
+ OS=windows
+ EXE=.exe
+ if [ "x$OSTYPE" = xcygwin ] ; then
+ OS=cygwin
+ HOST_CFLAGS="$CFLAGS -mno-cygwin"
+ HOST_LDFLAGS="$LDFLAGS -mno-cygwin"
+ fi
+ ;;
+esac
+
+log2 "OS=$OS"
+log2 "EXE=$EXE"
+
+# at this point, the value of OS should be one of the following:
+# linux-x86
+# linux-x86_64
+# darwin-x86
+# darwin-ppc
+# windows (MSys)
+# cygwin
+#
+# Note that cygwin is treated as a special case because it behaves very differently
+# for a few things
+#
+# other values may be possible but have not been tested
+
+# define HOST_OS as $OS without any cpu-specific suffix
+#
+case $OS in
+ linux-*) HOST_OS=linux
+ ;;
+ darwin-*) HOST_OS=darwin
+ ;;
+ *) HOST_OS=$OS
+esac
+
+# define HOST_ARCH as the $CPU
+HOST_ARCH=$CPU
+
+#### Toolchain support
+####
+
+# Various probes are going to need to run a small C program
+TMPC=/tmp/android-$$-test.c
+TMPO=/tmp/android-$$-test.o
+TMPE=/tmp/android-$$-test$EXE
+TMPL=/tmp/android-$$-test.log
+
+# cleanup temporary files
+clean_temp ()
+{
+ rm -f $TMPC $TMPO $TMPL $TMPE
+}
+
+# cleanup temp files then exit with an error
+clean_exit ()
+{
+ clean_temp
+ exit 1
+}
+
+# this function should be called to enforce the build of 32-bit binaries on 64-bit systems
+# that support it.
+FORCE_32BIT=no
+force_32bit_binaries ()
+{
+ if [ $CPU = x86_64 ] ; then
+ FORCE_32BIT=yes
+ case $OS in
+ linux-x86_64) OS=linux-x86 ;;
+ darwin-x86_64) OS=darwin-x86 ;;
+ esac
+ HOST_ARCH=x86
+ CPU=x86
+ log "Check32Bits: Forcing generation of 32-bit binaries (--try-64 to disable)"
+ fi
+}
+
+# Cygwin is normally not supported, unless you call this function
+#
+enable_cygwin ()
+{
+ if [ $OS = cygwin ] ; then
+ CFLAGS="$CFLAGS -mno-cygwin"
+ LDFLAGS="$LDFLAGS -mno-cygwin"
+ OS=windows
+ HOST_OS=windows
+ fi
+}
+
+# this function will setup the compiler and linker and check that they work as advertized
+# note that you should call 'force_32bit_binaries' before this one if you want it to work
+# as advertized.
+#
+setup_toolchain ()
+{
+ if [ "$OS" = cygwin ] ; then
+ echo "Do not compile this program or library with Cygwin, use MSYS instead !!"
+ echo "As an experimental feature, you can try to --try-cygwin option to override this"
+ exit 2
+ fi
+
+ if [ -z "$CC" ] ; then
+ CC=gcc
+ if [ $CPU = "powerpc" ] ; then
+ CC=gcc-3.3
+ fi
+ fi
+
+ # check that we can compile a trivial C program with this compiler
+ cat > $TMPC <<EOF
+int main(void) {}
+EOF
+
+ if [ $FORCE_32BIT = yes ] ; then
+ CFLAGS="$CFLAGS -m32"
+ LDFLAGS="$LDFLAGS -m32"
+ compile
+ if [ $? != 0 ] ; then
+ # sometimes, we need to also tell the assembler to generate 32-bit binaries
+ # this is highly dependent on your GCC installation (and no, we can't set
+ # this flag all the time)
+ CFLAGS="$CFLAGS -Wa,--32"
+ compile
+ fi
+ fi
+
+ compile
+ if [ $? != 0 ] ; then
+ echo "your C compiler doesn't seem to work:"
+ cat $TMPL
+ clean_exit
+ fi
+ log "CC : compiler check ok ($CC)"
+
+ # check that we can link the trivial program into an executable
+ if [ -z "$LD" ] ; then
+ LD=$CC
+ fi
+ link
+ if [ $? != 0 ] ; then
+ OLD_LD=$LD
+ LD=gcc
+ compile
+ link
+ if [ $? != 0 ] ; then
+ LD=$OLD_LD
+ echo "your linker doesn't seem to work:"
+ cat $TMPL
+ clean_exit
+ fi
+ fi
+ log "LD : linker check ok ($LD)"
+}
+
+# try to compile the current source file in $TMPC into an object
+# stores the error log into $TMPL
+#
+compile ()
+{
+ log2 "Object : $CC -o $TMPO -c $CFLAGS $TMPC"
+ $CC -o $TMPO -c $CFLAGS $TMPC 2> $TMPL
+}
+
+# try to link the recently built file into an executable. error log in $TMPL
+#
+link()
+{
+ log2 "Link : $LD -o $TMPE $TMPO $LDFLAGS"
+ $LD -o $TMPE $TMPO $LDFLAGS 2> $TMPL
+}
+
+# run a command
+#
+execute()
+{
+ log2 "Running: $*"
+ $*
+}
+
+# perform a simple compile / link / run of the source file in $TMPC
+compile_exec_run()
+{
+ log2 "RunExec : $CC -o $TMPE $CFLAGS $TMPC"
+ compile
+ if [ $? != 0 ] ; then
+ echo "Failure to compile test program"
+ cat $TMPC
+ cat $TMPL
+ clean_exit
+ fi
+ link
+ if [ $? != 0 ] ; then
+ echo "Failure to link test program"
+ cat $TMPC
+ echo "------"
+ cat $TMPL
+ clean_exit
+ fi
+ $TMPE
+}
+
+## Feature test support
+##
+
+# Each feature test allows us to check against a single target-specific feature
+# We run the feature checks in a Makefile in order to be able to do them in
+# parallel, and we also have some cached values in our output directory, just
+# in case.
+#
+# check that a given C program in $TMPC can be compiled on the host system
+# $1: variable name which will be set to "yes" or "no" depending on result
+# you can define EXTRA_CFLAGS for extra C compiler flags
+# for convenience, this variable will be unset by the function
+#
+feature_check_compile ()
+{
+ local result_cc=yes
+ local OLD_CFLAGS
+ OLD_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $EXTRA_CFLAGS"
+ compile
+ if [ $? != 0 ] ; then
+ result_cc=no
+ fi
+ eval $1=$result_cc
+ EXTRA_CFLAGS=
+ CFLAGS=$OLD_CFLAGS
+}
+
+# check that a given C program $TMPC can be linked on the host system
+# $1: variable name which will be set to "yes" or "no" depending on result
+# you can define EXTRA_CFLAGS for extra C compiler flags
+# you can define EXTRA_LDFLAGS for extra linker flags
+# for convenience, these variables will be unset by the function
+#
+feature_check_link ()
+{
+ local result_cl=yes
+ local OLD_CFLAGS OLD_LDFLAGS
+ OLD_CFLAGS=$CFLAGS
+ OLD_LDFLAGS=$LDFLAGS
+ CFLAGS="$CFLAGS $EXTRA_CFLAGS"
+ LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
+ compile
+ if [ $? != 0 ] ; then
+ result_cl=no
+ else
+ link
+ if [ $? != 0 ] ; then
+ result_cl=no
+ fi
+ fi
+ CFLAGS=$OLD_CFLAGS
+ LDFLAGS=$OLD_LDFLAGS
+ eval $1=$result_cl
+}
+
+# check that a given C header file exists on the host system
+# $1: variable name which will be set to "yes" or "no" depending on result
+# $2: header name
+#
+# you can define EXTRA_CFLAGS for extra C compiler flags
+# for convenience, this variable will be unset by the function.
+#
+feature_check_header ()
+{
+ local result_ch
+ log2 "HeaderChk : $2"
+ echo "#include $2" > $TMPC
+ cat >> $TMPC <<EOF
+ int main(void) { return 0; }
+EOF
+ feature_check_compile result_ch
+ eval $1=$result_ch
+ #eval result=$`echo $1`
+ #log "Host : $1=$result_ch"
+}
+
+# run the test program that is in $TMPC and set its exit status
+# in the $1 variable.
+# you can define EXTRA_CFLAGS and EXTRA_LDFLAGS
+#
+feature_run_exec ()
+{
+ local run_exec_result
+ local OLD_CFLAGS="$CFLAGS"
+ local OLD_LDFLAGS="$LDFLAGS"
+ CFLAGS="$CFLAGS $EXTRA_CFLAGS"
+ LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
+ compile_exec_run
+ run_exec_result=$?
+ CFLAGS="$OLD_CFLAGS"
+ LDFLAGS="$OLD_LDFLAGS"
+ eval $1=$run_exec_result
+ log "Host : $1=$run_exec_result"
+}
+
+## Android build system auto-detection
+##
+
+# check whether we're running within the Android build system
+# sets the variable IN_ANDROID_BUILD to either "yes" or "no"
+#
+# in case of success, defines ANDROID_TOP to point to the top
+# of the Android source tree.
+#
+check_android_build ()
+{
+ unset ANDROID_TOP
+ IN_ANDROID_BUILD=no
+
+ if [ -z "$ANDROID_PRODUCT_OUT" ] ; then
+ return ;
+ fi
+
+ ANDROID_TOP=`cd $ANDROID_PRODUCT_OUT/../../../.. && pwd`
+ log "ANDROID_TOP found at $ANDROID_TOP"
+ # $ANDROID_TOP/config/envsetup.make is for the old tree layout
+ # $ANDROID_TOP/build/envsetup.sh is for the new one
+ ANDROID_CONFIG_MK=$ANDROID_TOP/build/core/config.mk
+ if [ ! -f $ANDROID_CONFIG_MK ] ; then
+ ANDROID_CONFIG_MK=$ANDROID_TOP/config/envsetup.make
+ fi
+ if [ ! -f $ANDROID_CONFIG_MK ] ; then
+ echo "Weird: Cannot find build system root defaulting to non-Android build"
+ unset ANDROID_TOP
+ return
+ fi
+ # normalize ANDROID_TOP, we don't want a trailing /
+ ANDROID_TOPDIR=`dirname $ANDROID_TOP`
+ if [ "$ANDROID_TOPDIR" != "." ] ; then
+ ANDROID_TOP=$ANDROID_TOPDIR/`basename $ANDROID_TOP`
+ fi
+ IN_ANDROID_BUILD=yes
+}
+
+# Get the value of an Android build variable as an absolute path.
+# you should only call this if IN_ANDROID_BUILD is "yes"
+#
+get_android_abs_build_var ()
+{
+ (cd $ANDROID_TOP && CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core make -f $ANDROID_CONFIG_MK dumpvar-abs-$1)
+}
+
+# Locate the Android prebuilt directory for your os
+# you should only call this if IN_ANDROID_BUILD is "yes"
+#
+# This will set ANDROID_PREBUILT_HOST_TAG and ANDROID_PREBUILT
+#
+locate_android_prebuilt ()
+{
+ # locate prebuilt directory
+ ANDROID_PREBUILT_HOST_TAG=$OS
+ case $OS in
+ linux-*)
+ # Linux is a special case because in the old tree layout
+ # we simply used 'Linux' as the prebuilt host tag, but
+ # are now using "linux-x86" in the new layout
+ # check which one should be used
+ #
+ if [ -d $ANDROID_TOP/prebuilt/Linux ] ; then
+ PREBUILT_HOST_TAG=Linux
+ fi
+ ;;
+ esac
+ ANDROID_PREBUILT=$ANDROID_TOP/prebuilt/$ANDROID_PREBUILT_HOST_TAG
+ if [ ! -d $ANDROID_PREBUILT ] ; then
+ # this can happen when building on x86_64
+ case $OS in
+ linux-x86_64)
+ ANDROID_PREBUILT_HOST_TAG=linux-x86
+ ANDROID_PREBUILT=$ANDROID_TOP/prebuilt/$ANDROID_PREBUILT_HOST_TAG
+ log "Forcing usage of 32-bit prebuilts"
+ force_32bit_binaries
+ ;;
+ *)
+ esac
+ if [ ! -d $ANDROID_PREBUILT ] ; then
+ echo "Can't find the prebuilt directory $ANDROID_PREBUILT in Android build"
+ exit 1
+ fi
+ fi
+ log "Prebuilt : ANDROID_PREBUILT=$ANDROID_PREBUILT"
+}
+
+## Build configuration file support
+## you must define $config_mk before calling this function
+##
+create_config_mk ()
+{
+ # create the directory if needed
+ local config_dir
+ config_mk=${config_mk:-objs/config.make}
+ config_dir=`dirname $config_mk`
+ mkdir -p $config_dir 2> $TMPL
+ if [ $? != 0 ] ; then
+ echo "Can't create directory for build config file: $config_dir"
+ cat $TMPL
+ clean_exit
+ fi
+
+ # re-create the start of the configuration file
+ log "Generate : $config_mk"
+
+ echo "# This file was autogenerated by $PROGNAME. Do not edit !" > $config_mk
+ echo "OS := $OS" >> $config_mk
+ echo "HOST_OS := $HOST_OS" >> $config_mk
+ echo "HOST_ARCH := $HOST_ARCH" >> $config_mk
+ echo "CC := $CC" >> $config_mk
+ echo "HOST_CC := $CC" >> $config_mk
+ echo "LD := $LD" >> $config_mk
+ echo "CFLAGS := $CFLAGS" >> $config_mk
+ echo "LDFLAGS := $LDFLAGS" >> $config_mk
+}
+
+add_android_config_mk ()
+{
+ echo "" >> $config_mk
+ echo "TARGET_ARCH := arm" >> $config_mk
+ echo "HOST_PREBUILT_TAG := $ANDROID_PREBUILT_HOST_TAG" >> $config_mk
+ echo "PREBUILT := $ANDROID_PREBUILT" >> $config_mk
+}
diff --git a/android/build/definitions.make b/android/build/definitions.make
index cd03f89..4ba0d07 100644
--- a/android/build/definitions.make
+++ b/android/build/definitions.make
@@ -65,7 +65,7 @@ $$(OBJ): $$(SRC_PATH)/$$(SRC)
@mkdir -p $$(dir $$(PRIVATE_OBJ))
@echo "Compile: $$(PRIVATE_MODULE) <= $$(PRIVATE_SRC0)"
$(hide) $$(PRIVATE_CC) $$(PRIVATE_CFLAGS) -c -o $$(PRIVATE_OBJ) -MMD -MP -MF $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_SRC)
- $(hide) $$(SRC_PATH)/android/build/mkdeps.sh $$(PRIVATE_OBJ) $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_OBJ).d
+ $(hide) $$(BUILD_SYSTEM)/mkdeps.sh $$(PRIVATE_OBJ) $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_OBJ).d
endef
# Compile an Objective-C source file
@@ -85,7 +85,23 @@ $$(OBJ): $$(SRC_PATH)/$$(SRC)
@mkdir -p $$(dir $$(PRIVATE_OBJ))
@echo "Compile: $$(PRIVATE_MODULE) <= $$(PRIVATE_SRC0)"
$(hide) $$(PRIVATE_CC) $$(PRIVATE_CFLAGS) -c -o $$(PRIVATE_OBJ) -MMD -MP -MF $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_SRC)
- $(hide) $$(SRC_PATH)/android/build/mkdeps.sh $$(PRIVATE_OBJ) $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_OBJ).d
+ $(hide) $$(BUILD_SYSTEM)/mkdeps.sh $$(PRIVATE_OBJ) $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_OBJ).d
+endef
+
+# Install a file
+#
+define install-target
+SRC:=$(1)
+DST:=$(2)
+$$(DST): PRIVATE_SRC := $$(SRC)
+$$(DST): PRIVATE_DST := $$(DST)
+$$(DST): PRIVATE_DST_NAME := $$(notdir $$(DST))
+$$(DST): PRIVATE_SRC_NAME := $$(SRC)
+$$(DST): $$(SRC)
+ @mkdir -p $$(dir $$(PRIVATE_DST))
+ @echo "Install: $$(PRIVATE_DST_NAME) <= $$(PRIVATE_SRC_NAME)"
+ $(hide) cp -f $$(PRIVATE_SRC) $$(PRIVATE_DST)
+install: $$(DST)
endef
# for now, we only use prebuilt SDL libraries, so copy them
diff --git a/android/main.c b/android/main.c
index cd4162a..e90beaa 100644
--- a/android/main.c
+++ b/android/main.c
@@ -58,7 +58,6 @@
#include "android/utils/dirscanner.h"
#include "android/utils/path.h"
#include "android/utils/timezone.h"
-#include "android/utils/display.h"
#include "android/cmdline-option.h"
#include "android/help.h"
@@ -426,7 +425,7 @@ get_default_scale( AndroidOptions* opts )
/* we need to get the host dpi resolution ? */
int xdpi, ydpi;
- if ( get_monitor_resolution( &xdpi, &ydpi ) < 0 ) {
+ if ( SDL_WM_GetMonitorDPI( &xdpi, &ydpi ) < 0 ) {
fprintf(stderr, "could not get monitor DPI resolution from system. please use -dpi-monitor to specify one\n" );
exit(1);
}
diff --git a/android/skin/window.c b/android/skin/window.c
index 7ce5759..674b594 100644
--- a/android/skin/window.c
+++ b/android/skin/window.c
@@ -14,7 +14,6 @@
#include "android/skin/scaler.h"
#include "android/charmap.h"
#include "android/utils/debug.h"
-#include "android/utils/display.h"
#include "android/hw-sensors.h"
#include <SDL_syswm.h>
#include "qemu-common.h"
@@ -1107,12 +1106,19 @@ skin_window_resize( SkinWindow* window )
int fullscreen = window->fullscreen;
if (fullscreen) {
- if (get_nearest_monitor_rect(&window_x, &window_y,
- &window_w, &window_h) < 0) {
+ SDL_Rect r;
+ if (SDL_WM_GetMonitorRect(&r) < 0) {
fullscreen = 0;
} else {
- double x_scale = window_w * 1.0 / layout_w;
- double y_scale = window_h * 1.0 / layout_h;
+ double x_scale, y_scale;
+
+ window_x = r.x;
+ window_y = r.y;
+ window_w = r.w;
+ window_h = r.h;
+
+ x_scale = window_w * 1.0 / layout_w;
+ y_scale = window_h * 1.0 / layout_h;
scale = (x_scale <= y_scale) ? x_scale : y_scale;
}
diff --git a/android/utils/display-quartz.m b/android/utils/display-quartz.m
deleted file mode 100644
index 594657e..0000000
--- a/android/utils/display-quartz.m
+++ /dev/null
@@ -1,111 +0,0 @@
-/* Copyright (C) 2007-2008 The Android Open Source Project
-**
-** This software is licensed under the terms of the GNU General Public
-** License version 2, as published by the Free Software Foundation, and
-** may be copied, distributed, and modified under those terms.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-*/
-
-/* this is the Quartz-specific implementation of
- * <android/utils/display.h>
- */
-
-#include "android/utils/display.h"
-#include "android/utils/debug.h"
-
-#define D(...) VERBOSE_PRINT(init,__VA_ARGS__)
-
-#include <stdio.h>
-#include <Cocoa/Cocoa.h>
-#include <Carbon/Carbon.h>
-#include <SDL_syswm.h>
-
-int
-get_monitor_resolution( int *px_dpi, int *py_dpi )
-{
- fprintf(stderr, "emulator: FIXME: implement get_monitor_resolution on OS X\n" );
- return -1;
-}
-
-int
-get_nearest_monitor_rect( int *x, int *y, int *width, int *height )
-{
- SDL_SysWMinfo info;
- NSWindow* window;
-
- SDL_VERSION(&info.version);
- if ( SDL_GetWMInfo(&info) < 0 ) {
- D( "%s: SDL_GetWMInfo() failed: %s", __FUNCTION__, SDL_GetError());
- return -1;
- }
- window = info.nsWindowPtr;
- if (window == NULL) {
- D( "%s: SDL_GetWMInfo() returned NULL NSWindow ptr",
- __FUNCTION__ );
- return -1;
- }
- else
- {
- NSRect frame = [ window frame ];
- int fx1 = frame.origin.x;
- int fy1 = frame.origin.y;
- int fx2 = frame.size.width + fx1;
- int fy2 = frame.size.height + fy1;
- NSArray* screens = [ NSScreen screens ];
- unsigned int count = [ screens count ];
- int bestScreen = -1;
- int bestArea = 0;
-
- unsigned int n;
- printf( "window frame (%d,%d) (%d,%d)\n", fx1, fy1, fx2, fy2 );
-
- /* we need to compute which screen has the most window pixels */
- for (n = 0; n < count; n++) {
- NSScreen* screen = [ screens objectAtIndex: n ];
- NSRect vis = [ screen visibleFrame ];
- int vx1 = vis.origin.x;
- int vy1 = vis.origin.y;
- int vx2 = vis.size.width + vx1;
- int vy2 = vis.size.height + vy1;
- int cx1, cx2, cy1, cy2, cArea;
-
- //printf( "screen %d/%d frame (%d,%d) (%d,%d)\n", n+1, count,
- // vx1, vy1, vx2, vy2 );
-
- if (fx1 >= vx2 || vx1 >= fx2 || fy1 >= vy2 || vy1 >= fy2)
- continue;
-
- cx1 = (fx1 < vx1) ? vx1 : fx1;
- cx2 = (fx2 > vx2) ? vx2 : fx2;
- cy1 = (fy1 < vy1) ? vy1 : fy1;
- cy2 = (fy2 > vy2) ? vy2 : fy2;
-
- if (cx1 >= cx2 || cy1 >= cy2)
- continue;
-
- cArea = (cx2-cx1)*(cy2-cy1);
-
- if (bestScreen < 0 || cArea > bestArea) {
- bestScreen = n;
- bestArea = cArea;
- }
- }
- if (bestScreen < 0)
- bestScreen = 0;
-
- {
- NSScreen* screen = [ screens objectAtIndex: bestScreen ];
- NSRect vis = [ screen visibleFrame ];
-
- *x = vis.origin.x;
- *y = vis.origin.y;
- *width = vis.size.width;
- *height = vis.size.height;
- }
- return 0;
- }
-};
diff --git a/android/utils/display.c b/android/utils/display.c
deleted file mode 100644
index e1ba507..0000000
--- a/android/utils/display.c
+++ /dev/null
@@ -1,245 +0,0 @@
-/* Copyright (C) 2007-2008 The Android Open Source Project
-**
-** This software is licensed under the terms of the GNU General Public
-** License version 2, as published by the Free Software Foundation, and
-** may be copied, distributed, and modified under those terms.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-*/
-
-#include "android/utils/display.h"
-#include "android/utils/debug.h"
-
-#define D(...) VERBOSE_PRINT(init,__VA_ARGS__)
-
-/** HOST RESOLUTION SETTINGS
- **
- ** return the main monitor's DPI resolution according to the host device
- ** beware: this is not always reliable or even obtainable.
- **
- ** returns 0 on success, or -1 in case of error (e.g. the system returns funky values)
- **/
-
-/** NOTE: the following code assumes that we exclusively use X11 on Linux, and Quartz on OS X
- **/
-
-#ifdef _WIN32
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <SDL_syswm.h>
-
-int
-get_monitor_resolution( int *px_dpi, int *py_dpi )
-{
- HDC displayDC = CreateDC( "DISPLAY", NULL, NULL, NULL );
- int xdpi, ydpi;
-
- if (displayDC == NULL) {
- D( "%s: could not get display DC\n", __FUNCTION__ );
- return -1;
- }
- xdpi = GetDeviceCaps( displayDC, LOGPIXELSX );
- ydpi = GetDeviceCaps( displayDC, LOGPIXELSY );
-
- /* sanity checks */
- if (xdpi < 20 || xdpi > 400 || ydpi < 20 || ydpi > 400) {
- D( "%s: bad resolution: xpi=%d ydpi=%d", __FUNCTION__,
- xdpi, ydpi );
- return -1;
- }
-
- *px_dpi = xdpi;
- *py_dpi = ydpi;
- return 0;
-}
-
-int
-get_nearest_monitor_rect( int *x, int *y, int *width, int *height )
-{
- SDL_SysWMinfo info;
- HMONITOR monitor;
- MONITORINFO monitorInfo;
-
- SDL_VERSION(&info.version);
-
- if ( !SDL_GetWMInfo(&info) ) {
- D( "%s: SDL_GetWMInfo() failed: %s", __FUNCTION__, SDL_GetError());
- return -1;
- }
-
- monitor = MonitorFromWindow( info.window, MONITOR_DEFAULTTONEAREST );
- monitorInfo.cbSize = sizeof(monitorInfo);
- GetMonitorInfo( monitor, &monitorInfo );
-
- *x = monitorInfo.rcMonitor.left;
- *y = monitorInfo.rcMonitor.top;
- *width = monitorInfo.rcMonitor.right - *x;
- *height = monitorInfo.rcMonitor.bottom - *y;
-
- D("%s: found (x,y,w,h)=(%d,%d,%d,%d)", __FUNCTION__,
- *x, *y, *width, *height);
-
- return 0;
-}
-
-
-#elif defined __APPLE__
-
-/* the real implementation is in display-quartz.m, but
- * unfortunately, the Android build system doesn't know
- * how to build Objective-C sources, so provide stubs
- * here instead.
- *
- * CONFIG_NO_COCOA is set by Makefile.android
- */
-
-#ifdef CONFIG_NO_COCOA
-int
-get_monitor_resolution( int *px_dpi, int *py_dpi )
-{
- return -1;
-}
-
-int
-get_nearest_monitor_rect( int *x, int *y, int *width, int *height )
-{
- return -1;
-}
-#endif /* CONFIG_NO_COCOA */
-
-#else /* Linux and others */
-#include <SDL.h>
-#include <SDL_syswm.h>
-#include <dlfcn.h>
-#include <X11/Xlib.h>
-#define MM_PER_INCH 25.4
-
-#define DYNLINK_FUNCTIONS \
- DYNLINK_FUNC(int,XDefaultScreen,(Display*)) \
- DYNLINK_FUNC(int,XDisplayWidth,(Display*,int)) \
- DYNLINK_FUNC(int,XDisplayWidthMM,(Display*,int)) \
- DYNLINK_FUNC(int,XDisplayHeight,(Display*,int)) \
- DYNLINK_FUNC(int,XDisplayHeightMM,(Display*,int)) \
-
-#define DYNLINK_FUNCTIONS_INIT \
- x11_dynlink_init
-
-#include "dynlink.h"
-
-static int x11_lib_inited;
-static void* x11_lib;
-
-int
-x11_lib_init( void )
-{
- if (!x11_lib_inited) {
- x11_lib_inited = 1;
-
- x11_lib = dlopen( "libX11.so", RTLD_NOW );
-
- if (x11_lib == NULL) {
- x11_lib = dlopen( "libX11.so.6", RTLD_NOW );
- }
- if (x11_lib == NULL) {
- D("%s: Could not find libX11.so on this machine",
- __FUNCTION__);
- return -1;
- }
-
- if (x11_dynlink_init(x11_lib) < 0) {
- D("%s: didn't find necessary symbols in libX11.so",
- __FUNCTION__);
- dlclose(x11_lib);
- x11_lib = NULL;
- }
- }
- return x11_lib ? 0 : -1;
-}
-
-
-int
-get_monitor_resolution( int *px_dpi, int *py_dpi )
-{
- SDL_SysWMinfo info;
- Display* display;
- int screen;
- int width, width_mm, height, height_mm, xdpi, ydpi;
-
- SDL_VERSION(&info.version);
-
- if ( !SDL_GetWMInfo(&info) ) {
- D( "%s: SDL_GetWMInfo() failed: %s", __FUNCTION__, SDL_GetError());
- return -1;
- }
-
- if (x11_lib_init() < 0)
- return -1;
-
- display = info.info.x11.display;
- screen = FF(XDefaultScreen)(display);
-
- width = FF(XDisplayWidth)(display, screen);
- width_mm = FF(XDisplayWidthMM)(display, screen);
- height = FF(XDisplayHeight)(display, screen);
- height_mm = FF(XDisplayHeightMM)(display, screen);
-
- if (width_mm <= 0 || height_mm <= 0) {
- D( "%s: bad screen dimensions: width_mm = %d, height_mm = %d",
- __FUNCTION__, width_mm, height_mm);
- return -1;
- }
-
- D( "%s: found screen width=%d height=%d width_mm=%d height_mm=%d",
- __FUNCTION__, width, height, width_mm, height_mm );
-
- xdpi = width * MM_PER_INCH / width_mm;
- ydpi = height * MM_PER_INCH / height_mm;
-
- if (xdpi < 20 || xdpi > 400 || ydpi < 20 || ydpi > 400) {
- D( "%s: bad resolution: xpi=%d ydpi=%d", __FUNCTION__,
- xdpi, ydpi );
- return -1;
- }
-
- *px_dpi = xdpi;
- *py_dpi = ydpi;
-
- return 0;
-}
-
-int
-get_nearest_monitor_rect( int *x, int *y, int *width, int *height )
-{
- SDL_SysWMinfo info;
- Display* display;
- int screen;
-
- SDL_VERSION(&info.version);
-
- if ( !SDL_GetWMInfo(&info) ) {
- D( "%s: SDL_GetWMInfo() failed: %s", __FUNCTION__, SDL_GetError());
- return -1;
- }
-
- if (x11_lib_init() < 0)
- return -1;
-
- display = info.info.x11.display;
- screen = FF(XDefaultScreen)(display);
-
- *x = 0;
- *y = 0;
- *width = FF(XDisplayWidth)(display, screen);
- *height = FF(XDisplayHeight)(display, screen);
-
- D("%s: found (x,y,w,h)=(%d,%d,%d,%d)", __FUNCTION__,
- *x, *y, *width, *height);
-
- return 0;
-}
-
-#endif
diff --git a/android/utils/display.h b/android/utils/display.h
deleted file mode 100644
index 7254aca..0000000
--- a/android/utils/display.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright (C) 2007-2008 The Android Open Source Project
-**
-** This software is licensed under the terms of the GNU General Public
-** License version 2, as published by the Free Software Foundation, and
-** may be copied, distributed, and modified under those terms.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-*/
-
-#ifndef _ANDROID_UTILS_DISPLAY_H
-#define _ANDROID_UTILS_DISPLAY_H
-
-/** HOST RESOLUTION SETTINGS
- **
- ** return the main monitor's DPI resolution according to the host device
- ** beware: this is not always reliable or even obtainable.
- **
- ** returns 0 on success, or -1 in case of error (e.g. the system returns funky values)
- **/
-extern int get_monitor_resolution( int *px_dpi, int *py_dpi );
-
-/** return the size in pixels of the nearest monitor for the current window.
- ** this is used to implement full-screen presentation mode.
- **/
-
-extern int get_nearest_monitor_rect( int *x, int *y, int *width, int *height );
-
-#endif /* _ANDROID_UTILS_DISPLAY_H */