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 | |
parent | 04739b2d1f7ffcecb6f8398afdcc81e41921d1b4 (diff) | |
download | fluxbox_pavel-17b21635a2c6abd20277dcd087a40785c5806abc.zip fluxbox_pavel-17b21635a2c6abd20277dcd087a40785c5806abc.tar.bz2 |
cleanup created corner pixmaps, moved the initCorners() function out of the class
-rw-r--r-- | src/FbTk/Shape.cc | 53 | ||||
-rw-r--r-- | 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 { | |||
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) { |
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: | |||
63 | FbWindow *m_shapesource; ///< window to pull shape from | 63 | FbWindow *m_shapesource; ///< window to pull shape from |
64 | int m_shapesource_xoff, m_shapesource_yoff; | 64 | int m_shapesource_xoff, m_shapesource_yoff; |
65 | 65 | ||
66 | void initCorners(int screen_num); | ||
67 | |||
68 | |||
69 | int m_shapeplaces; ///< places to shape | 66 | int m_shapeplaces; ///< places to shape |
70 | }; | 67 | }; |
71 | 68 | ||