gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ./ChangeLog ./configure.ac backend/gnash....


From: Rob Savoye
Subject: [Gnash-commit] gnash ./ChangeLog ./configure.ac backend/gnash....
Date: Sat, 18 Mar 2006 23:39:35 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Branch:         
Changes by:     Rob Savoye <address@hidden>     06/03/18 23:39:34

Modified files:
        .              : ChangeLog configure.ac 
        backend        : gnash.cpp render_handler_ogl.cpp 
        libbase        : log.cpp log.h 
        macros         : gtk2.m4 
        plugin         : player.cpp player.h plugin.cpp plugin.h 
        server         : Movie.cpp Sprite.cpp dlist.cpp impl.h 
                         morph2.cpp shape.cpp text.cpp 
Added files:
        plugin/mozilla-sdk/include: prcvar.h prerr.h prerror.h prinit.h 
                                    prinrval.h prlock.h prthread.h 
                                    prwin16.h 

Log message:
        * server/Movie.cpp: Add GNASH_REPORT_FUNCTION to some functions.
        * server/Sprite.cpp: Add GNASH_REPORT_FUNCTION to some functions.
        * server/dlist.cpp: Add GNASH_REPORT_FUNCTION to some functions.
        * server/impl.h: Add GNASH_REPORT_FUNCTION to some functions.
        * server/morph2.cpp: Add GNASH_REPORT_FUNCTION to some functions.
        * server/shape.cpp: Add GNASH_REPORT_FUNCTION to some functions.
        * server/text.cpp: Add GNASH_REPORT_FUNCTION to some functions.
        * plugin/mozilla-sdk/include/{prcvar.h, prerr.h, prerror.h,
        prinit.h, prinrval.h, prlock.h, prthread.h, prwin16.h}: New files
        copied from Firefox so we can use NSPR without Firefox sources.
        * backend/gnash.cpp: Add -w option to enable producing the disk
        based log file, instead of enabling it by default as it can get
        huge. This log is only useful to developers. This disk log *is*
        produced by default when using the plugin.
        * libbase/log.h: Add a log_trace() function that works like
        GNASH_REPORT_FUNCTION, but also prints the pointer of the current
        instance. Useful for debugging multi-threaded programs. Tracing
        now always prints to the disk file, and only the terminal display
        is controlled by the verbosity level.
        * libbase/log.cpp: Add a log_trace() function that works like
        GNASH_REPORT_FUNCTION, but also prints the pointer of the current
        instance. Useful for debugging multi-threaded programs. Tracing
        now always prints to the disk file, and only the terminal display
        is controlled by the verbosity level. Strip the CR from messages
        passed to the log_* wrapper and replace it with a endl so the
        timestamps work for all the old messages too.
        * server/types.cpp: Small fix to color matrix loading, /256.0
        instead of /255.0/
        * plugin/player.cpp: Use Mozilla NSPR API for mutexes, threads and
        condition variables instead of SDL. For now, only play the movie
        once.
        * plugin/plugin.cpp: Use Mozilla NSPR API for mutexes, threads,
        and condition variables instead of SDL.
        * plugin/plugin.h: Use Mozilla NSPR API for mutexes, threads, and
        condition variables instead of SDL.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/ChangeLog.diff?tr1=1.187&tr2=1.188&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/configure.ac.diff?tr1=1.49&tr2=1.50&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/backend/gnash.cpp.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/backend/render_handler_ogl.cpp.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/libbase/log.cpp.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/libbase/log.h.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/macros/gtk2.m4.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/plugin/player.cpp.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/plugin/player.h.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/plugin/plugin.cpp.diff?tr1=1.18&tr2=1.19&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/plugin/plugin.h.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/plugin/mozilla-sdk/include/prcvar.h?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/plugin/mozilla-sdk/include/prerr.h?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/plugin/mozilla-sdk/include/prerror.h?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/plugin/mozilla-sdk/include/prinit.h?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/plugin/mozilla-sdk/include/prinrval.h?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/plugin/mozilla-sdk/include/prlock.h?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/plugin/mozilla-sdk/include/prthread.h?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/plugin/mozilla-sdk/include/prwin16.h?rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/Movie.cpp.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/Sprite.cpp.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/dlist.cpp.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/impl.h.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/morph2.cpp.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/shape.cpp.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/text.cpp.diff?tr1=1.10&tr2=1.11&r1=text&r2=text

Patches:
Index: gnash/ChangeLog
diff -u gnash/ChangeLog:1.187 gnash/ChangeLog:1.188
--- gnash/ChangeLog:1.187       Sat Mar 18 12:22:59 2006
+++ gnash/ChangeLog     Sat Mar 18 23:39:34 2006
@@ -1,3 +1,41 @@
+2006-03-18  Rob Savoye  <address@hidden>
+
+       * server/Movie.cpp: Add GNASH_REPORT_FUNCTION to some functions.
+       * server/Sprite.cpp: Add GNASH_REPORT_FUNCTION to some functions.
+       * server/dlist.cpp: Add GNASH_REPORT_FUNCTION to some functions.
+       * server/impl.h: Add GNASH_REPORT_FUNCTION to some functions.
+       * server/morph2.cpp: Add GNASH_REPORT_FUNCTION to some functions.
+       * server/shape.cpp: Add GNASH_REPORT_FUNCTION to some functions.
+       * server/text.cpp: Add GNASH_REPORT_FUNCTION to some functions.
+       * plugin/mozilla-sdk/include/{prcvar.h, prerr.h, prerror.h,
+       prinit.h, prinrval.h, prlock.h, prthread.h, prwin16.h}: New files
+       copied from Firefox so we can use NSPR without Firefox sources.
+       * backend/gnash.cpp: Add -w option to enable producing the disk
+       based log file, instead of enabling it by default as it can get
+       huge. This log is only useful to developers. This disk log *is*
+       produced by default when using the plugin.
+       * libbase/log.h: Add a log_trace() function that works like
+       GNASH_REPORT_FUNCTION, but also prints the pointer of the current
+       instance. Useful for debugging multi-threaded programs. Tracing
+       now always prints to the disk file, and only the terminal display
+       is controlled by the verbosity level.
+       * libbase/log.cpp: Add a log_trace() function that works like
+       GNASH_REPORT_FUNCTION, but also prints the pointer of the current
+       instance. Useful for debugging multi-threaded programs. Tracing
+       now always prints to the disk file, and only the terminal display
+       is controlled by the verbosity level. Strip the CR from messages
+       passed to the log_* wrapper and replace it with a endl so the
+       timestamps work for all the old messages too.
+       * server/types.cpp: Small fix to color matrix loading, /256.0
+       instead of /255.0/
+       * plugin/player.cpp: Use Mozilla NSPR API for mutexes, threads and
+       condition variables instead of SDL. For now, only play the movie
+       once.
+       * plugin/plugin.cpp: Use Mozilla NSPR API for mutexes, threads,
+       and condition variables instead of SDL.
+       * plugin/plugin.h: Use Mozilla NSPR API for mutexes, threads, and
+       condition variables instead of SDL.
+
 2006-03-18  Tomas Groth Christensen  <address@hidden>
 
        * backend/sound_handler_sdl.cpp: Make mp3-support depend on
@@ -5,8 +43,21 @@
        * macros/docbook.m4: Include the J2REDIR enviroment variable
        in the list of where java could be.
        
+2006-03-17  Rob Savoye  <address@hidden>
+
+       * server/button.cpp: Clear() m_actions after resizing when
+       destructing a button. Bug #16105
+
 2006-03-11  Rob Savoye  <address@hidden>
 
+       * doc/C/Makefile.am: Add logging.xml.
+       * libbase/log.h: Only print TRACE messages at verbose level 2. Add
+       getVerbosity() accessor.
+       * server/impl.cpp: Add fixme_loader(), and set the unimplemented
+       tags to that so we know when we hit one.
+       * server/impl.h: Add prototype for fixme_loader().
+       * server/text.cpp: Clean up warning message.
+
        * doc/C/internals.xml: Add section on the new debug logging
        system. 
        * doc/C/logging.xml: New section on the new debug logging
@@ -960,9 +1011,6 @@
 
        * Makefile.am (ACLOCAL_AMFLAGS): Add so autoreconf works. 
 
-       * server/action.cpp: Add missing opcodes to opcode table so we can
-       at least know when they get invoked.
-
 2006-02-03 Michael Carlson <address@hidden>
 
        * server/action.cpp: SetTarget is now implemented for targets
Index: gnash/backend/gnash.cpp
diff -u gnash/backend/gnash.cpp:1.17 gnash/backend/gnash.cpp:1.18
--- gnash/backend/gnash.cpp:1.17        Sun Mar 12 00:35:15 2006
+++ gnash/backend/gnash.cpp     Sat Mar 18 23:39:34 2006
@@ -92,6 +92,8 @@
 static bool    s_event_thread = false;
 static bool    s_start_waiting = false;
 
+extern SDL_mutex *glMutex;
+
 static tu_file*
 file_opener(const char* url)
 // Callback function.  This opens files for the library.
@@ -190,8 +192,11 @@
             exit(0);
         }
     }
+
+    dbglogfile.setWriteDisk(false);
+//    dbglogfile.removeLog();
     
-    while ((c = getopt (argc, argv, "hvaps:cfd:m:x:r:t:b:1e")) != -1) {
+    while ((c = getopt (argc, argv, "hvaps:cfd:m:x:r:t:b:1ew")) != -1) {
        switch (c) {
          case 'h':
              usage (argv[0]);
@@ -200,6 +205,11 @@
               dbglogfile.setVerbosity();
              dbglogfile << "Verbose output turned on" << endl;
              break;
+         case 'w':
+//              dbglogfile.openLog();
+              dbglogfile.setWriteDisk(true);
+             dbglogfile << "Logging to disk disabled." << endl;
+             break;
          case 'a':
              gnash::set_verbose_action(true);
              break;
@@ -798,6 +808,7 @@
         "  -f          Run full speed (no sleep) and log frame rate\n"
 //         "  -e          Use SDL Event thread\n"
         "  -x <ID>     X11 Window ID for display\n"
+        "  -w          Produce the disk based debug log\n"
         "  -1          Play once; exit when/if movie reaches the last frame\n"
         "  -r <0|1|2>  0 disables renderering & sound (good for batch tests)\n"
         "              1 enables rendering & sound (default setting)\n"
Index: gnash/backend/render_handler_ogl.cpp
diff -u gnash/backend/render_handler_ogl.cpp:1.8 
gnash/backend/render_handler_ogl.cpp:1.9
--- gnash/backend/render_handler_ogl.cpp:1.8    Sat Mar 11 20:47:24 2006
+++ gnash/backend/render_handler_ogl.cpp        Sat Mar 18 23:39:34 2006
@@ -14,7 +14,7 @@
 
 #include "log.h"
 
-#include <string.h>    // for memset()
+#include <cstring>
 
 using namespace gnash;
 
@@ -134,6 +134,7 @@
        // Push our style into OpenGL.
        void apply(/*const matrix& current_matrix*/) const
        {
+           GNASH_REPORT_FUNCTION;
            assert(m_mode != INVALID);
            
            if (m_mode == COLOR) {
@@ -353,6 +354,7 @@
        // coordinates of the movie that correspond to the viewport
        // bounds.
        {
+           GNASH_REPORT_FUNCTION;
            
            m_display_width = fabsf(x1 - x0);
            m_display_height = fabsf(y1 - y0);
@@ -432,6 +434,8 @@
        // Clean up after rendering a frame.  Client program is still
        // responsible for calling glSwapBuffers() or whatever.
        {
+           GNASH_REPORT_FUNCTION;
+           
            glMatrixMode(GL_MODELVIEW);
            glPopMatrix();
        }
@@ -522,6 +526,8 @@
 
     void       draw_mesh_strip(const void* coords, int vertex_count)
        {
+           GNASH_REPORT_FUNCTION;
+           
 #define NORMAL_RENDERING
 //#define MULTIPASS_ANTIALIASING
 
@@ -639,6 +645,7 @@
     void       draw_line_strip(const void* coords, int vertex_count)
        // Draw the line strip formed by the sequence of points.
        {
+           GNASH_REPORT_FUNCTION;
            // Set up current style.
            m_current_styles[LINE_STYLE].apply();
 
@@ -668,6 +675,7 @@
        //
        // Intended for textured glyph rendering.
        {
+           GNASH_REPORT_FUNCTION;
            assert(bi);
 
            apply_color(color);
@@ -703,6 +711,7 @@
        
     void begin_submit_mask()
        {
+           GNASH_REPORT_FUNCTION;
            glEnable(GL_STENCIL_TEST); 
            glClearStencil(0);
            glClear(GL_STENCIL_BUFFER_BIT);
@@ -739,6 +748,7 @@
 // Sets the current texture to a resampled/expanded version of the
 // given image data.
 {
+    GNASH_REPORT_FUNCTION;
     assert(bytes_per_pixel == 3 || bytes_per_pixel == 4);
 
     unsigned int       in_format = bytes_per_pixel == 3 ? GL_RGB : GL_RGBA;
@@ -787,6 +797,7 @@
 // DESTRUCTIVELY generate mipmaps of the given image.  The image data
 // and width/height of im are munged in this process.
 {
+    GNASH_REPORT_FUNCTION;
     int        level = 1;
     while (im->m_width > 1 || im->m_height > 1)
        {
@@ -820,6 +831,7 @@
 // resampled version of the given src image.  Does a bilinear
 // resampling to create the dst image.
 {
+    GNASH_REPORT_FUNCTION;
     assert(bytes_per_pixel == 3 || bytes_per_pixel == 4);
 
     assert(dst_width >= src_width);
@@ -938,6 +950,7 @@
 // Make a placeholder bitmap_info.  Must be filled in later before
 // using.
 {
+    GNASH_REPORT_FUNCTION;
     m_texture_id = 0;
     m_original_width = 0;
     m_original_height = 0;
@@ -950,6 +963,7 @@
 //
 // !! Munges *data in order to create mipmaps !!
 {
+    GNASH_REPORT_FUNCTION;
     assert(width > 0);
     assert(height > 0);
     assert(data);
@@ -994,6 +1008,7 @@
 bitmap_info_ogl::bitmap_info_ogl(image::rgb* im)
 // NOTE: This function destroys im's data in the process of making mipmaps.
 {
+    GNASH_REPORT_FUNCTION;
     assert(im);
 
     // Create the texture.
@@ -1073,6 +1088,7 @@
 // Version of the constructor that takes an image with alpha.
 // NOTE: This function destroys im's data in the process of making mipmaps.
 {
+    GNASH_REPORT_FUNCTION;
     assert(im);
 
     // Create the texture.
@@ -1151,6 +1167,7 @@
 gnash::render_handler* gnash::create_render_handler_ogl()
 // Factory.
 {
+    GNASH_REPORT_FUNCTION;
     return new render_handler_ogl;
 }
 
Index: gnash/configure.ac
diff -u gnash/configure.ac:1.49 gnash/configure.ac:1.50
--- gnash/configure.ac:1.49     Fri Mar 10 14:51:36 2006
+++ gnash/configure.ac  Sat Mar 18 23:39:34 2006
@@ -54,6 +54,9 @@
   *)   AC_MSG_ERROR([bad value ${enableval} for enable-gtkplug option]) ;;
 esac],gtkplug=no)
 AM_CONDITIONAL(GTKPLUG, test x$gtkplug = xyes)
+if test x$gtkplug = xyes; then
+  AC_DEFINE(USE_GTK_PLUG,1,[Defined when using GTKPLUG support])
+fi
 
 dnl Add KFLASH support, if specified.
 AC_ARG_ENABLE(klash, [  --enable-klash           Enable support for Konqueror 
plugin],
Index: gnash/libbase/log.cpp
diff -u gnash/libbase/log.cpp:1.1 gnash/libbase/log.cpp:1.2
--- gnash/libbase/log.cpp:1.1   Sat Mar 11 19:24:27 2006
+++ gnash/libbase/log.cpp       Sat Mar 18 23:39:34 2006
@@ -69,6 +69,7 @@
 
 namespace gnash {
 
+// static data to be hared amongst all classes.
 ofstream LogFile::_console;
 int LogFile::_verbose = 0;
 
@@ -127,7 +128,22 @@
     va_start (ap, fmt);
     vsprintf (tmp, fmt, ap);
     
-    dbglogfile << tmp;
+    dbglogfile << tmp << endl;
+    
+    va_end (ap);
+}
+
+void
+log_trace(const char* fmt, ...)
+{
+    va_list ap;
+    char tmp[BUFFER_SIZE];
+    memset(tmp, 0, BUFFER_SIZE);
+    
+    va_start (ap, fmt);
+    vsprintf (tmp, fmt, ap);
+    
+    dbglogfile << "TRACE: " << tmp << endl;
     
     va_end (ap);
 }
@@ -142,8 +158,8 @@
     
     va_start (ap, fmt);
     vsprintf (tmp, fmt, ap);
-    
-    dbglogfile << "ERROR: " << tmp;
+
+    dbglogfile << "ERROR: " << tmp << endl;
     
     va_end (ap);    
 }
@@ -157,7 +173,7 @@
     va_start (ap, fmt);
     vsprintf (tmp, fmt, ap);
     
-    dbglogfile << "WARNING: " << tmp;
+    dbglogfile << "WARNING: " << tmp << endl;
     
     va_end (ap);    
 }
@@ -169,7 +185,7 @@
 }
 
 // Default constructor
-LogFile::LogFile (void): _state(OPEN), _stamp(true), _write(true)
+LogFile::LogFile (void): _state(OPEN), _stamp(true), _write(true), 
_trace(false)
 {
     string loadfile;
     
@@ -378,24 +394,66 @@
 }
 
 /// \brief print a const char * string
+///
+/// This function is more complex than the other logging functions
+/// because it has hooks to look for the TRACE: keyword for logging
+/// function calls. We always want these to be logged to the disk
+/// file, but optionally printed to the terminal window.
+///
+/// Since the traceing functions use varargs, they always become a
+/// const char * string after processing the arguments. That means we
+/// can look for the keyword to determine what to do.
 LogFile& 
-LogFile::operator << (const char *c)
+LogFile::operator << (const char *str)
 {
+    char *c = (char *)str;
+    
     _logentry = timestamp();
     _logentry += ": ";
 
+    // See if we have the TRACE keyword
+    if (strstr(str, "TRACE:")) {
+       _trace = true;
+    }    
+
+    // Since the log_* functions are wrappers for the older API used
+    // for logging, we have to strip the CR off the end otr we get
+    // blanks lines as the previous implementation required a CR, and
+    // now we don't.
+    int len = strlen(c);
+    if (c[len] == '\n') {
+       c[len] = 0;
+    }
+    
+    if (c[len-1] == '\n') {
+       c[len-1] = 0;
+    }
+    
     if (_stamp == true && (_state == IDLE || _state == OPEN)) {
       _state = INPROGRESS;
-      if (_verbose) {
-         cout << _logentry  << c;
+      if (_trace) {
+         if (_verbose >= TRACELEVEL) {
+             cout << _logentry  << c;
+         }
+      } else {
+         if (_verbose) {
+             cout << _logentry  << c;
+         }
       }
       if (_write) {
          _outstream << _logentry << c;
       }
     } else {
-       if (_verbose) {
-           cout << c;
+       if (_trace) {
+           if (_verbose >= TRACELEVEL) {
+               cout << c;
+           }
+       } else {
+           if (_verbose) {
+               cout << c;
+           }
        }
+       
        if (_write) {
            _outstream << c;
        }
@@ -443,8 +501,14 @@
 ostream&
 LogFile::operator << (ostream & (&)(ostream &))
 {
-    if (_verbose) {
-       cout << "\r" << endl;
+    if (_trace) {
+       if (_verbose >= TRACELEVEL) {
+           cout << "\r" << endl;
+       }
+    } else {
+       if (_verbose) {
+           cout << "\r" << endl;
+       }
     }
     
     if (_write) {
@@ -453,6 +517,7 @@
     }
     
     _state = IDLE;
+    _trace = false;
     
     // FIXME: This is probably not the value to return
     return cout;
Index: gnash/libbase/log.h
diff -u gnash/libbase/log.h:1.2 gnash/libbase/log.h:1.3
--- gnash/libbase/log.h:1.2     Sun Mar 12 00:35:15 2006
+++ gnash/libbase/log.h Sat Mar 18 23:39:34 2006
@@ -64,6 +64,7 @@
 extern std::ostream& stampoff(std::ostream& x);
 extern std::ostream& timestamp(std::ostream& x);
 extern std::ostream& datetimestamp(std::ostream& x);
+#define TRACELEVEL 2
 
 class Verbose {
     int level;
@@ -79,8 +80,6 @@
     LogFile (const char *);
     ~LogFile(void) {
        if (_state == OPEN) {
-           //      flush();
-           //      state = CLOSED;
            closeLog();
        }
     }
@@ -143,6 +142,7 @@
     static int          _verbose;
     bool                _stamp;
     bool                _write;
+    bool                _trace;
     std::string                 _filespec;
     std::string                 _logentry;
     friend std::ostream & operator << (std::ostream &os, LogFile& e);
@@ -152,36 +152,32 @@
 void log_msg(const char* fmt, ...) __attribute__((format (printf, 1, 2)));
 void log_error(const char* fmt, ...) __attribute__((format (printf, 1, 2)));
 void log_warning(const char* fmt, ...) __attribute__((format (printf, 1, 2)));
+void log_trace(const char* fmt, ...) __attribute__((format (printf, 1, 2)));
 
 extern LogFile dbglogfile;
 
 struct __Host_Function_Report__ {
     const char *func;
 
-    // Only print function tracing messages when two -v options have been 
supplied.
+    // Only print function tracing messages when tmultiplewo -v
+    // options have been supplied. 
     __Host_Function_Report__(void) {
-       if (dbglogfile.getVerbosity() > 1) {
-           dbglogfile << "TRACE: enter" << std::endl;
-       }
+       log_trace("entering");
     }
 
     __Host_Function_Report__(char *_func) {
-       if (dbglogfile.getVerbosity() > 1) {
-           func = _func;
-           dbglogfile << "TRACE: " << func << " enter" << std::endl;
-       }
+       func = _func;
+       log_trace("%s enter", func);
     }
 
     __Host_Function_Report__(const char *_func) {
-       if (dbglogfile.getVerbosity() > 1) {
-           func = _func;
-           dbglogfile << "TRACE: " << func << " enter" << std::endl;
-       }
+       func = _func;
+       log_trace("%s enter", func);
     }
 
     ~__Host_Function_Report__(void) {
-       if (dbglogfile.getVerbosity() > 1) {
-           dbglogfile << "TRACE: " << func << " return" << std::endl;
+       if (dbglogfile.getVerbosity() >= TRACELEVEL+1) {
+           log_trace("returning");
        }
     }
 };
@@ -192,10 +188,10 @@
 #define GNASH_REPORT_RETURN
 #else
 #define GNASH_REPORT_FUNCTION \
-    log_msg"TRACE: %s entering at %d\n", __PRETTY_FUNCTION__, __LINE__)
+    log_trace("entering")
 
 #define GNASH_REPORT_RETURN \
-    log_msg"TRACE: %s returning at %d\n", __PRETTY_FUNCTION__, __LINE__)
+    log_trace("returning")
 #endif
 
 }
Index: gnash/macros/gtk2.m4
diff -u gnash/macros/gtk2.m4:1.2 gnash/macros/gtk2.m4:1.3
--- gnash/macros/gtk2.m4:1.2    Thu Mar  9 19:29:06 2006
+++ gnash/macros/gtk2.m4        Sat Mar 18 23:39:34 2006
@@ -50,7 +50,7 @@
     fi
   ])
 
-  if test x"$glext" = x"yes"; then
+  if test x"$glext" = x"yes" -o x"$gtkplug" = x"yes"; then
     dnl Attempt to find the top level directory, which unfortunately has a
     dnl version number attached. At least on Debain based systems, this
     dnl doesn't seem to get a directory that is unversioned.
Index: gnash/plugin/player.cpp
diff -u gnash/plugin/player.cpp:1.9 gnash/plugin/player.cpp:1.10
--- gnash/plugin/player.cpp:1.9 Thu Mar  9 19:29:06 2006
+++ gnash/plugin/player.cpp     Sat Mar 18 23:39:34 2006
@@ -46,13 +46,16 @@
 // don't care about.
 #define NO_NSPR_10_SUPPORT
 
-#include <SDL.h>
-#include <SDL_thread.h>
+//#include <SDL.h>
+//#include <SDL_thread.h>
 
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <iostream>
+#include <signal.h>
 
+#include "log.h"
 #include "gnash.h"
 #include "plugin.h"
 #include "ogl.h"
@@ -63,10 +66,18 @@
 #include "xmlsocket.h"
 #include "Movie.h"
 
+// Mozilla SDK headers
+#include "prinit.h"
+#include "plugin.h"
+#include "prlock.h"
+#include "prcvar.h"
+#include "prthread.h"
+
 // Define is you just want a hard coded OpenGL graphic
-#define TEST_GRAPHIC
+//#define TEST_GRAPHIC
 
 #ifdef HAVE_LIBXML
+
 bool gofast = false;           // FIXME: this flag gets set based on
                                // an XML message written using
                                // SendCommand(""). This way a movie
@@ -87,10 +98,9 @@
 bool GLinitialized = false;
 bool processing = false;
 
-//extern Display     *gxDisplay;
-extern SDL_mutex   *glMutex;
-extern SDL_cond    *gCond;
-extern SDL_mutex   *playerMutex;
+using namespace std;
+using namespace gnash;
+
 
 #define OVERSIZE       1.0f
 
@@ -98,39 +108,27 @@
 static int doneYet = 0;
 
 static float   s_scale = 1.0f;
-static bool    s_antialiased = false;
-static int     s_bit_depth = 16;
+//static bool  s_antialiased = false;
+//static int   s_bit_depth = 16;
 static bool    s_verbose = false;
 static bool    s_background = true;
-static bool    s_measure_performance = false;
-static bool    s_event_thread = false;
+//static bool  s_measure_performance = false;
+//static bool  s_event_thread = false;
 static bool    s_start_waiting = false;
 
-SDL_mutex *Pmutex;
+//SDL_mutex *Pmutex;
+static void interupt_handler (int);
 
 static void
 message_log(const char* message)
 // Process a log message.
 {
     if (s_verbose) {
-        fputs(message, stdout);
+       fputs(message, stdout);
         fflush(stdout); // needed on osx for some reason
     }
 }
 
-static void
-log_callback(bool error, const char* message)
-// Error callback for handling messages.
-{
-    if (error) {
-        // Log, and also print to stderr.
-        message_log(message);
-        fputs(message, stderr);
-    } else {
-        message_log(message);
-    }
-}
-
 static tu_file*
 file_opener(const char* url)
 // Callback function.  This opens files for the library.
@@ -155,22 +153,23 @@
 {
     assert(tu_types_validate());
     float      exit_timeout = 0;
-    bool do_sound = false;
-//    bool do_loop = true;
-    int  delay = 5;
+    bool       do_sound = false;
+    int                delay = 31;
+    int                retries = 0;
     float      tex_lod_bias;
+    struct sigaction  act;
 
-    Pmutex = SDL_CreateMutex();
+//    Pmutex = SDL_CreateMutex();
     
     const char *infile = inst->getFilename();
     
-    printf("%s: Playing %s\n", __PRETTY_FUNCTION__, infile);
+    log_msg("%s: Playing %s\n", __PRETTY_FUNCTION__, infile);
     
     // -1.0 tends to look good.
     tex_lod_bias = -1.2f;  
     
     if (infile == NULL) {
-        printf("no input file\n");
+        log_msg("no input file\n");
         exit(1);
     }
     
@@ -181,15 +180,15 @@
         sleep(10);
     }
 #endif
+#if 0
     gnash::set_verbose_action(true);
-    gnash::set_verbose_parse(true);    
-
+    gnash::set_verbose_parse(true);
+#endif
+// Uncomment this if you don't want debug logs stored to disk
+//    dbglogfile.setWriteDisk(false);
+    
     gnash::register_file_opener_callback(file_opener);
     gnash::register_fscommand_callback(fs_callback);
-//    if (s_verbose == true) {
-    gnash::register_log_callback(log_callback);
-//    }
-    //gnash::set_antialiased(s_antialiased);
     
     gnash::sound_handler  *sound = NULL;
     gnash::render_handler *render = NULL;
@@ -199,55 +198,60 @@
        gnash::set_sound_handler(sound);
     }
 #endif
-    // Grab control of the display
-//     inst->lockGL();
-    inst->lockX();
-    inst->setGL();
+    inst->lockDisplay();
     render = gnash::create_render_handler_ogl();
     gnash::set_render_handler(render);
-    // Release control of the display
-    inst->freeX();
-    //    inst->freeGL();
-    
+    inst->freeDisplay();
+
     // Get info about the width & height of the movie.
     int        movie_version = 0;
     int        movie_width = 0;
     int        movie_height = 0;
-    float      movie_fps = 30.0f;
+    float movie_fps = 30.0f;
     gnash::get_movie_info(infile, &movie_version, &movie_width, &movie_height, 
&movie_fps, NULL, NULL);
     if (movie_version == 0) {
         fprintf(stderr, "error: can't get info about %s\n", infile);
         exit(1);
     }
-    
+    log_msg("Movie %s: width is %d, height is %d, version is %d\n", infile,
+           movie_width, movie_height, movie_version);
+
+#if 1
     int        width = int(movie_width * s_scale);
     int        height = int(movie_height * s_scale);
-    
-    printf("Passed in width is %d, height is %d\n", inst->getWidth(),
+#else
+    int        width = inst->getWidth();
+    int        height = inst->getHeight();
+#endif
+    log_msg("Passed in width is %d, height is %d\n", inst->getWidth(),
           inst->getHeight());
-    printf("Calculated width is %d, height is %d\n", width, height);
-    //atexit(SDL_Quit);
-    
-//    printf("%s: at line %d\n", __PRETTY_FUNCTION__, __LINE__);    
+    log_msg("Calculated width is %d, height is %d\n",
+           int(movie_width * s_scale), int(movie_height * s_scale));
     
     // Load the actual movie.
+    inst->lockDisplay();
     gnash::movie_definition*   md = gnash::create_library_movie(infile);
+    inst->freeDisplay();
     if (md == NULL) {
         fprintf(stderr, "error: can't create a movie from '%s'\n", infile);
         exit(1);
     }
 
+    inst->lockDisplay();
     gnash::movie_interface*    m = create_library_movie_inst(md);
+    inst->freeDisplay();
     if (m == NULL) {
         fprintf(stderr, "error: can't create movie instance\n");
-        exit(1);
+//     inst->freeDisplay();
+       exit(1);
     }
+//    inst->freeDisplay();
     gnash::set_current_root(m);
 
     // Mouse state.
 
-     int       mouse_x = 0;
-     int       mouse_y = 0;
+    int        mouse_x = 0;
+    int        mouse_y = 0;
     int        mouse_buttons = 0;
     
     float      speed_scale = 1.0f;
@@ -255,7 +259,12 @@
     start_ticks = SDL_GetTicks();
     Uint32     last_ticks = start_ticks;
     int        frame_counter = 0;
-    int        last_logged_fps = last_ticks;
+//    int      last_logged_fps = last_ticks;
+
+    // Trap ^C so we can kill all the threads
+    act.sa_handler = interupt_handler;
+//    act.sa_flags = SA_NOCLDSTOP;
+    sigaction (SIGSEGV, &act, NULL);
 
     for (;;) {
        Uint32  ticks;
@@ -267,14 +276,23 @@
         // Check auto timeout counter.
        if (exit_timeout > 0
            && ticks - start_ticks > (Uint32) (exit_timeout * 1000)) {
-           printf("Auto exiting now...\n");
-           // Auto exit now.
+           dbglogfile << "Auto exiting now..." << endl;
            break;
        }
         m = gnash::get_current_root();
         gnash::delete_unused_root();
+       width = inst->getWidth();
+       height = inst->getHeight();
+       inst->lockDisplay();
        m->set_display_viewport(0, 0, width, height);
-//     m->set_background_alpha(s_background ? 1.0f : 0.05f);
+       inst->resizeWindow(width,height);
+       inst->freeDisplay();
+
+// //  GLfloat ratio = (GLfloat)width / (GLfloat)height;
+// //  glViewport(0, 0, (GLint)width, (GLint)height);
+// //  gluPerspective(45.0f, ratio, 0.1f, 100.0f);
+
+       m->set_background_alpha(s_background ? 1.0f : 0.05f);
        m->notify_mouse_state(mouse_x, mouse_y, mouse_buttons);    
         m->advance(delta_t * speed_scale);
 //     if (do_render) {
@@ -284,36 +302,50 @@
        
         
 #ifdef TEST_GRAPHIC
-       printf("We made it!!!\n");
+       dbglogfile << "We made it!!!" << endl;
        inst->drawTestScene();
 #else
-       printf("Display rendered graphic!!!\n");
-       // Grab control of the display
-       inst->lockGL();
-       inst->lockX();
-       inst->setGL();
+       dbglogfile << "Display rendered graphic!!!" << endl;
+       inst->lockDisplay();
        m->display();
        inst->swapBuffers();
-       // Release control of the display
-       inst->unsetGL();
-       inst->freeX();
-       inst->freeGL();
+       inst->freeDisplay();
 #endif
 
        frame_counter++;
- 
+
+#ifndef TEST_GRAPHIC
+#if 1                          // FIXME: run forever ?
        // See if we should exit
        if (m->get_current_frame() + 1 == md->get_frame_count()) {
-           printf("Reached the end of the movie...\n");
-           // We're reached the end of the movie; exit.
+           dbglogfile << "Reached the end of the movie..." << endl;
            break;
        }
-
+#endif
+#else
+       if (retries++ > 5) {
+           break;   
+       }
+#endif
+       NPBool die = inst->getShutdown();
+       if (die) {
+           dbglogfile << "Shutting down as requested..." << endl;
+           break;
+       }
+       
+//     void *pd = PR_GetThreadPrivate(inst->getThreadKey());
+//     dbglogfile << "Thread Data is: " << (char *)pd << endl;
        //glPopAttrib ();
        
        // Don't hog the CPU.
-       printf("About to sleep for %d seconds...!!!\n", delay);
-       SDL_Delay(delay);
+#ifdef TEST_GRAPHIC
+       dbglogfile << "About to sleep for 1 second...!!!" << endl;
+       sleep(1);
+#else
+       dbglogfile << "About to sleep for " << delay
+                  << " milliseconds...!!!" << endl;
+       PR_Sleep(delay);
+#endif
     }
 //    SDL_KillThread(thread);  // kill the network read thread
 //    SDL_Quit();
@@ -355,7 +387,7 @@
     ptr->user.data2 = 0;
 #endif
     
-    printf("Initializing event thread...\n");
+    log_msg("Initializing event thread...\n");
     
     while (gnash::check_sockets(xml_fd) == -1) {
         sleep(10); // Delay to give the socket time to
@@ -369,7 +401,7 @@
     // issue with CPU load.
     sleep(20);
     
-    printf("Enabling Event Wait Mode...\n");
+    log_msg("Enabling Event Wait Mode...\n");
     s_start_waiting = true;
     
     while (!doneYet) {
@@ -393,44 +425,29 @@
     return 0;
 }
 
-int
+void
 playerThread(void *arg)
 {
-    int retries = 0;
     nsPluginInstance *inst = (nsPluginInstance *)arg;    
-    printf("%s: instance is %p for %s\n", __PRETTY_FUNCTION__, inst,
+    log_trace("%s: instance is %p for %s\n", __PRETTY_FUNCTION__, inst,
           inst->getFilename());
     
-    SDL_CondWait(gCond, playerMutex);
+//    SDL_CondWait(gCond, playerMutex);
+//    inst->condWait();
 
     main_loop(inst);
 
-    printf("%s: Done this = %p...\n", __PRETTY_FUNCTION__, inst);
+    log_msg("%s: Done this = %p...\n", __PRETTY_FUNCTION__, inst);
 
-    pthread_exit(inst);
-    return 0;
+    return;
 }
 
-int
-playerThread3(void *arg)
+void
+interupt_handler (int sig)
 {
-    int retries = 0;    
-    nsPluginInstance *inst = (nsPluginInstance *)arg;
-    
-    printf("%s: instance is %p\n", __PRETTY_FUNCTION__, inst);
-
-    SDL_CondWait(gCond, playerMutex);
-    
-    while (retries++ < 3) {
-       printf("%s: Looping... %s\n", __PRETTY_FUNCTION__, inst->getFilename());
-       sleep(1+retries);
-    }
-
-    printf("%s: Done this = %p...\n", __PRETTY_FUNCTION__, inst);
-    
-    pthread_exit(arg);
+    dbglogfile << "Got a signal #" << sig << endl;
     
-    return 0;
+    exit(-1);
 }
 
 // Local Variables:
Index: gnash/plugin/player.h
diff -u gnash/plugin/player.h:1.4 gnash/plugin/player.h:1.5
--- gnash/plugin/player.h:1.4   Thu Mar  9 19:29:06 2006
+++ gnash/plugin/player.h       Sat Mar 18 23:39:34 2006
@@ -39,10 +39,8 @@
 #ifndef __GNASH_PLAYER_H__
 #define __GNASH_PLAYER_H__
 
-int playerThread(void *inst);
-int playerThread2(void *inst);
-int playerThread3(void *inst);
 int main_loop(nsPluginInstance *inst);
+void playerThread(void *inst);
 
 // EOF of __GNASH_PLAYER_H__
 #endif
Index: gnash/plugin/plugin.cpp
diff -u gnash/plugin/plugin.cpp:1.18 gnash/plugin/plugin.cpp:1.19
--- gnash/plugin/plugin.cpp:1.18        Thu Mar  9 19:29:06 2006
+++ gnash/plugin/plugin.cpp     Sat Mar 18 23:39:34 2006
@@ -55,44 +55,60 @@
 #ifdef HAVE_GTK_GTKGL_H
 #include <gtk/gtkgl.h>
 #endif
+#ifdef USE_GTK_PLUG
+#include <gtk/gtk.h>
+#include <gdk/gdk.h>
+#endif
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <X11/XKBlib.h>
 #include <X11/keysym.h>
 #include <X11/Sunkeysym.h>
-// #include <SDL.h>
-#include <SDL_thread.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-
+#include <iostream>
 #include <string>
 
 #include "tu_file.h"
 #include "tu_types.h"
-//#include "Thread.h"
 #include "player.h"
 #include "xmlsocket.h"
 
+// Mozilla SDK headers
+#include "prinit.h"
+#include "prlock.h"
+#include "prcvar.h"
+#include "prerr.h"
+#include "prerror.h"
+#include "prthread.h"
+
 using namespace std;
 using namespace gnash;
 
 extern bool processing;
 
-// Static members. We have to share this data amongst all
-NPBool       nsPluginInstance::_plugInitialized = FALSE;
-Display     *nsPluginInstance::_xDisplay = NULL;
-SDL_mutex   *nsPluginInstance::_glMutex = NULL;
-SDL_cond    *nsPluginInstance::_gCond = NULL;
-SDL_mutex   *nsPluginInstance::_playerMutex = NULL;
+extern NPNetscapeFuncs NPNFuncs;
 
-// These aren't static members of the class because we have to
-// call these from the C callback for the Mozilla SDK.
+NPBool      plugInitialized = FALSE;
 Display     *gxDisplay = NULL;
-SDL_mutex   *glMutex = NULL;
-SDL_cond    *gCond = NULL;
-SDL_mutex   *playerMutex = NULL;
+PRLock      *glMutex = NULL;
+PRLock      *playerMutex = NULL;
+PRCondVar   *playerCond = NULL;
+
+// Static members. We have to share this data amongst all
+//Display     *nsPluginInstance::gxDisplay = NULL;
+//PRLock      *nsPluginInstance::_playerMutex = NULL;
+//PRCondVar   *nsPluginInstance::_playerCond = NULL;
+//SDL_cond    *nsPluginInstance::_gCond = NULL;
+//SDL_mutex   *nsPluginInstance::_playerMutex = NULL;
+//PRLock      *nsPluginInstance::_prlock = NULL;
+
+GtkWidget   *gtkplug = NULL;
+GtkMenu     *popup_menu = NULL;
+GtkMenuItem *menuitem_play = NULL;
+GtkMenuItem *menuitem_pause = NULL;
 
 // static int   streamfd = -1;
 // static float s_scale = 1.0f;
@@ -101,8 +117,8 @@
 static bool  waitforgdb = false;
 
 const int INBUFSIZE = 1024;
-static void xt_event_handler(Widget xtwidget, nsPluginInstance *plugin,
-                XEvent *xevent, Boolean *b);
+// static void xt_event_handler(Widget xtwidget, nsPluginInstance *plugin,
+//              XEvent *xevent, Boolean *b);
 
 #if 0
 static int attributeList_noFSAA[] = { GLX_RGBA, GLX_DOUBLEBUFFER, 
GLX_STENCIL_SIZE, 1, None };
@@ -119,6 +135,105 @@
                                // want to make sure it all works.
 #endif // HAVE_LIBXML
 
+#ifdef USE_GTK_PLUG
+// destroy a GtkWidget. This is only used if using an external window
+// was used to render the movie in.
+gboolean
+destroy_callback(GtkWidget * widget, GdkEvent * event,
+              nsPluginInstance * instance)
+{
+    gtk_widget_destroy(widget);
+}
+
+gboolean
+fixme_callback(GtkWidget * widget, GdkEvent * event,
+              nsPluginInstance * instance)
+{
+    GNASH_REPORT_FUNCTION;
+
+    dbglogfile << "Got a Callback! " << event->type << endl;
+    
+    switch (event->type) {
+      case GDK_DESTROY:
+         dbglogfile << "Got a DESTROY event" << endl;
+         break;
+      case GDK_EXPOSE:
+//       dbglogfile << "Got an EXPOSE event" << endl;
+           break;
+      case GDK_KEY_PRESS:
+         dbglogfile << "Got a KEY PRESS event" << endl;
+         break;
+      case GDK_KEY_RELEASE:
+         dbglogfile << "Got a KEY RELEASE event" << endl;          
+         break;
+      case GDK_MAP:
+//       dbglogfile << "Got a MAP event" << endl;
+         break;
+      case GDK_FOCUS_CHANGE:
+//       dbglogfile << "Got a FOCUS CHANGE event" << endl;
+         break;
+      case GDK_BUTTON_PRESS:
+         dbglogfile << "Got a BUTTON PRESS event" << endl;
+         break;
+      case GDK_ENTER_NOTIFY:
+//       dbglogfile << "Got a ENTER event" << endl;
+         break;
+      case GDK_LEAVE_NOTIFY:
+//       dbglogfile << "Got a LEAVE event" << endl;
+         break;
+      case GDK_NOTHING:
+      case GDK_DELETE:
+      case GDK_MOTION_NOTIFY:
+      case GDK_2BUTTON_PRESS:
+      case GDK_3BUTTON_PRESS:
+      case GDK_BUTTON_RELEASE:
+      case GDK_CONFIGURE:
+      case GDK_UNMAP:
+      case GDK_PROPERTY_NOTIFY:
+      case GDK_SELECTION_CLEAR:
+      case GDK_SELECTION_NOTIFY:
+      case GDK_SELECTION_REQUEST:        
+      case GDK_PROXIMITY_IN:
+      case GDK_PROXIMITY_OUT:
+      case GDK_DRAG_ENTER:
+      case GDK_DRAG_LEAVE:
+      case GDK_DRAG_MOTION:
+      case GDK_DRAG_STATUS:
+      case GDK_DROP_START:
+      case GDK_DROP_FINISHED:
+      case GDK_CLIENT_EVENT:
+      case GDK_VISIBILITY_NOTIFY:
+      case GDK_NO_EXPOSE:
+      case GDK_SCROLL:
+      case GDK_WINDOW_STATE:
+      case GDK_SETTING:
+      case GDK_OWNER_CHANGE:
+      case GDK_GRAB_BROKEN:
+         break;
+    }
+    
+    
+//     gtk_widget_hide(GTK_WIDGET(instance->gtkwidget));
+//     instance->Quit();
+    return TRUE;
+}
+
+#endif
+
+void
+PR_CALLBACK Destructor(void *data)
+{
+    GNASH_REPORT_FUNCTION;
+
+    /*
+     * We don't actually free the storage since it's actually allocated
+     * on the stack. Normally, this would not be the case and this is
+     * the opportunity to free whatever.
+    PR_Free(data);
+     */
+}  /* Destructor */
+
+
 /// \brief Return the MIME Type description for this plugin.
 char*
 NPP_GetMIMEDescription(void)
@@ -139,12 +254,82 @@
 NPError
 NS_PluginInitialize()
 {
-    printf("%s: Initializing the Plugin\n", __PRETTY_FUNCTION__);
-    glMutex = SDL_CreateMutex();
-    playerMutex = SDL_CreateMutex();
-    gCond = SDL_CreateCond();
+    GNASH_REPORT_FUNCTION;
 
+    NPError err = NPERR_NO_ERROR;
+    PRBool supportsXEmbed = PR_FALSE;
+    NPNToolkitType toolkit;
+
+    // This mutex is to lock the display before doing any OpenGL or
+    // X11 function calls.
+    glMutex = PR_NewLock();
+    if (glMutex) {
+       dbglogfile << "Allocated new GL Mutex" << endl;
+    } else {
+       dbglogfile << "ERROR: Couldn't allocate new GL Mutex!" << endl;
+    }
+    
+
+    // This mutex is only used with the condition variable.
+    playerMutex = PR_NewLock();
+    if (playerMutex) {
+       dbglogfile << "Allocated new X11 Mutex" << endl;
+    } else {
+       dbglogfile << "ERROR: Couldn't allocate new Player Mutex!" << endl;
+    }
+
+    // This is used to signal the player when it should start playing
+    // a movie.
+    playerCond = PR_NewCondVar(playerMutex);
+    if (playerCond) {
+       dbglogfile << "Allocated new condition variable" << endl;
+    } else {
+       dbglogfile << "ERROR: Couldn't allocate new Condition Variable!" << 
endl;
+    }
+
+    // Open a connection to the X11 server so we can lock the Display
+    // when swapping GLX contexts.
     gxDisplay = XOpenDisplay(NULL);
+    if (gxDisplay) {
+       dbglogfile << "Opened connection to X11 server" << endl;
+    } else {
+       dbglogfile << "ERROR: Couldn't open a connection to the X11 server!" << 
endl;
+    }
+    
+    dbglogfile.setVerbosity(1);
+
+    // Make sure that the browser supports functionality we need
+    err = CallNPN_GetValueProc(NPNFuncs.getvalue, NULL,
+                               NPNVSupportsXEmbedBool,
+                               (void *)&supportsXEmbed);
+
+    if (err != NPERR_NO_ERROR || supportsXEmbed != PR_TRUE) {
+       log_warning("No xEmbed support in this Mozilla version!");
+        return NPERR_INCOMPATIBLE_VERSION_ERROR;
+    } else {
+       dbglogfile << "xEmbed supported in this Mozilla version" << endl;
+    }
+
+    err = CallNPN_GetValueProc(NPNFuncs.getvalue, NULL,
+                               NPNVToolkit,
+                               (void *)&toolkit);
+    
+    if (err != NPERR_NO_ERROR || toolkit != NPNVGtk2) {
+       log_warning("No GTK2 support in this Mozilla version! Have %d",
+                   (int)toolkit);
+        return NPERR_INCOMPATIBLE_VERSION_ERROR;
+    } else {
+       dbglogfile << "Gtk2+ supported in this Mozilla version" << endl;
+    }
+
+//     if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_NOPARACHUTE)) {
+//     fprintf(stderr, "Unable to init SDL: %s", SDL_GetError());
+//     exit(1);
+//     }
+    
+    plugInitialized = TRUE;
+
+    GNASH_REPORT_RETURN;
     
     return NPERR_NO_ERROR;
 }
@@ -158,16 +343,39 @@
 void
 NS_PluginShutdown()
 {
-    printf("%s(%d): Shutting down the plugin\n", __PRETTY_FUNCTION__, 
__LINE__);
-    XCloseDisplay(gxDisplay);
-    gxDisplay = NULL;
-    SDL_DestroyMutex(glMutex);
-    glMutex = NULL;
-    SDL_DestroyMutex(playerMutex);
-    playerMutex = NULL;
-    SDL_DestroyCond(gCond);
-    gCond = NULL;
-//    SDL_Quit();
+    GNASH_REPORT_FUNCTION;
+
+    if (!plugInitialized) {
+       dbglogfile << "Plugin already shut down" << endl;
+       return;
+    }
+    
+    if (playerMutex) {
+       PR_DestroyLock(playerMutex);
+       playerMutex = NULL;
+       dbglogfile << "Destroyed Player Mutex" << endl;
+    }
+
+    if (glMutex) {
+       PR_DestroyLock(glMutex);
+       glMutex = NULL;
+       dbglogfile << "Destroyed GL Mutex" << endl;
+    }
+
+    if (playerCond) {
+       PR_DestroyCondVar(playerCond);
+       playerCond = NULL;
+       dbglogfile << "Destroyed Player condition variable" << endl;
+    }
+
+    if (gxDisplay) {
+       XCloseDisplay(gxDisplay);
+       gxDisplay = NULL;
+       dbglogfile << "Closed connection to X11 server" << endl;
+    }
+
+    GNASH_REPORT_RETURN;
+    plugInitialized = FALSE;
 }
 
 /// \brief Retrieve values from the plugin for the Browser
@@ -178,6 +386,8 @@
 NPError
 NS_PluginGetValue(NPPVariable aVariable, void *aValue)
 {
+    GNASH_REPORT_FUNCTION;
+    
     char tmp[1024];
     NPError err = NPERR_NO_ERROR;
     
@@ -195,13 +405,18 @@
              );
           *((char **)aValue) = tmp;
           break;
-      case NPPVpluginTimerInterval:
       case NPPVpluginNeedsXEmbed:
+#ifdef USE_GTK_PLUG
+//       *((PRBool *)aValue) = PR_TRUE;
+         break;
+#endif
+      case NPPVpluginTimerInterval:
       case NPPVpluginKeepLibraryInMemory:
       default:
           err = NPERR_INVALID_PARAM;
           break;
     }
+    GNASH_REPORT_RETURN;
     return err;
 }
 
@@ -212,12 +427,14 @@
 nsPluginInstanceBase *
 NS_NewPluginInstance(nsPluginCreateData * aCreateDataStruct)
 {
-    printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+    GNASH_REPORT_FUNCTION;
+    
     if(!aCreateDataStruct)
         return NULL;
 
     nsPluginInstance * plugin = new 
nsPluginInstance(aCreateDataStruct->instance);
     
+    GNASH_REPORT_RETURN;
     return plugin;
 }
 
@@ -228,10 +445,12 @@
 void
 NS_DestroyPluginInstance(nsPluginInstanceBase * aPlugin)
 {
-    printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+    GNASH_REPORT_FUNCTION;
+
     if (aPlugin) {
         delete (nsPluginInstance *)aPlugin;
     }
+    GNASH_REPORT_RETURN;
 }
 
 //
@@ -241,29 +460,22 @@
 /// \brief Construct a new nsPluginInstance object
 nsPluginInstance::nsPluginInstance(NPP aInstance) : nsPluginInstanceBase(),
                                                     mInstance(aInstance),
-                                                    mWindow(0),
+                                                    _window(0),
                                                     mXtwidget(0),
                                                     mFontInfo(0),
-                                                   mContext(NULL),
-                                                   _glInitialized(FALSE)
+                                                   _glxContext(NULL),
+                                                   _shutdown(FALSE),
+                                                   _glInitialized(FALSE),
+                                                   _thread(NULL),
+                                                   _newwin(FALSE)
 {
-    printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
-//    _plugInitialized(FALSE);
-    bShutting = FALSE;
-    mThread = NULL;
-//    mMutex = SDL_CreateMutex();
+    GNASH_REPORT_FUNCTION;
 }
 
 /// \brief Destroy a nsPluginInstance object
 nsPluginInstance::~nsPluginInstance()
 {
-    printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
-//     if (mThread != NULL) {
-//     SDL_KillThread(mThread);
-//     }
-//    if (gCond) {
-//        SDL_DestroyCond(gCond);
-//    }
+    GNASH_REPORT_FUNCTION;
 }
 
 /// \brief Initialize an instance of the plugin object
@@ -274,13 +486,15 @@
 NPBool
 nsPluginInstance::init(NPWindow* aWindow)
 {
+    log_trace("%s: enter for instance %p", __PRETTY_FUNCTION__, this);
+    
     if(aWindow == NULL) {
-       printf("%s: ERROR: Window handle was bogus!\n", __PRETTY_FUNCTION__);
+       log_msg("%s: ERROR: Window handle was bogus!", __PRETTY_FUNCTION__);
         return FALSE;
     } else {
-       printf("%s: X origin = %d, Y Origin = %d, Width = %d,"
-              " Height = %d, WindowID = %p, this = %p\n",
-              __PRETTY_FUNCTION__,
+       log_msg("%s: X origin = %d, Y Origin = %d, Width = %d,"
+              " Height = %d, WindowID = %p, this = %p",
+               __FUNCTION__,
               aWindow->x, aWindow->y, aWindow->width, aWindow->height,
               aWindow->window, this);
     }
@@ -289,27 +503,10 @@
     // attach GDB to it.
     bool gdb = false;
     while (gdb) {
-       printf ("Waiting for GDB for pid %d\n", getpid());
+       dbglogfile << "Waiting for GDB for pid " << getpid() << endl;
        sleep(5);
-    }    
-
-    if (_plugInitialized) {
-       printf("%s Already initialized...\n", __PRETTY_FUNCTION__);
-       return TRUE;
     }
-
-    initGL();
-
-    _plugInitialized = TRUE;
-
-//    mThread = SDL_CreateThread(playerThread3, this);
     
-//     char SDL_windowhack[32];
-//     sprintf (SDL_windowhack,"SDL_WINDOWID=%d", aWindow->window);
-//     putenv (SDL_windowhack);
-    
-//    _plugInitialized = TRUE;
-
     return TRUE;
 }
 
@@ -321,14 +518,21 @@
 void
 nsPluginInstance::shut()
 {
-    printf("%s(%d): Entering. \n", __PRETTY_FUNCTION__, __LINE__);
+    log_trace("%s: enter for instance %p", __PRETTY_FUNCTION__, this);    
 
-    destroyContext();
-    
-    if (mThread) {
-       SDL_KillThread(mThread);
-       mThread = NULL;
+    if (_thread) {
+       dbglogfile << "Waiting for the thread to terminate..." << endl;
+       PRStatus rv = PR_SetThreadPrivate(_thread_key, (void *)"stop");
+       _shutdown = TRUE;
+//     PR_Interrupt(_thread);
+//     if (PR_PENDING_INTERRUPT_ERROR == PR_GetError()) {
+//         dbglogfile << "ERROR: Couldn't interupt thread!" << endl;
+//     }
+       
+       PR_JoinThread(_thread);
+       _thread = NULL;
     }
+    destroyContext();
 }
 
 /// \brief Set the window to be used to render in
@@ -341,69 +545,76 @@
 NPError
 nsPluginInstance::SetWindow(NPWindow* aWindow)
 {
+    log_trace("%s: enter for instance %p", __PRETTY_FUNCTION__, this);    
+    
     if(aWindow == NULL) {
-       printf("%s: ERROR: Window handle was bogus!\n", __PRETTY_FUNCTION__);
+       dbglogfile << __FUNCTION__ << ": ERROR: Window handle was bogus!" << 
endl;
         return FALSE;
     } else {
-       printf("%s: X origin = %d, Y Origin = %d, Width = %d,"
-              " Height = %d, WindowID = %p, this = %p\n",
-              __PRETTY_FUNCTION__,
+       log_msg("%s: X origin = %d, Y Origin = %d, Width = %d,"
+              " Height = %d, WindowID = %p, this = %p",
+              __FUNCTION__,
               aWindow->x, aWindow->y, aWindow->width, aWindow->height,
               aWindow->window, this);
     }    
     
 //     if (_glInitialized) {
-//     printf("%s Already initialized...\n", __PRETTY_FUNCTION__);
+//     log_msg("%s Already initialized...", __FUNCTION__);
 //     return TRUE;
 //     }    
     
     if (aWindow->x == mX && aWindow->y == mY
        && aWindow->width == mWidth
        && aWindow->height == mHeight
-       && (unsigned long)(aWindow->window) == mWindow) {
+       && (unsigned long)(aWindow->window) == _window) {
        return TRUE;
     }
 
     lockGL();
     lockX();
-    
     mX = aWindow->x;
     mY = aWindow->y;
     mWidth = aWindow->width;
     mHeight = aWindow->height;
     
-    if (mWindow == (Window) aWindow->window) {
+    if (_window == (Window) aWindow->window) {
         // The page with the plugin is being resized.
         // Save any UI information because the next time
         // around expect a SetWindow with a new window id.
-       printf("Error: Setwindow() called with same window handle - but 
resizing plugin unhandled!\n");
+       dbglogfile << __FUNCTION__ << "Error: Setwindow() called with same 
window handle - but resizing plugin unhandled!" << endl;
     } else {
-        mWindow = (Window) aWindow->window;
-        NPSetWindowCallbackStruct *ws_info = (NPSetWindowCallbackStruct 
*)aWindow->ws_info;
+        _window = (Window) aWindow->window;
+        NPSetWindowCallbackStruct *ws_info =
+           (NPSetWindowCallbackStruct *)aWindow->ws_info;
        mVisual = ws_info->visual;
         mDepth = ws_info->depth;
         mColormap = ws_info->colormap;
-//        _xDisplay = ws_info->display;
+//        gxDisplay = ws_info->display;
 
         if (!mFontInfo) {
-            if (!(mFontInfo = XLoadQueryFont(gxDisplay, "9x15")))
-                printf("Cannot open 9X15 font\n");
+            if (!(mFontInfo = XLoadQueryFont(gxDisplay, "9x15"))) {
+                dbglogfile << "ERROR: Cannot open 9X15 font!" << endl;
+           }
         }
        
-       XVisualInfo *vi = glXChooseVisual(gxDisplay, DefaultScreen(gxDisplay), 
attributeList_FSAA);
+       XVisualInfo *vi = glXChooseVisual(gxDisplay, DefaultScreen(gxDisplay),
+                                         attributeList_FSAA);
        if (vi == NULL) {
-           vi = glXChooseVisual(gxDisplay, DefaultScreen(gxDisplay), 
attributeList_noFSAA);
+           vi = glXChooseVisual(gxDisplay, DefaultScreen(gxDisplay),
+                                attributeList_noFSAA);
        } else {
            vi->visual = mVisual;
        }
        
-       mContext = glXCreateContext(gxDisplay, vi, 0, GL_TRUE);
-       if (mContext) {
-           printf("%s: Got new glxContext %p\n", __PRETTY_FUNCTION__, 
mContext);
-           _glInitialized = TRUE;
+       _glxContext = glXCreateContext(gxDisplay, vi, 0, GL_TRUE);
+       if (_glxContext) {
+           dbglogfile << __FUNCTION__ << ": Got new glxContext "
+                      << (void *)_glxContext << endl;
            setGL();
+           initGL();
+           _glInitialized = TRUE;
        } else {
-           printf("%s: ERROR: Couldn't get new glxContext!\n", 
__PRETTY_FUNCTION__);
+           dbglogfile << __FUNCTION__ << ": ERROR: Couldn't get new 
glxContext!" << endl;
        }
 
         // add xt event handler#
@@ -414,9 +625,55 @@
 //         XtAddEventHandler(xtwidget, event_mask, FALSE,
 //                           (XtEventHandler) xt_event_handler, this);
     }
-    freeX();
+
+
+#ifdef USE_GTK_PLUG_XXXXXXX
+    gtkplug = gtk_plug_new(_window);
+//     if (_newwin) {
+//     _gtkwidget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+//     } else {
+//     _gtkwidget = gtk_window_new(GTK_WINDOW_POPUP);
+//     }
+    gtk_window_set_title(GTK_WINDOW(gtkplug), "Gnash player");
+    
+    gtk_widget_add_events(gtkplug, GDK_BUTTON_PRESS_MASK);
+    gtk_widget_add_events(gtkplug, GDK_BUTTON_RELEASE_MASK);
+    g_signal_connect(GTK_OBJECT(gtkplug), "button_press_event",
+                    GTK_SIGNAL_FUNC(fixme_callback), this);
+    
+    gtk_signal_connect(GTK_OBJECT(gtkplug), "delete_event",
+                      GTK_SIGNAL_FUNC(destroy_callback), this);
+    
+    g_signal_connect(GTK_OBJECT(gtkplug), "expose_event",
+                    GTK_SIGNAL_FUNC(fixme_callback), this);
+    
+    g_signal_connect(GTK_OBJECT(gtkplug), "key_press_event",
+                    GTK_SIGNAL_FUNC(fixme_callback), this);
+    
+    g_signal_connect(GTK_OBJECT(gtkplug), "focus_in_event",
+                    GTK_SIGNAL_FUNC(fixme_callback), this);
+    
+    g_signal_connect(GTK_OBJECT(gtkplug), "focus_out_event",
+                    GTK_SIGNAL_FUNC(fixme_callback), this);
+    
+    g_signal_connect(GTK_OBJECT(gtkplug), "map_event",
+                    GTK_SIGNAL_FUNC(fixme_callback), this);
+
+//    gtk_widget_realize(gtkplug);
+//     popup_menu = GTK_MENU(gtk_menu_new());
+//     menuitem_play =
+//     GTK_MENU_ITEM(gtk_menu_item_new_with_label("Play"));
+//     gtk_menu_append(popup_menu, GTK_WIDGET(menuitem_play));
+//     gtk_widget_show(GTK_WIDGET(menuitem_play));
     
+    gtk_widget_show(gtkplug);
+//    gtk_widget_set_usize(_gtkwidget,mWidth, mHeight);    
+#endif
     resizeWindow(mWidth,mHeight);
+
+    unsetGL();
+    freeX();
+    freeGL();
     
     return NPERR_NO_ERROR;
 }
@@ -424,13 +681,16 @@
 const char *
 nsPluginInstance::getVersion()
 {
-    printf("%s(%d): Entering. \n", __PRETTY_FUNCTION__, __LINE__);
+    GNASH_REPORT_FUNCTION;
+    
     return NPN_UserAgent(mInstance);
 }
 
 NPError
 nsPluginInstance::GetValue(NPPVariable aVariable, void *aValue)
 {
+    log_trace("%s: enter for instance %p", __PRETTY_FUNCTION__, this);    
+    
     NPError err = NPERR_NO_ERROR;
     switch (aVariable) {
       case NPPVpluginNameString:
@@ -453,7 +713,7 @@
 nsPluginInstance::WriteStatus(char *msg) const
 {
     NPN_Status(mInstance, msg);
-    printf("%s\n", msg);
+    log_msg("%s", msg);
 
     return NPERR_NO_ERROR;
 }
@@ -472,6 +732,8 @@
 nsPluginInstance::NewStream(NPMIMEType type, NPStream * stream,
                             NPBool seekable, uint16 * stype)
 {
+    log_trace("%s: enter for instance %p", __PRETTY_FUNCTION__, this);    
+    
     char tmp[300];
     memset(tmp, 0, 300);
     string url = stream->url;
@@ -479,7 +741,7 @@
     unsigned int start, end, eq;
     bool dumpopts = false;
 
-    printf("%s: this = %p, URL is %s\n", __PRETTY_FUNCTION__,
+    log_msg("%s: this = %p, URL is %s", __FUNCTION__,
           (void *)this, stream->url);
 
     end   = url.find(".swf", 0) + 4;
@@ -494,7 +756,7 @@
        opts = url.substr(start+1, end);
     }
 
-    printf("The full URL is %s\n", url.c_str());
+    dbglogfile << __FUNCTION__ << ": The full URL is " << url << endl;
     while (opts.size() > 0) {
        start = 0;
        eq = opts.find("=", 0);
@@ -511,11 +773,12 @@
        string name = opts.substr(start, eq);
        string value = opts.substr(eq+1, end-eq-1);
        if (dumpopts) {
-           printf("Option %s = %s\n", name.c_str(), value.c_str());
+           dbglogfile << __FUNCTION__ << "Option " << name << " = "
+                      << value << endl;
        }
        // Look for our special debug flags
        if (name == "debug") {
-           printf("Debug flag is %s\n", value.c_str());
+           dbglogfile << __FUNCTION__ << "Debug flag is " << value << endl;
            if (value == "waitforgdb") {
                waitforgdb = true;
            }
@@ -531,8 +794,8 @@
        opts.erase(start, end);
     }
     
-    //  printf("%s: URL is %s\n", __PRETTY_FUNCTION__, url.c_str());
-    printf("%s: Open stream for %s, this = %p\n", __PRETTY_FUNCTION__,
+    //  log_msg("%s: URL is %s", __PRETTY_FUNCTION__, url.c_str());
+    log_msg("%s: Open stream for %s, this = %p", __FUNCTION__,
           fname.c_str(), (void *)this);
 
     sprintf(tmp, "Loading Flash movie %s", fname.c_str());
@@ -559,13 +822,15 @@
 NPError
 nsPluginInstance::DestroyStream(NPStream * stream, NPError reason)
 {
+    log_trace("%s: enter for instance %p", __PRETTY_FUNCTION__, this);    
+    
     char tmp[300];
     memset(tmp, 0, 300);
     nsPluginInstance *arg = (nsPluginInstance *)this;
     sprintf(tmp, "Done Flash movie %s", swf_file.c_str());
     WriteStatus(tmp);
 
-    printf("%s: this = %p, URL is %s\n", __PRETTY_FUNCTION__,
+    log_msg("%s: this = %p, URL is %s", __PRETTY_FUNCTION__,
           (void *)arg, stream->url);
     processing = false;
 
@@ -576,21 +841,40 @@
     
     // Wait for GDB
     if (waitforgdb) {
-       printf("Attach GDB to PID %d to debug!\n", getpid());
-       printf("This thread will block until then!...\n");
-       printf("Once blocked here, you can set other breakpoints.\n");
-       printf("do a \"set variable waitforgdb=false\" to continue\n");
+       log_msg("Attach GDB to PID %d to debug!", getpid());
+       log_msg("This thread will block until then!...");
+       log_msg("Once blocked here, you can set other breakpoints.");
+       log_msg("do a \"set variable waitforgdb=false\" to continue");
        while (waitforgdb) {
            sleep(1);
        }
     }
 
-    printf("%s: Starting player Thread for this = %p\n",
+    log_msg("%s: Starting player Thread for this = %p",
           __PRETTY_FUNCTION__, (void *)this);
-    mThread = SDL_CreateThread(playerThread, this);
+
+
+//     PRStatus rv;
+//     rv = PR_NewThreadPrivateIndex(&_thread_key, Destructor);
+//     rv = PR_SetThreadPrivate(_thread_key, (void *)"run");
+
+    // PR_USER_THREAD -        PR_Cleanup blocks until the last thread of
+    //                 type PR_USER_THREAD terminates.
+    // PR_SYSTEM_THREAD - NSPR ignores threads of type
+    // PR_SYSTEM_THREAD when determining when a call to PR_Cleanup
+    // should return.
+    //
+    // PR_LOCAL_THREAD - A local thread, scheduled locally by NSPR
+    // within the process.
+    // PR_GLOBAL_THREAD - A global thread, scheduled by the host OS.
+    // PR_GLOBAL_BOUND_THREAD -        A global bound (kernel) thread,
+    // scheduled by the host OS 
+    _thread = PR_CreateThread(PR_USER_THREAD, playerThread, this,
+                             PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,
+                             PR_JOINABLE_THREAD, 0);
     
-    SDL_mutexP(playerMutex);
-    SDL_CondBroadcast(gCond);    
+//     PR_Lock(playerMutex);
+//     PR_NotifyCondVar(playerCond);
 
     sprintf(tmp, "Started thread for Flash movie %s", swf_file.c_str());
     WriteStatus(tmp);
@@ -602,16 +886,17 @@
 nsPluginInstance::URLNotify(const char *url, NPReason reason,
                             void *notifyData)
 {
-    printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
-    printf("URL: %s\nReason %i\n", url, reason);
+    log_trace("%s: enter for instance %p", __PRETTY_FUNCTION__, this);    
+    
+    log_msg("URL: %s\nReason %i", url, reason);
 }
 
 /// \brief Return how many bytes we can read into the buffer
 int32
 nsPluginInstance::WriteReady(NPStream * stream)
 {
-//   printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
-//   printf("Stream for %s is ready\n", stream->url);
+//   log_msg("%s(%d): Entering", __PRETTY_FUNCTION__, __LINE__);
+//   log_msg("Stream for %s is ready", stream->url);
 
     return INBUFSIZE;
 }
@@ -623,8 +908,8 @@
 nsPluginInstance::Write(NPStream * stream, int32 offset, int32 len,
                         void *buffer)
 {
-//   printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
-//   printf("Reading Stream %s, offset is %d, length = %d \n",
+//   log_msg("%s(%d): Entering", __PRETTY_FUNCTION__, __LINE__);
+//   log_msg("Reading Stream %s, offset is %d, length = %d",
 //          stream->url, offset, len);
 
     return write(_streamfd, buffer, len);
@@ -635,19 +920,17 @@
 void
 nsPluginInstance::initGL()
 {
-    printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+    log_trace("%s: enter for instance %p", __PRETTY_FUNCTION__, this);    
     
     if (_glInitialized) {
-       printf("%s: OpenGL already initialized...\n", __PRETTY_FUNCTION__);
+       dbglogfile << __FUNCTION__ << ": OpenGL already initialized..."  << 
endl;
        return;
     }
-    
+
     // Grab control of the display
-    lockGL();
-    lockX();
-    setGL();
+//    lockDisplay();
     
-    printf("%s: Initializing OpenGL...\n", __PRETTY_FUNCTION__);
+    dbglogfile << __FUNCTION__ << ": Initializing OpenGL..." << endl;
 
     // Enable smooth shading 
     glShadeModel(GL_SMOOTH);
@@ -667,61 +950,64 @@
     // Really Nice Perspective Calculations 
     glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
 
+    if (_glxContext) {
+       _glInitialized = TRUE;
+    }
+       
     // Release control of the display
-    unsetGL();
-    freeX();
-    freeGL();
+//    freeDisplay();
 }
 
 /// \brief Shutdown OpenGL
 void
 nsPluginInstance::destroyContext()
 {
-    printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+    log_trace("%s: enter for instance %p", __PRETTY_FUNCTION__, this);    
 
     if (!_glInitialized) {
-       printf("%s: OpenGL already killed...\n", __PRETTY_FUNCTION__);
+       dbglogfile << __FUNCTION__ << ": OpenGL already killed..." << endl;
        return;
     }
 
-    if (gxDisplay && mContext) {
+    if (gxDisplay && _glxContext) {
        // Grab control of the display
-       lockGL();
-       lockX();    
+//     lockDisplay();
+       lockGL();
+       lockX();
        setGL();
        
-       printf("%s: Destroying GLX Context %p...\n", __PRETTY_FUNCTION__,
-              mContext);
-       glXDestroyContext(gxDisplay, mContext);
-       _glInitialized = FALSE;
-       mContext = NULL;
-       
+       dbglogfile << __FUNCTION__ << ": Destroying GLX Context "
+                  << (void *)_glxContext << endl;
+       glXDestroyContext(gxDisplay, _glxContext);
+       _glxContext = NULL;
+
+//     freeDisplay();
        // Release control of the display
-       unsetGL();
-       freeX();
-       freeGL();
+       unsetGL();
+       freeX();
+       freeGL();
     }
+    _glInitialized = FALSE;
 }
 
 /// \brief Resize our viewport after a window resize event
 int
 nsPluginInstance::resizeWindow( int width, int height )
 {
-    printf("%s(%d): Width = %d, Height = %d\n",
-          __PRETTY_FUNCTION__, __LINE__, width, height);
+    log_trace("%s: enter for instance %p", __PRETTY_FUNCTION__, this);    
 
-    if (!_plugInitialized) {
-       printf("%s: OpenGL not initialized...\n", __PRETTY_FUNCTION__);
+    log_msg("%s: Width = %d, Height = %d",  __FUNCTION__, width, height);
+
+    if (!plugInitialized || !_glxContext) {
+       dbglogfile << __FUNCTION__ << ": OpenGL not initialized..." << endl;
        return true;
     }
 
     // Grab control of the display
-    lockGL();
-    lockX();
-    setGL();
+//     lockGL();
+//     lockX();
+//     setGL();
     
-    printf("%s: Resizing window...\n", __PRETTY_FUNCTION__);
-
     // Height / width ration 
     GLfloat ratio;
   
@@ -749,9 +1035,9 @@
 //    glLoadIdentity();
   
     // Release control of the display
-    unsetGL();
-    freeX();
-    freeGL();
+//     unsetGL();
+//     freeX();
+//     freeGL();
 
     return(true);
 }
@@ -763,21 +1049,12 @@
 void
 nsPluginInstance::drawTestScene( void )
 {
-    printf("%s: for instance %p\n", __PRETTY_FUNCTION__, this);
+    log_trace("%s: enter for instance %p", __PRETTY_FUNCTION__, this);    
 
-    static SDL_mutex   *mutant = NULL;
-
-    if (!mutant) {
-        mutant = SDL_CreateMutex();
-    }
-
-    SDL_mutexP(mutant);
     // Grab control of the display
-    lockGL();
-    lockX();
-    setGL();
+    lockDisplay();
     
-    printf("%s: Drawing graphic...\n", __PRETTY_FUNCTION__);
+    dbglogfile << __FUNCTION__ << ": Drawing graphic..." << endl;
 
     // Clear The Screen And The Depth Buffer
     glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
@@ -802,17 +1079,16 @@
       glVertex3f(  1.0f,  1.0f, 0.0f ); // Top Right
       glVertex3f(  1.0f, -1.0f, 0.0f ); // Bottom Right
       glVertex3f( -1.0f, -1.0f, 0.0f ); // Bottom Left
-    glEnd( );                   // Done Drawing The Quad
+    glEnd();                   // Done Drawing The Quad
 
     swapBuffers();
     
     // Release control of the display
-    unsetGL();
-    freeX();
-    freeGL();
-    SDL_mutexP(mutant);
+    freeDisplay();
+//    SDL_mutexP(mutant);
 }
 
+#if 0
 /// \brief Handle X events
 ///
 /// This C function handles events from X, like keyboard events, or
@@ -821,7 +1097,8 @@
 xt_event_handler(Widget xtwidget, nsPluginInstance *plugin,
                 XEvent *xevent, Boolean *b)
 {
-    printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, __LINE__);
+    GNASH_REPORT_FUNCTION;
+
     int        keycode;
     KeySym     keysym;
 #if 0
@@ -829,7 +1106,7 @@
     SDL_keysym sdl_keysym;
 
     //    handleKeyPress((SDL_keysym)keysym);
-    printf("Peep Event returned %d\n", SDL_PeepEvents(&sdl_event, 1, 
SDL_PEEKEVENT, 
SDL_USEREVENT|SDL_ACTIVEEVENT|SDL_KEYDOWN|SDL_KEYUP|SDL_MOUSEBUTTONUP|SDL_MOUSEBUTTONDOWN));
+    log_msg("Peep Event returned %d", SDL_PeepEvents(&sdl_event, 1, 
SDL_PEEKEVENT, 
SDL_USEREVENT|SDL_ACTIVEEVENT|SDL_KEYDOWN|SDL_KEYUP|SDL_MOUSEBUTTONUP|SDL_MOUSEBUTTONDOWN));
   
     if (SDL_PollEvent(&sdl_event)) {
         switch(sdl_event.type) {
@@ -862,43 +1139,43 @@
 //                   m->display();
 //               }
 // #endif
-//               printf("Drawing GL Scene for expose event!\n");
+//               log_msg("Drawing GL Scene for expose event!");
 //           } else {
-                 printf("GL Surface not initialized yet, ignoring expose 
event!\n");
+                 log_msg("GL Surface not initialized yet, ignoring expose 
event!");
 //           }
           }
           break;
       case ButtonPress:
 //     fe.type = FeButtonPress;
-          printf("Button Press\n");
+          log_msg("Button Press");
           break;
       case ButtonRelease:
           //     fe.type = FeButtonRelease;
-          printf("Button Release\n");
+          log_msg("Button Release");
           break;
       case KeyPress:
           keycode = xevent->xkey.keycode;
                plugin->lockX();
           keysym = XLookupKeysym((XKeyEvent*)xevent, 0);
-          printf ("%s(%d): Keysym is %s\n", __PRETTY_FUNCTION__, __LINE__,
+          log_msg ("%s(%d): Keysym is %s", __PRETTY_FUNCTION__, __LINE__,
                   XKeysymToString(keysym));
                plugin->freeX();
 
           switch (keysym) {
             case XK_Up:
-                printf("Key Up\n");
+                log_msg("Key Up");
                 break;
             case XK_Down:
-                printf("Key Down\n");
+                log_msg("Key Down");
                 break;
             case XK_Left:
-                printf("Key Left\n");
+                log_msg("Key Left");
                 break;
             case XK_Right:
-                printf("Key Right\n");
+                log_msg("Key Right");
                 break;
             case XK_Return:
-                printf("Key Return\n");
+                log_msg("Key Return");
                 break;
       
             default:
@@ -906,7 +1183,7 @@
           }
     }
 }
-
+#endif
 
 // Local Variables:
 // mode: C++
Index: gnash/plugin/plugin.h
diff -u gnash/plugin/plugin.h:1.8 gnash/plugin/plugin.h:1.9
--- gnash/plugin/plugin.h:1.8   Thu Mar  9 19:29:06 2006
+++ gnash/plugin/plugin.h       Sat Mar 18 23:39:34 2006
@@ -39,16 +39,28 @@
 #ifndef __PLUGIN_H__
 #define __PLUGIN_H__
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 /* Xlib/Xt stuff */
 #include <X11/Xlib.h>
 #include <X11/Intrinsic.h>
 #include <X11/cursorfont.h>
 #include <GL/glx.h>
+#ifdef USE_GTK_PLUG
+#include <gtk/gtk.h>
+#endif
 #include <string>
 #include <map>
 #include "pluginbase.h"
-#include <SDL.h>
-#include <SDL_thread.h>
+//#include <SDL.h>
+//#include <SDL_thread.h>
+
+#include "log.h"
+#include "prlock.h"
+#include "prcvar.h"
+#include "prthread.h"
 
 /* ascii codes for various special keys */
 #define ESCAPE 27
@@ -59,8 +71,11 @@
 #define LEFT_ARROW 75
 #define RIGHT_ARROW 77
 
+extern NPBool      plugInitialized;
 extern Display     *gxDisplay;
-extern SDL_mutex   *glMutex;
+extern PRLock      *glMutex;
+extern PRLock      *playerMutex;
+extern PRCondVar   *playerCond;
 
 class nsPluginInstance : public nsPluginInstanceBase
 {
@@ -69,7 +84,7 @@
     virtual ~nsPluginInstance();
 
     NPBool init(NPWindow *aWindow);
-    NPBool isInitialized() {return _plugInitialized;}
+    NPBool isInitialized() {return plugInitialized;}
     NPError GetValue(NPPVariable variable, void *value);
     NPError SetWindow(NPWindow *aWindow);
     NPError NewStream(NPMIMEType type, NPStream *stream, NPBool seekable,
@@ -83,59 +98,101 @@
 
     // accessors
     const char  *getVersion();
-    Window      getWindow()     { return mWindow; };
+    Window      getWindow()     { return _window; };
     Display     *getDisplay()   { return gxDisplay; };
     unsigned int getDepth()     { return mDepth; };
     int         getWidth()      { return mWidth; };
     int         getHeight()     { return mHeight; };
     const char *getFilename()   { return swf_file.c_str(); };
+    PRUintn    getThreadKey()   { return _thread_key; };
+    NPBool     getShutdown()    { return _shutdown; };
 
     // Set the current GL context
-    void setGL() {
-        printf("%s: Entering gxDisplay = %p, mWindow = %p, mContext = %p\n",
-               __PRETTY_FUNCTION__, gxDisplay, (void *)mWindow, (void 
*)mContext);
-        if (mContext) {
-            glXMakeCurrent(gxDisplay, mWindow, mContext);
+    inline void setGL() {
+        gnash::log_trace("%s: gxDisplay = %p, _window = %p, _glxContext = %p 
for instance %p",
+                         __PRETTY_FUNCTION__, gxDisplay, (void *)_window,
+                         (void *)_glxContext, this);
+        if (gxDisplay && _glxContext && _window) {
+            glXMakeCurrent(gxDisplay, _window, _glxContext);
         }
     }
-    void unsetGL() {
-        printf("%s: Entering, this is %p\n", __PRETTY_FUNCTION__, this);
-        glXMakeCurrent(gxDisplay, None, NULL);
+    inline void unsetGL() {
+        gnash::log_trace("%s: for instance %p", __PRETTY_FUNCTION__, this);
+        if (gxDisplay) {
+            glXMakeCurrent(gxDisplay, None, NULL);
+        }
     }
     // Protect the GL state from multiple threads
-    void lockGL() {
-        printf("%s: Entering, this is %p\n", __PRETTY_FUNCTION__, this);
-        SDL_mutexP(glMutex);
-    }
-    void freeGL() {
-        printf("%s: Entering, this is %p\n", __PRETTY_FUNCTION__, this);
-        SDL_mutexV(glMutex);
+    inline void lockGL() {
+        gnash::log_trace("%s: for instance %p", __PRETTY_FUNCTION__, this);
+        if (glMutex) {
+            PR_Lock(glMutex);
+        } else {
+            gnash::log_error("%s, bad mutex pointer in instance %p!",
+                             __PRETTY_FUNCTION__, this);
+        }
+    }
+    inline void freeGL() {
+        gnash::log_trace("%s: for instance %p", __PRETTY_FUNCTION__, this);
+        if (glMutex) {
+            PR_Unlock(glMutex);
+        } else {
+            gnash::log_error("%s, bad mutex pointer in instance %p!",
+                             __PRETTY_FUNCTION__, this);
+        }
     }
 
     // Protect the X context
-    void lockX() {
-        printf("%s: Entering, this is %p\n", __PRETTY_FUNCTION__, this);
-        XLockDisplay(gxDisplay);
-    }
-    void freeX() {
-        printf("%s: Entering, this is %p\n", __PRETTY_FUNCTION__, this);
-        XUnlockDisplay(gxDisplay);
+    inline void lockX() {
+        gnash::log_trace("%s: for instance %p", __PRETTY_FUNCTION__, this);
+        if (gxDisplay) {
+            XLockDisplay(gxDisplay);
+        }
+    }
+    inline void freeX() {
+        gnash::log_trace("%s: for instance %p", __PRETTY_FUNCTION__, this);
+        if (gxDisplay) {
+            XUnlockDisplay(gxDisplay);
+        }
     }
     
     void swapBuffers() {
-        printf("%s: Entering, this is %p\n", __PRETTY_FUNCTION__, this);
-        glXSwapBuffers(gxDisplay, mWindow);
+        gnash::log_trace("%s: for instance %p", __PRETTY_FUNCTION__, this);
+        if (gxDisplay && _window) {
+//             glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+//             glFlush();
+            glXSwapBuffers(gxDisplay, _window);
+        }
     }
-    void drawTestScene();
-    bool getShutting() { return bShutting; }
-
-    void initGL();
+    void lockDisplay() {
+        gnash::log_trace("%s: for instance %p", __PRETTY_FUNCTION__, this);
+        lockGL();
+        lockX();
+        setGL();
+    }
+    
+    void freeDisplay() {
+        gnash::log_trace("%s: for instance %p", __PRETTY_FUNCTION__, this);
+        unsetGL();
+        freeX();
+        freeGL();
+    }    
     void destroyContext();
     int resizeWindow(int width,int height);
+    void condWait() {
+        gnash::log_trace("%s: for instance %p", __PRETTY_FUNCTION__, this);
+        PR_WaitCondVar(playerCond, PR_INTERVAL_NO_TIMEOUT);
+//        PR_WaitCondVar(_playerCond, PR_INTERVAL_NO_WAIT);
+    }
+
+    
+    void drawTestScene();
+    void initGL();
 
 private:
     // This is a data is unique for each thread
     NPP                 mInstance;
+    Window              _window;
     Widget              mXtwidget;
     XFontStruct         *mFontInfo;
     std::string         swf_file;
@@ -146,22 +203,19 @@
     Visual              *mVisual;
     Colormap            mColormap;
     unsigned int        mDepth;
-    bool                bShutting;
     std::map<std::string, std::string> _options;
-    SDL_Thread          *mThread;
-    GLXContext          mContext;
-    Window              mWindow;
+    GLXContext          _glxContext;
     int                 _streamfd;
+    NPBool              _shutdown;
     NPBool              _glInitialized;
-    
-    // This data is shared amongst all instantiations of this class
-    static NPBool       _plugInitialized;
-    static Display     *_xDisplay;
-    static SDL_mutex   *_glMutex;
-    static SDL_cond    *_gCond;
-    static SDL_mutex   *_playerMutex;
-//    static XtAppContext _xContext;
-//    static int          _instantiations;
+    PRThread            *_thread;
+    PRUintn             _thread_key;
+
+#ifdef USE_GTK_PLUG
+    NPBool              _newwin;
+    GtkWidget           *_gtkwidget;
+    unsigned long       _delete_signal_id;
+#endif
 };
 
 // end of __PLUGIN_H__
Index: gnash/server/Movie.cpp
diff -u gnash/server/Movie.cpp:1.10 gnash/server/Movie.cpp:1.11
--- gnash/server/Movie.cpp:1.10 Thu Mar  9 19:29:06 2006
+++ gnash/server/Movie.cpp      Sat Mar 18 23:39:34 2006
@@ -671,7 +671,8 @@
                
        void movie_root::advance(float delta_time)
        {
-//         printf("%s:\n", __PRETTY_FUNCTION__); // FIXME:
+            GNASH_REPORT_FUNCTION;
+            
            if (m_on_event_load_called == false)
                {
                    // Must do loading events.  For child sprites this is
@@ -726,7 +727,7 @@
 
        void movie_root::display()
        {
-//             printf("%s(%d): ", __PRETTY_FUNCTION__, __LINE__);
+           GNASH_REPORT_FUNCTION;
            if (m_movie->get_visible() == false)
                {
                    // Don't display.
Index: gnash/server/Sprite.cpp
diff -u gnash/server/Sprite.cpp:1.17 gnash/server/Sprite.cpp:1.18
--- gnash/server/Sprite.cpp:1.17        Thu Mar  9 19:29:06 2006
+++ gnash/server/Sprite.cpp     Sat Mar 18 23:39:34 2006
@@ -1212,6 +1212,8 @@
 
        void sprite_instance::display()
        {
+           GNASH_REPORT_FUNCTION;
+           
            if (get_visible() == false)
                {
                    // We're invisible, so don't display!
Index: gnash/server/dlist.cpp
diff -u gnash/server/dlist.cpp:1.5 gnash/server/dlist.cpp:1.6
--- gnash/server/dlist.cpp:1.5  Sat Feb 25 03:15:51 2006
+++ gnash/server/dlist.cpp      Sat Mar 18 23:39:34 2006
@@ -467,7 +467,8 @@
        void    display_list::advance(float delta_time)
        // advance referenced characters.
        {
-//             printf("%s:\n", __PRETTY_FUNCTION__); // FIXME:
+//             GNASH_REPORT_FUNCTION;
+
                int n = m_display_object_array.size();
                for (int i = 0; i < n; i++)
                {
@@ -516,7 +517,8 @@
        // Display the referenced characters. Lower depths
        // are obscured by higher depths.
        {
-//             printf("%s(%d): \n", __PRETTY_FUNCTION__, __LINE__);
+//             GNASH_REPORT_FUNCTION;
+               
 //             printf(".");
 
                bool masked = false;
Index: gnash/server/impl.h
diff -u gnash/server/impl.h:1.16 gnash/server/impl.h:1.17
--- gnash/server/impl.h:1.16    Sun Mar 12 00:35:15 2006
+++ gnash/server/impl.h Sat Mar 18 23:39:34 2006
@@ -527,7 +527,7 @@
 
                virtual void    display()
                {
-//                     printf("%s(%d): Entering\n", __PRETTY_FUNCTION__, 
__LINE__);
+                       GNASH_REPORT_FUNCTION;
                
                        m_def->display(this);   // pass in transform info
                        do_display_callback();
Index: gnash/server/morph2.cpp
diff -u gnash/server/morph2.cpp:1.4 gnash/server/morph2.cpp:1.5
--- gnash/server/morph2.cpp:1.4 Sun Feb 26 21:44:53 2006
+++ gnash/server/morph2.cpp     Sat Mar 18 23:39:34 2006
@@ -28,8 +28,8 @@
 
        void    morph2_character_def::display(character* inst)
        {
-//             printf("%s(%d): ", __PRETTY_FUNCTION__, __LINE__);
-
+               GNASH_REPORT_FUNCTION;
+               
                unsigned int i;
                float ratio = inst->m_ratio;
 
Index: gnash/server/shape.cpp
diff -u gnash/server/shape.cpp:1.9 gnash/server/shape.cpp:1.10
--- gnash/server/shape.cpp:1.9  Sun Feb 26 21:44:53 2006
+++ gnash/server/shape.cpp      Sat Mar 18 23:39:34 2006
@@ -372,6 +372,8 @@
 
        void    mesh::display(const base_fill_style& style, float ratio) const
        {
+               GNASH_REPORT_FUNCTION;
+
                // pass mesh to renderer.
                if (m_triangle_strip.size() > 0)
                {
@@ -432,6 +434,8 @@
        void    line_strip::display(const base_line_style& style, float ratio) 
const
        // Render this line strip in the given style.
        {
+               GNASH_REPORT_FUNCTION;
+
                assert(m_coords.size() > 1);
                assert((m_coords.size() & 1) == 0);
 
@@ -666,6 +670,8 @@
                const std::vector<line_style>& line_styles) const
        // Throw our meshes at the renderer.
        {
+               GNASH_REPORT_FUNCTION;
+
                assert(m_error_tolerance > 0);
 
                // Setup transforms.
@@ -694,6 +700,8 @@
                float ratio) const
        // Throw our meshes at the renderer.
        {
+               GNASH_REPORT_FUNCTION;
+
                assert(m_error_tolerance > 0);
 
                // Setup transforms.
@@ -1082,7 +1090,7 @@
        void    shape_character_def::display(character* inst)
        // Draw the shape using our own inherent styles.
        {
-//             printf("%s(%d): ", __PRETTY_FUNCTION__, __LINE__);
+               GNASH_REPORT_FUNCTION;
 
                matrix  mat = inst->get_world_matrix();
                cxform  cx = inst->get_world_cxform();
@@ -1258,7 +1266,7 @@
        // override our default set of fill styles (e.g. when
        // rendering text).
        {
-//             printf("%s(%d): ", __PRETTY_FUNCTION__, __LINE__);
+               GNASH_REPORT_FUNCTION;
 
                // Compute the error tolerance in object-space.
                float   max_scale = mat.get_max_scale();
Index: gnash/server/text.cpp
diff -u gnash/server/text.cpp:1.10 gnash/server/text.cpp:1.11
--- gnash/server/text.cpp:1.10  Sun Mar 12 00:35:15 2006
+++ gnash/server/text.cpp       Sat Mar 18 23:39:34 2006
@@ -290,7 +290,7 @@
 
        void text_character_def::display(character* inst)
        {
-//             printf("%s(%d): ", __PRETTY_FUNCTION__, __LINE__);
+               GNASH_REPORT_FUNCTION;
                display_glyph_records(m_matrix, inst,
                        m_text_glyph_records, m_root_def);
        }
@@ -869,7 +869,7 @@
        void
        edit_text_character::display()
        {
-//             printf("%s(%d): ", __PRETTY_FUNCTION__, __LINE__);
+               GNASH_REPORT_FUNCTION;
 
                if (m_def->m_border)
                {




reply via email to

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