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 | |
parent | d75cb35327a2b82e0a1e8e4bf9a72b4996a0a3c8 (diff) | |
download | fluxbox-fabfc410029cfd606729dfd118e50dc336abf010.zip fluxbox-fabfc410029cfd606729dfd118e50dc336abf010.tar.bz2 |
use FbPixmap
-rw-r--r-- | src/Shape.cc | 48 | ||||
-rw-r--r-- | src/Shape.hh | 10 |
2 files changed, 31 insertions, 27 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 | } | ||
diff --git a/src/Shape.hh b/src/Shape.hh index 0bc037f..53faaaa 100644 --- a/src/Shape.hh +++ b/src/Shape.hh | |||
@@ -19,15 +19,17 @@ | |||
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.hh,v 1.3 2003/12/16 23:32:02 fluxgen Exp $ | 22 | // $Id: Shape.hh,v 1.4 2004/01/11 15:02:11 fluxgen Exp $ |
23 | 23 | ||
24 | #ifndef SHAPE_HH | 24 | #ifndef SHAPE_HH |
25 | #define SHAPE_HH | 25 | #define SHAPE_HH |
26 | 26 | ||
27 | #include <X11/Xlib.h> | 27 | #include <X11/Xlib.h> |
28 | #include <memory> | ||
28 | 29 | ||
29 | namespace FbTk { | 30 | namespace FbTk { |
30 | class FbWindow; | 31 | class FbWindow; |
32 | class FbPixmap; | ||
31 | } | 33 | } |
32 | 34 | ||
33 | /// creates round corners on windows | 35 | /// creates round corners on windows |
@@ -49,16 +51,16 @@ public: | |||
49 | void update(); | 51 | void update(); |
50 | /// assign a new window | 52 | /// assign a new window |
51 | void setWindow(FbTk::FbWindow &win); | 53 | void setWindow(FbTk::FbWindow &win); |
54 | unsigned int width() const; | ||
55 | unsigned int height() const; | ||
52 | // sets shape notify mask | 56 | // sets shape notify mask |
53 | static void setShapeNotify(const FbTk::FbWindow &win); | 57 | static void setShapeNotify(const FbTk::FbWindow &win); |
54 | /// @return true if window has shape | 58 | /// @return true if window has shape |
55 | static bool isShaped(const FbTk::FbWindow &win); | 59 | static bool isShaped(const FbTk::FbWindow &win); |
56 | private: | 60 | private: |
57 | FbTk::FbWindow *m_win; ///< window to be shaped | 61 | FbTk::FbWindow *m_win; ///< window to be shaped |
58 | Pixmap m_shape; ///< our shape pixmap | 62 | std::auto_ptr<FbTk::FbPixmap> m_shape; ///< our shape pixmap |
59 | int m_shapeplaces; ///< places to shape | 63 | int m_shapeplaces; ///< places to shape |
60 | unsigned int m_width; ///< width of window (the "old" size), if width != window width then shape resizes | ||
61 | unsigned int m_height; ///< height of window (the "old" size), if height != window height then shape resizes | ||
62 | }; | 64 | }; |
63 | 65 | ||
64 | #endif // SHAPE_HH | 66 | #endif // SHAPE_HH |