From 17b21635a2c6abd20277dcd087a40785c5806abc Mon Sep 17 00:00:00 2001 From: Mathias Gumz Date: Sun, 16 May 2010 14:25:36 +0200 Subject: cleanup created corner pixmaps, moved the initCorners() function out of the class --- src/FbTk/Shape.cc | 53 +++++++++++++++++++++++++++++++++-------------------- src/FbTk/Shape.hh | 3 --- 2 files changed, 33 insertions(+), 23 deletions(-) diff --git a/src/FbTk/Shape.cc b/src/FbTk/Shape.cc index c952403..91ecffc 100644 --- a/src/FbTk/Shape.cc +++ b/src/FbTk/Shape.cc @@ -109,6 +109,36 @@ struct CornerPixmaps { // unfortunately, we need a separate pixmap per screen std::vector s_corners; +unsigned long nr_shapes = 0; + +void initCorners(FbWindow& win) { + + if (s_corners.empty()) + s_corners.resize(ScreenCount(App::instance()->display())); + + static const unsigned char left_bits[] = { 0xc0, 0xf8, 0xfc, 0xfe, 0xfe, 0xfe, 0xff, 0xff }; + static const unsigned char right_bits[] = { 0x03, 0x1f, 0x3f, 0x7f, 0x7f, 0x7f, 0xff, 0xff}; + static const unsigned char bottom_left_bits[] = { 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfc, 0xf8, 0xc0 }; + static const unsigned char bottom_right_bits[] = { 0xff, 0xff, 0x7f, 0x7f, 0x7f, 0x3f, 0x1f, 0x03 }; + + const int screen_num = win.screenNumber(); + s_corners[screen_num].topleft = makePixmap(win, left_bits); + s_corners[screen_num].topright = makePixmap(win, right_bits); + s_corners[screen_num].botleft = makePixmap(win, bottom_left_bits); + s_corners[screen_num].botright = makePixmap(win, bottom_right_bits); + + nr_shapes++; // refcounting +} + +void cleanCorners() { + + if (nr_shapes == 0) { + s_corners.clear(); + } else { + nr_shapes--; // refcounting + } +} + } // end of anonymous namespace Shape::Shape(FbWindow &win, int shapeplaces): @@ -119,7 +149,7 @@ Shape::Shape(FbWindow &win, int shapeplaces): m_shapeplaces(shapeplaces) { #ifdef SHAPE - initCorners(win.screenNumber()); + initCorners(win); #endif update(); @@ -143,26 +173,9 @@ Shape::~Shape() { 0, ShapeSet); } -#endif // SHAPE -} - -void Shape::initCorners(int screen_num) { - if (!m_win->window()) - return; - - if (s_corners.size() == 0) - s_corners.resize(ScreenCount(App::instance()->display())); - - static const unsigned char left_bits[] = { 0xc0, 0xf8, 0xfc, 0xfe, 0xfe, 0xfe, 0xff, 0xff }; - static const unsigned char right_bits[] = { 0x03, 0x1f, 0x3f, 0x7f, 0x7f, 0x7f, 0xff, 0xff}; - static const unsigned char bottom_left_bits[] = { 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfc, 0xf8, 0xc0 }; - static const unsigned char bottom_right_bits[] = { 0xff, 0xff, 0x7f, 0x7f, 0x7f, 0x3f, 0x1f, 0x03 }; - - s_corners[screen_num].topleft = makePixmap(*m_win, left_bits); - s_corners[screen_num].topright = makePixmap(*m_win, right_bits); - s_corners[screen_num].botleft = makePixmap(*m_win, bottom_left_bits); - s_corners[screen_num].botright = makePixmap(*m_win, bottom_right_bits); + cleanCorners(); +#endif // SHAPE } void Shape::setPlaces(int shapeplaces) { diff --git a/src/FbTk/Shape.hh b/src/FbTk/Shape.hh index 49c1d3f..816470e 100644 --- a/src/FbTk/Shape.hh +++ b/src/FbTk/Shape.hh @@ -63,9 +63,6 @@ private: FbWindow *m_shapesource; ///< window to pull shape from int m_shapesource_xoff, m_shapesource_yoff; - void initCorners(int screen_num); - - int m_shapeplaces; ///< places to shape }; -- cgit v0.11.2