From 08f6ca0514de8e24fb98e6a8b057598fc70ebd64 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Fri, 9 Jan 2004 01:19:48 +0000 Subject: save some memory --- src/FbTk/GContext.cc | 20 +++++++++++++------- src/FbTk/GContext.hh | 4 ++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/FbTk/GContext.cc b/src/FbTk/GContext.cc index e0f66a4..dae8fac 100644 --- a/src/FbTk/GContext.cc +++ b/src/FbTk/GContext.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: GContext.cc,v 1.5 2003/11/28 22:50:55 fluxgen Exp $ +// $Id: GContext.cc,v 1.6 2004/01/09 01:19:48 fluxgen Exp $ #include "GContext.hh" @@ -31,27 +31,33 @@ namespace FbTk { +Display *GContext::m_display = 0; + GContext::GContext(const FbTk::FbDrawable &drawable): - m_display(FbTk::App::instance()->display()), - m_gc(XCreateGC(m_display, + m_gc(XCreateGC(m_display != 0 ? m_display : FbTk::App::instance()->display(), drawable.drawable(), 0, 0)) { + if (m_display == 0) + m_display = FbTk::App::instance()->display(); + setGraphicsExposure(false); } GContext::GContext(Drawable drawable): - m_display(FbTk::App::instance()->display()), - m_gc(XCreateGC(m_display, + m_gc(XCreateGC(m_display != 0 ? m_display : FbTk::App::instance()->display(), drawable, 0, 0)) { + if (m_display == 0) + m_display = FbTk::App::instance()->display(); setGraphicsExposure(false); } GContext::GContext(Drawable d, const GContext &gc): - m_display(FbTk::App::instance()->display()), - m_gc(XCreateGC(m_display, + m_gc(XCreateGC(m_display != 0 ? m_display : FbTk::App::instance()->display(), d, 0, 0)) { + if (m_display == 0) + m_display = FbTk::App::instance()->display(); setGraphicsExposure(false); copy(gc); } diff --git a/src/FbTk/GContext.hh b/src/FbTk/GContext.hh index 94aec3e..462ea32 100644 --- a/src/FbTk/GContext.hh +++ b/src/FbTk/GContext.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: GContext.hh,v 1.6 2003/12/16 17:06:51 fluxgen Exp $ +// $Id: GContext.hh,v 1.7 2004/01/09 01:19:48 fluxgen Exp $ #ifndef FBTK_GCONTEXT_HH #define FBTK_GCONTEXT_HH @@ -98,7 +98,7 @@ public: private: GContext(const GContext &cont); - Display *m_display; // worth caching + static Display *m_display; // worth caching GC m_gc; }; -- cgit v0.11.2