CVSROOT: /sources/gnash Module name: gnash Changes by: Bastiaan Jacques <bjacques> 07/06/10 14:46:45
Modified files: . : ChangeLog gui : kde.cpp kde_glue_agg.cpp kde_glue_agg.h kdesup.h Log message: * gui/kde{sup.h, .cpp}: Comment out debugging statements. Make setTimeout work. Quit KdeGui gracefully rather than calling exit(0). Avoid conversion compiler warnings. Switch class pointers to auto_ptr. Small code cleanups. * gui/kde_glue_agg{.cpp, .h}: Contain the rendering buffer in a scoped_array. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.3506&r2=1.3507 http://cvs.savannah.gnu.org/viewcvs/gnash/gui/kde.cpp?cvsroot=gnash&r1=1.15&r2=1.16 http://cvs.savannah.gnu.org/viewcvs/gnash/gui/kde_glue_agg.cpp?cvsroot=gnash&r1=1.1&r2=1.2 http://cvs.savannah.gnu.org/viewcvs/gnash/gui/kde_glue_agg.h?cvsroot=gnash&r1=1.1&r2=1.2 http://cvs.savannah.gnu.org/viewcvs/gnash/gui/kdesup.h?cvsroot=gnash&r1=1.18&r2=1.19 Patches: Index: ChangeLog =================================================================== RCS file: /sources/gnash/gnash/ChangeLog,v retrieving revision 1.3506 retrieving revision 1.3507 diff -u -b -r1.3506 -r1.3507 --- ChangeLog 10 Jun 2007 07:36:13 -0000 1.3506 +++ ChangeLog 10 Jun 2007 14:46:44 -0000 1.3507 @@ -1,3 +1,12 @@ +2007-06-10 Bastiaan Jacques <[EMAIL PROTECTED]> + + * gui/kde{sup.h, .cpp}: Comment out debugging statements. Make + setTimeout work. Quit KdeGui gracefully rather than calling + exit(0). Avoid conversion compiler warnings. Switch class + pointers to auto_ptr. Small code cleanups. + * gui/kde_glue_agg{.cpp, .h}: Contain the rendering buffer in + a scoped_array. + 2007-06-10 Sandro Santilli <[EMAIL PROTECTED]> * gui/Makefile.am: klash.moc is a source file for the kde Index: gui/kde.cpp =================================================================== RCS file: /sources/gnash/gnash/gui/kde.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -b -r1.15 -r1.16 --- gui/kde.cpp 9 Jun 2007 19:42:05 -0000 1.15 +++ gui/kde.cpp 10 Jun 2007 14:46:44 -0000 1.16 @@ -22,12 +22,13 @@ #endif -#include <qtimer.h> #include <qwidget.h> #include <qmessagebox.h> #include <qcursor.h> #include <qxembed.h> #include <qnamespace.h> +#include <qtimer.h> +#include <qeventloop.h> #include "Range2d.h" @@ -39,9 +40,6 @@ #include "kdesup.h" #include "klash.moc" -//#include <cstdio> -#include <X11/keysym.h> - using namespace std; namespace gnash @@ -50,29 +48,25 @@ KdeGui::~KdeGui() { // GNASH_REPORT_FUNCTION; - delete _qwidget; } KdeGui::KdeGui(unsigned long xid, float scale, bool loop, unsigned int depth) : Gui(xid, scale, loop, depth) { - GNASH_REPORT_FUNCTION; - - } bool KdeGui::init(int argc, char **argv[]) { - _qapp = new QApplication(argc, *argv); - _qwidget = new qwidget(this); +// GNASH_REPORT_FUNCTION; + _qapp.reset(new QApplication(argc, *argv)); + _qwidget.reset(new qwidget(this)); if (_xid) { QXEmbed::initialize(); - QXEmbed::embedClientIntoWindow(_qwidget, _xid); + QXEmbed::embedClientIntoWindow(_qwidget.get(), _xid); } -// GNASH_REPORT_FUNCTION; _glue.init (argc, argv); return true; @@ -81,15 +75,15 @@ bool KdeGui::createWindow(const char* windowtitle, int width, int height) { - GNASH_REPORT_FUNCTION; +// GNASH_REPORT_FUNCTION; _qwidget->setGeometry(0, 0, width, height); _qwidget->setCaption(windowtitle); - _qapp->setMainWidget(_qwidget); + _qapp->setMainWidget(_qwidget.get()); _qwidget->show(); - _glue.prepDrawingArea(_qwidget); + _glue.prepDrawingArea(_qwidget.get()); _renderer = _glue.createRenderHandler(); _glue.initBuffer(width, height); @@ -118,13 +112,13 @@ KdeGui::setTimeout(unsigned int timeout) { // GNASH_REPORT_FUNCTION; -// _timeout = timeout; + QTimer::singleShot(timeout, _qapp.get(), SLOT(quit())); } void KdeGui::setInterval(unsigned int interval) { - GNASH_REPORT_FUNCTION; +// GNASH_REPORT_FUNCTION; _qwidget->setInterval(interval); } @@ -132,9 +126,7 @@ bool KdeGui::run() { - GNASH_REPORT_FUNCTION; - // _qwidget->connect(&_qapp, SIGNAL(lastWindowClosed()), &_qapp, SLOT(quit())); - +// GNASH_REPORT_FUNCTION; _qapp->exec(); return true; @@ -259,6 +251,12 @@ resize_view(width, height); } +void +KdeGui::quit() +{ + _qapp->eventLoop()->exit(); +} + /// \brief restart the movie from the beginning void @@ -273,12 +271,7 @@ qwidget::menuitem_quit_callback() { // GNASH_REPORT_FUNCTION; -#if 0 - _qapp->closeAllWindows(); - _qapp->quit(); - #endif - - exit(0); + _godfather->quit(); } /// \brief Start the movie playing from the current frame. @@ -346,14 +339,14 @@ void qwidget::mouseMoveEvent(QMouseEvent *event) { - GNASH_REPORT_FUNCTION; +// GNASH_REPORT_FUNCTION; assert(_godfather); QPoint position = event->pos(); - float xscale = _godfather->getXScale(); - float yscale = _godfather->getYScale(); + int newX = static_cast<int> (position.x() / _godfather->getXScale()); + int newY = static_cast<int> (position.y() / _godfather->getYScale()); - _godfather->notify_mouse_moved(position.x() / xscale, position.y() / yscale); + _godfather->notify_mouse_moved(newX, newY); } qwidget::qwidget(KdeGui* godfather) @@ -394,13 +387,13 @@ } void -qwidget::mousePressEvent(QMouseEvent *event) +qwidget::mousePressEvent(QMouseEvent* /* event */) { _godfather->notify_mouse_clicked(true, 1); } void -qwidget::mouseReleaseEvent(QMouseEvent *event) +qwidget::mouseReleaseEvent(QMouseEvent* /* event */) { _godfather->notify_mouse_clicked(false, 1); } @@ -429,10 +422,12 @@ const QRegion& region = event->region(); QRect rect = region.boundingRect(); - geometry::Range2d<int> range(PIXELS_TO_TWIPS(rect.x()-1), - PIXELS_TO_TWIPS(rect.y()-1), - PIXELS_TO_TWIPS(rect.right()+1), - PIXELS_TO_TWIPS(rect.bottom()+1)); + int xmin = static_cast<int> (PIXELS_TO_TWIPS(rect.x()-1)), + ymin = static_cast<int> (PIXELS_TO_TWIPS(rect.y()-1)), + xmax = static_cast<int> (PIXELS_TO_TWIPS(rect.right()+1)), + ymax = static_cast<int> (PIXELS_TO_TWIPS(rect.bottom()+1)); + + geometry::Range2d<int> range(xmin, ymin, xmax, ymax); InvalidatedRanges ranges; ranges.add(range); Index: gui/kde_glue_agg.cpp =================================================================== RCS file: /sources/gnash/gnash/gui/kde_glue_agg.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- gui/kde_glue_agg.cpp 9 Jun 2007 19:42:05 -0000 1.1 +++ gui/kde_glue_agg.cpp 10 Jun 2007 14:46:44 -0000 1.2 @@ -15,7 +15,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -/* $Id: kde_glue_agg.cpp,v 1.1 2007/06/09 19:42:05 bjacques Exp $ */ +/* $Id: kde_glue_agg.cpp,v 1.2 2007/06/10 14:46:44 bjacques Exp $ */ #include "kde_glue_agg.h" #include "render_handler.h" @@ -27,8 +27,7 @@ { KdeAggGlue::KdeAggGlue() -: _offscreenbuf(NULL), - _renderer(NULL), +: _renderer(NULL), _width(0), _height(0) { @@ -69,14 +68,14 @@ int bufsize = (width * height * depth_bytes / CHUNK_SIZE + 1) * CHUNK_SIZE; - _offscreenbuf = new unsigned char[bufsize]; + _offscreenbuf.reset(new unsigned char[bufsize]); // Only the AGG renderer has the function init_buffer, which is *not* part of // the renderer api. It allows us to change the renderers movie size (and buffer // address) during run-time. render_handler_agg_base * renderer = static_cast<render_handler_agg_base *>(_renderer); - renderer->init_buffer(_offscreenbuf, bufsize, width, height); + renderer->init_buffer(_offscreenbuf.get(), bufsize, width, height); _width = width; _height = height; @@ -84,7 +83,7 @@ _validbounds.setTo(0, 0, _width, _height); _drawbounds.push_back(_validbounds); - _qimage.reset(new QImage(_offscreenbuf, _width, _height, 32 /* bits per pixel */, + _qimage.reset(new QImage(_offscreenbuf.get(), _width, _height, 32 /* bits per pixel */, 0 , 0, QImage::IgnoreEndian)); } @@ -145,12 +144,6 @@ void KdeAggGlue::resize(int width, int height) { - if (!_offscreenbuf) { - // If initialisation has not taken place yet, we don't want to touch this. - return; - } - - delete [] _offscreenbuf; initBuffer(width, height); } Index: gui/kde_glue_agg.h =================================================================== RCS file: /sources/gnash/gnash/gui/kde_glue_agg.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- gui/kde_glue_agg.h 9 Jun 2007 19:42:05 -0000 1.1 +++ gui/kde_glue_agg.h 10 Jun 2007 14:46:44 -0000 1.2 @@ -17,6 +17,7 @@ #include "kde_glue.h" #include <qimage.h> +#include <boost/scoped_array.hpp> namespace gnash @@ -39,8 +40,8 @@ private: int _width; int _height; - unsigned char* _offscreenbuf; - render_handler* _renderer; + boost::scoped_array<unsigned char> _offscreenbuf; + render_handler* _renderer; // We don't own this pointer. geometry::Range2d<int> _validbounds; std::vector< geometry::Range2d<int> > _drawbounds; std::auto_ptr<QImage> _qimage; Index: gui/kdesup.h =================================================================== RCS file: /sources/gnash/gnash/gui/kdesup.h,v retrieving revision 1.18 retrieving revision 1.19 diff -u -b -r1.18 -r1.19 --- gui/kdesup.h 9 Jun 2007 19:42:05 -0000 1.18 +++ gui/kdesup.h 10 Jun 2007 14:46:45 -0000 1.19 @@ -28,41 +28,22 @@ #include "tu_config.h" #include "gui.h" -#if 0 -#include <qobject.h> -#include <qgl.h> -#include <qwidget.h> - -#include <qtimer.h> -#include <qapplication.h> -#include <qeventloop.h> -#include <qlabel.h> -#include <qevent.h> -#include <qkeycode.h> - -#endif - #include <qapplication.h> #include <qpopupmenu.h> #ifdef RENDERER_OPENGL # include <qgl.h> # include "kde_glue_opengl.h" +# define WIDGETCLASS QGLWidget +# define GLUE KdeOpenGLGlue #elif defined(RENDERER_CAIRO) // #include <cairo.h> // #include "kde_glue_cairo.h" # error "Cairo not supported yet for KDE!" #elif defined(RENDERER_AGG) # include "kde_glue_agg.h" -#endif - - -#ifdef RENDERER_OPENGL -#define WIDGETCLASS QGLWidget -#define GLUE KdeOpenGLGlue -#else -#define WIDGETCLASS QWidget -#define GLUE KdeAggGlue +# define WIDGETCLASS QWidget +# define GLUE KdeAggGlue #endif @@ -121,13 +102,12 @@ virtual void handleKeyEvent(QKeyEvent *event, bool down); void setInvalidatedRegions(const InvalidatedRanges& ranges); void resize(int width, int height); + void quit(); private: - QApplication* _qapp; - qwidget* _qwidget; + std::auto_ptr<QApplication> _qapp; + std::auto_ptr<qwidget> _qwidget; GLUE _glue; - QTimer *_timer; - gnash::key::code qtToGnashKey(QKeyEvent *event); int qtToGnashModifier(Qt::ButtonState state); }; _______________________________________________ Gnash-commit mailing list Gnash-commit@gnu.org http://lists.gnu.org/mailman/listinfo/gnash-commit