diff options
author | Mathias Gumz <akira at fluxbox dot org> | 2010-05-16 12:25:36 (GMT) |
---|---|---|
committer | Mathias Gumz <akira at fluxbox dot org> | 2010-05-16 12:25:36 (GMT) |
commit | 17b21635a2c6abd20277dcd087a40785c5806abc (patch) | |
tree | 6f756a8578c9a8b2ce011e7fc7702b16104baa4e /src/FbTk/Shape.cc | |
parent | 04739b2d1f7ffcecb6f8398afdcc81e41921d1b4 (diff) | |
download | fluxbox-17b21635a2c6abd20277dcd087a40785c5806abc.zip fluxbox-17b21635a2c6abd20277dcd087a40785c5806abc.tar.bz2 |
cleanup created corner pixmaps, moved the initCorners() function out of the class
Diffstat (limited to 'src/FbTk/Shape.cc')
-rw-r--r-- | src/FbTk/Shape.cc | 53 |
1 files changed, 33 insertions, 20 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 { | |||
109 | // unfortunately, we need a separate pixmap per screen | 109 | // unfortunately, we need a separate pixmap per screen |
110 | std::vector<CornerPixmaps> s_corners; | 110 | std::vector<CornerPixmaps> s_corners; |
111 | 111 | ||
112 | unsigned long nr_shapes = 0; | ||
113 | |||
114 | void initCorners(FbWindow& win) { | ||
115 | |||
116 | if (s_corners.empty()) | ||
117 | s_corners.resize(ScreenCount(App::instance()->display())); | ||
118 | |||
119 | static const unsigned char left_bits[] = { 0xc0, 0xf8, 0xfc, 0xfe, 0xfe, 0xfe, 0xff, 0xff }; | ||
120 | static const unsigned char right_bits[] = { 0x03, 0x1f, 0x3f, 0x7f, 0x7f, 0x7f, 0xff, 0xff}; | ||
121 | static const unsigned char bottom_left_bits[] = { 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfc, 0xf8, 0xc0 }; | ||
122 | static const unsigned char bottom_right_bits[] = { 0xff, 0xff, 0x7f, 0x7f, 0x7f, 0x3f, 0x1f, 0x03 }; | ||
123 | |||
124 | const int screen_num = win.screenNumber(); | ||
125 | s_corners[screen_num].topleft = makePixmap(win, left_bits); | ||
126 | s_corners[screen_num].topright = makePixmap(win, right_bits); | ||
127 | s_corners[screen_num].botleft = makePixmap(win, bottom_left_bits); | ||
128 | s_corners[screen_num].botright = makePixmap(win, bottom_right_bits); | ||
129 | |||
130 | nr_shapes++; // refcounting | ||
131 | } | ||
132 | |||
133 | void cleanCorners() { | ||
134 | |||
135 | if (nr_shapes == 0) { | ||
136 | s_corners.clear(); | ||
137 | } else { | ||
138 | nr_shapes--; // refcounting | ||
139 | } | ||
140 | } | ||
141 | |||
112 | } // end of anonymous namespace | 142 | } // end of anonymous namespace |
113 | 143 | ||
114 | Shape::Shape(FbWindow &win, int shapeplaces): | 144 | Shape::Shape(FbWindow &win, int shapeplaces): |
@@ -119,7 +149,7 @@ Shape::Shape(FbWindow &win, int shapeplaces): | |||
119 | m_shapeplaces(shapeplaces) { | 149 | m_shapeplaces(shapeplaces) { |
120 | 150 | ||
121 | #ifdef SHAPE | 151 | #ifdef SHAPE |
122 | initCorners(win.screenNumber()); | 152 | initCorners(win); |
123 | #endif | 153 | #endif |
124 | 154 | ||
125 | update(); | 155 | update(); |
@@ -143,26 +173,9 @@ Shape::~Shape() { | |||
143 | 0, | 173 | 0, |
144 | ShapeSet); | 174 | ShapeSet); |
145 | } | 175 | } |
146 | #endif // SHAPE | ||
147 | } | ||
148 | |||
149 | void Shape::initCorners(int screen_num) { | ||
150 | if (!m_win->window()) | ||
151 | return; | ||
152 | |||
153 | if (s_corners.size() == 0) | ||
154 | s_corners.resize(ScreenCount(App::instance()->display())); | ||
155 | |||
156 | static const unsigned char left_bits[] = { 0xc0, 0xf8, 0xfc, 0xfe, 0xfe, 0xfe, 0xff, 0xff }; | ||
157 | static const unsigned char right_bits[] = { 0x03, 0x1f, 0x3f, 0x7f, 0x7f, 0x7f, 0xff, 0xff}; | ||
158 | static const unsigned char bottom_left_bits[] = { 0xff, 0xff, 0xfe, 0xfe, 0xfe, 0xfc, 0xf8, 0xc0 }; | ||
159 | static const unsigned char bottom_right_bits[] = { 0xff, 0xff, 0x7f, 0x7f, 0x7f, 0x3f, 0x1f, 0x03 }; | ||
160 | |||
161 | s_corners[screen_num].topleft = makePixmap(*m_win, left_bits); | ||
162 | s_corners[screen_num].topright = makePixmap(*m_win, right_bits); | ||
163 | s_corners[screen_num].botleft = makePixmap(*m_win, bottom_left_bits); | ||
164 | s_corners[screen_num].botright = makePixmap(*m_win, bottom_right_bits); | ||
165 | 176 | ||
177 | cleanCorners(); | ||
178 | #endif // SHAPE | ||
166 | } | 179 | } |
167 | 180 | ||
168 | void Shape::setPlaces(int shapeplaces) { | 181 | void Shape::setPlaces(int shapeplaces) { |