diff options
author | fluxgen <fluxgen> | 2004-01-11 15:02:11 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2004-01-11 15:02:11 (GMT) |
commit | fabfc410029cfd606729dfd118e50dc336abf010 (patch) | |
tree | 83e35e1a66843f8e277b80b5b85dcd4ea0a05865 /src/Shape.cc | |
parent | d75cb35327a2b82e0a1e8e4bf9a72b4996a0a3c8 (diff) | |
download | fluxbox-fabfc410029cfd606729dfd118e50dc336abf010.zip fluxbox-fabfc410029cfd606729dfd118e50dc336abf010.tar.bz2 |
use FbPixmap
Diffstat (limited to 'src/Shape.cc')
-rw-r--r-- | src/Shape.cc | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/src/Shape.cc b/src/Shape.cc index 76cac96..de03ab2 100644 --- a/src/Shape.cc +++ b/src/Shape.cc | |||
@@ -19,12 +19,14 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // $Id: Shape.cc,v 1.8 2004/01/09 02:17:46 fluxgen Exp $ | 22 | // $Id: Shape.cc,v 1.9 2004/01/11 15:02:11 fluxgen Exp $ |
23 | 23 | ||
24 | #include "Shape.hh" | 24 | #include "Shape.hh" |
25 | |||
25 | #include "FbTk/FbWindow.hh" | 26 | #include "FbTk/FbWindow.hh" |
26 | #include "FbTk/App.hh" | 27 | #include "FbTk/App.hh" |
27 | #include "FbTk/GContext.hh" | 28 | #include "FbTk/GContext.hh" |
29 | #include "FbTk/FbPixmap.hh" | ||
28 | 30 | ||
29 | #include <cstring> | 31 | #include <cstring> |
30 | 32 | ||
@@ -39,7 +41,7 @@ using namespace std; | |||
39 | 41 | ||
40 | namespace { | 42 | namespace { |
41 | 43 | ||
42 | Pixmap createShape(FbTk::FbWindow &win, int place) { | 44 | FbTk::FbPixmap *createShape(FbTk::FbWindow &win, int place) { |
43 | if (win.window() == 0 || place == 0 || | 45 | if (win.window() == 0 || place == 0 || |
44 | win.width() < 3 || win.height() < 3) | 46 | win.width() < 3 || win.height() < 3) |
45 | return 0; | 47 | return 0; |
@@ -111,39 +113,34 @@ Pixmap createShape(FbTk::FbWindow &win, int place) { | |||
111 | } | 113 | } |
112 | } | 114 | } |
113 | 115 | ||
114 | Pixmap pm = XCreatePixmap(disp, win.window(), win_width, win_height, 1); | 116 | FbTk::FbPixmap *pm = new FbTk::FbPixmap(win, win_width, win_height, 1); |
117 | |||
115 | 118 | ||
116 | FbTk::GContext gc(pm); | 119 | FbTk::GContext gc(*pm); |
117 | 120 | ||
118 | XPutImage(disp, pm, gc.gc(), ximage, 0, 0, 0, 0, | 121 | XPutImage(disp, pm->drawable(), gc.gc(), ximage, 0, 0, 0, 0, |
119 | win_width, win_height); | 122 | win_width, win_height); |
120 | 123 | ||
121 | XDestroyImage(ximage); | 124 | XDestroyImage(ximage); |
122 | 125 | ||
123 | return pm; | 126 | return pm; |
124 | 127 | ||
125 | |||
126 | } | 128 | } |
127 | 129 | ||
128 | }; // end anonymous namespace | 130 | } // end anonymous namespace |
129 | 131 | ||
130 | Shape::Shape(FbTk::FbWindow &win, int shapeplaces): | 132 | Shape::Shape(FbTk::FbWindow &win, int shapeplaces): |
131 | m_win(&win), | 133 | m_win(&win), |
132 | m_shapeplaces(shapeplaces) { | 134 | m_shapeplaces(shapeplaces) { |
133 | 135 | ||
134 | m_shape = createShape(win, shapeplaces); | 136 | m_shape.reset(createShape(win, shapeplaces)); |
135 | m_width = win.width(); | ||
136 | m_height = win.height(); | ||
137 | |||
138 | } | 137 | } |
139 | 138 | ||
140 | Shape::~Shape() { | 139 | Shape::~Shape() { |
141 | if (m_shape != 0) | ||
142 | XFreePixmap(FbTk::App::instance()->display(), m_shape); | ||
143 | 140 | ||
144 | #ifdef SHAPE | 141 | #ifdef SHAPE |
145 | if (m_win != 0 && m_win->window()) { | 142 | if (m_win != 0 && m_win->window()) { |
146 | // reset shape of window | 143 | // Reset shape of window |
147 | XShapeCombineMask(FbTk::App::instance()->display(), | 144 | XShapeCombineMask(FbTk::App::instance()->display(), |
148 | m_win->window(), | 145 | m_win->window(), |
149 | ShapeBounding, | 146 | ShapeBounding, |
@@ -162,14 +159,10 @@ void Shape::update() { | |||
162 | if (m_win == 0 || m_win->window() == 0) | 159 | if (m_win == 0 || m_win->window() == 0) |
163 | return; | 160 | return; |
164 | #ifdef SHAPE | 161 | #ifdef SHAPE |
165 | if (m_win->width() != m_width || | 162 | if (m_shape.get() == 0 || |
166 | m_win->height() != m_height) { | 163 | m_win->width() != width() || |
167 | if (m_shape != 0) | 164 | m_win->height() != height()) { |
168 | XFreePixmap(FbTk::App::instance()->display(), m_shape); | 165 | m_shape.reset(createShape(*m_win, m_shapeplaces)); |
169 | m_shape = createShape(*m_win, m_shapeplaces); | ||
170 | m_width = m_win->width(); | ||
171 | m_height = m_win->height(); | ||
172 | |||
173 | } | 166 | } |
174 | 167 | ||
175 | // the m_shape can be = 0 which will just reset the shape mask | 168 | // the m_shape can be = 0 which will just reset the shape mask |
@@ -178,9 +171,10 @@ void Shape::update() { | |||
178 | m_win->window(), | 171 | m_win->window(), |
179 | ShapeBounding, | 172 | ShapeBounding, |
180 | -m_win->borderWidth(), -m_win->borderWidth(), | 173 | -m_win->borderWidth(), -m_win->borderWidth(), |
181 | m_shape, | 174 | m_shape.get() ? m_shape->drawable() : 0, |
182 | ShapeSet); | 175 | ShapeSet); |
183 | 176 | ||
177 | |||
184 | #endif // SHAPE | 178 | #endif // SHAPE |
185 | 179 | ||
186 | } | 180 | } |
@@ -215,3 +209,11 @@ bool Shape::isShaped(const FbTk::FbWindow &win) { | |||
215 | 209 | ||
216 | return (shaped != 0 ? true : false); | 210 | return (shaped != 0 ? true : false); |
217 | } | 211 | } |
212 | |||
213 | unsigned int Shape::width() const { | ||
214 | return m_shape.get() ? m_shape->width() : 0; | ||
215 | } | ||
216 | |||
217 | unsigned int Shape::height() const { | ||
218 | return m_shape.get() ? m_shape->height() : 0; | ||
219 | } | ||