Browse Source

Remove old Carbon-based OS X graphics back-end

This back-end has been deprecated by Apple for a while, and has not been used in Panda.  As we will no longer be supporting 32-bit macs going forward, and the Carbon windowing API is not available for 64-bit mac, there's no point in keeping it.
rdb 7 years ago
parent
commit
58acc25ea2

+ 4 - 34
makepanda/makepanda.py

@@ -94,7 +94,7 @@ PkgListSet(["PYTHON", "DIRECT",                        # Python support
   "GTK2",                                              # GTK2 is used for PStats on Unix
   "MFC", "WX", "FLTK",                                 # Used for web plug-in only
   "ROCKET",                                            # GUI libraries
-  "CARBON", "COCOA",                                   # Mac OS X toolkits
+  "COCOA",                                             # Mac OS X toolkits
   "X11",                                               # Unix platform support
   "PANDATOOL", "PVIEW", "DEPLOYTOOLS",                 # Toolchain
   "SKEL",                                              # Example SKEL project
@@ -178,6 +178,7 @@ def parseopts(args):
     # Options for which to display a deprecation warning.
     removedopts = [
         "use-touchinput", "no-touchinput", "no-awesomium", "no-directscripts",
+        "no-carbon",
         ]
 
     # All recognized options.
@@ -622,7 +623,6 @@ if (COMPILER == "MSVC"):
     PkgDisable("GLES")
     PkgDisable("GLES2")
     PkgDisable("EGL")
-    PkgDisable("CARBON")
     PkgDisable("COCOA")
     DefSymbol("FLEX", "YY_NO_UNISTD_H")
     if (PkgSkip("PYTHON")==0):
@@ -875,14 +875,10 @@ if (COMPILER == "MSVC"):
 
 if (COMPILER=="GCC"):
     if GetTarget() != "darwin":
-        PkgDisable("CARBON")
         PkgDisable("COCOA")
     elif RUNTIME:
         # We don't support Cocoa in the runtime yet.
         PkgDisable("COCOA")
-    if 'x86_64' in OSX_ARCHS:
-        # 64-bits OS X doesn't have Carbon.
-        PkgDisable("CARBON")
 
     #if (PkgSkip("PYTHON")==0):
     #    IncDirectory("PYTHON", SDK["PYTHON"])
@@ -2450,7 +2446,6 @@ DTOOL_CONFIG=[
     ("HAVE_ARTOOLKIT",                 'UNDEF',                  'UNDEF'),
     ("HAVE_DIRECTCAM",                 'UNDEF',                  'UNDEF'),
     ("HAVE_SQUISH",                    'UNDEF',                  'UNDEF'),
-    ("HAVE_CARBON",                    'UNDEF',                  'UNDEF'),
     ("HAVE_COCOA",                     'UNDEF',                  'UNDEF'),
     ("HAVE_OPENAL_FRAMEWORK",          'UNDEF',                  'UNDEF'),
     ("HAVE_ROCKET_PYTHON",             '1',                      '1'),
@@ -3354,7 +3349,6 @@ if not PkgSkip("EGG"):
 if GetTarget() == 'windows':
     CopyAllHeaders('panda/src/wgldisplay')
 elif GetTarget() == 'darwin':
-    CopyAllHeaders('panda/src/osxdisplay')
     CopyAllHeaders('panda/src/cocoadisplay')
 elif GetTarget() == 'android':
     CopyAllHeaders('panda/src/android')
@@ -4875,26 +4869,6 @@ if (GetTarget() == 'darwin' and PkgSkip("COCOA")==0 and PkgSkip("GL")==0 and not
   TargetAdd('libpandagl.dll', input=COMMON_PANDA_LIBS)
   TargetAdd('libpandagl.dll', opts=['MODULE', 'GL', 'NVIDIACG', 'CGGL', 'COCOA', 'CARBON'])
 
-#
-# DIRECTORY: panda/src/osxdisplay/
-#
-
-elif (GetTarget() == 'darwin' and PkgSkip("CARBON")==0 and PkgSkip("GL")==0 and not RUNTIME):
-  OPTS=['DIR:panda/src/osxdisplay', 'BUILDING:PANDAGL',  'GL', 'NVIDIACG', 'CGGL']
-  TargetAdd('p3osxdisplay_composite1.obj', opts=OPTS, input='p3osxdisplay_composite1.cxx')
-  TargetAdd('p3osxdisplay_osxGraphicsWindow.obj', opts=OPTS, input='osxGraphicsWindow.mm')
-  OPTS=['DIR:panda/metalibs/pandagl', 'BUILDING:PANDAGL',  'GL', 'NVIDIACG', 'CGGL']
-  TargetAdd('pandagl_pandagl.obj', opts=OPTS, input='pandagl.cxx')
-  TargetAdd('libpandagl.dll', input='pandagl_pandagl.obj')
-  TargetAdd('libpandagl.dll', input='p3glgsg_config_glgsg.obj')
-  TargetAdd('libpandagl.dll', input='p3glgsg_glgsg.obj')
-  TargetAdd('libpandagl.dll', input='p3osxdisplay_composite1.obj')
-  TargetAdd('libpandagl.dll', input='p3osxdisplay_osxGraphicsWindow.obj')
-  if (PkgSkip('PANDAFX')==0):
-    TargetAdd('libpandagl.dll', input='libpandafx.dll')
-  TargetAdd('libpandagl.dll', input=COMMON_PANDA_LIBS)
-  TargetAdd('libpandagl.dll', opts=['MODULE', 'GL', 'NVIDIACG', 'CGGL', 'CARBON', 'AGL', 'COCOA'])
-
 #
 # DIRECTORY: panda/src/wgldisplay/
 #
@@ -5247,14 +5221,10 @@ if (not RUNTIME and (GetTarget() in ('windows', 'darwin') or PkgSkip("X11")==0)
   TargetAdd('p3tinydisplay_ztriangle_3.obj', opts=OPTS, input='ztriangle_3.cxx')
   TargetAdd('p3tinydisplay_ztriangle_4.obj', opts=OPTS, input='ztriangle_4.cxx')
   TargetAdd('p3tinydisplay_ztriangle_table.obj', opts=OPTS, input='ztriangle_table.cxx')
-  if GetTarget() == 'darwin':
-    TargetAdd('p3tinydisplay_tinyOsxGraphicsWindow.obj', opts=OPTS, input='tinyOsxGraphicsWindow.mm')
-    TargetAdd('libp3tinydisplay.dll', input='p3tinydisplay_tinyOsxGraphicsWindow.obj')
-    TargetAdd('libp3tinydisplay.dll', opts=['CARBON', 'AGL', 'COCOA'])
-  elif GetTarget() == 'windows':
+  if GetTarget() == 'windows':
     TargetAdd('libp3tinydisplay.dll', input='libp3windisplay.dll')
     TargetAdd('libp3tinydisplay.dll', opts=['WINIMM', 'WINGDI', 'WINKERNEL', 'WINOLDNAMES', 'WINUSER', 'WINMM'])
-  else:
+  elif GetTarget() != 'darwin':
     TargetAdd('libp3tinydisplay.dll', input='p3x11display_composite1.obj')
     TargetAdd('libp3tinydisplay.dll', opts=['X11'])
   TargetAdd('libp3tinydisplay.dll', input='p3tinydisplay_composite1.obj')

+ 0 - 19
makepanda/makepanda.vcproj

@@ -1619,7 +1619,6 @@
 				<File RelativePath="..\panda\src\tinydisplay\zmath.cxx"></File>
 				<File RelativePath="..\panda\src\tinydisplay\zdither.cxx"></File>
 				<File RelativePath="..\panda\src\tinydisplay\zbuffer.cxx"></File>
-				<File RelativePath="..\panda\src\tinydisplay\tinyOsxGraphicsPipe.cxx"></File>
 				<File RelativePath="..\panda\src\tinydisplay\tinydisplay_composite2.cxx"></File>
 				<File RelativePath="..\panda\src\tinydisplay\tinySDLGraphicsWindow.I"></File>
 				<File RelativePath="..\panda\src\tinydisplay\tinyOffscreenGraphicsPipe.cxx"></File>
@@ -1627,13 +1626,11 @@
 				<File RelativePath="..\panda\src\tinydisplay\tinyOffscreenGraphicsPipe.I"></File>
 				<File RelativePath="..\panda\src\tinydisplay\tinyWinGraphicsWindow.h"></File>
 				<File RelativePath="..\panda\src\tinydisplay\image_util.cxx"></File>
-				<File RelativePath="..\panda\src\tinydisplay\tinyOsxGraphicsPipe.I"></File>
 				<File RelativePath="..\panda\src\tinydisplay\tinyGeomMunger.h"></File>
 				<File RelativePath="..\panda\src\tinydisplay\tinyGeomMunger.cxx"></File>
 				<File RelativePath="..\panda\src\tinydisplay\tinyWinGraphicsPipe.cxx"></File>
 				<File RelativePath="..\panda\src\tinydisplay\td_texture.cxx"></File>
 				<File RelativePath="..\panda\src\tinydisplay\tinyWinGraphicsWindow.cxx"></File>
-				<File RelativePath="..\panda\src\tinydisplay\tinyOsxGraphicsWindow.h"></File>
 				<File RelativePath="..\panda\src\tinydisplay\config_tinydisplay.cxx"></File>
 				<File RelativePath="..\panda\src\tinydisplay\tinySDLGraphicsPipe.h"></File>
 				<File RelativePath="..\panda\src\tinydisplay\ztriangle_code_3.h"></File>
@@ -1675,12 +1672,10 @@
 				<File RelativePath="..\panda\src\tinydisplay\ztriangle_code_1.h"></File>
 				<File RelativePath="..\panda\src\tinydisplay\tinyXGraphicsWindow.h"></File>
 				<File RelativePath="..\panda\src\tinydisplay\ztriangle_2.cxx"></File>
-				<File RelativePath="..\panda\src\tinydisplay\tinyOsxGraphicsWindow.I"></File>
 				<File RelativePath="..\panda\src\tinydisplay\ztriangle_3.cxx"></File>
 				<File RelativePath="..\panda\src\tinydisplay\init.cxx"></File>
 				<File RelativePath="..\panda\src\tinydisplay\zbuffer.h"></File>
 				<File RelativePath="..\panda\src\tinydisplay\vertex.cxx"></File>
-				<File RelativePath="..\panda\src\tinydisplay\tinyOsxGraphicsPipe.h"></File>
 				<File RelativePath="..\panda\src\tinydisplay\tinyWinGraphicsWindow.I"></File>
 				<File RelativePath="..\panda\src\tinydisplay\tinyGraphicsStateGuardian.cxx"></File>
 				<File RelativePath="..\panda\src\tinydisplay\tinyXGraphicsPipe.h"></File>
@@ -3506,20 +3501,6 @@
 				<File RelativePath="..\panda\src\physx\physxConvexShapeDesc.I"></File>
 				<File RelativePath="..\panda\src\physx\physxMaterialDesc.h"></File>
 			</Filter>
-			<Filter Name="osxdisplay">
-				<File RelativePath="..\panda\src\osxdisplay\osxGraphicsBuffer.h"></File>
-				<File RelativePath="..\panda\src\osxdisplay\osxGraphicsWindow.I"></File>
-				<File RelativePath="..\panda\src\osxdisplay\osxGraphicsPipe.cxx"></File>
-				<File RelativePath="..\panda\src\osxdisplay\osxGraphicsBuffer.cxx"></File>
-				<File RelativePath="..\panda\src\osxdisplay\config_osxdisplay.h"></File>
-				<File RelativePath="..\panda\src\osxdisplay\resize_box.rgb.c"></File>
-				<File RelativePath="..\panda\src\osxdisplay\osxGraphicsStateGuardian.h"></File>
-				<File RelativePath="..\panda\src\osxdisplay\osxGraphicsWindow.h"></File>
-				<File RelativePath="..\panda\src\osxdisplay\config_osxdisplay.cxx"></File>
-				<File RelativePath="..\panda\src\osxdisplay\osxGraphicsPipe.h"></File>
-				<File RelativePath="..\panda\src\osxdisplay\osxdisplay_composite1.cxx"></File>
-				<File RelativePath="..\panda\src\osxdisplay\osxGraphicsStateGuardian.cxx"></File>
-			</Filter>
 			<Filter Name="net">
 				<File RelativePath="..\panda\src\net\queuedConnectionReader.cxx"></File>
 				<File RelativePath="..\panda\src\net\datagramGeneratorNet.I"></File>

+ 2 - 9
panda/metalibs/pandagl/pandagl.cxx

@@ -16,9 +16,6 @@
 #if defined(HAVE_COCOA)
 #include "config_cocoadisplay.h"
 #include "cocoaGraphicsPipe.h"
-#elif defined(HAVE_CARBON)
-#include "config_osxdisplay.h"
-#include "osxGraphicsPipe.h"
 #endif
 
 #ifdef HAVE_GLX
@@ -26,8 +23,8 @@
 #include "glxGraphicsPipe.h"
 #endif
 
-#if !defined(HAVE_WGL) && !defined(HAVE_COCOA) && !defined(HAVE_CARBON) && !defined(HAVE_GLX)
-#error One of HAVE_WGL, HAVE_COCOA, HAVE_CARBON or HAVE_GLX must be defined when compiling pandagl!
+#if !defined(HAVE_WGL) && !defined(HAVE_COCOA) && !defined(HAVE_GLX)
+#error One of HAVE_WGL, HAVE_COCOA or HAVE_GLX must be defined when compiling pandagl!
 #endif
 
 /**
@@ -46,8 +43,6 @@ init_libpandagl() {
 
 #if defined(HAVE_COCOA)
   init_libcocoadisplay();
-#elif defined(HAVE_CARBON)
-  init_libosxdisplay();
 #endif
 
 #ifdef IS_LINUX
@@ -67,8 +62,6 @@ get_pipe_type_pandagl() {
 
 #if defined(HAVE_COCOA)
   return CocoaGraphicsPipe::get_class_type().get_index();
-#elif defined(HAVE_CARBON)
-  return osxGraphicsPipe::get_class_type().get_index();
 #endif
 
 #ifdef HAVE_GLX

+ 0 - 87
panda/src/osxdisplay/config_osxdisplay.cxx

@@ -1,87 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file config_osxdisplay.cxx
- */
-
-#include "config_osxdisplay.h"
-#include "osxGraphicsBuffer.h"
-#include "osxGraphicsPipe.h"
-#include "osxGraphicsStateGuardian.h"
-#include "osxGraphicsWindow.h"
-
-#include "graphicsPipeSelection.h"
-#include "dconfig.h"
-#include "pandaSystem.h"
-
-
-#if !defined(CPPPARSER) && !defined(LINK_ALL_STATIC) && !defined(BUILDING_PANDA_OSXDISPLAY)
-  #error Buildsystem error: BUILDING_PANDA_OSXDISPLAY not defined
-#endif
-
-Configure(config_osxdisplay);
-
-NotifyCategoryDef(osxdisplay, "display");
-
-ConfigureFn(config_osxdisplay) {
-  init_libosxdisplay();
-}
-
-ConfigVariableBool show_resize_box
-("show-resize-box", true,
- PRC_DESC("When this variable is true, then resizable OSX Panda windows will "
-          "be rendered with a resize control in the lower-right corner.  "
-          "This is specially handled by Panda, since otherwise the 3-d "
-          "window would completely hide any resize control drawn by the "
-          "OS.  Set this variable false to allow this control to be hidden."));
-
-ConfigVariableBool osx_support_gl_buffer
-("osx-support-gl-buffer", true,
- PRC_DESC("Set this true to support use of GLBuffers on OSX.  When true, there is a risk of "
-          "a program crash due to buggy driver support for GLBuffers.  "
-          "If this is false, offscreen buffers will be created as "
-          "AGLPbuffers, which are less powerful, and appear to have their "
-          "own set of problems."));
-
-ConfigVariableBool osx_disable_event_loop
-("osx-disable-event-loop", false,
- PRC_DESC("Set this true to disable the window event loop for the Panda "
-          "windows.  This makes sense only in a publish environment where "
-          "the window event loop is already handled by another part of the "
-          "app."));
-
-ConfigVariableInt osx_mouse_wheel_scale
-("osx-mouse-wheel-scale", 1,
- PRC_DESC("Specify the number of units to spin the Mac mouse wheel to "
-          "represent a single wheel_up or wheel_down message."));
-
-/**
- * Initializes the library.  This must be called at least once before any of
- * the functions or classes in this library can be used.  Normally it will be
- * called by the static initializers and need not be called explicitly, but
- * special cases exist.
- */
-void
-init_libosxdisplay() {
-  static bool initialized = false;
-  if (initialized) {
-    return;
-  }
-  initialized = true;
-
-  osxGraphicsBuffer::init_type();
-  osxGraphicsPipe::init_type();
-  osxGraphicsWindow::init_type();
-  osxGraphicsStateGuardian::init_type();
-
-  GraphicsPipeSelection *selection = GraphicsPipeSelection::get_global_ptr();
-  selection->add_pipe_type(osxGraphicsPipe::get_class_type(), osxGraphicsPipe::pipe_constructor);
-
-  PandaSystem *ps = PandaSystem::get_global_ptr();
-  ps->set_system_tag("OpenGL", "window_system", "OSX");
-}

+ 0 - 29
panda/src/osxdisplay/config_osxdisplay.h

@@ -1,29 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file config_osxdisplay.h
- */
-
-#ifndef __CONFIG_OSXDISPLAY_H__
-#define __CONFIG_OSXDISPLAY_H__
-
-#include "pandabase.h"
-#include "notifyCategoryProxy.h"
-#include "configVariableBool.h"
-#include "configVariableInt.h"
-
-NotifyCategoryDecl( osxdisplay , EXPCL_PANDA_OSXDISPLAY, EXPTP_PANDA_OSXDISPLAY);
-
-extern EXPCL_PANDA_OSXDISPLAY void init_libosxdisplay();
-
-extern ConfigVariableBool show_resize_box;
-extern ConfigVariableBool osx_support_gl_buffer;
-extern ConfigVariableBool osx_disable_event_loop;
-extern ConfigVariableInt osx_mouse_wheel_scale;
-
-#endif /* __CONFIG_OSXDISPLAY_H__ */

+ 0 - 200
panda/src/osxdisplay/osxGraphicsBuffer.cxx

@@ -1,200 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file osxGraphicsBuffer.cxx
- */
-
-#include "osxGraphicsBuffer.h"
-#include "osxGraphicsStateGuardian.h"
-#include "config_osxdisplay.h"
-#include "osxGraphicsPipe.h"
-
-#include "graphicsPipe.h"
-#include "glgsg.h"
-#include "pStatTimer.h"
-
-TypeHandle osxGraphicsBuffer::_type_handle;
-
-/**
- *
- */
-osxGraphicsBuffer::
-osxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe,
-                  const std::string &name,
-                  const FrameBufferProperties &fb_prop,
-                  const WindowProperties &win_prop,
-                  int flags,
-                  GraphicsStateGuardian *gsg,
-                  GraphicsOutput *host) :
-  GraphicsBuffer(engine, pipe, name, fb_prop, win_prop, flags, gsg, host)
-{
-  osxGraphicsPipe *osx_pipe;
-  DCAST_INTO_V(osx_pipe, _pipe);
-
-  _pbuffer = nullptr;
-
-  // Since the pbuffer never gets flipped, we get screenshots from the same
-  // buffer we draw into.
-  _screenshot_buffer_type = _draw_buffer_type;
-}
-
-/**
- *
- */
-osxGraphicsBuffer::
-~osxGraphicsBuffer() {
-  nassertv(_pbuffer == nullptr);
-}
-
-/**
- * This function will be called within the draw thread before beginning
- * rendering for a given frame.  It should do whatever setup is required, and
- * return true if the frame should be rendered, or false if it should be
- * skipped.
- */
-bool osxGraphicsBuffer::
-begin_frame(FrameMode mode, Thread *current_thread) {
-  PStatTimer timer(_make_current_pcollector);
-
-  begin_frame_spam(mode);
-  if (_gsg == nullptr) {
-    return false;
-  }
-  nassertr(_pbuffer != nullptr, false);
-
-  osxGraphicsStateGuardian *osxgsg;
-  DCAST_INTO_R(osxgsg, _gsg, false);
-  if (!aglSetPBuffer(osxgsg->get_context(), _pbuffer, 0, 0, 0)) {
-    report_agl_error("aglSetPBuffer");
-    return false;
-  }
-
-  if (!aglSetCurrentContext(osxgsg->get_context())) {
-    report_agl_error("aglSetCurrentContext");
-    return false;
-  }
-
-  osxgsg->reset_if_new();
-
-  if (mode == FM_render) {
-    CDLockedReader cdata(_cycler);
-    for (size_t i = 0; i != cdata->_textures.size(); ++i) {
-      const RenderTexture &rt = cdata->_textures[i];
-      RenderTextureMode rtm_mode = rt._rtm_mode;
-      if (rtm_mode == RTM_bind_or_copy) {
-        CDWriter cdataw(_cycler, cdata, false);
-        nassertr(cdata->_textures.size() == cdataw->_textures.size(), false);
-        cdataw->_textures[i]._rtm_mode = RTM_copy_texture;
-      }
-    }
-    clear_cube_map_selection();
-  }
-  _gsg->set_current_properties(&get_fb_properties());
-  return _gsg->begin_frame(current_thread);
-}
-
-/**
- * This function will be called within the draw thread after rendering is
- * completed for a given frame.  It should do whatever finalization is
- * required.
- */
-void osxGraphicsBuffer::
-end_frame(FrameMode mode, Thread *current_thread) {
-  end_frame_spam(mode);
-  nassertv(_gsg != nullptr);
-
-  if (mode == FM_render) {
-    copy_to_textures();
-  }
-
-  _gsg->end_frame(current_thread);
-
-  if (mode == FM_render) {
-    trigger_flip();
-    clear_cube_map_selection();
-  }
-}
-
-/**
- * Closes the buffer right now.  Called from the window thread.
- */
-void osxGraphicsBuffer::
-close_buffer() {
-  if (_gsg != nullptr) {
-    // aglSetPBuffer(osxgsg->get_context(), _pbuffer, 0, 0, 0);
-    _gsg.clear();
-  }
-  if (_pbuffer != nullptr) {
-    aglDestroyPBuffer(_pbuffer);
-    _pbuffer = nullptr;
-  }
-  _is_valid = false;
-}
-
-/**
- * Opens the buffer right now.  Called from the window thread.  Returns true
- * if the buffer is successfully opened, or false if there was a problem.
- */
-bool osxGraphicsBuffer::
-open_buffer() {
-  if (_gsg == 0) {
-    _gsg = new osxGraphicsStateGuardian(_engine, _pipe, nullptr);
-  }
-
-  if (_pbuffer == nullptr) {
-    GLenum target = GL_TEXTURE_RECTANGLE_ARB;
-    if (_size[0] == Texture::up_to_power_2(_size[0]) &&
-        _size[1] == Texture::up_to_power_2(_size[1])) {
-      // It's a power-of-two size, so we can use GL_TEXTURE_2D as the target.
-      // Dunno, but maybe this will be more likely to work on some hardware.
-      target = GL_TEXTURE_2D;
-    }
-    if (!aglCreatePBuffer(_size.get_x(), _size.get_y(), target, GL_RGBA, 0, &_pbuffer)) {
-      report_agl_error("aglCreatePBuffer");
-      close_buffer();
-      return false;
-    }
-  }
-
-  osxGraphicsStateGuardian *osxgsg;
-  DCAST_INTO_R(osxgsg, _gsg, false);
-
-  OSStatus stat = osxgsg->build_gl(false, true, _fb_properties);
-  if (stat != noErr) {
-    return false;
-  }
-
-  if (!aglSetPBuffer(osxgsg->get_context(), _pbuffer, 0, 0, 0)) {
-    report_agl_error("aglSetPBuffer");
-    close_buffer();
-    return false;
-  }
-
-  if (!aglSetCurrentContext(osxgsg->get_context())) {
-    report_agl_error("aglSetCurrentContext");
-    return false;
-  }
-
-  osxgsg->reset_if_new();
-  if (!osxgsg->is_valid()) {
-    close_buffer();
-    return false;
-  }
-
-  /*
-  if (!osxgsg->get_fb_properties().verify_hardware_software
-      (_fb_properties, osxgsg->get_gl_renderer())) {
-    close_buffer();
-    return false;
-  }
-  _fb_properties = osxgsg->get_fb_properties();
-  */
-
-  _is_valid = true;
-  return true;
-}

+ 0 - 69
panda/src/osxdisplay/osxGraphicsBuffer.h

@@ -1,69 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file osxGraphicsBuffer.h
- */
-
-#ifndef OSXGRAPHICSBUFFER_H
-#define OSXGRAPHICSBUFFER_H
-#include <Carbon/Carbon.h>
-
-#define __glext_h_
-#include <OpenGL/gl.h>
-#include <AGL/agl.h>
-
-#include "pandabase.h"
-#include "graphicsBuffer.h"
-#include "glgsg.h"
-
-/**
- * An offscreen buffer in the OSX environment.  This creates an AGLPbuffer.
- */
-class osxGraphicsBuffer : public GraphicsBuffer {
-public:
-  osxGraphicsBuffer(GraphicsEngine *engine, GraphicsPipe *pipe,
-                    const std::string &name,
-                    const FrameBufferProperties &fb_prop,
-                    const WindowProperties &win_prop,
-                    int flags,
-                    GraphicsStateGuardian *gsg,
-                    GraphicsOutput *host);
-  virtual ~osxGraphicsBuffer();
-
-  virtual bool begin_frame(FrameMode mode, Thread *current_thread);
-  virtual void end_frame(FrameMode mode, Thread *current_thread);
-
-protected:
-  virtual void close_buffer();
-  virtual bool open_buffer();
-
-private:
-  AGLPbuffer _pbuffer;
-
-public:
-  static TypeHandle get_class_type() {
-    return _type_handle;
-  }
-  static void init_type() {
-    GraphicsBuffer::init_type();
-    register_type(_type_handle, "osxGraphicsBuffer",
-                  GraphicsBuffer::get_class_type());
-  }
-  virtual TypeHandle get_type() const {
-    return get_class_type();
-  }
-  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
-  static TypeHandle _type_handle;
-
-  friend class osxGraphicsStateGuardian;
-};
-
-
-#endif

+ 0 - 451
panda/src/osxdisplay/osxGraphicsPipe.cxx

@@ -1,451 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file osxGraphicsPipe.cxx
- */
-
-#include "osxGraphicsPipe.h"
-#include "config_osxdisplay.h"
-#include "osxGraphicsWindow.h"
-#include "osxGraphicsBuffer.h"
-#include "osxGraphicsStateGuardian.h"
-#include "pnmImage.h"
-#include "subprocessWindow.h"
-#include "nativeWindowHandle.h"
-#include "displayInformation.h"
-#import <Carbon/Carbon.h>
-
-// some macros to make code more readable.
-#define GetModeWidth(mode) GetDictionaryLong((mode), kCGDisplayWidth)
-#define GetModeHeight(mode) GetDictionaryLong((mode), kCGDisplayHeight)
-#define GetModeRefreshRate(mode) GetDictionaryLong((mode), kCGDisplayRefreshRate)
-#define GetModeBitsPerPixel(mode) GetDictionaryLong((mode), kCGDisplayBitsPerPixel)
-#define GetModeSafeForHardware(mode) GetDictionaryBoolean((mode), kCGDisplayModeIsSafeForHardware)
-#define GetModeStretched(mode) GetDictionaryBoolean((mode), kCGDisplayModeIsStretched)
-#define MAX_DISPLAYS 32
-
-Boolean GetDictionaryBoolean(CFDictionaryRef theDict, const void* key) {
-  // get a boolean from the dictionary
-  Boolean value = false;
-  CFBooleanRef boolRef;
-  boolRef = (CFBooleanRef)CFDictionaryGetValue(theDict, key);
-  if (boolRef != nullptr)
-    value = CFBooleanGetValue(boolRef);
-  return value;
-}
-
-long GetDictionaryLong(CFDictionaryRef theDict, const void* key) {
-  // get a long from the dictionary
-  long value = 0;
-  CFNumberRef numRef;
-  numRef = (CFNumberRef)CFDictionaryGetValue(theDict, key);
-  if (numRef != nullptr)
-    CFNumberGetValue(numRef, kCFNumberLongType, &value);
-  return value;
-}
-
-static CFComparisonResult CompareModes (const void *val1,const void *val2,void *context) {
-  // CFArray comparison callback for sorting display modes.
-#pragma unused(context)
-  CFDictionaryRef thisMode = (CFDictionaryRef)val1;
-  CFDictionaryRef otherMode = (CFDictionaryRef)val2;
-
-  long width = GetModeWidth(thisMode);
-  long otherWidth = GetModeWidth(otherMode);
-  long height = GetModeHeight(thisMode);
-  long otherHeight = GetModeHeight(otherMode);
-
-  // sort modes in screen size order
-  if (width * height < otherWidth * otherHeight) {
-    return kCFCompareLessThan;
-  } else if (width * height > otherWidth * otherHeight) {
-    return kCFCompareGreaterThan;
-  }
-
-  // sort modes by bits per pixel
-  long bitsPerPixel = GetModeBitsPerPixel(thisMode);
-  long otherBitsPerPixel = GetModeBitsPerPixel(otherMode);
-  if (bitsPerPixel < otherBitsPerPixel) {
-    return kCFCompareLessThan;
-  } else if (bitsPerPixel > otherBitsPerPixel) {
-    return kCFCompareGreaterThan;
-  }
-
-  // sort modes by refresh rate.
-  long refreshRate = GetModeRefreshRate(thisMode);
-  long otherRefreshRate = GetModeRefreshRate(otherMode);
-  if (refreshRate < otherRefreshRate) {
-    return kCFCompareLessThan;
-  } else if (refreshRate > otherRefreshRate) {
-    return kCFCompareGreaterThan;
-  }
-
-  return kCFCompareEqualTo;
-}
-
-CFArrayRef GSCGDisplayAvailableModesUsefulForOpenGL(CGDirectDisplayID display) {
-  // get a list of all possible display modes for this system.
-  CFArrayRef availableModes = CGDisplayAvailableModes(display);
-  unsigned int numberOfAvailableModes = CFArrayGetCount(availableModes);
-
-  // creat mutable array to hold the display modes we are interested int.
-  CFMutableArrayRef usefulModes = CFArrayCreateMutable(kCFAllocatorDefault, numberOfAvailableModes, nullptr);
-
-  // get the current bits per pixel.
-  long currentModeBitsPerPixel = GetModeBitsPerPixel(CGDisplayCurrentMode(display));
-
-  unsigned int i;
-  for (i= 0; i<numberOfAvailableModes; ++i) {
-    // look at each mode in the available list
-    CFDictionaryRef mode = (CFDictionaryRef)CFArrayGetValueAtIndex(availableModes, i);
-
-    // we are only interested in modes with the same bits per pixel as
-    // current.  to allow for switching from fullscreen to windowed modes.
-    // that are safe for this hardward that are not stretched.
-    long bitsPerPixel = GetModeBitsPerPixel(mode);
-    Boolean safeForHardware = GetModeSafeForHardware(mode);
-    Boolean stretched = GetModeStretched(mode);
-
-    if ((bitsPerPixel != currentModeBitsPerPixel) || (!safeForHardware) || (stretched)) {
-      continue; // skip this mode
-    }
-
-    long width = GetModeWidth(mode);
-    long height = GetModeHeight(mode);
-    long refreshRate = GetModeRefreshRate(mode);
-    Boolean replaced = false;
-    Boolean skipped = false;
-
-    // now check to see if we already added a mode like this one.  we want the
-    // highest refresh rate for this widthheight
-    unsigned int j;
-    unsigned int currentNumberOfUsefulModes =  CFArrayGetCount(usefulModes);
-    for (j = 0; j < currentNumberOfUsefulModes; ++j) {
-      CFDictionaryRef otherMode = (CFDictionaryRef)CFArrayGetValueAtIndex(usefulModes, j);
-      long otherWidth = GetModeWidth(otherMode);
-      long otherHeight = GetModeHeight(otherMode);
-      if ((otherWidth == width) && (otherHeight == height)) {
-        long otherRefreshRate = GetModeRefreshRate(otherMode);
-        if (otherRefreshRate < refreshRate) {
-          // replace lower refresh rate.
-          const void* value = mode;
-          CFArrayReplaceValues(usefulModes, CFRangeMake(j ,1), &value, 1);
-          replaced = true;
-          break;
-        }
-        else if (otherRefreshRate > refreshRate) {
-          skipped = true;
-          break;
-        }
-      }
-    }
-    // this is a useful mode so add it to the array.
-    if (!replaced && !skipped) {
-      CFArrayAppendValue(usefulModes, mode);
-    }
-  }
-  // now sort the useful mode array, using the comparison callback.
-  CFArraySortValues( usefulModes,
-    CFRangeMake(0, CFArrayGetCount(usefulModes)),
-    (CFComparatorFunction) CompareModes, nullptr);
-  // return the CFArray of the useful display modes.
-  return usefulModes;
-}
-
-TypeHandle osxGraphicsPipe::_type_handle;
-
-/**
- *
- */
-osxGraphicsPipe::
-osxGraphicsPipe() {
-  CGRect display_bounds = CGDisplayBounds(kCGDirectMainDisplay);
-  _display_width = CGRectGetWidth(display_bounds);
-  _display_height = CGRectGetHeight(display_bounds);
-
-  CGDirectDisplayID display, displayArray[MAX_DISPLAYS] ;
-  CGDisplayCount numDisplays;
-  CFDictionaryRef displayMode;
-  CFArrayRef displayModeArray;
-  int number, i;
-  CGGetActiveDisplayList (MAX_DISPLAYS, displayArray, &numDisplays);
-  display = displayArray [numDisplays - 1];
-  displayModeArray = GSCGDisplayAvailableModesUsefulForOpenGL( display );
-  number = CFArrayGetCount( displayModeArray );
-  DisplayMode *displays = new DisplayMode[ number ];
-  for(i = 0; i < number; i++) {
-     displayMode = (CFDictionaryRef) CFArrayGetValueAtIndex (displayModeArray, i);
-     _display_information -> _total_display_modes++;
-     displays[i].width = (signed int)GetModeWidth (displayMode);
-     displays[i].height = (signed int)GetModeHeight (displayMode);
-     displays[i].bits_per_pixel = (signed int)GetModeBitsPerPixel (displayMode);
-     displays[i].refresh_rate = (signed int)GetModeRefreshRate (displayMode);
-  }
-  _display_information -> _display_mode_array = displays;
-}
-
-/**
- *
- */
-osxGraphicsPipe::
-~osxGraphicsPipe() {
-}
-
-/**
- * Returns the name of the rendering interface associated with this
- * GraphicsPipe.  This is used to present to the user to allow him/her to
- * choose between several possible GraphicsPipes available on a particular
- * platform, so the name should be meaningful and unique for a given platform.
- */
-std::string osxGraphicsPipe::
-get_interface_name() const {
-  return "OpenGL";
-}
-
-/**
- * This function is passed to the GraphicsPipeSelection object to allow the
- * user to make a default osxGraphicsPipe.
- */
-PT(GraphicsPipe) osxGraphicsPipe::
-pipe_constructor() {
-  return new osxGraphicsPipe;
-}
-
-/**
- * Returns an indication of the thread in which this GraphicsPipe requires its
- * window processing to be performed: typically either the app thread (e.g.
- * X) or the draw thread (Windows).
- */
-GraphicsPipe::PreferredWindowThread
-osxGraphicsPipe::get_preferred_window_thread() const {
-  return PWT_app;
-}
-
-/**
- * Creates a new Quartz bitmap image with the data in the indicated PNMImage.
- * The caller should eventually free this image via CGImageRelease.
- */
-CGImageRef osxGraphicsPipe::
-create_cg_image(const PNMImage &pnm_image) {
-  size_t width = pnm_image.get_x_size();
-  size_t height = pnm_image.get_y_size();
-
-#ifdef PGM_BIGGRAYS
-  size_t bytes_per_component = 2;
-#else
-  size_t bytes_per_component = 1;
-#endif
-  size_t bits_per_component = bytes_per_component * 8;
-  size_t num_components = pnm_image.get_num_channels();
-
-  size_t bits_per_pixel = num_components * bits_per_component;
-  size_t bytes_per_row = num_components * bytes_per_component * width;
-
-  size_t num_bytes = bytes_per_row * height;
-  bool has_alpha;
-  bool is_grayscale;
-
-  CFStringRef color_space_name = nullptr;
-  switch (pnm_image.get_color_type()) {
-  case PNMImage::CT_grayscale:
-    color_space_name = kCGColorSpaceGenericGray;
-    has_alpha = false;
-    is_grayscale = true;
-    break;
-
-  case PNMImage::CT_two_channel:
-    color_space_name = kCGColorSpaceGenericGray;
-    has_alpha = true;
-    is_grayscale = true;
-    break;
-
-  case PNMImage::CT_color:
-    color_space_name = kCGColorSpaceGenericRGB;
-    has_alpha = false;
-    is_grayscale = false;
-    break;
-
-  case PNMImage::CT_four_channel:
-    color_space_name = kCGColorSpaceGenericRGB;
-    has_alpha = true;
-    is_grayscale = false;
-    break;
-
-  case PNMImage::CT_invalid:
-    // Shouldn't get here.
-    nassertr(false, nullptr);
-    break;
-  }
-  nassertr(color_space_name != nullptr, nullptr);
-
-  CGColorSpaceRef color_space = CGColorSpaceCreateWithName(color_space_name);
-  nassertr(color_space != nullptr, nullptr);
-
-  CGBitmapInfo bitmap_info = 0;
-#ifdef PGM_BIGGRAYS
-  bitmap_info |= kCGBitmapByteOrder16Host;
-#endif
-  if (has_alpha) {
-    bitmap_info |= kCGImageAlphaLast;
-  }
-
-  // Now convert the pixel data to a format friendly to CGImageCreate().
-  char *char_array = (char *)PANDA_MALLOC_ARRAY(num_bytes);
-
-  xelval *dp = (xelval *)char_array;
-  for (size_t yi = 0; yi < height; ++yi) {
-    for (size_t xi = 0; xi < width; ++xi) {
-      if (is_grayscale) {
-        *dp++ = (xelval)(pnm_image.get_gray(xi, yi) * PGM_MAXMAXVAL);
-      } else {
-        *dp++ = (xelval)(pnm_image.get_red(xi, yi) * PGM_MAXMAXVAL);
-        *dp++ = (xelval)(pnm_image.get_green(xi, yi) * PGM_MAXMAXVAL);
-        *dp++ = (xelval)(pnm_image.get_blue(xi, yi) * PGM_MAXMAXVAL);
-      }
-      if (has_alpha) {
-        *dp++ = (xelval)(pnm_image.get_alpha(xi, yi) * PGM_MAXMAXVAL);
-      }
-    }
-  }
-  nassertr((void *)dp == (void *)(char_array + num_bytes), nullptr);
-
-  CGDataProviderRef provider =
-    CGDataProviderCreateWithData(nullptr, char_array, num_bytes, release_data);
-  nassertr(provider != nullptr, nullptr);
-
-  CGImageRef image = CGImageCreate
-    (width, height, bits_per_component, bits_per_pixel, bytes_per_row,
-     color_space, bitmap_info, provider,
-     nullptr, false, kCGRenderingIntentDefault);
-  nassertr(image != nullptr, nullptr);
-
-  CGColorSpaceRelease(color_space);
-  CGDataProviderRelease(provider);
-
-  return image;
-}
-
-/**
- * This callback is assigned to delete the data array allocated within
- * create_cg_image().
- */
-void osxGraphicsPipe::
-release_data(void *info, const void *data, size_t size) {
-  char *char_array = (char *)data;
-  PANDA_FREE_ARRAY(char_array);
-}
-
-/**
- * Creates a new window on the pipe, if possible.
- */
-PT(GraphicsOutput) osxGraphicsPipe::
-make_output(const std::string &name,
-            const FrameBufferProperties &fb_prop,
-            const WindowProperties &win_prop,
-            int flags,
-            GraphicsEngine *engine,
-            GraphicsStateGuardian *gsg,
-            GraphicsOutput *host,
-            int retry,
-            bool &precertify) {
-  if (!_is_valid) {
-    return nullptr;
-  }
-
-  osxGraphicsStateGuardian *osxgsg = 0;
-  if (gsg != 0) {
-    DCAST_INTO_R(osxgsg, gsg, nullptr);
-  }
-
-  // First thing to try: an osxGraphicsWindow
-
-  if (retry == 0) {
-    if (((flags&BF_require_parasite)!=0)||
-        ((flags&BF_refuse_window)!=0)||
-        ((flags&BF_resizeable)!=0)||
-        ((flags&BF_size_track_host)!=0)||
-        ((flags&BF_can_bind_color)!=0)||
-        ((flags&BF_can_bind_every)!=0)||
-        ((flags&BF_can_bind_layered)!=0)) {
-      return nullptr;
-    }
-    WindowHandle *window_handle = win_prop.get_parent_window();
-    if (window_handle != nullptr) {
-      osxdisplay_cat.info()
-        << "Got parent_window " << *window_handle << "\n";
-#ifdef SUPPORT_SUBPROCESS_WINDOW
-      WindowHandle::OSHandle *os_handle = window_handle->get_os_handle();
-      if (os_handle != nullptr &&
-          os_handle->is_of_type(NativeWindowHandle::SubprocessHandle::get_class_type())) {
-        return new SubprocessWindow(engine, this, name, fb_prop, win_prop,
-                                    flags, gsg, host);
-      }
-#endif  // SUPPORT_SUBPROCESS_WINDOW
-    }
-    return new osxGraphicsWindow(engine, this, name, fb_prop, win_prop,
-                                 flags, gsg, host);
-  }
-
-  // Second thing to try: a GLGraphicsBuffer
-
-  if (retry == 1) {
-    if (!osx_support_gl_buffer || !gl_support_fbo || host == nullptr ||
-        (flags & (BF_require_parasite | BF_require_window)) != 0) {
-      return nullptr;
-    }
-    // Early failure - if we are sure that this buffer WONT meet specs, we can
-    // bail out early.
-    if ((flags & BF_fb_props_optional) == 0) {
-      if (fb_prop.get_indexed_color() ||
-          fb_prop.get_back_buffers() > 0 ||
-          fb_prop.get_accum_bits() > 0) {
-        return nullptr;
-      }
-    }
-    if (osxgsg != nullptr && osxgsg->is_valid() && !osxgsg->needs_reset()) {
-      if (!osxgsg->_supports_framebuffer_object ||
-          osxgsg->_glDrawBuffers == nullptr) {
-        return nullptr;
-      } else if (fb_prop.is_basic()) {
-        // Early success - if we are sure that this buffer WILL meet specs, we
-        // can precertify it.
-        precertify = true;
-      }
-    }
-    return new GLGraphicsBuffer(engine, this, name, fb_prop, win_prop, flags, gsg, host);
-  }
-
-  // Third thing to try: an osxGraphicsBuffer
-  if (retry == 2) {
-    if ((!support_render_texture)||
-        ((flags&BF_require_parasite)!=0)||
-        ((flags&BF_require_window)!=0)||
-        ((flags&BF_resizeable)!=0)||
-        ((flags&BF_size_track_host)!=0)||
-        ((flags&BF_can_bind_every)!=0)||
-        ((flags&BF_can_bind_layered)!=0)) {
-      return nullptr;
-    }
-    return new osxGraphicsBuffer(engine, this, name, fb_prop, win_prop,
-                                 flags, gsg, host);
-  }
-
-  // Nothing else left to try.
-  return nullptr;
-}
-
-/**
- * This is called when make_output() is used to create a
- * CallbackGraphicsWindow.  If the GraphicsPipe can construct a GSG that's not
- * associated with any particular window object, do so now, assuming the
- * correct graphics context has been set up externally.
- */
-PT(GraphicsStateGuardian) osxGraphicsPipe::
-make_callback_gsg(GraphicsEngine *engine) {
-  return new osxGraphicsStateGuardian(engine, this, nullptr);
-}

+ 0 - 73
panda/src/osxdisplay/osxGraphicsPipe.h

@@ -1,73 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file osxGraphicsPipe.h
- */
-
-#ifndef OSXGRAPHICSPIPE_H
-#define OSXGRAPHICSPIPE_H
-
-#include "pandabase.h"
-#include "graphicsPipe.h"
-
-#include <Carbon/Carbon.h>
-
-class osxGraphicsStateGuardian;
-class PNMImage;
-
-/**
- * This graphics pipe represents the interface for creating OpenGL graphics
- * windows on the various OSX's.
- */
-class EXPCL_PANDA_OSXDISPLAY osxGraphicsPipe : public GraphicsPipe {
-public:
-  osxGraphicsPipe();
-  virtual ~osxGraphicsPipe();
-
-  virtual std::string get_interface_name() const;
-  static PT(GraphicsPipe) pipe_constructor();
-  virtual PreferredWindowThread get_preferred_window_thread() const;
-
-  static CGImageRef create_cg_image(const PNMImage &pnm_image);
-
-private:
-  static void release_data(void *info, const void *data, size_t size);
-
-protected:
-  virtual PT(GraphicsOutput) make_output(const std::string &name,
-                                         const FrameBufferProperties &fb_prop,
-                                         const WindowProperties &win_prop,
-                                         int flags,
-                                         GraphicsEngine *engine,
-                                         GraphicsStateGuardian *gsg,
-                                         GraphicsOutput *host,
-                                         int retry,
-                                         bool &precertify);
-  virtual PT(GraphicsStateGuardian) make_callback_gsg(GraphicsEngine *engine);
-
-public:
-  static TypeHandle get_class_type() {
-    return _type_handle;
-  }
-  static void init_type() {
-    GraphicsPipe::init_type();
-    register_type(_type_handle, "osxGraphicsPipe",
-                  GraphicsPipe::get_class_type());
-  }
-  virtual TypeHandle get_type() const {
-    return get_class_type();
-  }
-  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
-  static TypeHandle _type_handle;
-
-  friend class osxGraphicsBuffer;
-};
-
-#endif

+ 0 - 459
panda/src/osxdisplay/osxGraphicsStateGuardian.cxx

@@ -1,459 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file osxGraphicsStateGuardian.cxx
- */
-
-#include "osxGraphicsStateGuardian.h"
-#include "osxGraphicsBuffer.h"
-#include "string_utils.h"
-#include "config_osxdisplay.h"
-#include "depthWriteAttrib.h"
-#include "depthTestAttrib.h"
-#include "textureAttrib.h"
-#include "pnmImage.h"
-
-#include <OpenGL/gl.h>
-#import <mach-o/dyld.h>
-
-// This is generated data for the standard texture we use for drawing the
-// resize box in the window corner.
-#include "resize_box.rgb.c"
-
-TypeHandle osxGraphicsStateGuardian::_type_handle;
-
-/**
- * Returns the pointer to the GL extension function with the indicated name.
- * It is the responsibility of the caller to ensure that the required
- * extension is defined in the OpenGL runtime prior to calling this; it is an
- * error to call this for a function that is not defined.
- */
-void *osxGraphicsStateGuardian::
-do_get_extension_func(const char *name) {
-  std::string fullname = "_" + std::string(name);
-  NSSymbol symbol = nullptr;
-
-  if (NSIsSymbolNameDefined(fullname.c_str())) {
-    symbol = NSLookupAndBindSymbol(fullname.c_str());
-  }
-
-  return symbol ? NSAddressOfSymbol(symbol) : nullptr;
-}
-
-/**
- *
- */
-osxGraphicsStateGuardian::
-osxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe,
-                         osxGraphicsStateGuardian *share_with) :
-  GLGraphicsStateGuardian(engine, pipe),
-  _share_with(share_with),
-  _aglPixFmt(nullptr),
-  _aglcontext(nullptr)
-{
-  _shared_buffer = 1011;
-  get_gamma_table();
-}
-
-/**
- *
- */
-osxGraphicsStateGuardian::
-~osxGraphicsStateGuardian() {
-  if (_aglcontext != (AGLContext)nullptr) {
-    aglSetCurrentContext(nullptr);
-    aglDestroyContext(_aglcontext);
-    report_agl_error("aglDestroyContext");
-    _aglcontext = (AGLContext)nullptr;
-  }
-}
-
-/**
- * Resets all internal state as if the gsg were newly created.
- */
-void osxGraphicsStateGuardian::reset()
-{
-/*
-  if(_aglcontext != (AGLContext)NULL)
-  {
-     aglDestroyContext(_aglcontext);
-     report_agl_error();
-     _aglcontext = (AGLContext)NULL;
-  }
-  */
-
-  GLGraphicsStateGuardian::reset();
-
-  if (_aglcontext != (AGLContext)nullptr) {
-    // Apply the video-sync setting.
-    GLint value = sync_video ? 1 : 0;
-    aglSetInteger(_aglcontext, AGL_SWAP_INTERVAL, &value);
-  }
-}
-
-/**
- * Draws an OSX-style resize icon in the bottom right corner of the current
- * display region.  This is normally done automatically at the end of each
- * frame when the window is indicated as resizable, since the 3-D graphics
- * overlay the normal, OS-drawn resize icon and the user won't be able see it.
- */
-void osxGraphicsStateGuardian::
-draw_resize_box() {
-  // This state is created, once, and never freed.
-  static CPT(RenderState) state;
-  if (state == nullptr) {
-    state = RenderState::make(TransparencyAttrib::make(TransparencyAttrib::M_alpha),
-                              DepthWriteAttrib::make(DepthWriteAttrib::M_off),
-                              DepthTestAttrib::make(DepthTestAttrib::M_none));
-
-    // Get the default texture to apply to the resize box; it's compiled into
-    // the code.
-    std::string resize_box_string((const char *)resize_box, resize_box_len);
-    std::istringstream resize_box_strm(resize_box_string);
-    PNMImage resize_box_pnm;
-    if (resize_box_pnm.read(resize_box_strm, "resize_box.rgb")) {
-      PT(Texture) tex = new Texture;
-      tex->set_name("resize_box.rgb");
-      tex->load(resize_box_pnm);
-      tex->set_minfilter(SamplerState::FT_linear);
-      tex->set_magfilter(SamplerState::FT_linear);
-      state = state->add_attrib(TextureAttrib::make(tex));
-    }
-  }
-
-  // Clear out the lens.
-  _projection_mat_inv = _projection_mat = TransformState::make_identity();
-  prepare_lens();
-
-  // Set the state to our specific, known state for drawing the icon.
-  set_state_and_transform(state, TransformState::make_identity());
-
-  // Now determine the inner corner of the quad, choosing a 15x15 pixel square
-  // in the lower-right corner, computed from the viewport size.
-  PN_stdfloat inner_x = 1.0f - (15.0f * 2.0f / _viewport_width);
-  PN_stdfloat inner_y = (15.0f * 2.0f / _viewport_height) - 1.0f;
-
-  // Draw the quad.  We just use the slow, simple immediate mode calls here.
-  // It's just one quad, after all.
-  glBegin(GL_QUADS);
-
-  glColor4f(1.0, 1.0, 1.0, 1.0);
-  glTexCoord2f(0.0, 0.0);
-  glVertex2f(inner_x, -1.0);
-
-  glTexCoord2f(0.9375, 0.0);
-  glVertex2f(1.0, -1.0);
-
-  glTexCoord2f(0.9375, 0.9375);
-  glVertex2f(1.0, inner_y);
-
-  glTexCoord2f(0.0, 0.9375);
-  glVertex2f(inner_x, inner_y);
-
-  glEnd();
-}
-
-/**
- * This function will build up a context for a gsg..
- */
-OSStatus osxGraphicsStateGuardian::
-build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props) {
-  if (_aglcontext) {
-    describe_pixel_format(fb_props);
-    return noErr; // already built
-  }
-
-  OSStatus err = noErr;
-
-  GDHandle display = GetMainDevice();
-
-  pvector<GLint> attrib;
-  if (!fb_props.get_indexed_color()) {
-    attrib.push_back(AGL_RGBA);
-    int color_bits = fb_props.get_color_bits();
-    int alpha_bits = fb_props.get_alpha_bits();
-    attrib.push_back(AGL_BUFFER_SIZE);
-    attrib.push_back(color_bits + alpha_bits);
-    attrib.push_back(AGL_PIXEL_SIZE);
-    attrib.push_back(color_bits);
-    attrib.push_back(AGL_RED_SIZE);
-    attrib.push_back(fb_props.get_red_bits());
-    attrib.push_back(AGL_GREEN_SIZE);
-    attrib.push_back(fb_props.get_green_bits());
-    attrib.push_back(AGL_BLUE_SIZE);
-    attrib.push_back(fb_props.get_blue_bits());
-    attrib.push_back(AGL_ALPHA_SIZE);
-    attrib.push_back(alpha_bits);
-  }
-  attrib.push_back(AGL_DEPTH_SIZE);
-  attrib.push_back(fb_props.get_depth_bits());
-  attrib.push_back(AGL_STENCIL_SIZE);
-  attrib.push_back(fb_props.get_stencil_bits());
-  if (fb_props.get_multisamples() != 0) {
-    attrib.push_back(AGL_MULTISAMPLE);
-    attrib.push_back(AGL_SAMPLE_BUFFERS_ARB);
-    attrib.push_back(1);
-    attrib.push_back(AGL_SAMPLES_ARB);
-    attrib.push_back(fb_props.get_multisamples());
-  }
-
-  if (fb_props.is_stereo()) {
-    attrib.push_back(AGL_STEREO);
-  }
-
-  if (!fb_props.is_single_buffered()) {
-    attrib.push_back(AGL_DOUBLEBUFFER);
-  }
-  if (full_screen) {
-    attrib.push_back(AGL_FULLSCREEN);
-  }
-  if (pbuffer) {
-    attrib.push_back(AGL_PBUFFER);
-  }
-
-  if (fb_props.get_force_hardware()) {
-    attrib.push_back(AGL_ACCELERATED);
-    attrib.push_back(AGL_NO_RECOVERY);
-  }
-
-  // Allow the system to choose the largest buffers requested that meets all
-  // our selections.
-  attrib.push_back(AGL_MAXIMUM_POLICY);
-
-  // Terminate the list.
-  attrib.push_back(AGL_NONE);
-
-  // build context
-  _aglcontext = nullptr;
-  _aglPixFmt = aglChoosePixelFormat(&display, 1, &attrib[0]);
-  err = report_agl_error("aglChoosePixelFormat");
-  if (_aglPixFmt) {
-    if(_share_with == nullptr) {
-      _aglcontext = aglCreateContext(_aglPixFmt, nullptr);
-    } else {
-      _aglcontext = aglCreateContext(_aglPixFmt, ((osxGraphicsStateGuardian *)_share_with)->_aglcontext);
-    }
-    err = report_agl_error("aglCreateContext");
-
-    if (_aglcontext == nullptr) {
-      osxdisplay_cat.error()
-        << "osxGraphicsStateGuardian::build_gl Error Getting GL Context \n" ;
-      if(err == noErr) {
-        err = -1;
-      }
-    } else {
-      aglSetInteger(_aglcontext, AGL_BUFFER_NAME, &_shared_buffer);
-      err = report_agl_error("aglSetInteger AGL_BUFFER_NAME");
-    }
-
-  } else {
-    osxdisplay_cat.error()
-      << "osxGraphicsStateGuardian::build_gl Error Getting Pixel Format\n" ;
-    osxdisplay_cat.error()
-      << fb_props << "\n";
-    if(err == noErr) {
-      err = -1;
-    }
-  }
-
-  if (err == noErr) {
-    describe_pixel_format(fb_props);
-  }
-
-  if (osxdisplay_cat.is_debug()) {
-    osxdisplay_cat.debug()
-      << "osxGraphicsStateGuardian::build_gl Returning :" << err << "\n";
-    osxdisplay_cat.debug()
-      << fb_props << "\n";
-  }
-
-  return err;
-}
-
-
-/**
- * Fills in the fb_props member with the appropriate values according to the
- * chosen pixel format.
- */
-void osxGraphicsStateGuardian::
-describe_pixel_format(FrameBufferProperties &fb_props) {
-  fb_props.clear();
-  GLint value;
-
-  if (aglDescribePixelFormat(_aglPixFmt, AGL_RGBA, &value)) {
-    fb_props.set_indexed_color(!value);
-    fb_props.set_rgb_color(value);
-  }
-  if (aglDescribePixelFormat(_aglPixFmt, AGL_DEPTH_SIZE, &value)) {
-    fb_props.set_depth_bits(value);
-  }
-  int color_bits = 0;
-  if (aglDescribePixelFormat(_aglPixFmt, AGL_RED_SIZE, &value)) {
-    fb_props.set_red_bits(value);
-    color_bits += value;
-  }
-  if (aglDescribePixelFormat(_aglPixFmt, AGL_GREEN_SIZE, &value)) {
-    fb_props.set_green_bits(value);
-    color_bits += value;
-  }
-  if (aglDescribePixelFormat(_aglPixFmt, AGL_BLUE_SIZE, &value)) {
-    fb_props.set_blue_bits(value);
-    color_bits += value;
-  }
-  fb_props.set_color_bits(color_bits);
-  if (aglDescribePixelFormat(_aglPixFmt, AGL_ALPHA_SIZE, &value)) {
-    fb_props.set_alpha_bits(value);
-  }
-
-  if (aglDescribePixelFormat(_aglPixFmt, AGL_STENCIL_SIZE, &value)) {
-    fb_props.set_stencil_bits(value);
-  }
-
-  int accum_bits = 0;
-  if (aglDescribePixelFormat(_aglPixFmt, AGL_ACCUM_RED_SIZE, &value)) {
-    accum_bits += value;
-  }
-  if (aglDescribePixelFormat(_aglPixFmt, AGL_ACCUM_GREEN_SIZE, &value)) {
-    accum_bits += value;
-  }
-  if (aglDescribePixelFormat(_aglPixFmt, AGL_ACCUM_BLUE_SIZE, &value)) {
-    accum_bits += value;
-  }
-
-  if (aglDescribePixelFormat(_aglPixFmt, AGL_SAMPLES_ARB, &value)) {
-    fb_props.set_multisamples(value);
-  }
-
-  if (aglDescribePixelFormat(_aglPixFmt, AGL_DOUBLEBUFFER, &value)) {
-    if (value) {
-      fb_props.set_back_buffers(1);
-    } else {
-      fb_props.set_back_buffers(0);
-    }
-  }
-
-  if (aglDescribePixelFormat(_aglPixFmt, AGL_STEREO, &value)) {
-    fb_props.set_stereo(value);
-  }
-
-  // Until we query the renderer, we don't know whether it's hardware or
-  // software based, so set both flags to indicate we don't know.
-  fb_props.set_force_hardware(true);
-  fb_props.set_force_software(true);
-
-  GLint ndevs;
-  AGLDevice *gdevs = aglDevicesOfPixelFormat(_aglPixFmt, &ndevs);
-  if (gdevs != nullptr) {
-    AGLRendererInfo rinfo = aglQueryRendererInfo(gdevs, ndevs);
-    if (rinfo != nullptr) {
-      if (aglDescribeRenderer(rinfo, AGL_ACCELERATED, &value)) {
-        // Now we know whether it's hardware or software.
-        fb_props.set_force_hardware(value);
-        fb_props.set_force_software(!value);
-      }
-      if (aglDescribeRenderer(rinfo, AGL_VIDEO_MEMORY, &value)) {
-        osxdisplay_cat.debug()
-          << "Reported video memory is " << value << "\n";
-      }
-      if (aglDescribeRenderer(rinfo, AGL_TEXTURE_MEMORY, &value)) {
-        osxdisplay_cat.debug()
-          << "Reported texture memory is " << value << "\n";
-      }
-    }
-  }
-}
-
-/**
- * Static function for getting the orig gamma tables
- */
-bool osxGraphicsStateGuardian::
-get_gamma_table() {
-  CGDisplayRestoreColorSyncSettings();
-  _cgErr = CGGetDisplayTransferByTable( 0, 256, _gOriginalRedTable, _gOriginalGreenTable, _gOriginalBlueTable, &_sampleCount);
-}
-
-/**
- * Static function for setting gamma which is needed for atexit.
- */
-bool osxGraphicsStateGuardian::
-static_set_gamma(bool restore, PN_stdfloat gamma) {
-  bool set;
-
-  set = false;
-
-  if (restore) {
-    CGDisplayRestoreColorSyncSettings();
-    set = true;
-    return set;
-  }
-  // CGDisplayRestoreColorSyncSettings();
-
-  // CGGammaValue gOriginalRedTable[ 256 ]; CGGammaValue gOriginalGreenTable[
-  // 256 ]; CGGammaValue gOriginalBlueTable[ 256 ];
-
-  // CGTableCount sampleCount; CGDisplayErr cgErr;
-
-  // cgErr = CGGetDisplayTransferByTable( 0, 256, _gOriginalRedTable,
-  // _gOriginalGreenTable, _gOriginalBlueTable, &_sampleCount);
-
-  CGGammaValue redTable[ 256 ];
-  CGGammaValue greenTable[ 256 ];
-  CGGammaValue blueTable[ 256 ];
-
-  short j, i;
-  short y[3];
-
-  for (j = 0; j < 3; j++) {
-    y[j] = 255;
-  }
-
-  y[0] = 256 * gamma;
-  y[1] = 256 * gamma;
-  y[2] = 256 * gamma;
-
-  for (i = 0; i < 256; i++) {
-    redTable[i] = _gOriginalRedTable[ i ] * (y[ 0 ] ) / 256;
-    greenTable[ i ] = _gOriginalGreenTable[ i ] * (y[ 1 ] ) / 256;
-    blueTable[ i ] = _gOriginalBlueTable[ i ] * (y[ 2 ] ) / 256;
-  }
-  _cgErr = CGSetDisplayTransferByTable( 0, 256, redTable, greenTable, blueTable);
-
-  if (_cgErr == 0) {
-    set = true;
-  }
-
-  return set;
-}
-
-/**
- * Non static version of setting gamma.  Returns true on success.
- */
-bool osxGraphicsStateGuardian::
-set_gamma(PN_stdfloat gamma) {
-  bool set;
-
-  set = static_set_gamma(false, gamma);
-
-  return set;
-}
-
-/**
- * Restore original gamma.
- */
-void osxGraphicsStateGuardian::
-restore_gamma() {
-  static_set_gamma(true, 1.0f);
-}
-
-/**
- * This function is passed to the atexit function.
- */
-void osxGraphicsStateGuardian::
-atexit_function() {
-  static_set_gamma(true, 1.0);
-}

+ 0 - 94
panda/src/osxdisplay/osxGraphicsStateGuardian.h

@@ -1,94 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file osxGraphicsStateGuardian.h
- */
-
-#ifndef OSXGRAPHICSSTATEGUARDIAN_H
-#define OSXGRAPHICSSTATEGUARDIAN_H
-#include <Carbon/Carbon.h>
-#include <ApplicationServices/ApplicationServices.h>
-
-#define __glext_h_
-#include <OpenGL/gl.h>
-#include <AGL/agl.h>
-
-#include "pandabase.h"
-#include "glgsg.h"
-
-#include "osxGraphicsWindow.h"
-
-class osxGraphicsWindow;
-
-/**
- * A tiny specialization on GLGraphicsStateGuardian to add some wgl-specific
- * information.
- */
-class osxGraphicsStateGuardian : public GLGraphicsStateGuardian {
-public:
-  osxGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe,
-                           osxGraphicsStateGuardian *share_with);
-  virtual ~osxGraphicsStateGuardian();
-  virtual void reset();
-
-  void draw_resize_box();
-
-  bool get_gamma_table();
-  bool static_set_gamma(bool restore, PN_stdfloat gamma);
-  bool set_gamma(PN_stdfloat gamma);
-  void atexit_function();
-  void restore_gamma();
-
-protected:
-  virtual void *do_get_extension_func(const char *name);
-
-public:
-  OSStatus build_gl(bool full_screen, bool pbuffer, FrameBufferProperties &fb_props);
-  AGLContext get_context() { return _aglcontext; };
-
-  const AGLPixelFormat get_agl_pixel_format() const { return _aglPixFmt; };
-
-private:
-  void describe_pixel_format(FrameBufferProperties &fb_props);
-
-  // We have to save a pointer to the GSG we intend to share texture context
-  // with, since we don't create our own context in the constructor.
-  PT(osxGraphicsStateGuardian) _share_with;
-  AGLPixelFormat _aglPixFmt;
-  AGLContext _aglcontext;
-  CGGammaValue _gOriginalRedTable[ 256 ];
-  CGGammaValue _gOriginalGreenTable[ 256 ];
-  CGGammaValue _gOriginalBlueTable[ 256 ];
-  uint32_t _sampleCount;
-  CGDisplayErr _cgErr;
-
-public:
-  GLint _shared_buffer;
-
-public:
-  static TypeHandle get_class_type() {
-    return _type_handle;
-  }
-  static void init_type() {
-    GLGraphicsStateGuardian::init_type();
-    register_type(_type_handle, "osxGraphicsStateGuardian",
-                  GLGraphicsStateGuardian::get_class_type());
-  }
-  virtual TypeHandle get_type() const {
-    return get_class_type();
-  }
-  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
-  static TypeHandle _type_handle;
-
-  friend class osxGraphicsBuffer;
-};
-
-
-#endif

+ 0 - 24
panda/src/osxdisplay/osxGraphicsWindow.I

@@ -1,24 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file osxGraphicsWindow.I
- * @author drose
- * @date 2009-02-13
- */
-
-/**
- *
- */
-inline void osxGraphicsWindow::
-send_key_event(ButtonHandle key, bool down) {
-  if (down) {
-    _input_devices[0].button_down(key);
-  } else {
-    _input_devices[0].button_up(key);
-  }
-}

+ 0 - 145
panda/src/osxdisplay/osxGraphicsWindow.h

@@ -1,145 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file osxGraphicsWindow.h
- */
-
-#ifndef OSXGRAPHICSWINDOW_H
-#define OSXGRAPHICSWINDOW_H
-
-#include "pandabase.h"
-#include "graphicsWindow.h"
-#include "buttonHandle.h"
-
-#include <Carbon/Carbon.h>
-
-#define __glext_h_
-#include <OpenGL/gl.h>
-#include <AGL/agl.h>
-
-#define HACK_SCREEN_HASH_CONTEXT true
-OSStatus report_agl_error(const std::string &comment);
-
-/**
- * An interface to the osx/ system for managing GL windows under X.
- */
-class osxGraphicsWindow : public GraphicsWindow {
-public:
-  osxGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
-                    const std::string &name,
-                    const FrameBufferProperties &fb_prop,
-                    const WindowProperties &win_prop,
-                    int flags,
-                    GraphicsStateGuardian *gsg,
-                    GraphicsOutput *host);
-  virtual ~osxGraphicsWindow();
-
-  virtual bool move_pointer(int device, int x, int y);
-
-  virtual bool begin_frame(FrameMode mode, Thread *current_thread);
-  virtual void end_frame(FrameMode mode, Thread *current_thread);
-  virtual void begin_flip();
-  virtual void end_flip();
-  virtual void process_events();
-
-  virtual bool do_reshape_request(int x_origin, int y_origin, bool has_origin,
-                                  int x_size, int y_size);
-
-  virtual void mouse_mode_absolute();
-  virtual void mouse_mode_relative();
-
-  virtual void set_properties_now(WindowProperties &properties);
-
-private:
-  void release_system_resources(bool destructing);
-  inline void send_key_event(ButtonHandle key, bool down);
-
-protected:
-  virtual void close_window();
-  virtual bool open_window();
-
-private:
-  bool os_open_window(WindowProperties &properties);
-
-  // a singleton .. for the events to find the right pipe to push the event
-  // into
-
-public: // do not call direct ..
-  OSStatus handle_key_input(EventHandlerCallRef myHandler, EventRef event,
-                            Boolean keyDown);
-  OSStatus handle_text_input(EventHandlerCallRef myHandler, EventRef event);
-  OSStatus handle_window_mouse_events(EventHandlerCallRef myHandler, EventRef event);
-  ButtonHandle osx_translate_key(UInt32 key,  EventRef event);
-  static osxGraphicsWindow *get_current_osx_window(WindowRef hint);
-
-  void handle_modifier_delta(UInt32 new_modifiers);
-  void handle_button_delta(UInt32 new_buttons);
-  void do_resize();
-
-  OSStatus event_handler(EventHandlerCallRef myHandler, EventRef event);
-
-  virtual void user_close_request();
-  void system_close_window();
-  void system_set_window_foreground(bool foreground);
-  void system_point_to_local_point(Point &global_point);
-  void local_point_to_system_point(Point &local_point);
-  AGLContext get_gsg_context();
-  AGLContext get_context();
-  OSStatus build_gl(bool full_screen);
-  bool set_icon_filename(const Filename &icon_filename);
-
-  void set_pointer_in_window(int x, int y);
-  void set_pointer_out_of_window();
-
-private:
-  UInt32 _last_key_modifiers;
-  UInt32 _last_buttons;
-  WindowRef _osx_window;
-  bool _is_fullscreen;
-
-  CGImageRef _pending_icon;
-  CGImageRef _current_icon;
-
-  int _ID;
-  static osxGraphicsWindow *full_screen_window;
-
-#ifdef HACK_SCREEN_HASH_CONTEXT
-  AGLContext _holder_aglcontext;
-#endif
-  CFDictionaryRef _originalMode;
-
-  // True if _properties.get_cursor_hidden() is true.
-  bool _cursor_hidden;
-
-  // True if the cursor is actually hidden right now via system calls.
-  bool _display_hide_cursor;
-
-  SInt32 _wheel_hdelta;
-  SInt32 _wheel_vdelta;
-
-public:
-  static TypeHandle get_class_type() {
-    return _type_handle;
-  }
-  static void init_type() {
-    GraphicsWindow::init_type();
-    register_type(_type_handle, "osxGraphicsWindow",
-                  GraphicsWindow::get_class_type());
-  }
-  virtual TypeHandle get_type() const {
-    return get_class_type();
-  }
-  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
-  static TypeHandle _type_handle;
-};
-
-#include "osxGraphicsWindow.I"
-
-#endif

+ 0 - 2019
panda/src/osxdisplay/osxGraphicsWindow.mm

@@ -1,2019 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file osxGraphicsWindow.mm
- */
-
-// We include these system header files first, because there is a namescope
-// conflict between them and some other header file that gets included later
-// (in particular, TCP_NODELAY must not be a #define symbol for these headers
-// to be included properly).
-
-#include <Carbon/Carbon.h>
-#include <Cocoa/Cocoa.h>
-#include <ApplicationServices/ApplicationServices.h>
-#include <OpenGL/gl.h>
-#include <AGL/agl.h>
-
-// We have to include this before we include the system OpenGLgl.h file, but
-// after we include all of the above header files.  Deal with this
-// contradiction later.
-#include "glgsg.h"
-
-#include "osxGraphicsWindow.h"
-#include "config_osxdisplay.h"
-#include "osxGraphicsPipe.h"
-#include "pStatTimer.h"
-#include "keyboardButton.h"
-#include "mouseButton.h"
-#include "osxGraphicsStateGuardian.h"
-#include "osxGraphicsPipe.h"
-#include "throw_event.h"
-#include "pnmImage.h"
-#include "virtualFileSystem.h"
-#include "config_putil.h"
-#include "pset.h"
-#include "pmutex.h"
-
-
-static Mutex &
-osx_global_mutex() {
-  static Mutex m("osx_global_mutex");
-  return m;
-}
-
-
-TypeHandle osxGraphicsWindow::_type_handle;
-osxGraphicsWindow *osxGraphicsWindow::full_screen_window = NULL;
-
-#define USER_CONTAINER
-
-#ifdef USER_CONTAINER
-
-pset<WindowRef> my_windows;
-static void
-add_a_window(WindowRef window) {
-  my_windows.insert(window);
-}
-
-static bool
-check_my_window(WindowRef window) {
-  return my_windows.find(window) != my_windows.end();
-}
-
-#else // USER_CONTAINER
-
-static void
-add_a_window(WindowRef window) {
-}
-
-static bool
-check_my_window(WindowRef window) {
-  return true;
-}
-
-#endif // USER_CONTAINER
-
-
-
-/**
- * Returns the active window for the purpose of recording events.
- */
-osxGraphicsWindow *osxGraphicsWindow::
-get_current_osx_window(WindowRef window) {
-  if (full_screen_window != NULL) {
-    return full_screen_window;
-  }
-
-  if (window == NULL) {
-    // HID use this path
-
-    // Assume first we are a child window.  If we cant find a window of that
-    // class, then we are standalone and can jsut grab the front window.
-    window = GetFrontWindowOfClass(kSimpleWindowClass, TRUE);
-    if (window == NULL) {
-      window = FrontNonFloatingWindow();
-    }
-  }
-
-  if (window && check_my_window(window)) {
-    return (osxGraphicsWindow *)GetWRefCon (window);
-  } else {
-    return NULL;
-  }
-}
-
-/**
- * Convenience function to report the current AGL error code as a formatted
- * error message.
- */
-OSStatus
-report_agl_error(const string &comment) {
-  GLenum err = aglGetError();
-  if (err != AGL_NO_ERROR) {
-    osxdisplay_cat.error()
-      << "AGL Error " << aglErrorString(err) << " [" <<comment << "]\n";
-  }
-
-  if (err == AGL_NO_ERROR) {
-    return noErr;
-  } else {
-    return (OSStatus)err;
-  }
-}
-
-/**
- * Vertically inverts a rendered image.
- */
-static void
-invert_gl_image(char *imageData, size_t imageSize, size_t rowBytes) {
-  char *buffer = (char*)alloca(rowBytes);
-  nassertv(buffer != (char *)NULL);
-
-  // Copy by rows through temp buffer
-  for (size_t i = 0, j = imageSize - rowBytes;
-       i < imageSize >> 1;
-       i += rowBytes, j -= rowBytes) {
-    memcpy(buffer, &imageData[i], rowBytes);
-    memcpy(&imageData[i], &imageData[j], rowBytes);
-    memcpy(&imageData[j], buffer, rowBytes);
-  }
-}
-
-/**
- * Drop a GL overlay onto a carbon window..
- */
-static void
-composite_gl_buffer_into_window(AGLContext ctx, Rect *bufferRect,
-                                GrafPtr out_port) {
-  GWorldPtr world;
-  QDErr err;
-
-  // blit OpenGL content into window backing store allocate buffer to hold
-  // pane image
-  long width = (bufferRect->right - bufferRect->left);
-  long height = (bufferRect->bottom - bufferRect->top);
-
-  Rect src_rect = {0, 0, height, width};
-  Rect ddrc_rect = {0, 0, height, width};
-  long row_bytes = width * 4;
-  long image_size = row_bytes * height;
-  char *image = (char *)NewPtr(image_size);
-
-  if (!image) {
-    osxdisplay_cat.error()
-      << "Out of memory in composite_gl_buffer_into_window()!\n";
-    return; // no harm in continuing
-  }
-
-  // pull GL content down to our image buffer
-  aglSetCurrentContext(ctx);
-  glReadPixels(0, 0, width, height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
-               image);
-
-  // GL buffers are upside-down relative to QD buffers, so we need to flip it
-  invert_gl_image(image, image_size, row_bytes);
-
-  // create a GWorld containing our image
-  err = NewGWorldFromPtr(&world, k32ARGBPixelFormat, &src_rect, 0, 0, 0,
-                         image, row_bytes);
-  if (err != noErr) {
-    osxdisplay_cat.error()
-      << " error in NewGWorldFromPtr, called from composite_gl_buffer_into_window()\n";
-    DisposePtr(image);
-    return;
-  }
-
-  GrafPtr port_save = NULL;
-  Boolean port_changed = QDSwapPort(out_port, &port_save);
-
-  CopyBits(GetPortBitMapForCopyBits(world),
-           GetPortBitMapForCopyBits(out_port),
-           &src_rect, &ddrc_rect, srcCopy, 0);
-
-  if (port_changed) {
-    QDSwapPort(port_save, NULL);
-  }
-
-  DisposeGWorld(world);
-  DisposePtr(image);
-}
-
-/**
- * The standard window event handler for non-fullscreen windows.
- */
-OSStatus osxGraphicsWindow::
-event_handler(EventHandlerCallRef myHandler, EventRef event) {
-  OSStatus result = eventNotHandledErr;
-  UInt32 the_class = GetEventClass(event);
-  UInt32 kind = GetEventKind(event);
-
-  WindowRef window = NULL;
-  GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL,
-                    sizeof(window), NULL, &window);
-
-  UInt32 attributes = 0;
-  GetEventParameter(event, kEventParamAttributes, typeUInt32, NULL,
-                    sizeof(attributes), NULL, &attributes);
-
-  if (osxdisplay_cat.is_spam()) {
-    osxdisplay_cat.spam()
-      << ClockObject::get_global_clock()->get_real_time()
-      << " event_handler: " << (void *)this << ", " << window
-      << ", " << the_class << ", " << kind << "\n";
-  }
-
-  switch (the_class) {
-  case kEventClassMouse:
-    result = handle_window_mouse_events (myHandler, event);
-    break;
-
-  case kEventClassWindow:
-    switch (kind) {
-    case kEventWindowCollapsing:
-      /*
-        Rect r;
-        GetWindowPortBounds (window, &r);
-        composite_gl_buffer_into_window(get_context(), &r, GetWindowPort (window));
-        UpdateCollapsedWindowDockTile (window);
-      */
-      system_set_window_foreground(false);
-      break;
-
-    case kEventWindowActivated: // called on click activation and initially
-      system_set_window_foreground(true);
-      do_resize();
-      break;
-
-    case kEventWindowDeactivated:
-      system_set_window_foreground(false);
-      break;
-
-    case kEventWindowClose: // called when window is being closed (close box)
-      // This is a message from the window manager indicating that the user
-      // has requested to close the window.
-      user_close_request();
-      result = noErr;
-      break;
-
-    case kEventWindowShown: // called on initial show (not on un-minimize)
-      if (window == FrontNonFloatingWindow ())
-        SetUserFocusWindow (window);
-      break;
-
-    case kEventWindowBoundsChanging:
-      // Gives us a chance to intercept resize attempts
-      if (attributes & kWindowBoundsChangeSizeChanged) {
-        // If the window is supposed to be fixed-size, enforce this.
-        if (_properties.get_fixed_size()) {
-          Rect bounds;
-          GetEventParameter(event, kEventParamCurrentBounds,
-                            typeQDRectangle, NULL, sizeof(bounds), NULL, &bounds);
-          bounds.right = bounds.left + _properties.get_x_size();
-          bounds.bottom = bounds.top + _properties.get_y_size();
-          SetEventParameter(event, kEventParamCurrentBounds,
-                            typeQDRectangle, sizeof(bounds), &bounds);
-          result = noErr;
-        }
-      }
-      break;
-
-    case kEventWindowBoundsChanged: // called for resize and moves (drag)
-      do_resize();
-      break;
-
-    case kEventWindowZoomed:
-      break;
-
-    case kEventWindowCollapsed:
-      {
-        WindowProperties properties;
-        properties.set_minimized(true);
-        system_changed_properties(properties);
-      }
-      break;
-
-    case kEventWindowExpanded:
-      {
-        WindowProperties properties;
-        properties.set_minimized(false);
-        system_changed_properties(properties);
-      }
-      break;
-    }
-    break;
-  }
-
-  return result;
-}
-
-/**
- * The user has requested to close the window, for instance with Cmd-W, or by
- * clicking on the close button.
- */
-void osxGraphicsWindow::
-user_close_request() {
-  string close_request_event = get_close_request_event();
-  if (!close_request_event.empty()) {
-    // In this case, the app has indicated a desire to intercept the request
-    // and process it directly.
-    throw_event(close_request_event);
-  } else {
-    // In this case, the default case, the app does not intend to service the
-    // request, so we do by closing the window.
-    close_window();
-  }
-}
-
-/**
- * The window has been closed by an OS resource, not by an internal request
- */
-void osxGraphicsWindow::
-system_close_window() {
-  if (osxdisplay_cat.is_debug()) {
-    osxdisplay_cat.debug()
-      << "System Closing Window \n";
-  }
-  release_system_resources(false);
-}
-
-/**
- * The C callback for Window Events
- *
- * We only hook this up for non-fullscreen windows, so we only handle system
- * window events.
- */
-static pascal OSStatus
-window_event_handler(EventHandlerCallRef my_handler, EventRef event, void *) {
-  // volatile().lock();
-
-  WindowRef window = NULL;
-  GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL,
-                    sizeof(WindowRef), NULL, &window);
-
-  if (window != NULL) {
-    osxGraphicsWindow *osx_win = osxGraphicsWindow::get_current_osx_window(window);
-    if (osx_win != (osxGraphicsWindow *)NULL) {
-      // osx_global_mutex().release();
-      return osx_win->event_handler(my_handler, event);
-    }
-  }
-
-  // osx_global_mutex().release();
-  return eventNotHandledErr;
-}
-
-/**
- *
- */
-void osxGraphicsWindow::
-do_resize() {
-  if (osxdisplay_cat.is_debug()) {
-    osxdisplay_cat.debug()
-      << "In Resize....." << _properties << "\n";
-  }
-
-  // only in window mode .. not full screen
-  if (_osx_window != NULL && !_is_fullscreen && _properties.has_size()) {
-    Rect rectPort = {
-      0, 0, 0, 0
-    };
-    CGRect viewRect = {
-      { 0.0f, 0.0f }, { 0.0f, 0.0f }
-    };
-
-    GetWindowPortBounds(_osx_window, &rectPort);
-    viewRect.size.width = (PN_stdfloat)(rectPort.right - rectPort.left);
-    viewRect.size.height = (PN_stdfloat)(rectPort.bottom - rectPort.top);
-
-    // tell panda
-    WindowProperties properties;
-    properties.set_size((int)viewRect.size.width,(int)viewRect.size.height);
-    properties.set_origin((int) rectPort.left,(int)rectPort.top);
-    system_changed_properties(properties);
-
-    if (osxdisplay_cat.is_debug()) {
-      osxdisplay_cat.debug()
-        << " Resizing Window " << viewRect.size.width
-        << " " << viewRect.size.height << "\n";
-    }
-
-    AGLContext context = get_gsg_context();
-    if (context != (AGLContext)NULL) {
-      // ping gl
-      if (!aglSetCurrentContext(context)) {
-        report_agl_error("aglSetCurrentContext");
-      }
-      aglUpdateContext(context);
-      report_agl_error("aglUpdateContext .. This is a Resize..");
-    }
-
-    if (osxdisplay_cat.is_debug()) {
-      osxdisplay_cat.debug()
-        << "Resize Complete.....\n";
-    }
-  }
-}
-
-/**
- * The C callback for Application events.
- *
- * Hooked once per application.
- */
-static pascal OSStatus
-app_event_handler(EventHandlerCallRef my_handler, EventRef event,
-                  void *user_data) {
-  OSStatus result = eventNotHandledErr;
-  {
-    // osx_global_mutex().lock();
-
-    osxGraphicsWindow *osx_win = NULL;
-    WindowRef window = NULL;
-    UInt32 the_class = GetEventClass (event);
-    UInt32 kind = GetEventKind (event);
-
-    GetEventParameter(event, kEventParamWindowRef, typeWindowRef, NULL,
-                      sizeof(WindowRef), NULL, (void*) &window);
-    osx_win = osxGraphicsWindow::get_current_osx_window(window);
-    if (osx_win == NULL) {
-      // osx_global_mutex().release();
-      return eventNotHandledErr;
-    }
-
-    switch (the_class) {
-    case kEventClassTextInput:
-      if (kind == kEventTextInputUnicodeForKeyEvent) {
-        osx_win->handle_text_input(my_handler, event);
-      }
-      // result = noErr; can not report handled .. the os will not sent the
-      // raw key strokes then if(osx_win->handle_text_input(my_handler, event)
-      // == noErr) result = noErr;
-      break;
-
-    case kEventClassKeyboard:
-      {
-        switch (kind) {
-        case kEventRawKeyRepeat:
-        case kEventRawKeyDown:
-          result = osx_win->handle_key_input (my_handler, event, true);
-          break;
-        case kEventRawKeyUp:
-          result = osx_win->handle_key_input (my_handler, event, false);
-          break;
-        case kEventRawKeyModifiersChanged:
-          {
-            UInt32 newModifiers;
-            OSStatus error = GetEventParameter(event, kEventParamKeyModifiers,typeUInt32, NULL,sizeof(UInt32), NULL, &newModifiers);
-            if (error == noErr) {
-              osx_win->handle_modifier_delta(newModifiers);
-              result = noErr;
-            }
-          }
-          break;
-        }
-      }
-      break;
-
-    case kEventClassMouse:
-      // osxdisplay_cat.info() << "Mouse movement handled by Application
-      // handler\n"; if(osxGraphicsWindow::full_screen_window != NULL)
-      result = osx_win->handle_window_mouse_events(my_handler, event);
-      // result = noErr;
-      break;
-    }
-
-    // osx_global_mutex().release();
-  }
-
-  return result;
-}
-
-/**
- * Trap Unicode Input.
- */
-OSStatus osxGraphicsWindow::
-handle_text_input(EventHandlerCallRef my_handler, EventRef text_event) {
-  UniChar *text = NULL;
-  UInt32 actual_size = 0;
-
-  OSStatus ret = GetEventParameter(text_event, kEventParamTextInputSendText,
-                                   typeUnicodeText, NULL, 0, &actual_size, NULL);
-  if (ret != noErr) {
-    return ret;
-  }
-
-  text = (UniChar*)NewPtr(actual_size);
-  if (text!= NULL) {
-    ret = GetEventParameter (text_event, kEventParamTextInputSendText,typeUnicodeText, NULL, actual_size, NULL, text);
-    if (ret != noErr) {
-      return ret;
-    }
-
-    for (unsigned int x = 0; x < actual_size/sizeof(UniChar); ++x) {
-      _input_devices[0].keystroke(text[x]);
-    }
-    DisposePtr((char *)text);
-  }
-
-  return ret;
-}
-
-/**
- * Clean up the OS level messes.
- */
-void osxGraphicsWindow::
-release_system_resources(bool destructing) {
-  if (_is_fullscreen) {
-    _is_fullscreen = false;
-    full_screen_window = NULL;
-
-    if (_originalMode != NULL) {
-      CGDisplaySwitchToMode(kCGDirectMainDisplay, _originalMode);
-    }
-
-    CGDisplayRelease(kCGDirectMainDisplay);
-    aglSetDrawable(get_gsg_context(), NULL);
-
-    _originalMode = NULL;
-  }
-
-  // if the gsg context is assigned to this window clear it..
-  if (_osx_window != NULL && GetWindowPort (_osx_window) == (GrafPtr)aglGetDrawable(get_gsg_context())) {
-    aglSetDrawable(get_gsg_context(),NULL);
-  }
-
-  // if we are the active gl context clear it..
-  if (aglGetCurrentContext() == get_gsg_context()) {
-    aglSetCurrentContext(NULL);
-  }
-
-  if (_osx_window != NULL) {
-    SetWRefCon(_osx_window, (long int) NULL);
-    HideWindow(_osx_window);
-    DisposeWindow(_osx_window);
-    _osx_window = NULL;
-  }
-
-  if (_holder_aglcontext) {
-    aglDestroyContext(_holder_aglcontext);
-    _holder_aglcontext = NULL;
-  }
-
-  if (_pending_icon != NULL) {
-    CGImageRelease(_pending_icon);
-    _pending_icon = NULL;
-  }
-
-  if (_current_icon != NULL) {
-    CGImageRelease(_current_icon);
-    _current_icon = NULL;
-  }
-
-  if (!destructing) {
-    WindowProperties properties;
-    properties.set_foreground(false);
-    properties.set_open(false);
-    properties.set_cursor_filename(Filename());
-    system_changed_properties(properties);
-  }
-
-  _is_fullscreen = false;
-  _osx_window = NULL;
-}
-
-
-static int id_seed = 100;
-
-/**
- *
- */
-osxGraphicsWindow::
-osxGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
-                  const string &name,
-                  const FrameBufferProperties &fb_prop,
-                  const WindowProperties &win_prop,
-                  int flags,
-                  GraphicsStateGuardian *gsg,
-                  GraphicsOutput *host) :
-  GraphicsWindow(engine, pipe, name, fb_prop, win_prop, flags, gsg, host),
-  _osx_window(NULL),
-  _is_fullscreen(false),
-  _pending_icon(NULL),
-  _current_icon(NULL),
-#ifdef HACK_SCREEN_HASH_CONTEXT
-  _holder_aglcontext(NULL),
-#endif
-  _originalMode(NULL),
-  _ID(id_seed++)
-{
-  GraphicsWindowInputDevice device =
-    GraphicsWindowInputDevice::pointer_and_keyboard(this, "keyboard/mouse");
-  _input_devices.push_back(device);
-  _input_devices[0].set_pointer_in_window(0, 0);
-  _last_key_modifiers = 0;
-  _last_buttons = 0;
-
-  _cursor_hidden = false;
-  _display_hide_cursor = false;
-  _wheel_hdelta = 0;
-  _wheel_vdelta = 0;
-
-  if (osxdisplay_cat.is_debug()) {
-    osxdisplay_cat.debug()
-      << "osxGraphicsWindow::osxGraphicsWindow() -" <<_ID << "\n";
-  }
-}
-
-/**
- *
- */
-osxGraphicsWindow::
-~osxGraphicsWindow() {
-  if (osxdisplay_cat.is_debug()) {
-    osxdisplay_cat.debug()
-      << "osxGraphicsWindow::~osxGraphicsWindow() -" <<_ID << "\n";
-  }
-
-  // Make sure the window callback won't come back to this (destructed) object
-  // any more.
-  if (_osx_window) {
-    SetWRefCon(_osx_window, (long) NULL);
-  }
-
-  release_system_resources(true);
-}
-
-/**
- * Helper to decide whitch context to use if any
- */
-AGLContext osxGraphicsWindow::
-get_context() {
-  if (_holder_aglcontext != NULL) {
-    return _holder_aglcontext;
-  }
-
-  return get_gsg_context();
-}
-
-/**
- *
- */
-AGLContext osxGraphicsWindow::
-get_gsg_context() {
-  if (_gsg != NULL) {
-    osxGraphicsStateGuardian *osxgsg = NULL;
-    osxgsg = DCAST(osxGraphicsStateGuardian, _gsg);
-    return osxgsg->get_context();
-  }
-  return NULL;
-}
-
-/**
- * Code of the class.. used to control the GL context Allocation.
- */
-OSStatus osxGraphicsWindow::
-build_gl(bool full_screen) {
-  // make sure the gsg is up and runnig..
-  osxGraphicsStateGuardian *osxgsg = NULL;
-  osxgsg = DCAST(osxGraphicsStateGuardian, _gsg);
-  OSStatus stat = osxgsg->build_gl(full_screen, false, _fb_properties);
-
-  if (stat != noErr) {
-    return stat;
-  }
-
-  OSStatus err = noErr;
-
-  if (osxgsg->get_agl_pixel_format()) {
-    _holder_aglcontext = aglCreateContext(osxgsg->get_agl_pixel_format(), NULL);
-
-    err = report_agl_error("aglCreateContext");
-    if (_holder_aglcontext == NULL) {
-      osxdisplay_cat.error()
-        << "osxGraphicsWindow::build_gl Error aglCreateContext \n";
-      if (err ==noErr) {
-        err = -1;
-      }
-    } else {
-      aglSetInteger(_holder_aglcontext, AGL_BUFFER_NAME, &osxgsg->_shared_buffer);
-      err = report_agl_error ("aglSetInteger AGL_BUFFER_NAME");
-    }
-  } else {
-    osxdisplay_cat.error()
-      << "osxGraphicsWindow::build_gl Error Getting PixelFormat \n";
-    if (err ==noErr) {
-      err = -1;
-    }
-  }
-  return err;
-}
-
-/**
- * Called internally to load up an icon file that should be applied to the
- * window.  Returns true on success, false on failure.
- */
-bool osxGraphicsWindow::
-set_icon_filename(const Filename &icon_filename) {
-  VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();
-
-  Filename icon_pathname = icon_filename;
-  if (!vfs->resolve_filename(icon_pathname, get_model_path())) {
-    // The filename doesn't exist along the search path.
-    if (icon_pathname.is_fully_qualified() && vfs->exists(icon_pathname)) {
-      // But it does exist locally, so accept it.
-
-    } else {
-      osxdisplay_cat.warning()
-        << "Could not find icon filename " << icon_filename << "\n";
-      return false;
-    }
-  }
-
-
-  PNMImage pnmimage;
-  if (!pnmimage.read(icon_pathname)) {
-    osxdisplay_cat.warning()
-      << "Could not read icon filename " << icon_pathname << "\n";
-    return false;
-  }
-
-  CGImageRef icon_image = osxGraphicsPipe::create_cg_image(pnmimage);
-  if (icon_image == NULL) {
-    return false;
-  }
-
-  if (_pending_icon != NULL) {
-    CGImageRelease(_pending_icon);
-    _pending_icon = NULL;
-  }
-  _pending_icon = icon_image;
-  return true;
-}
-
-/**
- * Indicates the mouse pointer is seen within the window.
- */
-void osxGraphicsWindow::
-set_pointer_in_window(int x, int y) {
-  _input_devices[0].set_pointer_in_window(x, y);
-
-  if (_cursor_hidden != _display_hide_cursor) {
-    if (_cursor_hidden) {
-      CGDisplayHideCursor(kCGDirectMainDisplay);
-      _display_hide_cursor = true;
-    } else {
-      CGDisplayShowCursor(kCGDirectMainDisplay);
-      _display_hide_cursor = false;
-    }
-  }
-}
-
-/**
- * Indicates the mouse pointer is no longer within the window.
- */
-void osxGraphicsWindow::
-set_pointer_out_of_window() {
-  _input_devices[0].set_pointer_out_of_window();
-
-  if (_display_hide_cursor) {
-    CGDisplayShowCursor(kCGDirectMainDisplay);
-    _display_hide_cursor = false;
-  }
-}
-
-
-/**
- * This function will be called within the draw thread before beginning
- * rendering for a given frame.  It should do whatever setup is required, and
- * return true if the frame should be rendered, or false if it should be
- * skipped.
- */
-bool osxGraphicsWindow::
-begin_frame(FrameMode mode, Thread *current_thread) {
-  PStatTimer timer(_make_current_pcollector);
-
-  begin_frame_spam(mode);
-  if (_gsg == (GraphicsStateGuardian *)NULL ||
-      (_osx_window == NULL && !_is_fullscreen)) {
-    // not powered up .. just abort..
-    return false;
-  }
-
-  // Now is a good time to apply the icon change that may have recently been
-  // requested.  By this point, we should be able to get a handle to the dock
-  // context.
-  if (_pending_icon != NULL) {
-    CGContextRef context = BeginCGContextForApplicationDockTile();
-    if (context != NULL) {
-      SetApplicationDockTileImage(_pending_icon);
-      EndCGContextForApplicationDockTile(context);
-
-      if (_current_icon != NULL) {
-        CGImageRelease(_current_icon);
-        _current_icon = NULL;
-      }
-      _current_icon = _pending_icon;
-      _pending_icon = NULL;
-    }
-  }
-
-  if (_is_fullscreen) {
-    aglSetFullScreen(get_gsg_context(),0,0,0,0);
-    report_agl_error ("aglSetFullScreen");
-
-  } else {
-    if (full_screen_window != NULL) {
-      return false;
-    }
-
-    if (!aglSetDrawable(get_gsg_context(), GetWindowPort (_osx_window))) {
-      report_agl_error("aglSetDrawable");
-    }
-  }
-
-  if (!aglSetCurrentContext(get_gsg_context())) {
-    report_agl_error ("aglSetCurrentContext");
-  }
-
-  _gsg->reset_if_new();
-  _gsg->set_current_properties(&get_fb_properties());
-
-  return _gsg->begin_frame(current_thread);
-}
-
-/**
- * This function will be called within the draw thread after rendering is
- * completed for a given frame.  It should do whatever finalization is
- * required.
- */
-void osxGraphicsWindow::
-end_frame(FrameMode mode, Thread *current_thread) {
-  end_frame_spam(mode);
-
-  if (mode == FM_render) {
-    nassertv(_gsg != (GraphicsStateGuardian *)NULL);
-
-    copy_to_textures();
-
-    if (!_properties.get_fixed_size() &&
-        !_properties.get_undecorated() &&
-        !_properties.get_fullscreen() &&
-        show_resize_box) {
-      // Draw a kludgey little resize box in the corner of the window, so the
-      // user knows he's supposed to be able to drag the window if he wants.
-      DisplayRegionPipelineReader dr_reader(_overlay_display_region, current_thread);
-      _gsg->prepare_display_region(&dr_reader);
-      DCAST(osxGraphicsStateGuardian, _gsg)->draw_resize_box();
-    }
-
-    aglSwapBuffers (get_gsg_context());
-    _gsg->end_frame(current_thread);
-  }
-}
-
-/**
- * This function will be called within the draw thread after end_frame() has
- * been called on all windows, to initiate the exchange of the front and back
- * buffers.
- *
- * This should instruct the window to prepare for the flip at the next video
- * sync, but it should not wait.
- *
- * We have the two separate functions, begin_flip() and end_flip(), to make it
- * easier to flip all of the windows at the same time.
- */
-void osxGraphicsWindow::
-end_flip() {
-  // cerr << " end_flip [" << _ID << "]\n";
-}
-
-void osxGraphicsWindow::
-begin_flip() {
-  // this forces a rip to proper context cerr << " begin_flip [" << _ID <<
-  // "]\n";
-  return;
-
-  if (_is_fullscreen) {
-    if (!aglSetFullScreen(get_gsg_context(),0,0,0,0)) {
-      report_agl_error("aglSetFullScreen");
-    }
-
-    if (!aglSetCurrentContext(get_gsg_context())) {
-      report_agl_error("aglSetCurrentContext");
-    }
-
-    aglSwapBuffers (get_gsg_context());
-  } else {
-    if (!aglSetDrawable (get_gsg_context(),GetWindowPort (_osx_window))) {
-      report_agl_error("aglSetDrawable");
-    }
-
-    if (!aglSetCurrentContext(get_gsg_context())) {
-      report_agl_error("aglSetCurrentContext");
-    }
-
-    aglSwapBuffers (get_gsg_context());
-  }
-}
-
-/**
- * Closes the window right now.  Called from the window thread.
- */
-void osxGraphicsWindow::
-close_window() {
-  system_close_window();
-
-  WindowProperties properties;
-  properties.set_open(false);
-  system_changed_properties(properties);
-
-  release_system_resources(false);
-  _gsg.clear();
- GraphicsWindow::close_window();
-}
-
-/*
- * HACK ALLERT ************ Undocumented OSX calls... I can not find any other
- * way to get the mouse focus to a window in OSX.. extern "C" { struct
- * CPSProcessSerNum { UInt32 lo; UInt32 hi; };
- */
-
-// extern OSErr CPSGetCurrentProcess(CPSProcessSerNum *psn); extern OSErr
-// CPSEnableForegroundOperation(struct CPSProcessSerNum *psn); extern OSErr
-// CPSSetProcessName (struct CPSProcessSerNum *psn, char *processname); extern
-// OSErr CPSSetFrontProcess(struct CPSProcessSerNum *psn); };
-
-/**
- * Opens the window right now.  Called from the window thread.  Returns true
- * if the window is successfully opened, or false if there was a problem.
- */
-bool osxGraphicsWindow::
-open_window() {
-  WindowProperties req_properties = _properties;
-
-  if (_gsg == 0) {
-    _gsg = new osxGraphicsStateGuardian(_engine, _pipe, NULL);
-  }
-
-  // osx_global_mutex().lock();
-  bool answer = os_open_window(req_properties);
-  // osx_global_mutex().release();
-  return answer;
-}
-
-/**
- * Actually makes the OS calls to open a window.
- */
-bool osxGraphicsWindow::
-os_open_window(WindowProperties &req_properties) {
-  OSErr err = noErr;
-
-  if (_current_icon != NULL && _pending_icon == NULL) {
-    // If we already have an icon specified, we'll need to reapply it when the
-    // window is successfully created.
-    _pending_icon = _current_icon;
-    _current_icon = NULL;
-  }
-
-  static bool GlobalInits = false;
-  if (!GlobalInits) {
-    // one time aplication inits.. to get a window open from a standalone
-    // aplication..
-
-    EventHandlerRef application_event_ref_ref1;
-    EventTypeSpec list1[] = {
-      // { kEventClassCommand, kEventProcessCommand }, { kEventClassCommand,
-      // kEventCommandUpdateStatus },
-      { kEventClassMouse, kEventMouseDown },// handle trackball functionality globaly because there is only a single user
-      { kEventClassMouse, kEventMouseUp },
-      { kEventClassMouse, kEventMouseMoved },
-      { kEventClassMouse, kEventMouseDragged },
-      { kEventClassMouse, kEventMouseWheelMoved } ,
-      { kEventClassKeyboard, kEventRawKeyDown },
-      { kEventClassKeyboard, kEventRawKeyUp } ,
-      { kEventClassKeyboard, kEventRawKeyRepeat },
-      { kEventClassKeyboard, kEventRawKeyModifiersChanged } ,
-      { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent},
-    };
-
-    EventHandlerUPP gEvtHandler = NewEventHandlerUPP(app_event_handler);
-    err = InstallApplicationEventHandler (gEvtHandler, GetEventTypeCount (list1) , list1, this, &application_event_ref_ref1);
-    GlobalInits = true;
-
-    ProcessSerialNumber psn = { 0, kCurrentProcess };
-
-    // Determine if we're running from a bundle.
-    CFDictionaryRef dref =
-      ProcessInformationCopyDictionary(&psn, kProcessDictionaryIncludeAllInformationMask);
-    // If the dictionary doesn't have "BundlePath" (or the BundlePath is the
-    // same as the executable path), then we're not running from a bundle, and
-    // we need to call TransformProcessType to make the process a "foreground"
-    // application, with its own icon in the dock and such.
-
-    bool has_bundle = false;
-
-    CFStringRef bundle_path = (CFStringRef)CFDictionaryGetValue(dref, CFSTR("BundlePath"));
-    if (bundle_path != NULL) {
-      // OK, we have a bundle path.  We're probably running in a bundle . . .
-      has_bundle = true;
-
-      // . . . unless it turns out it's the same as the executable path.
-      CFStringRef exe_path = (CFStringRef)CFDictionaryGetValue(dref, kCFBundleExecutableKey);
-      if (exe_path != NULL) {
-        if (CFStringCompare(bundle_path, exe_path, kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
-          has_bundle = false;
-        }
-        CFRelease(exe_path);
-      }
-
-      CFRelease(bundle_path);
-    }
-
-    if (!has_bundle) {
-      TransformProcessType(&psn, kProcessTransformToForegroundApplication);
-    }
-    SetFrontProcess(&psn);
-  }
-
-  bool wants_fullscreen = req_properties.has_fullscreen() && req_properties.get_fullscreen();
-  if (req_properties.get_minimized()) {
-    // A minimized window can't be fullscreen.
-    wants_fullscreen = false;
-  }
-
-  if (wants_fullscreen) {
-    if (osxdisplay_cat.is_debug()) {
-      osxdisplay_cat.debug()
-        << "Creating full screen\n";
-    }
-
-    // capture the main display
-    CGDisplayCapture(kCGDirectMainDisplay);
-    // if sized try and switch it..
-    if (req_properties.has_size()) {
-      _originalMode = CGDisplayCurrentMode(kCGDirectMainDisplay);
-      CFDictionaryRef newMode = CGDisplayBestModeForParameters(kCGDirectMainDisplay, 32, req_properties.get_x_size(), req_properties.get_y_size(), 0);
-      if (newMode == NULL) {
-        osxdisplay_cat.error()
-          << "Invalid fullscreen size: " << req_properties.get_x_size()
-          << ", " << req_properties.get_y_size()
-          << "\n";
-      } else {
-        CGDisplaySwitchToMode(kCGDirectMainDisplay, newMode);
-
-        // Set our new window size according to the size we actually got.
-
-        SInt32 width, height;
-        CFNumberGetValue((CFNumberRef)CFDictionaryGetValue(newMode, kCGDisplayWidth), kCFNumberSInt32Type, &width);
-        CFNumberGetValue((CFNumberRef)CFDictionaryGetValue(newMode, kCGDisplayHeight), kCFNumberSInt32Type, &height);
-
-        _properties.set_size(width, height);
-      }
-    }
-
-    if (build_gl(true) != noErr) {
-      if (_originalMode != NULL) {
-        CGDisplaySwitchToMode(kCGDirectMainDisplay, _originalMode);
-      }
-      _originalMode = NULL;
-
-      CGDisplayRelease(kCGDirectMainDisplay);
-      return false;
-    }
-
-    _properties.set_fullscreen(true);
-    _properties.set_minimized(false);
-    _properties.set_foreground(true);
-
-    _is_fullscreen = true;
-    full_screen_window = this;
-    req_properties.clear_fullscreen();
-
-  } else {
-    int x_origin = 10;
-    int y_origin = 50;
-    if (req_properties.has_origin()) {
-      y_origin  = req_properties.get_y_origin();
-      x_origin = req_properties.get_x_origin();
-    }
-
-    int x_size = 512;
-    int y_size = 512;
-    if (req_properties.has_size()) {
-      x_size = req_properties.get_x_size();
-      y_size = req_properties.get_y_size();
-    }
-
-    // A coordinate of -2 means to center the window on screen.
-    if (y_origin == -2 || x_origin == -2) {
-      if (y_origin == -2) {
-        y_origin = (_pipe->get_display_height() - y_size) / 2;
-      }
-      if (x_origin == -2) {
-        x_origin = (_pipe->get_display_width() - x_size) / 2;
-      }
-    }
-
-    // A coordinate of -1 means a default location.
-    if (y_origin == -1) {
-      y_origin = 50;
-    }
-    if (x_origin == -1) {
-      x_origin = 10;
-    }
-
-    _properties.set_origin(x_origin, y_origin);
-    _properties.set_size(x_size, y_size);
-
-    Rect r;
-    r.top = y_origin;
-    r.left = x_origin;
-    r.right = r.left + x_size;
-    r.bottom = r.top + y_size;
-
-    /*
-    if (req_properties.has_parent_window()) {
-      if (osxdisplay_cat.is_debug()) {
-        osxdisplay_cat.debug()
-          << "Creating child window\n";
-      }
-
-      CreateNewWindow(kSimpleWindowClass, kWindowNoAttributes, &r, &_osx_window);
-      add_a_window(_osx_window);
-
-      _properties.set_fixed_size(true);
-      if (osxdisplay_cat.is_debug()) {
-        osxdisplay_cat.debug()
-          << "Child window created\n";
-      }
-      } else */
-    {
-      int attributes = kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute;
-      if (req_properties.has_fixed_size() && req_properties.get_fixed_size()) {
-        attributes &= ~kWindowResizableAttribute;
-      }
-
-      if (req_properties.has_undecorated() && req_properties.get_undecorated()) {
-        // create a unmovable .. no edge window..
-
-        if (osxdisplay_cat.is_debug()) {
-          osxdisplay_cat.debug()
-            << "Creating undecorated window\n";
-        }
-
-        // We don't want a resize box either.
-        attributes &= ~kWindowResizableAttribute;
-        attributes |= kWindowNoTitleBarAttribute;
-        CreateNewWindow(kDocumentWindowClass, attributes, &r, &_osx_window);
-      } else {
-        // create a window with crome and sizing and sucj In this case, we
-        // want to constrain the window to the available size.
-
-        Rect bounds;
-        GetAvailableWindowPositioningBounds(GetMainDevice(), &bounds);
-
-        r.left = max(r.left, bounds.left);
-        r.right = min(r.right, bounds.right);
-        r.top = max(r.top, bounds.top);
-        r.bottom = min(r.bottom, bounds.bottom);
-
-        if (osxdisplay_cat.is_debug()) {
-          osxdisplay_cat.debug()
-            << "Creating standard window\n";
-        }
-        CreateNewWindow(kDocumentWindowClass, attributes, &r, &_osx_window);
-        add_a_window(_osx_window);
-      }
-    }
-
-    if (_osx_window) {
-      EventHandlerUPP gWinEvtHandler; // window event handler
-      EventTypeSpec list[] = {
-        { kEventClassWindow, kEventWindowCollapsing },
-        { kEventClassWindow, kEventWindowShown },
-        { kEventClassWindow, kEventWindowActivated },
-        { kEventClassWindow, kEventWindowDeactivated },
-        { kEventClassWindow, kEventWindowClose },
-        { kEventClassWindow, kEventWindowBoundsChanging },
-        { kEventClassWindow, kEventWindowBoundsChanged },
-
-        { kEventClassWindow, kEventWindowCollapsed },
-        { kEventClassWindow, kEventWindowExpanded },
-        { kEventClassWindow, kEventWindowZoomed },
-        { kEventClassWindow, kEventWindowClosed },
-      };
-
-      // point to the window record in the ref con of the window
-      SetWRefCon(_osx_window, (long) this);
-      gWinEvtHandler = NewEventHandlerUPP(window_event_handler);
-      InstallWindowEventHandler(_osx_window, gWinEvtHandler, GetEventTypeCount(list), list, (void*)this, NULL); // add event handler
-
-      ShowWindow (_osx_window);
-
-      if (osxdisplay_cat.is_debug()) {
-        osxdisplay_cat.debug()
-          << "Event handler installed, now build_gl\n";
-      }
-      if (build_gl(false) != noErr) {
-        osxdisplay_cat.error()
-          << "Error in build_gl\n";
-
-        HideWindow(_osx_window);
-        SetWRefCon(_osx_window, (long int) NULL);
-        DisposeWindow(_osx_window);
-        _osx_window = NULL;
-        return false;
-      }
-
-      if (osxdisplay_cat.is_debug()) {
-        osxdisplay_cat.debug()
-          << "build_gl complete, set properties\n";
-      }
-
-      // attach the holder context to the window..
-
-      if (!aglSetDrawable(_holder_aglcontext, GetWindowPort(_osx_window))) {
-        err = report_agl_error("aglSetDrawable");
-      }
-
-      if (req_properties.has_fullscreen()) {
-        _properties.set_fullscreen(false);
-        req_properties.clear_fullscreen();
-      }
-
-      if (req_properties.has_undecorated()) {
-        _properties.set_undecorated(req_properties.get_undecorated());
-        req_properties.clear_undecorated();
-      }
-
-      _properties.set_minimized(false);
-      _properties.set_foreground(true);
-
-      if (req_properties.has_minimized()) {
-        CollapseWindow(_osx_window, req_properties.get_minimized());
-        _properties.set_minimized(req_properties.get_minimized());
-        _properties.set_foreground(!req_properties.get_minimized());
-        req_properties.clear_minimized();
-      }
-    }
-
-    // Now measure the size and placement of the window we actually ended up
-    // with.
-    Rect rectPort = {0,0,0,0};
-    GetWindowPortBounds (_osx_window, &rectPort);
-    _properties.set_size((int)(rectPort.right - rectPort.left),(int) (rectPort.bottom - rectPort.top));
-    req_properties.clear_size();
-    req_properties.clear_origin();
-  }
-
-  if (req_properties.has_icon_filename()) {
-    set_icon_filename(req_properties.get_icon_filename());
-  }
-
-  if (req_properties.has_cursor_hidden()) {
-    _properties.set_cursor_hidden(req_properties.get_cursor_hidden());
-    _cursor_hidden = req_properties.get_cursor_hidden();
-    if (_cursor_hidden) {
-      if (!_display_hide_cursor) {
-        CGDisplayHideCursor(kCGDirectMainDisplay);
-        _display_hide_cursor = true;
-      }
-    } else {
-      if (_display_hide_cursor) {
-        CGDisplayShowCursor(kCGDirectMainDisplay);
-        _display_hide_cursor = false;
-      }
-    }
-    req_properties.clear_cursor_hidden();
-  }
-
-  _properties.set_open(true);
-
-  if (_properties.has_size()) {
-    set_size_and_recalc(_properties.get_x_size(), _properties.get_y_size());
-  }
-
-  return (err == noErr);
-}
-
-/**
- * Required event upcall, used to dispatch window and application events back
- * into panda.
- */
-void osxGraphicsWindow::
-process_events() {
-  GraphicsWindow::process_events();
-
-  if (!osx_disable_event_loop) {
-    EventRef theEvent;
-    EventTargetRef theTarget = GetEventDispatcherTarget();
-
-    /*if (!_properties.has_parent_window()) */ {
-      while (ReceiveNextEvent(0, NULL, kEventDurationNoWait, true, &theEvent)== noErr) {
-        SendEventToEventTarget (theEvent, theTarget);
-        ReleaseEvent(theEvent);
-      }
-    }
-  }
-}
-
-/**
- * Required event upcall, used to dispatch window and application events back
- * into panda.
- */
-OSStatus osxGraphicsWindow::
-handle_key_input(EventHandlerCallRef my_handler, EventRef event,
-                 Boolean key_down) {
-  if (osxdisplay_cat.is_debug()) {
-    UInt32 key_code;
-    GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL,
-                      sizeof(UInt32), NULL, &key_code);
-
-    osxdisplay_cat.debug()
-      << ClockObject::get_global_clock()->get_real_time()
-      << " handle_key_input: " << (void *)this << ", " << key_code
-      << ", " << (int)key_down << "\n";
-  }
-
-  // CallNextEventHandler(my_handler, event);
-
-  // We don't check the result of the above function.  In principle, this
-  // should return eventNotHandledErr if the key event is not handled by the
-  // OS, but in practice, testing this just seems to eat the Escape keypress
-  // meaninglessly.  Keypresses like F11 that are already mapped in the
-  // desktop seem to not even come into this function in the first place.
-  UInt32 new_modifiers = 0;
-  OSStatus error = GetEventParameter(event, kEventParamKeyModifiers,
-                                     typeUInt32, NULL, sizeof(UInt32),
-                                     NULL, &new_modifiers);
-  if (error == noErr) {
-    handle_modifier_delta(new_modifiers);
-  }
-
-  UInt32 key_code;
-  GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL,
-                    sizeof(UInt32), NULL, &key_code);
-  ButtonHandle button = osx_translate_key(key_code, event);
-
-  if (key_down) {
-    if ((new_modifiers & cmdKey) != 0) {
-      if (button == KeyboardButton::ascii_key("q") ||
-          button == KeyboardButton::ascii_key("w")) {
-        // Command-Q or Command-W: quit the application or close the window,
-        // respectively.  For now, we treat them both the same: close the
-        // window.
-        user_close_request();
-      }
-    }
-    send_key_event(button, true);
-  } else {
-    send_key_event(button, false);
-  }
-
-  return CallNextEventHandler(my_handler, event);
-  // return noErr;
-}
-
-/**
- *
- */
-void osxGraphicsWindow::
-system_set_window_foreground(bool foreground) {
-  WindowProperties properties;
-  properties.set_foreground(foreground);
-  system_changed_properties(properties);
-}
-
-/**
- *
- */
-void osxGraphicsWindow::
-system_point_to_local_point(Point &global_point) {
-  if (_osx_window != NULL) {
-    GrafPtr savePort;
-    Boolean port_changed = QDSwapPort(GetWindowPort(_osx_window), &savePort);
-
-    GlobalToLocal(&global_point);
-
-    if (port_changed) {
-      QDSwapPort(savePort, NULL);
-    }
-  }
-}
-
-/**
- *
- */
-OSStatus osxGraphicsWindow::
-handle_window_mouse_events(EventHandlerCallRef my_handler, EventRef event) {
-  WindowRef window = NULL;
-  OSStatus result = eventNotHandledErr;
-  UInt32 kind = GetEventKind(event);
-  EventMouseButton button = 0;
-  Point global_point = {0, 0};
-  UInt32 modifiers = 0;
-  Rect rect_port;
-  SInt32 this_wheel_delta;
-  EventMouseWheelAxis wheelAxis;
-
-  // cerr <<" Start Mouse Event " << _ID << "\n";
-
-  // Mac OS X v10.1 and later should this be front window???
-  GetEventParameter(event, kEventParamWindowRef, typeWindowRef, NULL,
-                    sizeof(WindowRef), NULL, &window);
-
-  if (!_is_fullscreen && (window == NULL || window != _osx_window)) {
-    if (kind == kEventMouseMoved) {
-      set_pointer_out_of_window();
-    }
-    return eventNotHandledErr;
-  }
-
-  GetWindowPortBounds(window, &rect_port);
-
-  // result = CallNextEventHandler(my_handler, event); if (eventNotHandledErr
-  // == result)
-  { // only handle events not already handled (prevents weird resize interaction)
-    switch (kind) {
-      // Whenever mouse button state changes, generate the appropriate Panda
-      // downup events to represent the change.
-
-    case kEventMouseDown:
-    case kEventMouseUp:
-      {
-        GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
-        if (_properties.get_mouse_mode() == WindowProperties::M_relative) {
-          HIPoint delta;
-          GetEventParameter(event, kEventParamMouseDelta, typeHIPoint, NULL, sizeof(HIPoint), NULL, (void*) &delta);
-
-          MouseData currMouse = get_pointer(0);
-          delta.x += currMouse.get_x();
-          delta.y += currMouse.get_y();
-          set_pointer_in_window((int)delta.x, (int)delta.y);
-        } else {
-          GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL , (void*) &global_point);
-          system_point_to_local_point(global_point);
-          set_pointer_in_window((int)global_point.h, (int)global_point.v);
-        }
-
-        UInt32 new_buttons = GetCurrentEventButtonState();
-        handle_button_delta(new_buttons);
-      }
-      result = noErr;
-      break;
-
-    case kEventMouseMoved:
-    case kEventMouseDragged:
-      if (_properties.get_mouse_mode() == WindowProperties::M_relative) {
-        HIPoint delta;
-        GetEventParameter(event, kEventParamMouseDelta, typeHIPoint, NULL, sizeof(HIPoint), NULL, (void*) &delta);
-
-        MouseData currMouse = get_pointer(0);
-        delta.x += currMouse.get_x();
-        delta.y += currMouse.get_y();
-        set_pointer_in_window((int)delta.x, (int)delta.y);
-      } else {
-        GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, (void*) &global_point);
-        system_point_to_local_point(global_point);
-
-        if (kind == kEventMouseMoved &&
-            (global_point.h < 0 || global_point.v < 0)) {
-          // Moving into the titlebar region.
-          set_pointer_out_of_window();
-        } else {
-          // Moving within the window itself (or dragging anywhere).
-          set_pointer_in_window((int)global_point.h, (int)global_point.v);
-        }
-      }
-      result = noErr;
-      break;
-
-    case kEventMouseWheelMoved:
-      GetEventParameter(event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(this_wheel_delta), NULL, &this_wheel_delta);
-      GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(wheelAxis), NULL, &wheelAxis);
-      GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &global_point);
-      system_point_to_local_point(global_point);
-
-      if (wheelAxis == kEventMouseWheelAxisX) {
-        set_pointer_in_window((int)global_point.h, (int)global_point.v);
-        _wheel_hdelta += this_wheel_delta;
-        SInt32 wheel_scale = osx_mouse_wheel_scale;
-        while (_wheel_hdelta > wheel_scale) {
-          _input_devices[0].button_down(MouseButton::wheel_left());
-          _input_devices[0].button_up(MouseButton::wheel_left());
-          _wheel_hdelta -= wheel_scale;
-        }
-        while (_wheel_hdelta < -wheel_scale) {
-          _input_devices[0].button_down(MouseButton::wheel_right());
-          _input_devices[0].button_up(MouseButton::wheel_right());
-          _wheel_hdelta += wheel_scale;
-        }
-      }
-      if (wheelAxis == kEventMouseWheelAxisY) {
-        set_pointer_in_window((int)global_point.h, (int)global_point.v);
-        _wheel_vdelta += this_wheel_delta;
-        SInt32 wheel_scale = osx_mouse_wheel_scale;
-        while (_wheel_vdelta > wheel_scale) {
-          _input_devices[0].button_down(MouseButton::wheel_up());
-          _input_devices[0].button_up(MouseButton::wheel_up());
-          _wheel_vdelta -= wheel_scale;
-        }
-        while (_wheel_vdelta < -wheel_scale) {
-          _input_devices[0].button_down(MouseButton::wheel_down());
-          _input_devices[0].button_up(MouseButton::wheel_down());
-          _wheel_vdelta += wheel_scale;
-        }
-      }
-      result = noErr;
-      break;
-    }
-    // result = noErr;
-  }
-
-  return result;
-}
-
-/**
- * MAC Key Codes to Panda Key Codes
- */
-ButtonHandle osxGraphicsWindow::
-osx_translate_key(UInt32 key, EventRef event) {
-  ButtonHandle nk = ButtonHandle::none();
-  switch (key) {
-  case   0: nk = KeyboardButton::ascii_key('a'); break;
-  case  11: nk = KeyboardButton::ascii_key('b'); break;
-  case   8: nk = KeyboardButton::ascii_key('c'); break;
-  case   2: nk = KeyboardButton::ascii_key('d'); break;
-  case  14: nk = KeyboardButton::ascii_key('e'); break;
-  case   3: nk = KeyboardButton::ascii_key('f'); break;
-  case   5: nk = KeyboardButton::ascii_key('g'); break;
-  case   4: nk = KeyboardButton::ascii_key('h'); break;
-  case  34: nk = KeyboardButton::ascii_key('i'); break;
-  case  38: nk = KeyboardButton::ascii_key('j'); break;
-  case  40: nk = KeyboardButton::ascii_key('k'); break;
-  case  37: nk = KeyboardButton::ascii_key('l'); break;
-  case  46: nk = KeyboardButton::ascii_key('m'); break;
-  case  45: nk = KeyboardButton::ascii_key('n'); break;
-  case  31: nk = KeyboardButton::ascii_key('o'); break;
-  case  35: nk = KeyboardButton::ascii_key('p'); break;
-  case  12: nk = KeyboardButton::ascii_key('q'); break;
-  case  15: nk = KeyboardButton::ascii_key('r'); break;
-  case   1: nk = KeyboardButton::ascii_key('s'); break;
-  case  17: nk = KeyboardButton::ascii_key('t'); break;
-  case  32: nk = KeyboardButton::ascii_key('u'); break;
-  case   9: nk = KeyboardButton::ascii_key('v'); break;
-  case  13: nk = KeyboardButton::ascii_key('w'); break;
-  case   7: nk = KeyboardButton::ascii_key('x'); break;
-  case  16: nk = KeyboardButton::ascii_key('y'); break;
-  case   6: nk = KeyboardButton::ascii_key('z'); break;
-
-    // top row numbers
-  case  29: nk = KeyboardButton::ascii_key('0'); break;
-  case  18: nk = KeyboardButton::ascii_key('1'); break;
-  case  19: nk = KeyboardButton::ascii_key('2'); break;
-  case  20: nk = KeyboardButton::ascii_key('3'); break;
-  case  21: nk = KeyboardButton::ascii_key('4'); break;
-  case  23: nk = KeyboardButton::ascii_key('5'); break;
-  case  22: nk = KeyboardButton::ascii_key('6'); break;
-  case  26: nk = KeyboardButton::ascii_key('7'); break;
-  case  28: nk = KeyboardButton::ascii_key('8'); break;
-  case  25: nk = KeyboardButton::ascii_key('9'); break;
-
-    // key pad ... do they really map to the top number in panda ?
-  case  82: nk = KeyboardButton::ascii_key('0'); break;
-  case  83: nk = KeyboardButton::ascii_key('1'); break;
-  case  84: nk = KeyboardButton::ascii_key('2'); break;
-  case  85: nk = KeyboardButton::ascii_key('3'); break;
-  case  86: nk = KeyboardButton::ascii_key('4'); break;
-  case  87: nk = KeyboardButton::ascii_key('5'); break;
-  case  88: nk = KeyboardButton::ascii_key('6'); break;
-  case  89: nk = KeyboardButton::ascii_key('7'); break;
-  case  91: nk = KeyboardButton::ascii_key('8'); break;
-  case  92: nk = KeyboardButton::ascii_key('9'); break;
-
-    // case  36: nk = KeyboardButton::ret(); break;  no return in panda ???
-  case  49: nk = KeyboardButton::space(); break;
-  case  51: nk = KeyboardButton::backspace(); break;
-  case  48: nk = KeyboardButton::tab(); break;
-  case  53: nk = KeyboardButton::escape(); break;
-  case  76: nk = KeyboardButton::enter(); break;
-  case  36: nk = KeyboardButton::enter(); break;
-
-  case 123: nk = KeyboardButton::left(); break;
-  case 124: nk = KeyboardButton::right(); break;
-  case 125: nk = KeyboardButton::down(); break;
-  case 126: nk = KeyboardButton::up(); break;
-  case 116: nk = KeyboardButton::page_up(); break;
-  case 121: nk = KeyboardButton::page_down(); break;
-  case 115: nk = KeyboardButton::home(); break;
-  case 119: nk = KeyboardButton::end(); break;
-  case 114: nk = KeyboardButton::help(); break;
-  case 117: nk = KeyboardButton::del(); break;
-
-    // case  71: nk = KeyboardButton::num_lock() break;
-
-  case 122: nk = KeyboardButton::f1(); break;
-  case 120: nk = KeyboardButton::f2(); break;
-  case  99: nk = KeyboardButton::f3(); break;
-  case 118: nk = KeyboardButton::f4(); break;
-  case  96: nk = KeyboardButton::f5(); break;
-  case  97: nk = KeyboardButton::f6(); break;
-  case  98: nk = KeyboardButton::f7(); break;
-  case 100: nk = KeyboardButton::f8(); break;
-  case 101: nk = KeyboardButton::f9(); break;
-  case 109: nk = KeyboardButton::f10(); break;
-  case 103: nk = KeyboardButton::f11(); break;
-  case 111: nk = KeyboardButton::f12(); break;
-
-  case 105: nk = KeyboardButton::f13(); break;
-  case 107: nk = KeyboardButton::f14(); break;
-  case 113: nk = KeyboardButton::f15(); break;
-  case 106: nk = KeyboardButton::f16(); break;
-
-    // shiftable chartablet
-  case  50: nk = KeyboardButton::ascii_key('`'); break;
-  case  27: nk = KeyboardButton::ascii_key('-'); break;
-  case  24: nk = KeyboardButton::ascii_key('='); break;
-  case  33: nk = KeyboardButton::ascii_key('['); break;
-  case  30: nk = KeyboardButton::ascii_key(']'); break;
-  case  42: nk = KeyboardButton::ascii_key('\\'); break;
-  case  41: nk = KeyboardButton::ascii_key(';'); break;
-  case  39: nk = KeyboardButton::ascii_key('\''); break;
-  case  43: nk = KeyboardButton::ascii_key(','); break;
-  case  47: nk = KeyboardButton::ascii_key('.'); break;
-  case  44: nk = KeyboardButton::ascii_key('/'); break;
-
-  default:
-    if (osxdisplay_cat.is_debug()) {
-      osxdisplay_cat.debug()
-        << " Untranslated KeyCode: " << key
-        << " (0x" << hex << key << dec << ")\n";
-    }
-
-    // not sure this is right .. but no mapping for keypad and such this at
-    // least does a best gess..
-
-    char charCode = 0;
-    if (GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, nil, sizeof(charCode), nil, &charCode) == noErr) {
-      nk = KeyboardButton::ascii_key(charCode);
-    }
-  }
-  return nk;
-}
-
-/**
- * Used to emulate key events for the MAC key modifiers.
- */
-void osxGraphicsWindow::
-handle_modifier_delta(UInt32 new_modifiers) {
-  UInt32 changed = _last_key_modifiers ^ new_modifiers;
-
-  if ((changed & (shiftKey | rightShiftKey)) != 0) {
-    send_key_event(KeyboardButton::shift(),(new_modifiers & (shiftKey | rightShiftKey)) != 0) ;
-  }
-
-  if ((changed & (optionKey | rightOptionKey)) != 0) {
-    send_key_event(KeyboardButton::alt(),(new_modifiers & (optionKey | rightOptionKey)) != 0);
-  }
-
-  if ((changed & (controlKey | rightControlKey)) != 0) {
-    send_key_event(KeyboardButton::control(),(new_modifiers & (controlKey | rightControlKey)) != 0);
-  }
-
-  if ((changed & cmdKey) != 0) {
-    send_key_event(KeyboardButton::meta(),(new_modifiers & cmdKey) != 0);
-  }
-
-  if ((changed & alphaLock) != 0) {
-    send_key_event(KeyboardButton::caps_lock(),(new_modifiers & alphaLock) != 0);
-  }
-
-  // save current state
-  _last_key_modifiers = new_modifiers;
-}
-
-/**
- * Used to emulate button events
- */
-void osxGraphicsWindow::
-handle_button_delta(UInt32 new_buttons) {
-  UInt32 changed = _last_buttons ^ new_buttons;
-
-  if (changed & 0x01) {
-    if (new_buttons & 0x01) {
-      _input_devices[0].button_down(MouseButton::one());
-    } else {
-      _input_devices[0].button_up(MouseButton::one());
-    }
-  }
-
-  if (changed & 0x04) {
-    if (new_buttons & 0x04) {
-      _input_devices[0].button_down(MouseButton::two());
-    } else {
-      _input_devices[0].button_up(MouseButton::two());
-    }
-  }
-
-  if (changed & 0x02) {
-    if (new_buttons & 0x02) {
-      _input_devices[0].button_down(MouseButton::three());
-    } else {
-      _input_devices[0].button_up(MouseButton::three());
-    }
-  }
-
-  _last_buttons = new_buttons;
-}
-
-/**
- * Forces the pointer to the indicated position within the window, if
- * possible.
- *
- * Returns true if successful, false on failure.  This may fail if the mouse
- * is not currently within the window, or if the API doesn't support this
- * operation.
- */
-bool osxGraphicsWindow::
-move_pointer(int device, int x, int y) {
-  if (_osx_window == NULL) {
-    return false;
-  }
-
-  if (osxdisplay_cat.is_debug()) {
-    osxdisplay_cat.debug()
-      << "move_pointer " << device <<" "<< x <<" "<< y <<"\n";
-  }
-
-  Point pt = { 0, 0 };
-  pt.h = x;
-  pt.v = y;
-  set_pointer_in_window(x, y);
-
-  if (_properties.get_mouse_mode() == WindowProperties::M_absolute) {
-    local_point_to_system_point(pt);
-    CGPoint new_position = { 0, 0 };
-    new_position.x = pt.h;
-    new_position.y = pt.v;
-    mouse_mode_relative();
-    CGWarpMouseCursorPosition(new_position);
-    mouse_mode_absolute();
-  }
-
-  return true;
-}
-
-/**
- *
- */
-bool osxGraphicsWindow::
-do_reshape_request(int x_origin, int y_origin, bool has_origin,
-                   int x_size, int y_size) {
-  if (osxdisplay_cat.is_debug()) {
-    osxdisplay_cat.debug()
-      << "Do Reshape\n";
-  }
-
-  if (_properties.get_fullscreen()) {
-    return false;
-  }
-
-  // A coordinate of -2 means to center the window on screen.
-  if (x_origin == -2 || y_origin == -2 || x_origin == -1 || y_origin == -1) {
-    if (y_origin == -2) {
-      y_origin = (_pipe->get_display_height() - y_size) / 2;
-    }
-    if (x_origin == -2) {
-      x_origin = (_pipe->get_display_width() - x_size) / 2;
-    }
-    if (y_origin == -1) {
-      y_origin = 50;
-    }
-    if (x_origin == -1) {
-      x_origin = 10;
-    }
-    _properties.set_origin(x_origin, y_origin);
-    system_changed_properties(_properties);
-  }
-
-  /*
-  if (_properties.has_parent_window()) {
-    if (has_origin) {
-      NSWindow* parentWindow = (NSWindow *)_properties.get_parent_window();
-      NSRect parentFrame = [parentWindow frame];
-
-      MoveWindow(_osx_window, x_origin+parentFrame.origin.x, y_origin+parentFrame.origin.y, false);
-    }
-    } else */
-  {
-    // We sometimes get a bogus origin of (0, 0). As a special hack, treat
-    // this as a special case, and ignore it.
-    if (has_origin) {
-      if (x_origin != 0 || y_origin != 0) {
-        MoveWindow(_osx_window, x_origin, y_origin, false);
-      }
-    }
-  }
-
-  if (!_properties.get_undecorated()) {
-    // Constrain the window to the available desktop size.
-    Rect bounds;
-    GetAvailableWindowPositioningBounds(GetMainDevice(), &bounds);
-
-    x_size = min(x_size, bounds.right - bounds.left);
-    y_size = min(y_size, bounds.bottom - bounds.top);
-  }
-
-  SizeWindow(_osx_window, x_size, y_size, false);
-
-  system_changed_size(x_size, y_size);
-  return true;
-}
-
-/**
- * Applies the requested set of properties to the window, if possible, for
- * instance to request a change in size or minimization status.
- *
- * The window properties are applied immediately, rather than waiting until
- * the next frame.  This implies that this method may *only* be called from
- * within the window thread.
- *
- * The properties that have been applied are cleared from the structure by
- * this function; so on return, whatever remains in the properties structure
- * are those that were unchanged for some reason (probably because the
- * underlying interface does not support changing that property on an open
- * window).
- */
-void osxGraphicsWindow::
-set_properties_now(WindowProperties &properties) {
-  if (osxdisplay_cat.is_debug()) {
-    osxdisplay_cat.debug()
-      << "------------------------------------------------------\n";
-    osxdisplay_cat.debug()
-      << "set_properties_now " << properties << "\n";
-  }
-
-  GraphicsWindow::set_properties_now(properties);
-
-  if (osxdisplay_cat.is_debug()) {
-    osxdisplay_cat.debug()
-      << "set_properties_now After Base Class" << properties << "\n";
-  }
-
-  // for some changes .. a full rebuild is required for the OS layer Window.
-  // I think it is the chrome attribute and full screen behaviour.
-  bool need_full_rebuild = false;
-
-  // if we are not full and transitioning to full
-  if (properties.has_fullscreen() &&
-      properties.get_fullscreen() != _properties.get_fullscreen()) {
-    need_full_rebuild = true;
-  }
-
-  // If we are fullscreen and requesting a size change
-  if (_properties.get_fullscreen() &&
-      (properties.has_size() &&
-       (properties.get_x_size() != _properties.get_x_size() ||
-        properties.get_y_size() != _properties.get_y_size()))) {
-    need_full_rebuild = true;
-  }
-
-  // If we are fullscreen and requesting a minimize change
-  if (_properties.get_fullscreen() &&
-      (properties.has_minimized() &&
-       (properties.get_minimized() != _properties.get_minimized()))) {
-    need_full_rebuild = true;
-  }
-
-  if (need_full_rebuild) {
-    // Logic here is .. take a union of the properties .. with the new allowed
-    // to overwrite the old states.  and start a bootstrap of a new window ..
-
-    // get a copy of my properties..
-    WindowProperties req_properties(_properties);
-    release_system_resources(false);
-    req_properties.add_properties(properties);
-
-    os_open_window(req_properties);
-
-    // Now we've handled all of the requested properties.
-    properties.clear();
-  }
-
-  if (properties.has_title()) {
-    _properties.set_title(properties.get_title());
-
-    if (_osx_window) {
-      SetWindowTitleWithCFString(_osx_window,
-                                 CFStringCreateWithCString(NULL,properties.get_title().c_str(),
-                                                           kCFStringEncodingMacRoman));
-    }
-    properties.clear_title();
-  }
-
-  // An icon filename means to load up the icon and save it.  We can't
-  // necessarily apply it immediately; it will get applied later, in the
-  // window event handler.
-  if (properties.has_icon_filename()) {
-    if (set_icon_filename(properties.get_icon_filename())) {
-      properties.clear_icon_filename();
-    }
-  }
-
-  // decorated .. if this changes it reqires a new window
-  if (properties.has_undecorated()) {
-    _properties.set_undecorated(properties.get_undecorated());
-    properties.clear_undecorated();
-  }
-
-  if (properties.has_cursor_hidden()) {
-    _properties.set_cursor_hidden(properties.get_cursor_hidden());
-    _cursor_hidden = properties.get_cursor_hidden();
-    if (_cursor_hidden) {
-      if (!_display_hide_cursor) {
-        CGDisplayHideCursor(kCGDirectMainDisplay);
-        _display_hide_cursor = true;
-      }
-    } else {
-      if (_display_hide_cursor) {
-        CGDisplayShowCursor(kCGDirectMainDisplay);
-        _display_hide_cursor = false;
-      }
-    }
-    properties.clear_cursor_hidden();
-  }
-
-  if (properties.has_minimized()) {
-    if (_properties.get_minimized() != properties.get_minimized()) {
-      CollapseWindow(_osx_window, properties.get_minimized());
-      _properties.set_minimized(properties.get_minimized());
-      _properties.set_foreground(!properties.get_minimized());
-    }
-    properties.clear_minimized();
-  }
-
-  if (properties.has_mouse_mode()) {
-    switch (properties.get_mouse_mode()) {
-    case WindowProperties::M_absolute:
-      CGAssociateMouseAndMouseCursorPosition(true);
-      _properties.set_mouse_mode(WindowProperties::M_absolute);
-      properties.clear_mouse_mode();
-      break;
-
-    case WindowProperties::M_relative:
-      CGAssociateMouseAndMouseCursorPosition(false);
-      _properties.set_mouse_mode(WindowProperties::M_relative);
-      properties.clear_mouse_mode();
-      break;
-
-    case WindowProperties::M_confined:
-      break;
-    }
-  }
-
-  if (osxdisplay_cat.is_debug()) {
-    osxdisplay_cat.debug()
-      << "set_properties_now Out....." << _properties << "\n";
-  }
-
-  return;
-}
-
-/**
- *
- */
-void osxGraphicsWindow::
-local_point_to_system_point(Point &local_point) {
-  if (_osx_window != NULL) {
-    GrafPtr save_port;
-    Boolean port_changed = QDSwapPort(GetWindowPort(_osx_window), &save_port);
-
-    LocalToGlobal(&local_point);
-
-    if (port_changed) {
-      QDSwapPort(save_port, NULL);
-    }
-  }
-}
-
-/**
- * detaches mouse.  Only mouse delta from now on.
- */
-void osxGraphicsWindow::
-mouse_mode_relative() {
-  CGAssociateMouseAndMouseCursorPosition(false);
-}
-
-
-/**
- * reattaches mouse to location
- */
-void osxGraphicsWindow::
-mouse_mode_absolute() {
-  CGAssociateMouseAndMouseCursorPosition(true);
-}

+ 0 - 4
panda/src/osxdisplay/p3osxdisplay_composite1.cxx

@@ -1,4 +0,0 @@
-#include "config_osxdisplay.cxx"
-#include "osxGraphicsBuffer.cxx"
-#include "osxGraphicsPipe.cxx"
-#include "osxGraphicsStateGuardian.cxx"

BIN
panda/src/osxdisplay/resize_box.rgb


+ 0 - 167
panda/src/osxdisplay/resize_box.rgb.c

@@ -1,167 +0,0 @@
-
-/*
- * This table was generated by the command:
- *
- * bin2c -static -string -n resize_box -o resize_box.rgb.c resize_box.rgb
- */
-
-#include <stddef.h>
-
-static const unsigned char resize_box[] = {
-  0x01, 0xda, 0x01, 0x01, 0x00, 0x03, 0x00, 0x10, 0x00, 0x10, 0x00,
-  0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x81, 0x00,
-  0x00, 0x06, 0x38, 0x00, 0x00, 0x05, 0xf2, 0x00, 0x00, 0x05, 0xb0,
-  0x00, 0x00, 0x05, 0x7a, 0x00, 0x00, 0x05, 0x41, 0x00, 0x00, 0x05,
-  0x0b, 0x00, 0x00, 0x04, 0xd9, 0x00, 0x00, 0x04, 0xb3, 0x00, 0x00,
-  0x04, 0x8a, 0x00, 0x00, 0x04, 0x64, 0x00, 0x00, 0x04, 0x42, 0x00,
-  0x00, 0x04, 0x30, 0x00, 0x00, 0x04, 0x1e, 0x00, 0x00, 0x04, 0x0c,
-  0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x06, 0x86, 0x00, 0x00, 0x06,
-  0x4b, 0x00, 0x00, 0x06, 0x04, 0x00, 0x00, 0x05, 0xc1, 0x00, 0x00,
-  0x05, 0x88, 0x00, 0x00, 0x05, 0x50, 0x00, 0x00, 0x05, 0x19, 0x00,
-  0x00, 0x04, 0xe6, 0x00, 0x00, 0x04, 0xbd, 0x00, 0x00, 0x04, 0x95,
-  0x00, 0x00, 0x04, 0x6e, 0x00, 0x00, 0x04, 0x4b, 0x00, 0x00, 0x04,
-  0x35, 0x00, 0x00, 0x04, 0x23, 0x00, 0x00, 0x04, 0x11, 0x00, 0x00,
-  0x04, 0x03, 0x00, 0x00, 0x06, 0x8b, 0x00, 0x00, 0x06, 0x5e, 0x00,
-  0x00, 0x06, 0x16, 0x00, 0x00, 0x05, 0xd2, 0x00, 0x00, 0x05, 0x96,
-  0x00, 0x00, 0x05, 0x5f, 0x00, 0x00, 0x05, 0x27, 0x00, 0x00, 0x04,
-  0xf3, 0x00, 0x00, 0x04, 0xc7, 0x00, 0x00, 0x04, 0xa0, 0x00, 0x00,
-  0x04, 0x78, 0x00, 0x00, 0x04, 0x54, 0x00, 0x00, 0x04, 0x3a, 0x00,
-  0x00, 0x04, 0x28, 0x00, 0x00, 0x04, 0x16, 0x00, 0x00, 0x04, 0x06,
-  0x00, 0x00, 0x06, 0x90, 0x00, 0x00, 0x06, 0x71, 0x00, 0x00, 0x06,
-  0x28, 0x00, 0x00, 0x05, 0xe3, 0x00, 0x00, 0x05, 0xa4, 0x00, 0x00,
-  0x05, 0x6e, 0x00, 0x00, 0x05, 0x35, 0x00, 0x00, 0x05, 0x00, 0x00,
-  0x00, 0x04, 0xd1, 0x00, 0x00, 0x04, 0xab, 0x00, 0x00, 0x04, 0x82,
-  0x00, 0x00, 0x04, 0x5d, 0x00, 0x00, 0x04, 0x3f, 0x00, 0x00, 0x04,
-  0x2d, 0x00, 0x00, 0x04, 0x1b, 0x00, 0x00, 0x04, 0x09, 0x00, 0x00,
-  0x00, 0x05, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x12, 0x00,
-  0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0f,
-  0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00,
-  0x0a, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00,
-  0x00, 0x09, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x05, 0x00,
-  0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05,
-  0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00,
-  0x11, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00,
-  0x00, 0x0e, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x0a, 0x00,
-  0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x09,
-  0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
-  0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
-  0x00, 0x13, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x11, 0x00,
-  0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x0e,
-  0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
-  0x0b, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00,
-  0x00, 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x05, 0x00,
-  0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10,
-  0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
-  0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00,
-  0x00, 0x0b, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00,
-  0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03,
-  0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
-  0x03, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10,
-  0x00, 0x00, 0x0f, 0xec, 0x01, 0x00, 0x00, 0x0f, 0xec, 0x01, 0x00,
-  0x00, 0x0f, 0xec, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x0f, 0xec,
-  0x01, 0x00, 0x00, 0x0f, 0xec, 0x01, 0x00, 0x00, 0x0f, 0xec, 0x01,
-  0x00, 0x00, 0x10, 0x00, 0x00, 0x0f, 0xec, 0x01, 0x00, 0x00, 0x0f,
-  0xec, 0x01, 0x00, 0x00, 0x0f, 0xec, 0x01, 0x00, 0x00, 0x10, 0x00,
-  0x00, 0x0d, 0xec, 0x81, 0xcf, 0x01, 0xec, 0x01, 0x00, 0x00, 0x0d,
-  0xec, 0x81, 0xcf, 0x01, 0xec, 0x01, 0x00, 0x00, 0x0d, 0xec, 0x81,
-  0xcf, 0x01, 0xec, 0x01, 0x00, 0x00, 0x0d, 0x00, 0x81, 0xff, 0x02,
-  0x00, 0x00, 0x0c, 0xec, 0x82, 0xcf, 0x80, 0x01, 0xec, 0x01, 0x00,
-  0x00, 0x0c, 0xec, 0x82, 0xcf, 0x80, 0x01, 0xec, 0x01, 0x00, 0x00,
-  0x0c, 0xec, 0x82, 0xcf, 0x80, 0x01, 0xec, 0x01, 0x00, 0x00, 0x0c,
-  0x00, 0x82, 0xff, 0xff, 0x02, 0x00, 0x00, 0x0b, 0xec, 0x83, 0xca,
-  0x7e, 0xec, 0x01, 0xec, 0x01, 0x00, 0x00, 0x0b, 0xec, 0x83, 0xca,
-  0x7e, 0xec, 0x01, 0xec, 0x01, 0x00, 0x00, 0x0b, 0xec, 0x83, 0xca,
-  0x7e, 0xec, 0x01, 0xec, 0x01, 0x00, 0x00, 0x0b, 0x00, 0x82, 0xff,
-  0xff, 0x03, 0x00, 0x00, 0x0a, 0xec, 0x82, 0xca, 0x7e, 0x03, 0xec,
-  0x01, 0x00, 0x00, 0x0a, 0xec, 0x82, 0xca, 0x7e, 0x03, 0xec, 0x01,
-  0x00, 0x00, 0x0a, 0xec, 0x82, 0xca, 0x7e, 0x03, 0xec, 0x01, 0x00,
-  0x00, 0x0a, 0x00, 0x82, 0xff, 0xff, 0x04, 0x00, 0x00, 0x09, 0xec,
-  0x85, 0xcc, 0x80, 0xec, 0xec, 0xcf, 0x01, 0xec, 0x01, 0x00, 0x00,
-  0x09, 0xec, 0x85, 0xcc, 0x80, 0xec, 0xec, 0xcf, 0x01, 0xec, 0x01,
-  0x00, 0x00, 0x09, 0xec, 0x85, 0xcc, 0x80, 0xec, 0xec, 0xcf, 0x01,
-  0xec, 0x01, 0x00, 0x00, 0x09, 0x00, 0x85, 0xff, 0xff, 0x00, 0x00,
-  0xff, 0x02, 0x00, 0x00, 0x08, 0xec, 0x86, 0xca, 0x80, 0xec, 0xec,
-  0xcf, 0x80, 0x01, 0xec, 0x01, 0x00, 0x00, 0x08, 0xec, 0x86, 0xca,
-  0x80, 0xec, 0xec, 0xcf, 0x80, 0x01, 0xec, 0x01, 0x00, 0x00, 0x08,
-  0xec, 0x86, 0xca, 0x80, 0xec, 0xec, 0xcf, 0x80, 0x01, 0xec, 0x01,
-  0x00, 0x00, 0x08, 0x00, 0x86, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff,
-  0x02, 0x00, 0x00, 0x07, 0xec, 0x87, 0xc6, 0x7e, 0xec, 0xec, 0xc9,
-  0x7e, 0xec, 0x01, 0xec, 0x01, 0x00, 0x00, 0x07, 0xec, 0x87, 0xc6,
-  0x7e, 0xec, 0xec, 0xc9, 0x7e, 0xec, 0x01, 0xec, 0x01, 0x00, 0x00,
-  0x07, 0xec, 0x87, 0xc6, 0x7e, 0xec, 0xec, 0xc9, 0x7e, 0xec, 0x01,
-  0xec, 0x01, 0x00, 0x00, 0x07, 0x00, 0x86, 0xff, 0xff, 0x00, 0x00,
-  0xff, 0xff, 0x03, 0x00, 0x00, 0x06, 0xec, 0x86, 0xc6, 0x7e, 0xec,
-  0xec, 0xc9, 0x7e, 0x03, 0xec, 0x01, 0x00, 0x00, 0x06, 0xec, 0x86,
-  0xc6, 0x7e, 0xec, 0xec, 0xc9, 0x7e, 0x03, 0xec, 0x01, 0x00, 0x00,
-  0x06, 0xec, 0x86, 0xc6, 0x7e, 0xec, 0xec, 0xc9, 0x7e, 0x03, 0xec,
-  0x01, 0x00, 0x00, 0x06, 0x00, 0x86, 0xff, 0xff, 0x00, 0x00, 0xff,
-  0xff, 0x04, 0x00, 0x00, 0x05, 0xec, 0x89, 0xc8, 0x80, 0xec, 0xec,
-  0xcd, 0x80, 0xec, 0xec, 0xcd, 0x01, 0xec, 0x01, 0x00, 0x00, 0x05,
-  0xec, 0x89, 0xc8, 0x80, 0xec, 0xec, 0xcd, 0x80, 0xec, 0xec, 0xcd,
-  0x01, 0xec, 0x01, 0x00, 0x00, 0x05, 0xec, 0x89, 0xc8, 0x80, 0xec,
-  0xec, 0xcd, 0x80, 0xec, 0xec, 0xcd, 0x01, 0xec, 0x01, 0x00, 0x00,
-  0x05, 0x00, 0x89, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
-  0xff, 0x02, 0x00, 0x00, 0x04, 0xec, 0x8a, 0xcd, 0x80, 0xec, 0xec,
-  0xcd, 0x80, 0xec, 0xec, 0xcd, 0x80, 0x01, 0xec, 0x01, 0x00, 0x00,
-  0x04, 0xec, 0x8a, 0xcd, 0x80, 0xec, 0xec, 0xcd, 0x80, 0xec, 0xec,
-  0xcd, 0x80, 0x01, 0xec, 0x01, 0x00, 0x00, 0x04, 0xec, 0x8a, 0xcd,
-  0x80, 0xec, 0xec, 0xcd, 0x80, 0xec, 0xec, 0xcd, 0x80, 0x01, 0xec,
-  0x01, 0x00, 0x00, 0x04, 0x00, 0x8a, 0xff, 0xff, 0x00, 0x00, 0xff,
-  0xff, 0x00, 0x00, 0xff, 0xff, 0x02, 0x00, 0x00, 0x03, 0xec, 0x8b,
-  0xc9, 0x7e, 0xec, 0xec, 0xc9, 0x7e, 0xec, 0xec, 0xc9, 0x7e, 0xec,
-  0x01, 0xec, 0x01, 0x00, 0x00, 0x03, 0xec, 0x8b, 0xc9, 0x7e, 0xec,
-  0xec, 0xc9, 0x7e, 0xec, 0xec, 0xc9, 0x7e, 0xec, 0x01, 0xec, 0x01,
-  0x00, 0x00, 0x03, 0xec, 0x8b, 0xc9, 0x7e, 0xec, 0xec, 0xc9, 0x7e,
-  0xec, 0xec, 0xc9, 0x7e, 0xec, 0x01, 0xec, 0x01, 0x00, 0x00, 0x03,
-  0x00, 0x8a, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff,
-  0xff, 0x03, 0x00, 0x00, 0x0f, 0xec, 0x01, 0x00, 0x00, 0x0f, 0xec,
-  0x01, 0x00, 0x00, 0x0f, 0xec, 0x01, 0x00, 0x00, 0x10, 0x00, 0x00
-};
-
-static const size_t resize_box_len = 1683;
-

+ 0 - 9
panda/src/pandabase/pandasymbols.h

@@ -122,7 +122,6 @@
   #define BUILDING_PANDA_COCOADISPLAY
   #define BUILDING_PANDA_GLGSG
   #define BUILDING_PANDA_GLXDISPLAY
-  #define BUILDING_PANDA_OSXDISPLAY
   #define BUILDING_PANDA_WGLDISPLAY
 #endif
 
@@ -340,14 +339,6 @@
   #define EXPTP_PANDA_NET IMPORT_TEMPL
 #endif
 
-#ifdef BUILDING_PANDA_OSXDISPLAY
-  #define EXPCL_PANDA_OSXDISPLAY EXPORT_CLASS
-  #define EXPTP_PANDA_OSXDISPLAY EXPORT_TEMPL
-#else
-  #define EXPCL_PANDA_OSXDISPLAY IMPORT_CLASS
-  #define EXPTP_PANDA_OSXDISPLAY IMPORT_TEMPL
-#endif
-
 #ifdef BUILDING_PANDA_PARAMETRICS
   #define EXPCL_PANDA_PARAMETRICS EXPORT_CLASS
   #define EXPTP_PANDA_PARAMETRICS EXPORT_TEMPL

+ 0 - 34
panda/src/tinydisplay/config_tinydisplay.cxx

@@ -16,8 +16,6 @@
 #include "tinyXGraphicsWindow.h"
 #include "tinyWinGraphicsPipe.h"
 #include "tinyWinGraphicsWindow.h"
-#include "tinyOsxGraphicsPipe.h"
-#include "tinyOsxGraphicsWindow.h"
 #include "tinySDLGraphicsPipe.h"
 #include "tinySDLGraphicsWindow.h"
 #include "tinyOffscreenGraphicsPipe.h"
@@ -40,26 +38,6 @@ ConfigureFn(config_tinydisplay) {
   init_libtinydisplay();
 }
 
-ConfigVariableBool show_resize_box
-("show-resize-box", true,
- PRC_DESC("When this variable is true, then resizable OSX Panda windows will "
-          "be rendered with a resize control in the lower-right corner.  "
-          "This is specially handled by Panda, since otherwise the 3-d "
-          "window would completely hide any resize control drawn by the "
-          "OS.  Set this variable false to allow this control to be hidden."));
-
-ConfigVariableBool osx_disable_event_loop
-("osx-disable-event-loop", false,
- PRC_DESC("Set this true to disable the window event loop for the Panda "
-          "windows.  This makes sense only in a publish environment where "
-          "the window event loop is already handled by another part of the "
-          "app."));
-
-ConfigVariableInt osx_mouse_wheel_scale
-("osx-mouse-wheel-scale", 1,
- PRC_DESC("Specify the number of units to spin the Mac mouse wheel to "
-          "represent a single wheel_up or wheel_down message."));
-
 ConfigVariableBool td_ignore_mipmaps
   ("td-ignore-mipmaps", false,
    PRC_DESC("Configure this true to disable use of mipmaps on the "
@@ -117,14 +95,6 @@ init_libtinydisplay() {
   ps->set_system_tag("TinyPanda", "native_window_system", "Win");
 #endif
 
-#if defined(IS_OSX) && !defined(BUILD_IPHONE) && defined(HAVE_CARBON) && !__LP64__
-  TinyOsxGraphicsPipe::init_type();
-  TinyOsxGraphicsWindow::init_type();
-  selection->add_pipe_type(TinyOsxGraphicsPipe::get_class_type(),
-                           TinyOsxGraphicsPipe::pipe_constructor);
-  ps->set_system_tag("TinyPanda", "native_window_system", "OSX");
-#endif
-
 #ifdef HAVE_SDL
   TinySDLGraphicsPipe::init_type();
   TinySDLGraphicsWindow::init_type();
@@ -150,10 +120,6 @@ get_pipe_type_p3tinydisplay() {
   return TinyWinGraphicsPipe::get_class_type().get_index();
 #endif
 
-#if defined(IS_OSX) && !defined(BUILD_IPHONE) && defined(HAVE_CARBON) && !__LP64__
-  return TinyOsxGraphicsPipe::get_class_type().get_index();
-#endif
-
 #ifdef HAVE_X11
   return TinyXGraphicsPipe::get_class_type().get_index();
 #endif

+ 0 - 4
panda/src/tinydisplay/config_tinydisplay.h

@@ -25,10 +25,6 @@ NotifyCategoryDecl(tinydisplay, EXPCL_TINYDISPLAY, EXPTP_TINYDISPLAY);
 extern EXPCL_TINYDISPLAY void init_libtinydisplay();
 extern "C" EXPCL_TINYDISPLAY int get_pipe_type_p3tinydisplay();
 
-extern ConfigVariableBool show_resize_box;
-extern ConfigVariableBool osx_disable_event_loop;
-extern ConfigVariableInt osx_mouse_wheel_scale;
-
 extern ConfigVariableInt td_texture_ram;
 extern ConfigVariableBool td_ignore_mipmaps;
 extern ConfigVariableBool td_ignore_clamp;

+ 0 - 6
panda/src/tinydisplay/p3tinydisplay_composite2.cxx

@@ -1,11 +1,5 @@
-// We have to include this early, before anyone includes
-// netinet/tcp.h, which will define TCP_NODELAY and other symbols and
-// confuse the Apple system headers.
-#include "tinyOsxGraphicsPipe.h"
-
 #include "tinyGraphicsStateGuardian.cxx"
 #include "tinyOffscreenGraphicsPipe.cxx"
-#include "tinyOsxGraphicsPipe.cxx"
 #include "tinySDLGraphicsPipe.cxx"
 #include "tinySDLGraphicsWindow.cxx"
 #include "tinyTextureContext.cxx"

+ 0 - 12
panda/src/tinydisplay/tinyOsxGraphicsPipe.I

@@ -1,12 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file tinyOsxGraphicsPipe.I
- * @author drose
- * @date 2008-05-12
- */

+ 0 - 252
panda/src/tinydisplay/tinyOsxGraphicsPipe.cxx

@@ -1,252 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file tinyOsxGraphicsPipe.cxx
- * @author drose
- * @date 2008-05-12
- */
-
-#include "pandabase.h"
-
-#if defined(IS_OSX) && !defined(BUILD_IPHONE) && defined(HAVE_CARBON) && !__LP64__
-
-#include "tinyOsxGraphicsPipe.h"
-#include "config_tinydisplay.h"
-#include "tinyOsxGraphicsWindow.h"
-#include "tinyGraphicsBuffer.h"
-#include "pnmImage.h"
-#include "subprocessWindow.h"
-#include "nativeWindowHandle.h"
-
-TypeHandle TinyOsxGraphicsPipe::_type_handle;
-
-/**
- *
- */
-TinyOsxGraphicsPipe::
-TinyOsxGraphicsPipe() {
-  CGRect display_bounds = CGDisplayBounds(kCGDirectMainDisplay);
-  _display_width = CGRectGetWidth(display_bounds);
-  _display_height = CGRectGetHeight(display_bounds);
-}
-
-/**
- *
- */
-TinyOsxGraphicsPipe::
-~TinyOsxGraphicsPipe() {
-}
-
-/**
- * Returns the name of the rendering interface associated with this
- * GraphicsPipe.  This is used to present to the user to allow him/her to
- * choose between several possible GraphicsPipes available on a particular
- * platform, so the name should be meaningful and unique for a given platform.
- */
-std::string TinyOsxGraphicsPipe::
-get_interface_name() const {
-  return "TinyPanda";
-}
-
-/**
- * This function is passed to the GraphicsPipeSelection object to allow the
- * user to make a default TinyOsxGraphicsPipe.
- */
-PT(GraphicsPipe) TinyOsxGraphicsPipe::
-pipe_constructor() {
-  return new TinyOsxGraphicsPipe;
-}
-
-/**
- * Creates a new Quartz bitmap image with the data in the indicated PNMImage.
- * The caller should eventually free this image via CGImageRelease.
- */
-CGImageRef TinyOsxGraphicsPipe::
-create_cg_image(const PNMImage &pnm_image) {
-  size_t width = pnm_image.get_x_size();
-  size_t height = pnm_image.get_y_size();
-
-#ifdef PGM_BIGGRAYS
-  size_t bytes_per_component = 2;
-#else
-  size_t bytes_per_component = 1;
-#endif
-  size_t bits_per_component = bytes_per_component * 8;
-  size_t num_components = pnm_image.get_num_channels();
-
-  size_t bits_per_pixel = num_components * bits_per_component;
-  size_t bytes_per_row = num_components * bytes_per_component * width;
-
-  size_t num_bytes = bytes_per_row * height;
-  bool has_alpha;
-  bool is_grayscale;
-
-  CFStringRef color_space_name = nullptr;
-  switch (pnm_image.get_color_type()) {
-  case PNMImage::CT_grayscale:
-    color_space_name = kCGColorSpaceGenericGray;
-    has_alpha = false;
-    is_grayscale = true;
-    break;
-
-  case PNMImage::CT_two_channel:
-    color_space_name = kCGColorSpaceGenericGray;
-    has_alpha = true;
-    is_grayscale = true;
-    break;
-
-  case PNMImage::CT_color:
-    color_space_name = kCGColorSpaceGenericRGB;
-    has_alpha = false;
-    is_grayscale = false;
-    break;
-
-  case PNMImage::CT_four_channel:
-    color_space_name = kCGColorSpaceGenericRGB;
-    has_alpha = true;
-    is_grayscale = false;
-    break;
-
-  case PNMImage::CT_invalid:
-    // Shouldn't get here.
-    nassertr(false, nullptr);
-    break;
-  }
-  nassertr(color_space_name != nullptr, nullptr);
-
-  CGColorSpaceRef color_space = CGColorSpaceCreateWithName(color_space_name);
-  nassertr(color_space != nullptr, nullptr);
-
-  CGBitmapInfo bitmap_info = 0;
-#ifdef PGM_BIGGRAYS
-  bitmap_info |= kCGBitmapByteOrder16Host;
-#endif
-  if (has_alpha) {
-    bitmap_info |= kCGImageAlphaLast;
-  }
-
-  // Now convert the pixel data to a format friendly to CGImageCreate().
-  char *char_array = (char *)PANDA_MALLOC_ARRAY(num_bytes);
-
-  xelval *dp = (xelval *)char_array;
-  for (size_t yi = 0; yi < height; ++yi) {
-    for (size_t xi = 0; xi < width; ++xi) {
-      if (is_grayscale) {
-        *dp++ = (xelval)(pnm_image.get_gray(xi, yi) * PGM_MAXMAXVAL);
-      } else {
-        *dp++ = (xelval)(pnm_image.get_red(xi, yi) * PGM_MAXMAXVAL);
-        *dp++ = (xelval)(pnm_image.get_green(xi, yi) * PGM_MAXMAXVAL);
-        *dp++ = (xelval)(pnm_image.get_blue(xi, yi) * PGM_MAXMAXVAL);
-      }
-      if (has_alpha) {
-        *dp++ = (xelval)(pnm_image.get_alpha(xi, yi) * PGM_MAXMAXVAL);
-      }
-    }
-  }
-  nassertr((void *)dp == (void *)(char_array + num_bytes), nullptr);
-
-  CGDataProviderRef provider =
-    CGDataProviderCreateWithData(nullptr, char_array, num_bytes, release_data);
-  nassertr(provider != nullptr, nullptr);
-
-  CGImageRef image = CGImageCreate
-    (width, height, bits_per_component, bits_per_pixel, bytes_per_row,
-     color_space, bitmap_info, provider,
-     nullptr, false, kCGRenderingIntentDefault);
-  nassertr(image != nullptr, nullptr);
-
-  CGColorSpaceRelease(color_space);
-  CGDataProviderRelease(provider);
-
-  return image;
-}
-
-/**
- * This callback is assigned to delete the data array allocated within
- * create_cg_image().
- */
-void TinyOsxGraphicsPipe::
-release_data(void *info, const void *data, size_t size) {
-  char *char_array = (char *)data;
-  PANDA_FREE_ARRAY(char_array);
-}
-
-/**
- * Creates a new window or buffer on the pipe, if possible.  This routine is
- * only called from GraphicsEngine::make_output.
- */
-PT(GraphicsOutput) TinyOsxGraphicsPipe::
-make_output(const std::string &name,
-            const FrameBufferProperties &fb_prop,
-            const WindowProperties &win_prop,
-            int flags,
-            GraphicsEngine *engine,
-            GraphicsStateGuardian *gsg,
-            GraphicsOutput *host,
-            int retry,
-            bool &precertify) {
-
-  if (!_is_valid) {
-    return nullptr;
-  }
-
-  TinyGraphicsStateGuardian *tinygsg = 0;
-  if (gsg != 0) {
-    DCAST_INTO_R(tinygsg, gsg, nullptr);
-  }
-
-  // First thing to try: a TinyOsxGraphicsWindow
-
-  if (retry == 0) {
-    if (((flags&BF_require_parasite)!=0)||
-        ((flags&BF_refuse_window)!=0)||
-        ((flags&BF_resizeable)!=0)||
-        ((flags&BF_size_track_host)!=0)||
-        ((flags&BF_rtt_cumulative)!=0)||
-        ((flags&BF_can_bind_color)!=0)||
-        ((flags&BF_can_bind_every)!=0)) {
-      return nullptr;
-    }
-    if ((flags & BF_fb_props_optional)==0) {
-      if ((fb_prop.get_aux_rgba() > 0)||
-          (fb_prop.get_aux_hrgba() > 0)||
-          (fb_prop.get_aux_float() > 0)) {
-        return nullptr;
-      }
-    }
-    WindowHandle *window_handle = win_prop.get_parent_window();
-    if (window_handle != nullptr) {
-      tinydisplay_cat.info()
-        << "Got parent_window " << *window_handle << "\n";
-#ifdef SUPPORT_SUBPROCESS_WINDOW
-      WindowHandle::OSHandle *os_handle = window_handle->get_os_handle();
-      if (os_handle != nullptr &&
-          os_handle->is_of_type(NativeWindowHandle::SubprocessHandle::get_class_type())) {
-        return new SubprocessWindow(engine, this, name, fb_prop, win_prop,
-                                    flags, gsg, host);
-      }
-#endif  // SUPPORT_SUBPROCESS_WINDOW
-    }
-    return new TinyOsxGraphicsWindow(engine, this, name, fb_prop, win_prop,
-                                     flags, gsg, host);
-  }
-
-  // Second thing to try: a TinyGraphicsBuffer
-  if (retry == 1) {
-    if (((flags&BF_require_parasite)!=0)||
-        ((flags&BF_require_window)!=0)) {
-      return nullptr;
-    }
-    return new TinyGraphicsBuffer(engine, this, name, fb_prop, win_prop, flags, gsg, host);
-  }
-
-  // Nothing else left to try.
-  return nullptr;
-}
-
-#endif  // IS_OSX

+ 0 - 79
panda/src/tinydisplay/tinyOsxGraphicsPipe.h

@@ -1,79 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file tinyOsxGraphicsPipe.h
- * @author drose
- * @date 2008-05-12
- */
-
-#ifndef TINYOSXGRAPHICSPIPE_H
-#define TINYOSXGRAPHICSPIPE_H
-
-#include "pandabase.h"
-
-#if defined(IS_OSX) && !defined(BUILD_IPHONE) && defined(HAVE_CARBON) && !__LP64__
-
-// We have to include this early, before anyone includes netinettcp.h, which
-// will define TCP_NODELAY and other symbols and confuse the Apple system
-// headers.
-#include <Carbon/Carbon.h>
-
-#include "graphicsPipe.h"
-#include "tinyGraphicsStateGuardian.h"
-
-/**
- * This graphics pipe represents the interface for creating TinyPanda graphics
- * windows on a Mac client.
- */
-class EXPCL_TINYDISPLAY TinyOsxGraphicsPipe : public GraphicsPipe {
-public:
-  TinyOsxGraphicsPipe();
-  virtual ~TinyOsxGraphicsPipe();
-
-  virtual std::string get_interface_name() const;
-  static PT(GraphicsPipe) pipe_constructor();
-
-  static CGImageRef create_cg_image(const PNMImage &pnm_image);
-
-private:
-  static void release_data(void *info, const void *data, size_t size);
-
-protected:
-  virtual PT(GraphicsOutput) make_output(const std::string &name,
-                                         const FrameBufferProperties &fb_prop,
-                                         const WindowProperties &win_prop,
-                                         int flags,
-                                         GraphicsEngine *engine,
-                                         GraphicsStateGuardian *gsg,
-                                         GraphicsOutput *host,
-                                         int retry,
-                                         bool &precertify);
-
-public:
-  static TypeHandle get_class_type() {
-    return _type_handle;
-  }
-  static void init_type() {
-    GraphicsPipe::init_type();
-    register_type(_type_handle, "TinyOsxGraphicsPipe",
-                  GraphicsPipe::get_class_type());
-  }
-  virtual TypeHandle get_type() const {
-    return get_class_type();
-  }
-  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
-  static TypeHandle _type_handle;
-};
-
-#include "tinyOsxGraphicsPipe.I"
-
-#endif  // IS_OSX
-
-#endif

+ 0 - 20
panda/src/tinydisplay/tinyOsxGraphicsWindow.I

@@ -1,20 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file tinyOsxGraphicsWindow.I
- * @author drose
- * @date 2008-05-12
- */
-
-inline void TinyOsxGraphicsWindow::SendKeyEvent( ButtonHandle  key, bool down)
-{
-  if(down)
-    _input_devices[0].button_down(key);
-  else
-    _input_devices[0].button_up(key);
-}

+ 0 - 146
panda/src/tinydisplay/tinyOsxGraphicsWindow.h

@@ -1,146 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file tinyOsxGraphicsWindow.h
- * @author drose
- * @date 2008-05-12
- */
-
-#ifndef TINYOSXGRAPHICSWINDOW_H
-#define TINYOSXGRAPHICSWINDOW_H
-
-#include "pandabase.h"
-
-#if defined(IS_OSX) && !defined(BUILD_IPHONE) && defined(HAVE_CARBON) && !__LP64__
-
-#include <Carbon/Carbon.h>
-
-#include "graphicsWindow.h"
-#include "buttonHandle.h"
-#include "tinyGraphicsStateGuardian.h"
-
-/**
- * Opens a window on OS X to display the TinyPanda software rendering.
- */
-class TinyOsxGraphicsWindow : public GraphicsWindow {
-public:
-  TinyOsxGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
-                        const std::string &name,
-                        const FrameBufferProperties &fb_prop,
-                        const WindowProperties &win_prop,
-                        int flags,
-                        GraphicsStateGuardian *gsg,
-                        GraphicsOutput *host);
-  virtual ~TinyOsxGraphicsWindow();
-
-  virtual bool move_pointer(int device, int x, int y);
-
-  virtual bool begin_frame(FrameMode mode, Thread *current_thread);
-  virtual void end_frame(FrameMode mode, Thread *current_thread);
-  virtual void begin_flip();
-  virtual void process_events();
-  virtual bool supports_pixel_zoom() const;
-
-  virtual bool do_reshape_request(int x_origin, int y_origin, bool has_origin,
-                                  int x_size, int y_size);
-
-  virtual void mouse_mode_absolute();
-  virtual void mouse_mode_relative();
-
-  virtual void set_properties_now(WindowProperties &properties);
-
-private:
-  void   ReleaseSystemResources();
-  inline void SendKeyEvent( ButtonHandle  key, bool down);
-
-protected:
-  virtual void close_window();
-  virtual bool open_window();
-
-private:
-
-  bool OSOpenWindow(WindowProperties &properties);
-
-    // a singleton .. for the events to find the right pipe to push the event
-    // into
-
-
-public: // do not call direct ..
-  OSStatus handleKeyInput (EventHandlerCallRef myHandler, EventRef event, Boolean keyDown);
-  OSStatus handleTextInput (EventHandlerCallRef myHandler, EventRef event);
-  OSStatus handleWindowMouseEvents (EventHandlerCallRef myHandler, EventRef event);
-  ButtonHandle OSX_TranslateKey( UInt32 key,  EventRef event );
-  static TinyOsxGraphicsWindow * GetCurrentOSxWindow (WindowRef hint);
-
-  void     HandleModifireDeleta(UInt32 modifiers);
-  void HandleButtonDelta(UInt32 new_buttons);
-  void     DoResize(void);
-
-  OSStatus event_handler(EventHandlerCallRef myHandler, EventRef event);
-
-  virtual void user_close_request();
-  void SystemCloseWindow();
-  void SystemSetWindowForground(bool forground);
-  void SystemPointToLocalPoint(Point &qdGlobalPoint);
-  void LocalPointToSystemPoint(Point &qdLocalPoint);
-  bool set_icon_filename(const Filename &icon_filename);
-
-  void set_pointer_in_window(int x, int y);
-  void set_pointer_out_of_window();
-
-private:
-  void create_frame_buffer();
-
-private:
-  ZBuffer *_frame_buffer;
-
-private:
-  UInt32 _last_key_modifiers;
-  UInt32 _last_buttons;
-  WindowRef _osx_window;
-  bool _is_fullscreen;
-
-  CGImageRef _pending_icon;
-  CGImageRef _current_icon;
-
-  int _ID;
-  static TinyOsxGraphicsWindow  *FullScreenWindow;
-
-  CFDictionaryRef _originalMode;
-
-  // True if _properties.get_cursor_hidden() is true.
-  bool _cursor_hidden;
-
-  // True if the cursor is actually hidden right now via system calls.
-  bool _display_hide_cursor;
-
-  SInt32 _wheel_delta;
-
-public:
-  static TypeHandle get_class_type() {
-    return _type_handle;
-  }
-  static void init_type() {
-    GraphicsWindow::init_type();
-    register_type(_type_handle, "TinyOsxGraphicsWindow",
-                  GraphicsWindow::get_class_type());
-  }
-  virtual TypeHandle get_type() const {
-    return get_class_type();
-  }
-  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
-
-private:
-  static TypeHandle _type_handle;
-};
-
-#include "tinyOsxGraphicsWindow.I"
-
-#endif  // IS_OSX
-
-#endif

+ 0 - 1734
panda/src/tinydisplay/tinyOsxGraphicsWindow.mm

@@ -1,1734 +0,0 @@
-/**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University.  All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license.  You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file tinyOsxGraphicsWindow.mm
- */
-
-#include "pandabase.h"
-
-#if defined(IS_OSX) && !defined(BUILD_IPHONE) && defined(HAVE_CARBON) && !__LP64__
-
-#include <Carbon/Carbon.h>
-#include <Cocoa/Cocoa.h>
-
-#include "tinyOsxGraphicsWindow.h"
-#include "config_tinydisplay.h"
-#include "tinyOsxGraphicsPipe.h"
-#include "pStatTimer.h"
-#include "keyboardButton.h"
-#include "mouseButton.h"
-#include "tinyGraphicsStateGuardian.h"
-#include "throw_event.h"
-#include "pnmImage.h"
-#include "virtualFileSystem.h"
-#include "config_putil.h"
-
-#include <ApplicationServices/ApplicationServices.h>
-
-#include "pmutex.h"
-// #include "mutexHolder.h"
-
-
-Mutex &OSXGloablMutex() {
-  static Mutex m("OSXWIN_Mutex");
-  return m;
-}
-
-struct work1 {
-  volatile bool work_done;
-};
-
-#define PANDA_CREATE_WINDOW  101
-static void Post_Event_Wait(unsigned short type, unsigned int data1 , unsigned int data2 , int target_window ) {
-    work1 w;
-    w.work_done = false;
-    NSEvent *ev = [NSEvent otherEventWithType:NSApplicationDefined
-                                     location:NSZeroPoint
-                                modifierFlags:0
-                                    timestamp:0.0f
-                                 windowNumber:target_window
-                                      context:nil
-                                      subtype:type
-                                        data1:data1
-                                        data2:(int)&w];
-
-    [NSApp postEvent:ev atStart:NO];
-    while (!w.work_done)
-        usleep(10);
-
-}
-
-
-TypeHandle TinyOsxGraphicsWindow::_type_handle;
-TinyOsxGraphicsWindow  * TinyOsxGraphicsWindow::FullScreenWindow = NULL;
-
-
-#define USER_CONTAINER
-
-#include <set>
-
-#ifdef USER_CONTAINER
-
-std::set< WindowRef >     MyWindows;
-void AddAWindow( WindowRef window) {
-     MyWindows.insert(window);
-}
-bool checkmywindow(WindowRef window) {
-   return MyWindows.find(window) != MyWindows.end();
-}
-#else
-
-void AddAWindow( WindowRef window) {
-}
-
-bool checkmywindow(WindowRef window) {
-    return true;
-}
-
-#endif
-
-
-
-/**
- * How to find the active window for events  on osx..
- *
- */
-TinyOsxGraphicsWindow* TinyOsxGraphicsWindow::GetCurrentOSxWindow(WindowRef window) {
-    if (FullScreenWindow != NULL)
-       return FullScreenWindow;
-
-    if (NULL == window)  // HID use this path
-    {
-        // Assume first we are a child window.  If we cant find a window of
-        // that class, then we are standalone and can jsut grab the front
-        // window.
-        window    =    GetFrontWindowOfClass(kSimpleWindowClass, TRUE);
-        if (NULL == window)
-            window    =    FrontNonFloatingWindow();
-    }
-
-    if (window  && checkmywindow(window)) {
-      return (TinyOsxGraphicsWindow *)GetWRefCon (window);
-    } else {
-      return NULL;
-    }
-}
-
-/**
- * The standard window event handler for non-fullscreen windows.
- */
-OSStatus TinyOsxGraphicsWindow::
-event_handler(EventHandlerCallRef myHandler, EventRef event) {
-
-  OSStatus result = eventNotHandledErr;
-  UInt32 the_class = GetEventClass(event);
-  UInt32 kind = GetEventKind(event);
-
-  WindowRef window = NULL;
-  GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL,
-                    sizeof(window), NULL, &window);
-
-  UInt32 attributes = 0;
-  GetEventParameter(event, kEventParamAttributes, typeUInt32, NULL,
-                    sizeof(attributes), NULL, &attributes);
-
-  if (tinydisplay_cat.is_spam()) {
-    tinydisplay_cat.spam() << ClockObject::get_global_clock()->get_real_time() << " event_handler: " << (void *)this << ", " << window << ", " << the_class << ", " << kind << "\n";
-  }
-
-  switch (the_class) {
-  case kEventClassMouse:
-    result  = handleWindowMouseEvents (myHandler, event);
-    break;
-
-  case kEventClassWindow:
-    switch (kind) {
-        case kEventWindowCollapsing:
-          /*
-          Rect r;
-          GetWindowPortBounds (window, &r);
-          CompositeGLBufferIntoWindow( get_context(), &r, GetWindowPort (window));
-          UpdateCollapsedWindowDockTile (window);
-          */
-          SystemSetWindowForground(false);
-          break;
-        case kEventWindowActivated: // called on click activation and initially
-          SystemSetWindowForground(true);
-          DoResize();
-          break;
-        case kEventWindowDeactivated:
-          SystemSetWindowForground(false);
-          break;
-        case kEventWindowClose: // called when window is being closed (close box)
-          // This is a message from the window manager indicating that the
-          // user has requested to close the window.
-          user_close_request();
-          result = noErr;
-          break;
-        case kEventWindowShown: // called on initial show (not on un-minimize)
-          if (window == FrontNonFloatingWindow ())
-            SetUserFocusWindow (window);
-          break;
-
-      case kEventWindowBoundsChanging:
-        // Gives us a chance to intercept resize attempts
-        if (attributes & kWindowBoundsChangeSizeChanged) {
-          // If the window is supposed to be fixed-size, enforce this.
-          if (_properties.get_fixed_size()) {
-            Rect bounds;
-            GetEventParameter(event, kEventParamCurrentBounds,
-                              typeQDRectangle, NULL, sizeof(bounds), NULL, &bounds);
-            bounds.right = bounds.left + _properties.get_x_size();
-            bounds.bottom = bounds.top + _properties.get_y_size();
-            SetEventParameter(event, kEventParamCurrentBounds,
-                              typeQDRectangle, sizeof(bounds), &bounds);                   result = noErr;
-          }
-        }
-        break;
-
-    case kEventWindowBoundsChanged: // called for resize and moves (drag)
-      DoResize();
-      break;
-    case kEventWindowZoomed:
-      break;
-    case kEventWindowCollapsed:
-      {
-        WindowProperties properties;
-        properties.set_minimized(true);
-        system_changed_properties(properties);
-      }
-      break;
-    case kEventWindowExpanded:
-      {
-        WindowProperties properties;
-        properties.set_minimized(false);
-        system_changed_properties(properties);
-      }
-      break;
-    }
-    break;
-  }
-
-  return result;
-}
-
-/**
- * The user has requested to close the window, for instance with Cmd-W, or by
- * clicking on the close button.
- */
-void TinyOsxGraphicsWindow::user_close_request() {
-  string close_request_event = get_close_request_event();
-  if (!close_request_event.empty()) {
-    // In this case, the app has indicated a desire to intercept the request
-    // and process it directly.
-    throw_event(close_request_event);
-  } else {
-    // In this case, the default case, the app does not intend to service the
-    // request, so we do by closing the window.
-    close_window();
-  }
-}
-
-/**
- * The Windows is closed by a OS resource not by a internal request
- *
- */
-void TinyOsxGraphicsWindow::SystemCloseWindow() {
-    if (tinydisplay_cat.is_debug())
-        tinydisplay_cat.debug() << "System Closing Window \n";
-    ReleaseSystemResources();
-};
-
-/**
- * The C callback for Window Events ..
- *
- * We only hook this up for non fullscreen window... so we only handle system
- * window events..
- *
- */
-static pascal OSStatus    windowEvtHndlr(EventHandlerCallRef myHandler, EventRef event, void *userData) {
-#pragma unused (userData)
-
-// volatile().lock();
-
-  WindowRef window = NULL;
-  GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window);
-
-  if (window != NULL) {
-    TinyOsxGraphicsWindow *osx_win = TinyOsxGraphicsWindow::GetCurrentOSxWindow(window);
-    if (osx_win != (TinyOsxGraphicsWindow *)NULL) {
-      // OSXGloablMutex().release();
-      return osx_win->event_handler(myHandler, event);
-    }
-  }
-
-  // OSXGloablMutex().release();
-  return eventNotHandledErr;
-}
-
-/**
- * The C callback for Window Events ..
- *
- * We only hook this up for none fullscreen window... so we only handle system
- * window events..
- *
- */
-void TinyOsxGraphicsWindow::DoResize(void) {
-  tinydisplay_cat.info() << "In Resize....." << _properties << "\n";
-
-  // only in window mode .. not full screen
-  if (_osx_window != NULL && !_is_fullscreen && _properties.has_size()) {
-    Rect                rectPort = {0,0,0,0};
-    CGRect                 viewRect = {{0.0f, 0.0f}, {0.0f, 0.0f}};
-
-    GetWindowPortBounds (_osx_window, &rectPort);
-    viewRect.size.width = (PN_stdfloat) (rectPort.right - rectPort.left);
-    viewRect.size.height = (PN_stdfloat) (rectPort.bottom - rectPort.top);
-    // tell panda
-    WindowProperties properties;
-    properties.set_size((int)viewRect.size.width,(int)viewRect.size.height);
-    properties.set_origin((int) rectPort.left,(int)rectPort.top);
-    system_changed_properties(properties);
-    ZB_resize(_frame_buffer, NULL, _properties.get_x_size(), _properties.get_y_size());
-
-    if (tinydisplay_cat.is_debug()) {
-      tinydisplay_cat.debug() << " Resizing Window " << viewRect.size.width << " " << viewRect.size.height << "\n";
-    }
-  }
-};
-
-/**
- * The C callback for APlication Events..
- *
- * Hooked  once for application
- *
- */
-static pascal OSStatus appEvtHndlr (EventHandlerCallRef myHandler, EventRef event, void* userData) {
-#pragma unused (myHandler)
-  OSStatus result = eventNotHandledErr;
-  {
-
-  // OSXGloablMutex().lock();
-
-  TinyOsxGraphicsWindow *osx_win = NULL;
-  WindowRef window = NULL;
-  UInt32 the_class = GetEventClass (event);
-  UInt32 kind = GetEventKind (event);
-
-  GetEventParameter(event, kEventParamWindowRef, typeWindowRef, NULL, sizeof(WindowRef), NULL, (void*) &window);
-  osx_win = TinyOsxGraphicsWindow::GetCurrentOSxWindow(window);
-  if (osx_win == NULL) {
-    // OSXGloablMutex().release();
-    return eventNotHandledErr;
-  }
-
-  switch (the_class) {
-    case kEventClassTextInput:
-      if (kind == kEventTextInputUnicodeForKeyEvent) {
-  osx_win->handleTextInput(myHandler, event);
-      }
-      // result = noErr; can not report handled .. the os will not sent the
-      // raw key strokes then if (osx_win->handleTextInput(myHandler, event)
-      // == noErr) result = noErr;
-      break;
-    case kEventClassKeyboard:
-      {
-      switch (kind) {
-  case kEventRawKeyRepeat:
-  case kEventRawKeyDown:
-      result = osx_win->handleKeyInput  (myHandler, event, true);
-      break;
-  case kEventRawKeyUp:
-      result = osx_win->handleKeyInput  (myHandler, event, false);
-      break;
-        case kEventRawKeyModifiersChanged:
-    {
-      UInt32 newModifiers;
-      OSStatus error = GetEventParameter(event, kEventParamKeyModifiers,typeUInt32, NULL,sizeof(UInt32), NULL, &newModifiers);
-      if (error == noErr) {
-        osx_win->HandleModifireDeleta(newModifiers);
-        result = noErr;
-      }
-    }
-    break;
-        }
-      }
-      break;
-
-    case kEventClassMouse:
-      // tinydisplay_cat.info() << "Mouse movement handled by Application
-      // handler\n"; if (TinyOsxGraphicsWindow::FullScreenWindow != NULL)
-    result = osx_win->handleWindowMouseEvents (myHandler, event);
-       // result = noErr;
-      break;
-  }
-
-  // OSXGloablMutex().release();
-  }
-
-  return result;
-}
-
-/**
- * Trap Unicode  Input.
- *
-
- *
- */
-OSStatus TinyOsxGraphicsWindow::handleTextInput (EventHandlerCallRef myHandler, EventRef theTextEvent) {
-  UniChar      *text = NULL;
-  UInt32       actualSize = 0;
-
-  OSStatus ret = GetEventParameter (theTextEvent, kEventParamTextInputSendText, typeUnicodeText, NULL, 0, &actualSize, NULL);
-  if (ret != noErr) {
-    return ret;
-  }
-
-  text = (UniChar*)NewPtr(actualSize);
-  if (text!= NULL) {
-    ret = GetEventParameter (theTextEvent, kEventParamTextInputSendText,typeUnicodeText, NULL, actualSize, NULL, text);
-    if (ret != noErr) {
-      return ret;
-    }
-
-    for (unsigned int x = 0; x < actualSize/sizeof(UniChar); ++x) {
-      _input_devices[0]->keystroke(text[x]);
-    }
-    DisposePtr((char *)text);
-  }
-
-  return ret;
-}
-/**
- * Clean up the OS level messes..
- */
-void TinyOsxGraphicsWindow::ReleaseSystemResources() {
-  if (_is_fullscreen) {
-    _is_fullscreen = false;
-    FullScreenWindow = NULL;
-
-    if (_originalMode != NULL)
-      CGDisplaySwitchToMode( kCGDirectMainDisplay, _originalMode );
-
-    CGDisplayRelease( kCGDirectMainDisplay );
-
-    _originalMode = NULL;
-  }
-
-  if (_osx_window != NULL) {
-    SetWRefCon (_osx_window, (long int) NULL);
-    HideWindow (_osx_window);
-    DisposeWindow(_osx_window);
-    _osx_window = NULL;
-  }
-
-  if (_pending_icon != NULL) {
-    CGImageRelease(_pending_icon);
-    _pending_icon = NULL;
-  }
-  if (_current_icon != NULL) {
-    CGImageRelease(_current_icon);
-    _current_icon = NULL;
-  }
-
-  WindowProperties properties;
-  properties.set_foreground(false);
-  properties.set_open(false);
-  properties.set_cursor_filename(Filename());
-  system_changed_properties(properties);
-
-  _is_fullscreen = false;
-  _osx_window = NULL;
-}
-
-
-static int id_seed = 100;
-
-/**
- *
- */
-TinyOsxGraphicsWindow::TinyOsxGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
-                                             const string &name,
-                                             const FrameBufferProperties &fb_prop,
-                                             const WindowProperties &win_prop,
-                                             int flags,
-                                             GraphicsStateGuardian *gsg,
-                                             GraphicsOutput *host) :
-  GraphicsWindow(engine, pipe, name, fb_prop, win_prop, flags, gsg, host),
-  _osx_window(NULL),
-  _is_fullscreen(false),
-  _pending_icon(NULL),
-  _current_icon(NULL),
-  _ID(id_seed++),
-  _originalMode(NULL) {
-  PT(InputDevice) device =
-    GraphicsWindowInputDevice::pointer_and_keyboard(this, "keyboard/mouse");
-  _input_devices.push_back(device);
-  device->set_pointer_in_window(0, 0);
-  _last_key_modifiers = 0;
-  _last_buttons = 0;
-
-  _cursor_hidden = false;
-  _display_hide_cursor = false;
-  _wheel_delta = 0;
-
-  _frame_buffer = NULL;
-  update_pixel_factor();
-
-  if (tinydisplay_cat.is_debug())
-    tinydisplay_cat.debug() << "TinyOsxGraphicsWindow::TinyOsxGraphicsWindow() -" <<_ID << "\n";
-}
-
-/**
- *
- */
-TinyOsxGraphicsWindow::~TinyOsxGraphicsWindow() {
-  if (tinydisplay_cat.is_debug())
-    tinydisplay_cat.debug() << "TinyOsxGraphicsWindow::~TinyOsxGraphicsWindow() -" <<_ID << "\n";
-
-  // Make sure the window callback won't come back to this (destructed) object
-  // any more.
-  if (_osx_window) {
-    SetWRefCon (_osx_window, (long) NULL);
-  }
-
-  ReleaseSystemResources();
-}
-
-/**
- * Called internally to load up an icon file that should be applied to the
- * window.  Returns true on success, false on failure.
- */
-bool TinyOsxGraphicsWindow::set_icon_filename(const Filename &icon_filename) {
-  VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();
-
-  Filename icon_pathname = icon_filename;
-  if (!vfs->resolve_filename(icon_pathname, get_model_path())) {
-    // The filename doesn't exist along the search path.
-    if (icon_pathname.is_fully_qualified() && vfs->exists(icon_pathname)) {
-      // But it does exist locally, so accept it.
-    } else {
-      tinydisplay_cat.warning()
-        << "Could not find icon filename " << icon_filename << "\n";
-      return false;
-    }
-  }
-
-
-  PNMImage pnmimage;
-  if (!pnmimage.read(icon_pathname)) {
-    tinydisplay_cat.warning()
-      << "Could not read icon filename " << icon_pathname << "\n";
-    return false;
-  }
-
-  CGImageRef icon_image = TinyOsxGraphicsPipe::create_cg_image(pnmimage);
-  if (icon_image == NULL) {
-    return false;
-  }
-
-  if (_pending_icon != NULL) {
-    CGImageRelease(_pending_icon);
-    _pending_icon = NULL;
-  }
-  _pending_icon = icon_image;
-  return true;
-}
-
-/**
- * Indicates the mouse pointer is seen within the window.
- */
-void TinyOsxGraphicsWindow::
-set_pointer_in_window(int x, int y) {
-  _input_devices[0]->set_pointer_in_window(x, y);
-
-  if (_cursor_hidden != _display_hide_cursor) {
-    if (_cursor_hidden) {
-      CGDisplayHideCursor(kCGDirectMainDisplay);
-      _display_hide_cursor = true;
-    } else {
-      CGDisplayShowCursor(kCGDirectMainDisplay);
-      _display_hide_cursor = false;
-    }
-  }
-}
-
-/**
- * Indicates the mouse pointer is no longer within the window.
- */
-void TinyOsxGraphicsWindow::
-set_pointer_out_of_window() {
-  _input_devices[0]->set_pointer_out_of_window();
-
-  if (_display_hide_cursor) {
-    CGDisplayShowCursor(kCGDirectMainDisplay);
-    _display_hide_cursor = false;
-  }
-}
-
-
-/**
- * This function will be called within the draw thread before beginning
- * rendering for a given frame.  It should do whatever setup is required, and
- * return true if the frame should be rendered, or false if it should be
- * skipped.
- */
-bool TinyOsxGraphicsWindow::begin_frame(FrameMode mode, Thread *current_thread) {
-  PStatTimer timer(_make_current_pcollector);
-
-  begin_frame_spam(mode);
-  if (_gsg == (GraphicsStateGuardian *)NULL ||
-      (_osx_window == NULL && !_is_fullscreen)) {
-    // not powered up .. just abort..
-    return false;
-  }
-
-  // Now is a good time to apply the icon change that may have recently been
-  // requested.  By this point, we should be able to get a handle to the dock
-  // context.
-  if (_pending_icon != NULL) {
-    CGContextRef context = BeginCGContextForApplicationDockTile();
-    if (context != NULL) {
-      SetApplicationDockTileImage(_pending_icon);
-      EndCGContextForApplicationDockTile(context);
-
-      if (_current_icon != NULL) {
-        CGImageRelease(_current_icon);
-        _current_icon = NULL;
-      }
-      _current_icon = _pending_icon;
-      _pending_icon = NULL;
-    }
-  }
-
-  TinyGraphicsStateGuardian *tinygsg;
-  DCAST_INTO_R(tinygsg, _gsg, false);
-
-  tinygsg->_current_frame_buffer = _frame_buffer;
-  tinygsg->reset_if_new();
-
-  _gsg->set_current_properties(&get_fb_properties());
-  return _gsg->begin_frame(current_thread);
-}
-
-/**
- * This function will be called within the draw thread after rendering is
- * completed for a given frame.  It should do whatever finalization is
- * required.
- */
-void TinyOsxGraphicsWindow::end_frame(FrameMode mode, Thread *current_thread) {
-  end_frame_spam(mode);
-
-  _gsg->end_frame(current_thread);
-
-  if (mode == FM_render) {
-
-    copy_to_textures();
-
-    trigger_flip();
-   clear_cube_map_selection();
-  }
-}
-
-/**
- * This function will be called within the draw thread after end_frame() has
- * been called on all windows, to initiate the exchange of the front and back
- * buffers.
- *
- * This should instruct the window to prepare for the flip at the next video
- * sync, but it should not wait.
- *
- * We have the two separate functions, begin_flip() and end_flip(), to make it
- * easier to flip all of the windows at the same time.
- */
-void TinyOsxGraphicsWindow::begin_flip() {
-  if (_osx_window == NULL) {
-    return;
-  }
-
-  QDErr err;
-
-  // blit rendered framebuffer into window backing store
-  Rect src_rect = {0, 0, _frame_buffer->ysize, _frame_buffer->xsize};
-  Rect ddrc_rect = {0, 0, _frame_buffer->ysize, _frame_buffer->xsize};
-  if (get_pixel_factor() != 1.0) {
-    src_rect.right = get_fb_x_size();
-    src_rect.bottom = get_fb_y_size();
-  }
-
-  // create a GWorld containing our image
-  GWorldPtr pGWorld;
-  err = NewGWorldFromPtr(&pGWorld, k32BGRAPixelFormat, &src_rect, 0, 0, 0,
-                         (char *)_frame_buffer->pbuf, _frame_buffer->linesize);
-  if (err != noErr) {
-    tinydisplay_cat.error()
-      << " error in NewGWorldFromPtr, called from begin_flip()\n";
-    return;
-  }
-
-  GrafPtr out_port = GetWindowPort(_osx_window);
-  GrafPtr portSave = NULL;
-  Boolean portChanged = QDSwapPort(out_port, &portSave);
-
-  {
-    static PStatCollector b2("Wait:Flip:Begin:CopyBits");
-    PStatTimer t2(b2);
-    CopyBits(GetPortBitMapForCopyBits(pGWorld),
-             GetPortBitMapForCopyBits(out_port),
-             &src_rect, &ddrc_rect, srcCopy, 0);
-  }
-
-  if (portChanged) {
-    QDSwapPort(portSave, NULL);
-  }
-
-  DisposeGWorld(pGWorld);
-}
-
-/**
- * Closes the window right now.  Called from the window thread.
- */
-void TinyOsxGraphicsWindow::close_window() {
-  SystemCloseWindow();
-
-  WindowProperties properties;
-  properties.set_open(false);
-  system_changed_properties(properties);
-
-  ReleaseSystemResources();
-  _gsg.clear();
- GraphicsWindow::close_window();
-}
-
-/*
- * HACK ALLERT ************ Undocumented OSX calls... I can not find any other
- * way to get the mouse focus to a window in OSX.. extern "C" { struct
- * CPSProcessSerNum { UInt32 lo; UInt32 hi; };
- */
-
-// extern OSErr CPSGetCurrentProcess(CPSProcessSerNum *psn); extern OSErr
-// CPSEnableForegroundOperation( struct CPSProcessSerNum *psn); extern OSErr
-// CPSSetProcessName ( struct CPSProcessSerNum *psn, char *processname);
-// extern OSErr CPSSetFrontProcess( struct CPSProcessSerNum *psn); };
-
-/**
- * Opens the window right now.  Called from the window thread.  Returns true
- * if the window is successfully opened, or false if there was a problem.
- */
-bool TinyOsxGraphicsWindow::open_window() {
-  // GSG CreationInitialization
-  TinyGraphicsStateGuardian *tinygsg;
-  if (_gsg == 0) {
-    // There is no old gsg.  Create a new one.
-    tinygsg = new TinyGraphicsStateGuardian(_engine, _pipe, NULL);
-    _gsg = tinygsg;
-  } else {
-    DCAST_INTO_R(tinygsg, _gsg, false);
-  }
-
-  create_frame_buffer();
-  if (_frame_buffer == NULL) {
-    tinydisplay_cat.error()
-      << "Could not create frame buffer.\n";
-    return false;
-  }
-
-  tinygsg->_current_frame_buffer = _frame_buffer;
-
-  tinygsg->reset_if_new();
-  if (!tinygsg->is_valid()) {
-    close_window();
-    return false;
-  }
-
-  WindowProperties req_properties  = _properties;
-  // OSXGloablMutex().lock();
-  bool answer =  OSOpenWindow(req_properties);
-  // OSXGloablMutex().release();
-  return answer;
-}
-
-
-bool TinyOsxGraphicsWindow::OSOpenWindow(WindowProperties &req_properties) {
-  OSErr err = noErr;
-
-  if (_current_icon != NULL && _pending_icon == NULL) {
-      // If we already have an icon specified, we'll need to reapply it when
-      // the window is successfully created.
-      _pending_icon = _current_icon;
-      _current_icon = NULL;
-  }
-
-  static bool GlobalInits = false;
-  if (!GlobalInits) {
-    // one time aplication inits.. to get a window open from a standalone
-    // aplication..
-
-    EventHandlerRef    application_event_ref_ref1;
-    EventTypeSpec    list1[] =
-      {
-        // { kEventClassCommand,  kEventProcessCommand }, {
-        // kEventClassCommand,  kEventCommandUpdateStatus },
-        { kEventClassMouse, kEventMouseDown },// handle trackball functionality globaly because there is only a single user
-        { kEventClassMouse, kEventMouseUp },
-        { kEventClassMouse, kEventMouseMoved },
-        { kEventClassMouse, kEventMouseDragged },
-        { kEventClassMouse, kEventMouseWheelMoved } ,
-        { kEventClassKeyboard, kEventRawKeyDown },
-        { kEventClassKeyboard, kEventRawKeyUp } ,
-        { kEventClassKeyboard, kEventRawKeyRepeat },
-        { kEventClassKeyboard, kEventRawKeyModifiersChanged }    ,
-        { kEventClassTextInput,    kEventTextInputUnicodeForKeyEvent},
-      };
-
-    EventHandlerUPP    gEvtHandler = NewEventHandlerUPP(appEvtHndlr);
-    err = InstallApplicationEventHandler (gEvtHandler, GetEventTypeCount (list1) , list1, this, &application_event_ref_ref1 );
-    GlobalInits = true;
-
-    ProcessSerialNumber psn = { 0, kCurrentProcess };
-
-    // Determine if we're running from a bundle.
-    CFDictionaryRef dref =
-      ProcessInformationCopyDictionary(&psn, kProcessDictionaryIncludeAllInformationMask);
-    // If the dictionary doesn't have "BundlePath" (or the BundlePath is the
-    // same as the executable path), then we're not running from a bundle, and
-    // we need to call TransformProcessType to make the process a "foreground"
-    // application, with its own icon in the dock and such.
-
-    bool has_bundle = false;
-
-    CFStringRef bundle_path = (CFStringRef)CFDictionaryGetValue(dref, CFSTR("BundlePath"));
-    if (bundle_path != NULL) {
-      // OK, we have a bundle path.  We're probably running in a bundle . . .
-      has_bundle = true;
-
-      // . . . unless it turns out it's the same as the executable path.
-      CFStringRef exe_path = (CFStringRef)CFDictionaryGetValue(dref, kCFBundleExecutableKey);
-      if (exe_path != NULL) {
-        if (CFStringCompare(bundle_path, exe_path, kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
-          has_bundle = false;
-        }
-        CFRelease(exe_path);
-      }
-
-      CFRelease(bundle_path);
-    }
-
-    if (!has_bundle) {
-      TransformProcessType(&psn, kProcessTransformToForegroundApplication);
-    }
-    SetFrontProcess(&psn);
-  }
-
-
-  bool wants_fullscreen = req_properties.has_fullscreen() && req_properties.get_fullscreen();
-  if (req_properties.get_minimized()) {
-    // A minimized window can't be fullscreen.
-    wants_fullscreen = false;
-  }
-
-  if (wants_fullscreen) {
-   tinydisplay_cat.info() << "Creating full screen\n";
-
-    // capture the main display
-    CGDisplayCapture(kCGDirectMainDisplay);
-    // if sized try and switch it..
-    if (req_properties.has_size()) {
-      _originalMode = CGDisplayCurrentMode(kCGDirectMainDisplay);
-      CFDictionaryRef newMode = CGDisplayBestModeForParameters(kCGDirectMainDisplay, 32, req_properties.get_x_size(), req_properties.get_y_size(), 0);
-      if (newMode == NULL) {
-        tinydisplay_cat.error()
-          << "Invalid fullscreen size: " << req_properties.get_x_size()
-          << ", " << req_properties.get_y_size()
-          << "\n";
-      } else {
-        CGDisplaySwitchToMode(kCGDirectMainDisplay, newMode);
-
-        // Set our new window size according to the size we actually got.
-        SInt32 width, height;
-        CFNumberGetValue((CFNumberRef)CFDictionaryGetValue(newMode, kCGDisplayWidth), kCFNumberSInt32Type, &width);
-        CFNumberGetValue((CFNumberRef)CFDictionaryGetValue(newMode, kCGDisplayHeight), kCFNumberSInt32Type, &height);
-
-        _properties.set_size(width, height);
-      }
-    }
-
-    _properties.set_fullscreen(true);
-    _properties.set_minimized(false);
-    _properties.set_foreground(true);
-
-    _is_fullscreen = true;
-    FullScreenWindow = this;
-    req_properties.clear_fullscreen();
-  } else {
-    int x_origin = 10;
-    int y_origin = 50;
-    if (req_properties.has_origin()) {
-      y_origin  = req_properties.get_y_origin();
-      x_origin = req_properties.get_x_origin();
-    }
-
-    int x_size = 512;
-    int y_size = 512;
-    if (req_properties.has_size()) {
-      x_size = req_properties.get_x_size();
-      y_size = req_properties.get_y_size();
-    }
-
-    // A coordinate of -2 means to center the window on screen.
-    if (y_origin == -2 || x_origin == -2) {
-      if (y_origin == -2) {
-        y_origin = (_pipe->get_display_height() - y_size) / 2;
-      }
-      if (x_origin == -2) {
-        x_origin = (_pipe->get_display_width() - x_size) / 2;
-      }
-    }
-
-    // A coordinate of -1 means a default location.
-    if (y_origin == -1) {
-      y_origin = 50;
-    }
-    if (x_origin == -1) {
-      x_origin = 10;
-    }
-
-    _properties.set_origin(x_origin, y_origin);
-    _properties.set_size(x_size, y_size);
-
-    Rect r;
-    r.top = y_origin;
-    r.left = x_origin;
-    r.right = r.left + x_size;
-    r.bottom = r.top + y_size;
-
-            /*
-    if (req_properties.has_parent_window()) {
-        tinydisplay_cat.info() << "Creating child window\n";
-
-        CreateNewWindow(kSimpleWindowClass, kWindowNoAttributes, &r, &_osx_window);
-        AddAWindow(_osx_window);
-
-        _properties.set_fixed_size(true);
-        tinydisplay_cat.info() << "Child window created\n";
-    }
-    else */
-    {
-      int attributes = kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute;
-      if (req_properties.has_fixed_size() && req_properties.get_fixed_size()) {
-        attributes &= ~kWindowResizableAttribute;
-      }
-
-      if (req_properties.has_undecorated() && req_properties.get_undecorated()) { // create a unmovable .. no edge window..
-  tinydisplay_cat.info() << "Creating undecorated window\n";
-
-        // We don't want a resize box either.
-        attributes &= ~kWindowResizableAttribute;
-        attributes |= kWindowNoTitleBarAttribute;
-  CreateNewWindow(kDocumentWindowClass, attributes, &r, &_osx_window);
-      }
-      else
-      { // create a window with crome and sizing and sucj
-  // In this case, we want to constrain the window to the available size.
-  Rect bounds;
-  GetAvailableWindowPositioningBounds(GetMainDevice(), &bounds);
-
-  r.left = max(r.left, bounds.left);
-  r.right = min(r.right, bounds.right);
-  r.top = max(r.top, bounds.top);
-  r.bottom = min(r.bottom, bounds.bottom);
-
-  tinydisplay_cat.info() << "Creating standard window\n";
-  CreateNewWindow(kDocumentWindowClass, attributes, &r, &_osx_window);
-  AddAWindow(_osx_window);
-      }
-    }
-
-
-    if (_osx_window) {
-
-      EventHandlerUPP gWinEvtHandler;            // window event handler
-      EventTypeSpec list[] =
-      {
-          { kEventClassWindow, kEventWindowCollapsing },
-          { kEventClassWindow, kEventWindowShown },
-          { kEventClassWindow, kEventWindowActivated },
-          { kEventClassWindow, kEventWindowDeactivated },
-          { kEventClassWindow, kEventWindowClose },
-          { kEventClassWindow, kEventWindowBoundsChanging },
-          { kEventClassWindow, kEventWindowBoundsChanged },
-
-          { kEventClassWindow, kEventWindowCollapsed },
-          { kEventClassWindow, kEventWindowExpanded },
-          { kEventClassWindow, kEventWindowZoomed },
-          { kEventClassWindow, kEventWindowClosed },
-      };
-
-      SetWRefCon (_osx_window, (long) this); // point to the window record in the ref con of the window
-      gWinEvtHandler = NewEventHandlerUPP(windowEvtHndlr);
-      InstallWindowEventHandler(_osx_window, gWinEvtHandler, GetEventTypeCount(list), list, (void*)this, NULL); // add event handler
-
-                  /*if (!req_properties.has_parent_window()) */
-      {
-          ShowWindow (_osx_window);
-      }
-                  /*
-      else
-      {
-
-          NSWindow*    parentWindow        =    (NSWindow *)req_properties.get_parent_window();
-      // NSView*        aView                =    [[parentWindow contentView]
-      // viewWithTag:378]; NSRect        aRect                =    [aView
-      // frame]; NSPoint        origin                =    [parentWindow
-      // convertBaseToScreen:aRect.origin];
-
-      // NSWindow*    childWindow            =    [[NSWindow alloc]
-      // initWithWindowRef:_osx_window];
-
-
-          Post_Event_Wait(PANDA_CREATE_WINDOW,(unsigned long) _osx_window,1,[parentWindow windowNumber]);
-
-      // [childWindow setFrameOrigin:origin]; [childWindow
-      // setAcceptsMouseMovedEvents:YES]; [childWindow
-      // setBackgroundColor:[NSColor blackColor]]; this seems to block till
-      // the parent accepts the connection ? [parentWindow
-      // addChildWindow:childWindow ordered:NSWindowAbove]; [childWindow
-      // orderFront:nil];
-
-
-          _properties.set_parent_window(req_properties.get_parent_window());
-          req_properties.clear_parent_window();
-
-                          }    */
-
-      if (req_properties.has_fullscreen()) {
-        _properties.set_fullscreen(false);
-        req_properties.clear_fullscreen();
-      }
-
-      if (req_properties.has_undecorated()) {
-        _properties.set_undecorated(req_properties.get_undecorated());
-        req_properties.clear_undecorated();
-      }
-
-      _properties.set_minimized(false);
-      _properties.set_foreground(true);
-
-      if (req_properties.has_minimized()) {
-        CollapseWindow(_osx_window, req_properties.get_minimized());
-        _properties.set_minimized(req_properties.get_minimized());
-        _properties.set_foreground(!req_properties.get_minimized());
-        req_properties.clear_minimized();
-      }
-    }
-
-    // Now measure the size and placement of the window we actually ended up
-    // with.
-    Rect rectPort = {0,0,0,0};
-    GetWindowPortBounds (_osx_window, &rectPort);
-    _properties.set_origin((int) rectPort.left, (int) rectPort.top);
-    _properties.set_size((int) (rectPort.right - rectPort.left), (int) (rectPort.bottom - rectPort.top));
-    req_properties.clear_size();
-    req_properties.clear_origin();
-  }
-
-  if (req_properties.has_icon_filename()) {
-    set_icon_filename(req_properties.get_icon_filename());
-  }
-
-  _properties.set_open(true);
-
-  if (_properties.has_size())
-      set_size_and_recalc(_properties.get_x_size(), _properties.get_y_size());
-
-
-  return (err == noErr);
-}
-
-/**
- * Required Event upcall . Used to dispatch Window and Aplication Events back
- * into panda
- *
- */
-void TinyOsxGraphicsWindow::process_events() {
-  GraphicsWindow::process_events();
-
-  if (!osx_disable_event_loop) {
-    EventRef          theEvent;
-    EventTargetRef theTarget    =    GetEventDispatcherTarget();
-
-    /*if (!_properties.has_parent_window())*/
-    {
-      while  (ReceiveNextEvent(0, NULL, kEventDurationNoWait, true, &theEvent)== noErr) {
-  SendEventToEventTarget (theEvent, theTarget);
-  ReleaseEvent(theEvent);
-      }
-    }
-  }
-};
-
-/**
- * Returns true if a call to set_pixel_zoom() will be respected, false if it
- * will be ignored.  If this returns false, then get_pixel_factor() will
- * always return 1.0, regardless of what value you specify for
- * set_pixel_zoom().
- *
- * This may return false if the underlying renderer doesn't support pixel
- * zooming, or if you have called this on a DisplayRegion that doesn't have
- * both set_clear_color() and set_clear_depth() enabled.
- */
-bool TinyOsxGraphicsWindow::
-supports_pixel_zoom() const {
-  return true;
-}
-
-/**
- * Required Event upcall . Used to dispatch Window and Aplication Events back
- * into panda
- */
-OSStatus TinyOsxGraphicsWindow::handleKeyInput (EventHandlerCallRef myHandler, EventRef event, Boolean keyDown) {
-  // key input handler
-
-  if (tinydisplay_cat.is_debug()) {
-    UInt32 keyCode;
-    GetEventParameter (event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode);
-
-    tinydisplay_cat.debug()
-      << ClockObject::get_global_clock()->get_real_time()
-      << " handleKeyInput: " << (void *)this << ", " << keyCode
-      << ", " << (int)keyDown << "\n";
-  }
-
-  // CallNextEventHandler(myHandler, event);
-
-  // We don't check the result of the above function.  In principle, this
-  // should return eventNotHandledErr if the key event is not handled by the
-  // OS, but in practice, testing this just seems to eat the Escape keypress
-  // meaninglessly.  Keypresses like F11 that are already mapped in the
-  // desktop seem to not even come into this function in the first place.
-  UInt32 newModifiers = 0;
-  OSStatus error = GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &newModifiers);
-  if (error == noErr) {
-    HandleModifireDeleta(newModifiers);
-  }
-
-  UInt32 keyCode;
-  GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode);
-  ButtonHandle button = OSX_TranslateKey(keyCode, event);
-
-  if (keyDown) {
-    if ((newModifiers & cmdKey) != 0) {
-      if (button == KeyboardButton::ascii_key('q') || button == KeyboardButton::ascii_key('w')) {
-        // Command-Q or Command-W: quit the application or close the window,
-        // respectively.  For now, we treat them both the same: close the
-        // window.
-        user_close_request();
-      }
-    }
-    SendKeyEvent(button, true);
-  } else {
-    SendKeyEvent(button, false);
-  }
-  return   CallNextEventHandler(myHandler, event);
-// return noErr;
-}
-
-/**
- *
- */
-void TinyOsxGraphicsWindow::SystemSetWindowForground(bool forground) {
-  WindowProperties properties;
-  properties.set_foreground(forground);
-  system_changed_properties(properties);
-}
-
-/**
- *
- */
-void TinyOsxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint) {
-  if (_osx_window != NULL) {
-    GrafPtr savePort;
-    Boolean    portChanged    =    QDSwapPort(GetWindowPort(_osx_window), &savePort);
-
-    GlobalToLocal(&qdGlobalPoint);
-
-    if (portChanged)
-      QDSwapPort(savePort, NULL);
-  }
-}
-
-/**
- *
- */
- OSStatus TinyOsxGraphicsWindow::handleWindowMouseEvents (EventHandlerCallRef myHandler, EventRef event) {
-  WindowRef            window = NULL;
-  OSStatus            result = eventNotHandledErr;
-  UInt32                 kind = GetEventKind (event);
- Point qdGlobalPoint = {0, 0};
-  UInt32                modifiers = 0;
-  Rect                 rectPort;
-  SInt32 this_wheel_delta;
-  EventMouseWheelAxis wheelAxis;
-
-  // cerr <<" Start Mouse Event " << _ID << "\n";
-
-  // Mac OS X v10.1 and later should this be front window???
-  GetEventParameter(event, kEventParamWindowRef, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window);
-
-  if (!_is_fullscreen && (window == NULL || window != _osx_window )) {
-    if (kind == kEventMouseMoved) {
-      set_pointer_out_of_window();
-    }
-    return eventNotHandledErr;
-  }
-
-
-
-  GetWindowPortBounds (window, &rectPort);
-
-  // result = CallNextEventHandler(myHandler, event); if (eventNotHandledErr
-  // == result) {  only handle events not already handled (prevents wierd
-  // resize interaction)
-  switch (kind) {
-     // Whenever mouse button state changes, generate the appropriate Panda
-     // downup events to represent the change.
-
-    case kEventMouseDown:
-    case kEventMouseUp:
-      {
-  GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
-  if (_properties.get_mouse_mode() == WindowProperties::M_relative) {
-    GetEventParameter(event, kEventParamMouseDelta,typeQDPoint, NULL, sizeof(Point),NULL    , (void*) &qdGlobalPoint);
-    MouseData currMouse = get_pointer(0);
-    qdGlobalPoint.h += currMouse.get_x();
-    qdGlobalPoint.v += currMouse.get_y();
-  }
-  else
-  {
-    GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL    , (void*) &qdGlobalPoint);
-    SystemPointToLocalPoint(qdGlobalPoint);
-  }
-
-  set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v);
-
-  UInt32 new_buttons = GetCurrentEventButtonState();
-  HandleButtonDelta(new_buttons);
-      }
-      result = noErr;
-      break;
-
-    case kEventMouseMoved:
-    case kEventMouseDragged:
-      if (_properties.get_mouse_mode()==WindowProperties::M_relative) {
-  GetEventParameter(event, kEventParamMouseDelta,typeQDPoint, NULL, sizeof(Point),NULL    , (void*) &qdGlobalPoint);
-
-  MouseData currMouse=get_pointer(0);
-  qdGlobalPoint.h+=currMouse.get_x();
-  qdGlobalPoint.v+=currMouse.get_y();
-      } else {
-  GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL    , (void*) &qdGlobalPoint);
-  SystemPointToLocalPoint(qdGlobalPoint);
-      }
-      if (kind == kEventMouseMoved &&
-    (qdGlobalPoint.h < 0 || qdGlobalPoint.v < 0)) {
-  // Moving into the titlebar region.
-  set_pointer_out_of_window();
-      } else {
-  // Moving within the window itself (or dragging anywhere).
-  set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v);
-      }
-      result = noErr;
-
-      break;
-
-    case kEventMouseWheelMoved:
-      GetEventParameter(event, kEventParamMouseWheelDelta, typeLongInteger, NULL, sizeof(this_wheel_delta), NULL, &this_wheel_delta);
-      GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(wheelAxis), NULL, &wheelAxis );
-      GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL    , (void*) &qdGlobalPoint);
-      SystemPointToLocalPoint(qdGlobalPoint);
-
-      if (wheelAxis == kEventMouseWheelAxisY) {
-        set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v);
-        _wheel_delta += this_wheel_delta;
-        SInt32 wheel_scale = osx_mouse_wheel_scale;
-        while (_wheel_delta > wheel_scale) {
-          _input_devices[0]->button_down(MouseButton::wheel_up());
-          _input_devices[0]->button_up(MouseButton::wheel_up());
-          _wheel_delta -= wheel_scale;
-        }
-        while (_wheel_delta < -wheel_scale) {
-          _input_devices[0]->button_down(MouseButton::wheel_down());
-          _input_devices[0]->button_up(MouseButton::wheel_down());
-          _wheel_delta += wheel_scale;
-        }
-      }
-      result = noErr;
-      break;
-    }
-    // result = noErr;
-
-   return result;
- }
-
-/**
- * MAC Key Codes to Panda Key Codes
- */
- ButtonHandle TinyOsxGraphicsWindow::OSX_TranslateKey(UInt32 key, EventRef event) {
-
-   ButtonHandle nk = ButtonHandle::none();
-   switch ( key ) {
-   case 0:    nk = KeyboardButton::ascii_key('a');       break;
-   case 11:   nk = KeyboardButton::ascii_key('b');       break;
-   case 8:    nk = KeyboardButton::ascii_key('c');       break;
-   case 2:    nk = KeyboardButton::ascii_key('d');       break;
-   case 14:   nk = KeyboardButton::ascii_key('e');       break;
-   case 3:    nk = KeyboardButton::ascii_key('f');       break;
-   case 5:    nk = KeyboardButton::ascii_key('g');       break;
-   case 4:    nk = KeyboardButton::ascii_key('h');       break;
-   case 34:   nk = KeyboardButton::ascii_key('i');       break;
-   case 38:   nk = KeyboardButton::ascii_key('j');       break;
-   case 40:   nk = KeyboardButton::ascii_key('k');       break;
-   case 37:   nk = KeyboardButton::ascii_key('l');       break;
-   case 46:   nk = KeyboardButton::ascii_key('m');       break;
-   case 45:   nk = KeyboardButton::ascii_key('n');       break;
-   case 31:   nk = KeyboardButton::ascii_key('o');       break;
-   case 35:   nk = KeyboardButton::ascii_key('p');       break;
-   case 12:   nk = KeyboardButton::ascii_key('q');       break;
-   case 15:   nk = KeyboardButton::ascii_key('r');       break;
-   case 1:    nk = KeyboardButton::ascii_key('s');       break;
-   case 17:   nk = KeyboardButton::ascii_key('t');       break;
-   case 32:   nk = KeyboardButton::ascii_key('u');       break;
-   case 9:    nk = KeyboardButton::ascii_key('v');       break;
-   case 13:   nk = KeyboardButton::ascii_key('w');       break;
-   case 7:    nk = KeyboardButton::ascii_key('x');       break;
-   case 16:   nk = KeyboardButton::ascii_key('y');       break;
-   case 6:    nk = KeyboardButton::ascii_key('z');       break;
-
-       // top row numbers
-   case 29:   nk = KeyboardButton::ascii_key('0');       break;
-   case 18:   nk = KeyboardButton::ascii_key('1');       break;
-   case 19:   nk = KeyboardButton::ascii_key('2');       break;
-   case 20:   nk = KeyboardButton::ascii_key('3');       break;
-   case 21:   nk = KeyboardButton::ascii_key('4');       break;
-   case 23:   nk = KeyboardButton::ascii_key('5');       break;
-   case 22:   nk = KeyboardButton::ascii_key('6');       break;
-   case 26:   nk = KeyboardButton::ascii_key('7');       break;
-   case 28:   nk = KeyboardButton::ascii_key('8');       break;
-   case 25:   nk = KeyboardButton::ascii_key('9');       break;
-
-       // key pad ... do they really map to the top number in panda ?
-   case 82:   nk = KeyboardButton::ascii_key('0');       break;
-   case 83:   nk = KeyboardButton::ascii_key('1');       break;
-   case 84:   nk = KeyboardButton::ascii_key('2');       break;
-   case 85:   nk = KeyboardButton::ascii_key('3');       break;
-   case 86:   nk = KeyboardButton::ascii_key('4');       break;
-   case 87:   nk = KeyboardButton::ascii_key('5');       break;
-   case 88:   nk = KeyboardButton::ascii_key('6');       break;
-   case 89:   nk = KeyboardButton::ascii_key('7');       break;
-   case 91:   nk = KeyboardButton::ascii_key('8');       break;
-   case 92:   nk = KeyboardButton::ascii_key('9');       break;
-
-
-       // case 36:   nk = KeyboardButton::ret();              break;    no
-       // return  in panda ???
-   case 49:   nk = KeyboardButton::space();               break;
-   case 51:   nk = KeyboardButton::backspace();          break;
-   case 48:   nk = KeyboardButton::tab();                  break;
-   case 53:   nk = KeyboardButton::escape();              break;
-   case 76:   nk = KeyboardButton::enter();              break;
-   case 36:   nk = KeyboardButton::enter();              break;
-
-   case 123:  nk = KeyboardButton::left();              break;
-   case 124:  nk = KeyboardButton::right();              break;
-   case 125:  nk = KeyboardButton::down();              break;
-   case 126:  nk = KeyboardButton::up();                  break;
-   case 116:  nk = KeyboardButton::page_up();              break;
-   case 121:  nk = KeyboardButton::page_down();          break;
-   case 115:  nk = KeyboardButton::home();              break;
-   case 119:  nk = KeyboardButton::end();                  break;
-   case 114:  nk = KeyboardButton::help();              break;
-   case 117:  nk = KeyboardButton::del();                  break;
-
-       // case  71:  nk = KeyboardButton::num_lock()        break;
-
-   case 122:  nk = KeyboardButton::f1();                  break;
-   case 120:  nk = KeyboardButton::f2();                  break;
-   case  99:  nk = KeyboardButton::f3();                  break;
-   case 118:  nk = KeyboardButton::f4();                  break;
-   case  96:  nk = KeyboardButton::f5();                  break;
-   case  97:  nk = KeyboardButton::f6();                  break;
-   case  98:  nk = KeyboardButton::f7();                  break;
-   case 100:  nk = KeyboardButton::f8();                  break;
-   case 101:  nk = KeyboardButton::f9();                  break;
-   case 109:  nk = KeyboardButton::f10();                  break;
-   case 103:  nk = KeyboardButton::f11();                  break;
-   case 111:  nk = KeyboardButton::f12();                  break;
-
-   case 105:  nk = KeyboardButton::f13();                  break;
-   case 107:  nk = KeyboardButton::f14();                  break;
-   case 113:  nk = KeyboardButton::f15();                  break;
-   case 106:  nk = KeyboardButton::f16();                  break;
-
-       // shiftable chartablet
-   case  50:  nk = KeyboardButton::ascii_key('`');      break;
-   case  27:  nk = KeyboardButton::ascii_key('-');      break;
-   case  24:  nk = KeyboardButton::ascii_key('=');      break;
-   case  33:  nk = KeyboardButton::ascii_key('[');      break;
-   case  30:  nk = KeyboardButton::ascii_key(']');      break;
-   case  42:  nk = KeyboardButton::ascii_key('\\');      break;
-   case  41:  nk = KeyboardButton::ascii_key(';');      break;
-   case  39:  nk = KeyboardButton::ascii_key('\'');      break;
-   case  43:  nk = KeyboardButton::ascii_key(',');      break;
-   case  47:  nk = KeyboardButton::ascii_key('.');      break;
-   case  44:  nk = KeyboardButton::ascii_key('/');      break;
-
-   default:
-     if (tinydisplay_cat.is_debug()) {
-       tinydisplay_cat.debug()
-   << " Untranslated KeyCode: " << key
-   << " (0x" << hex << key << dec << ")\n";
-     }
-
-     // not sure this is right .. but no mapping for keypad and such this at
-     // least does a best gess..
-
-     char charCode =  0;
-     if (GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, nil, sizeof( charCode ), nil, &charCode ) == noErr)
-       nk = KeyboardButton::ascii_key(charCode);
-   }
-   return nk;
- }
-/**
- * Used to emulate key events for the MAC key Modifiers..
- */
- void TinyOsxGraphicsWindow::HandleModifireDeleta(UInt32 newModifiers) {
-  UInt32 changed = _last_key_modifiers ^ newModifiers;
-
-  if ((changed & (shiftKey | rightShiftKey)) != 0)
-    SendKeyEvent(KeyboardButton::shift(),(newModifiers & (shiftKey | rightShiftKey)) != 0) ;
-
-  if ((changed & (optionKey | rightOptionKey)) != 0)
-    SendKeyEvent(KeyboardButton::alt(),(newModifiers & (optionKey | rightOptionKey)) != 0);
-
-
-  if ((changed & (controlKey | rightControlKey)) != 0)
-    SendKeyEvent(KeyboardButton::control(),(newModifiers & (controlKey | rightControlKey)) != 0);
-
-  if ((changed & cmdKey) != 0)
-    SendKeyEvent(KeyboardButton::meta(),(newModifiers & cmdKey) != 0);
-
-  if ((changed & alphaLock) != 0)
-    SendKeyEvent(KeyboardButton::caps_lock(),(newModifiers & alphaLock) != 0);
-
-  // save current state
-  _last_key_modifiers = newModifiers;
- };
-
-/**
- * Used to emulate buttons events
- */
-void TinyOsxGraphicsWindow::
-HandleButtonDelta(UInt32 new_buttons) {
-  UInt32 changed = _last_buttons ^ new_buttons;
-
-  if (changed & 0x01) {
-    if (new_buttons & 0x01) {
-      _input_devices[0]->button_down(MouseButton::one());
-    } else {
-      _input_devices[0]->button_up(MouseButton::one());
-    }
-  }
-
-  if (changed & 0x04) {
-    if (new_buttons & 0x04) {
-      _input_devices[0]->button_down(MouseButton::two());
-    } else {
-      _input_devices[0]->button_up(MouseButton::two());
-    }
-  }
-
-  if (changed & 0x02) {
-    if (new_buttons & 0x02) {
-      _input_devices[0]->button_down(MouseButton::three());
-    } else {
-      _input_devices[0]->button_up(MouseButton::three());
-    }
-  }
-
-  _last_buttons = new_buttons;
-}
-
-/**
- * Forces the pointer to the indicated position within the window, if
- * possible.
- *
- * Returns true if successful, false on failure.  This may fail if the mouse
- * is not currently within the window, or if the API doesn't support this
- * operation.
- */
-bool TinyOsxGraphicsWindow::move_pointer(int device, int x, int y) {
-  if (_osx_window == NULL) {
-    return false;
-  }
-
-  if (tinydisplay_cat.is_debug()) {
-    tinydisplay_cat.debug() << "move_pointer " << device <<" "<<  x <<" "<< y <<"\n";
-  }
-
-  Point pt = {0, 0};
-  pt.h = x;
-  pt.v = y;
-  set_pointer_in_window(x, y);
-
-  if (_properties.get_mouse_mode() == WindowProperties::M_absolute) {
-     LocalPointToSystemPoint(pt);
-     CGPoint newCursorPosition = {0, 0};
-     newCursorPosition.x = pt.h;
-     newCursorPosition.y = pt.v;
-     mouse_mode_relative();
-     CGWarpMouseCursorPosition(newCursorPosition);
-     mouse_mode_absolute();
-  }
-
-  return true;
-};
-
-bool TinyOsxGraphicsWindow::do_reshape_request(int x_origin, int y_origin, bool has_origin, int x_size, int y_size) {
-  tinydisplay_cat.info() << "Do Reshape\n";
-
-  if (_properties.get_fullscreen()) {
-    return false;
-  }
-
-  // A coordinate of -2 means to center the window on screen.
-  if (x_origin == -2 || y_origin == -2 || x_origin == -1 || y_origin == -1) {
-    if (y_origin == -2) {
-      y_origin = (_pipe->get_display_height() - y_size) / 2;
-    }
-    if (x_origin == -2) {
-      x_origin = (_pipe->get_display_width() - x_size) / 2;
-    }
-    if (y_origin == -1) {
-      y_origin = 50;
-    }
-    if (x_origin == -1) {
-      x_origin = 10;
-    }
-    _properties.set_origin(x_origin, y_origin);
-    system_changed_properties(_properties);
-  }
-
-  /*
-  if (_properties.has_parent_window()) {
-    if (has_origin) {
-      NSWindow*    parentWindow        =    (NSWindow *)_properties.get_parent_window();
-      NSRect        parentFrame            =    [parentWindow frame];
-
-      MoveWindow(_osx_window, x_origin+parentFrame.origin.x, y_origin+parentFrame.origin.y, false);
-     }
-  }
-  else*/
-  {
-    // We sometimes get a bogus origin of (0, 0).  As a special hack, treat
-    // this as a special case, and ignore it.
-    if (has_origin) {
-      if (x_origin != 0 || y_origin != 0) {
-        MoveWindow(_osx_window, x_origin, y_origin, false);
-      }
-    }
-  }
-
-  if (!_properties.get_undecorated()) {
-    // Constrain the window to the available desktop size.
-    Rect bounds;
-    GetAvailableWindowPositioningBounds(GetMainDevice(), &bounds);
-
-    x_size = min(x_size, bounds.right - bounds.left);
-    y_size = min(y_size, bounds.bottom - bounds.top);
-  }
-
-  SizeWindow(_osx_window, x_size, y_size, false);
-
-  system_changed_size(x_size, y_size);
-  ZB_resize(_frame_buffer, NULL, _properties.get_x_size(), _properties.get_y_size());
-  return true;
-}
-
-/**
- * Applies the requested set of properties to the window, if possible, for
- * instance to request a change in size or minimization status.
- *
- * The window properties are applied immediately, rather than waiting until
- * the next frame.  This implies that this method may *only* be called from
- * within the window thread.
- *
- * The properties that have been applied are cleared from the structure by
- * this function; so on return, whatever remains in the properties structure
- * are those that were unchanged for some reason (probably because the
- * underlying interface does not support changing that property on an open
- * window).
- */
-void TinyOsxGraphicsWindow::set_properties_now(WindowProperties &properties) {
-  if (tinydisplay_cat.is_debug()) {
-    tinydisplay_cat.debug()
-      << "------------------------------------------------------\n";
-    tinydisplay_cat.debug()
-      << "set_properties_now " << properties << "\n";
-  }
-
-  GraphicsWindow::set_properties_now(properties);
-
-  if (tinydisplay_cat.is_debug()) {
-    tinydisplay_cat.debug()
-      << "set_properties_now After Base Class" << properties << "\n";
-  }
-
-  // for some changes .. a full rebuild is required for the OS layer Window.
-  // I think it is the crome atribute and full screen behaviour.
-  bool need_full_rebuild = false;
-
-  // if we are not full and transitioning to full
-  if (properties.has_fullscreen() &&
-      properties.get_fullscreen() != _properties.get_fullscreen()) {
-    need_full_rebuild = true;
-  }
-
-  // If we are fullscreen and requesting a size change
-  if (_properties.get_fullscreen() &&
-      (properties.has_size() &&
-       (properties.get_x_size() != _properties.get_x_size() ||
-        properties.get_y_size() != _properties.get_y_size()))) {
-    need_full_rebuild = true;
-  }
-
-  // If we are fullscreen and requesting a minimize change
-  if (_properties.get_fullscreen() &&
-      (properties.has_minimized() &&
-       (properties.get_minimized() != _properties.get_minimized()))) {
-    need_full_rebuild = true;
-  }
-
-  if (need_full_rebuild) {
-    // Logic here is ..  take a union of the properties .. with the new
-    // allowed to overwrite the old states.  and start a bootstrap of a new
-    // window ..
-
-    // get a copy of my properties..
-    WindowProperties req_properties(_properties);
-    ReleaseSystemResources();
-    req_properties.add_properties(properties);
-
-    OSOpenWindow(req_properties);
-
-    // Now we've handled all of the requested properties.
-    properties.clear();
-  }
-
-  if (properties.has_title()) {
-    _properties.set_title(properties.get_title());
-    if (_osx_window) {
-      SetWindowTitleWithCFString(_osx_window,
-                                 CFStringCreateWithCString(NULL,properties.get_title().c_str(),
-                                                           kCFStringEncodingMacRoman));
-    }
-    properties.clear_title();
-  }
-
-  // An icon filename means to load up the icon and save it.  We can't
-  // necessarily apply it immediately; it will get applied later, in the
-  // window event handler.
-  if (properties.has_icon_filename()) {
-    if (set_icon_filename(properties.get_icon_filename())) {
-      properties.clear_icon_filename();
-    }
-  }
-
-  // decorated .. if this changes it reqires a new window
-  if (properties.has_undecorated()) {
-    _properties.set_undecorated(properties.get_undecorated());
-    properties.clear_undecorated();
-  }
-
-  if (properties.has_cursor_hidden()) {
-    _properties.set_cursor_hidden(properties.get_cursor_hidden());
-    _cursor_hidden = properties.get_cursor_hidden();
-    if (_cursor_hidden && _input_devices[0]->has_pointer()) {
-      if (!_display_hide_cursor) {
-        CGDisplayHideCursor(kCGDirectMainDisplay);
-        _display_hide_cursor = true;
-      }
-    } else {
-      if (_display_hide_cursor) {
-        CGDisplayShowCursor(kCGDirectMainDisplay);
-        _display_hide_cursor = false;
-      }
-    }
-    properties.clear_cursor_hidden();
-  }
-
-  if (properties.has_minimized()) {
-    if (_properties.get_minimized() != properties.get_minimized()) {
-      CollapseWindow(_osx_window, properties.get_minimized());
-      _properties.set_minimized(properties.get_minimized());
-      _properties.set_foreground(!properties.get_minimized());
-    }
-    properties.clear_minimized();
-  }
-
-  if (tinydisplay_cat.is_debug()) {
-    tinydisplay_cat.debug()
-      << "set_properties_now  Out....." << _properties << "\n";
-  }
-
-  return;
-}
-
-/**
-
- */
-void TinyOsxGraphicsWindow::LocalPointToSystemPoint(Point &qdLocalPoint) {
-  if (_osx_window != NULL) {
-    GrafPtr savePort;
-    Boolean portChanged = QDSwapPort(GetWindowPort(_osx_window), &savePort);
-
-    LocalToGlobal( &qdLocalPoint );
-
-    if (portChanged) {
-      QDSwapPort(savePort, NULL);
-    }
-  }
-}
-
-/**
- * Detaches mouse.  Only mouse delta from now on.
- */
-void TinyOsxGraphicsWindow::mouse_mode_relative() {
-  CGAssociateMouseAndMouseCursorPosition(false);
-}
-
-/**
- * Reattaches mouse to location
- */
-void TinyOsxGraphicsWindow::mouse_mode_absolute() {
-  CGAssociateMouseAndMouseCursorPosition(true);
-}
-
-/**
- * Creates a suitable frame buffer for the current window size.
- */
-void TinyOsxGraphicsWindow::
-create_frame_buffer() {
-  if (_frame_buffer != NULL) {
-    ZB_close(_frame_buffer);
-    _frame_buffer = NULL;
-  }
-
-  _frame_buffer = ZB_open(_properties.get_x_size(), _properties.get_y_size(), ZB_MODE_RGBA, 0, 0, 0, 0);
-}
-
-#endif  // IS_OSX