diff options
author | rathnor <rathnor> | 2004-09-12 14:56:20 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2004-09-12 14:56:20 (GMT) |
commit | 42c1fd3ae3dd058e146b7350c65b74386123c25c (patch) | |
tree | cc549c2c7b12c87f8c33198f5b30f00d9dd30bc6 /src/FbTk | |
parent | c39234195a46cece2bdb18dfdde6c91c7a190dc4 (diff) | |
download | fluxbox_paul-42c1fd3ae3dd058e146b7350c65b74386123c25c.zip fluxbox_paul-42c1fd3ae3dd058e146b7350c65b74386123c25c.tar.bz2 |
preliminary support for composite/compositing manager. Also general work
for consistency with transparency resources
Diffstat (limited to 'src/FbTk')
-rw-r--r-- | src/FbTk/FbWindow.cc | 24 | ||||
-rw-r--r-- | src/FbTk/FbWindow.hh | 5 | ||||
-rw-r--r-- | src/FbTk/Menu.cc | 11 | ||||
-rw-r--r-- | src/FbTk/Transparent.cc | 68 | ||||
-rw-r--r-- | src/FbTk/Transparent.hh | 9 |
5 files changed, 91 insertions, 26 deletions
diff --git a/src/FbTk/FbWindow.cc b/src/FbTk/FbWindow.cc index 2e69339..7e6c863 100644 --- a/src/FbTk/FbWindow.cc +++ b/src/FbTk/FbWindow.cc | |||
@@ -19,7 +19,7 @@ | |||
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: FbWindow.cc,v 1.42 2004/09/11 22:59:15 fluxgen Exp $ | 22 | // $Id: FbWindow.cc,v 1.43 2004/09/12 14:56:19 rathnor Exp $ |
23 | 23 | ||
24 | #include "FbWindow.hh" | 24 | #include "FbWindow.hh" |
25 | #include "FbPixmap.hh" | 25 | #include "FbPixmap.hh" |
@@ -161,6 +161,9 @@ void FbWindow::clearArea(int x, int y, | |||
161 | 161 | ||
162 | void FbWindow::updateTransparent(int the_x, int the_y, unsigned int the_width, unsigned int the_height) { | 162 | void FbWindow::updateTransparent(int the_x, int the_y, unsigned int the_width, unsigned int the_height) { |
163 | #ifdef HAVE_XRENDER | 163 | #ifdef HAVE_XRENDER |
164 | if (!m_transparent.get()) | ||
165 | return; | ||
166 | |||
164 | if (width() == 0 || height() == 0) | 167 | if (width() == 0 || height() == 0) |
165 | return; | 168 | return; |
166 | 169 | ||
@@ -174,9 +177,6 @@ void FbWindow::updateTransparent(int the_x, int the_y, unsigned int the_width, u | |||
174 | the_y = 0; | 177 | the_y = 0; |
175 | } | 178 | } |
176 | 179 | ||
177 | if (!m_transparent.get()) | ||
178 | return; | ||
179 | |||
180 | // update source and destination if needed | 180 | // update source and destination if needed |
181 | Pixmap root = FbPixmap::getRootPixmap(screenNumber()); | 181 | Pixmap root = FbPixmap::getRootPixmap(screenNumber()); |
182 | if (m_transparent->source() != root) | 182 | if (m_transparent->source() != root) |
@@ -215,7 +215,13 @@ void FbWindow::updateTransparent(int the_x, int the_y, unsigned int the_width, u | |||
215 | 215 | ||
216 | void FbWindow::setAlpha(unsigned char alpha) { | 216 | void FbWindow::setAlpha(unsigned char alpha) { |
217 | #ifdef HAVE_XRENDER | 217 | #ifdef HAVE_XRENDER |
218 | if (m_transparent.get() == 0 && alpha < 255) { | 218 | if (FbTk::Transparent::haveComposite()) { |
219 | if (m_transparent.get() != 0) | ||
220 | m_transparent.reset(0); | ||
221 | |||
222 | // don't setOpaque, let controlling objects do that | ||
223 | // since it's only needed on toplevel windows | ||
224 | } else if (m_transparent.get() == 0 && alpha < 255) { | ||
219 | m_transparent.reset(new Transparent(FbPixmap::getRootPixmap(screenNumber()), window(), alpha, screenNumber())); | 225 | m_transparent.reset(new Transparent(FbPixmap::getRootPixmap(screenNumber()), window(), alpha, screenNumber())); |
220 | } else if (alpha < 255 && alpha != m_transparent->alpha()) | 226 | } else if (alpha < 255 && alpha != m_transparent->alpha()) |
221 | m_transparent->setAlpha(alpha); | 227 | m_transparent->setAlpha(alpha); |
@@ -395,6 +401,14 @@ long FbWindow::eventMask() const { | |||
395 | 401 | ||
396 | } | 402 | } |
397 | 403 | ||
404 | void FbWindow::setOpaque(unsigned char alpha) { | ||
405 | #ifdef HAVE_XRENDER | ||
406 | static Atom m_alphaatom = XInternAtom(display(), "_NET_WM_WINDOW_OPACITY", False); | ||
407 | unsigned int opacity = alpha << 24; | ||
408 | changeProperty(m_alphaatom, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &opacity, 1l); | ||
409 | #endif // HAVE_XRENDER | ||
410 | } | ||
411 | |||
398 | void FbWindow::setBufferPixmap(Pixmap pm) { | 412 | void FbWindow::setBufferPixmap(Pixmap pm) { |
399 | m_buffer_pm = pm; | 413 | m_buffer_pm = pm; |
400 | } | 414 | } |
diff --git a/src/FbTk/FbWindow.hh b/src/FbTk/FbWindow.hh index c39b8c1..d408216 100644 --- a/src/FbTk/FbWindow.hh +++ b/src/FbTk/FbWindow.hh | |||
@@ -19,7 +19,7 @@ | |||
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: FbWindow.hh,v 1.34 2004/09/11 12:33:14 rathnor Exp $ | 22 | // $Id: FbWindow.hh,v 1.35 2004/09/12 14:56:19 rathnor Exp $ |
23 | 23 | ||
24 | #ifndef FBTK_FBWINDOW_HH | 24 | #ifndef FBTK_FBWINDOW_HH |
25 | #define FBTK_FBWINDOW_HH | 25 | #define FBTK_FBWINDOW_HH |
@@ -163,6 +163,9 @@ public: | |||
163 | inline bool operator == (const FbWindow &win) const { return m_window == win.m_window; } | 163 | inline bool operator == (const FbWindow &win) const { return m_window == win.m_window; } |
164 | inline bool operator != (const FbWindow &win) const { return m_window != win.m_window; } | 164 | inline bool operator != (const FbWindow &win) const { return m_window != win.m_window; } |
165 | 165 | ||
166 | // used for composite | ||
167 | void setOpaque(unsigned char alpha); | ||
168 | |||
166 | protected: | 169 | protected: |
167 | /// creates a window with x window client (m_window = client) | 170 | /// creates a window with x window client (m_window = client) |
168 | explicit FbWindow(Window client); | 171 | explicit FbWindow(Window client); |
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 5cfb1d1..b1e186d 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: Menu.cc,v 1.84 2004/09/11 22:59:15 fluxgen Exp $ | 25 | // $Id: Menu.cc,v 1.85 2004/09/12 14:56:19 rathnor Exp $ |
26 | 26 | ||
27 | //use GNU extensions | 27 | //use GNU extensions |
28 | #ifndef _GNU_SOURCE | 28 | #ifndef _GNU_SOURCE |
@@ -1379,10 +1379,14 @@ void Menu::keyPressEvent(XKeyEvent &event) { | |||
1379 | 1379 | ||
1380 | void Menu::reconfigure() { | 1380 | void Menu::reconfigure() { |
1381 | 1381 | ||
1382 | if (alpha() == 255 && m_transp.get() != 0) { | 1382 | if (FbTk::Transparent::haveComposite()) { |
1383 | if (m_transp.get() != 0) | ||
1384 | m_transp.reset(0); | ||
1385 | |||
1386 | menu.window.setOpaque(alpha()); | ||
1387 | } else if (alpha() == 255 && m_transp.get() != 0) { | ||
1383 | m_transp.reset(0); | 1388 | m_transp.reset(0); |
1384 | } else if (alpha () < 255) { | 1389 | } else if (alpha () < 255) { |
1385 | |||
1386 | if (m_transp.get() == 0) { | 1390 | if (m_transp.get() == 0) { |
1387 | m_transp.reset(new Transparent(FbPixmap::getRootPixmap(screenNumber()), | 1391 | m_transp.reset(new Transparent(FbPixmap::getRootPixmap(screenNumber()), |
1388 | m_real_frame_pm.drawable(), alpha(), | 1392 | m_real_frame_pm.drawable(), alpha(), |
@@ -1484,7 +1488,6 @@ void Menu::renderTransp(int x, int y, | |||
1484 | if (m_transp->source() != root) | 1488 | if (m_transp->source() != root) |
1485 | m_transp->setSource(root, screenNumber()); | 1489 | m_transp->setSource(root, screenNumber()); |
1486 | 1490 | ||
1487 | |||
1488 | if (m_transp->dest() != m_real_frame_pm.drawable()) | 1491 | if (m_transp->dest() != m_real_frame_pm.drawable()) |
1489 | m_transp->setDest(m_real_frame_pm.drawable(), screenNumber()); | 1492 | m_transp->setDest(m_real_frame_pm.drawable(), screenNumber()); |
1490 | 1493 | ||
diff --git a/src/FbTk/Transparent.cc b/src/FbTk/Transparent.cc index b6521b9..f8ca2a8 100644 --- a/src/FbTk/Transparent.cc +++ b/src/FbTk/Transparent.cc | |||
@@ -19,7 +19,7 @@ | |||
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: Transparent.cc,v 1.8 2004/09/11 15:52:23 rathnor Exp $ | 22 | // $Id: Transparent.cc,v 1.9 2004/09/12 14:56:20 rathnor Exp $ |
23 | 23 | ||
24 | #include "Transparent.hh" | 24 | #include "Transparent.hh" |
25 | #include "App.hh" | 25 | #include "App.hh" |
@@ -99,26 +99,67 @@ namespace FbTk { | |||
99 | 99 | ||
100 | bool Transparent::s_init = false; | 100 | bool Transparent::s_init = false; |
101 | bool Transparent::s_render = false; | 101 | bool Transparent::s_render = false; |
102 | bool Transparent::s_composite = false; | ||
102 | 103 | ||
103 | Transparent::Transparent(Drawable src, Drawable dest, unsigned char alpha, int screen_num): | 104 | void Transparent::init() { |
104 | m_alpha_pic(0), m_src_pic(0), m_dest_pic(0), | ||
105 | m_source(src), m_dest(dest), m_alpha(alpha) { | ||
106 | |||
107 | Display *disp = FbTk::App::instance()->display(); | 105 | Display *disp = FbTk::App::instance()->display(); |
108 | 106 | ||
109 | // check for RENDER support | 107 | int major_opcode, first_event, first_error; |
110 | if (!s_init) { | 108 | if (XQueryExtension(disp, "RENDER", |
111 | int major_opcode, first_event, first_error; | 109 | &major_opcode, |
112 | if (XQueryExtension(disp, "RENDER", | 110 | &first_event, &first_error) == False) { |
111 | s_render = false; | ||
112 | s_composite = false; | ||
113 | } else { // we have RENDER support | ||
114 | s_render = true; | ||
115 | |||
116 | if (XQueryExtension(disp, "Composite", | ||
113 | &major_opcode, | 117 | &major_opcode, |
114 | &first_event, &first_error) == False) { | 118 | &first_event, &first_error) == False) { |
115 | s_render = false; | 119 | s_composite = false; |
116 | } else { // we got RENDER support | 120 | } else { // we have Composite support |
117 | s_render = true; | 121 | s_composite = true; |
118 | } | 122 | } |
119 | s_init = true; | ||
120 | } | 123 | } |
124 | s_init = true; | ||
125 | } | ||
121 | 126 | ||
127 | void Transparent::usePseudoTransparent(bool no_composite) { | ||
128 | if (s_composite != no_composite) | ||
129 | return; | ||
130 | |||
131 | s_init = false; | ||
132 | init(); // only use render if we have it | ||
133 | |||
134 | if (no_composite) | ||
135 | s_composite = false; | ||
136 | } | ||
137 | |||
138 | bool Transparent::haveComposite(bool for_real) { | ||
139 | if (for_real) { | ||
140 | Display *disp = FbTk::App::instance()->display(); | ||
141 | int major_opcode, first_event, first_error; | ||
142 | |||
143 | return (XQueryExtension(disp, "Composite", | ||
144 | &major_opcode, | ||
145 | &first_event, &first_error) == True); | ||
146 | } else { | ||
147 | if (!s_init) | ||
148 | init(); | ||
149 | |||
150 | return s_composite; | ||
151 | } | ||
152 | } | ||
153 | |||
154 | Transparent::Transparent(Drawable src, Drawable dest, unsigned char alpha, int screen_num): | ||
155 | m_alpha_pic(0), m_src_pic(0), m_dest_pic(0), | ||
156 | m_source(src), m_dest(dest), m_alpha(alpha) { | ||
157 | |||
158 | Display *disp = FbTk::App::instance()->display(); | ||
159 | |||
160 | // check for Extension support | ||
161 | if (!s_init) | ||
162 | init(); | ||
122 | 163 | ||
123 | #ifdef HAVE_XRENDER | 164 | #ifdef HAVE_XRENDER |
124 | if (!s_render) | 165 | if (!s_render) |
@@ -126,7 +167,6 @@ Transparent::Transparent(Drawable src, Drawable dest, unsigned char alpha, int s | |||
126 | 167 | ||
127 | allocAlpha(m_alpha); | 168 | allocAlpha(m_alpha); |
128 | 169 | ||
129 | |||
130 | XRenderPictFormat *format = | 170 | XRenderPictFormat *format = |
131 | XRenderFindVisualFormat(disp, | 171 | XRenderFindVisualFormat(disp, |
132 | DefaultVisual(disp, screen_num)); | 172 | DefaultVisual(disp, screen_num)); |
diff --git a/src/FbTk/Transparent.hh b/src/FbTk/Transparent.hh index fe29826..9aeeead 100644 --- a/src/FbTk/Transparent.hh +++ b/src/FbTk/Transparent.hh | |||
@@ -19,7 +19,7 @@ | |||
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: Transparent.hh,v 1.3 2003/05/13 21:16:27 fluxgen Exp $ | 22 | // $Id: Transparent.hh,v 1.4 2004/09/12 14:56:20 rathnor Exp $ |
23 | 23 | ||
24 | #ifndef FBTK_TRANSPARENT_HH | 24 | #ifndef FBTK_TRANSPARENT_HH |
25 | #define FBTK_TRANSPARENT_HH | 25 | #define FBTK_TRANSPARENT_HH |
@@ -50,6 +50,10 @@ public: | |||
50 | Drawable dest() const { return m_dest; } | 50 | Drawable dest() const { return m_dest; } |
51 | Drawable source() const { return m_source; } | 51 | Drawable source() const { return m_source; } |
52 | 52 | ||
53 | static bool haveComposite(bool for_real = false); | ||
54 | static bool haveRender() { if (!s_init) init(); return s_render; } | ||
55 | static void usePseudoTransparent(bool no_composite); | ||
56 | |||
53 | private: | 57 | private: |
54 | void freeAlpha(); | 58 | void freeAlpha(); |
55 | void allocAlpha(unsigned char newval); | 59 | void allocAlpha(unsigned char newval); |
@@ -61,7 +65,8 @@ private: | |||
61 | 65 | ||
62 | static bool s_init; | 66 | static bool s_init; |
63 | static bool s_render; ///< wheter we have RENDER support | 67 | static bool s_render; ///< wheter we have RENDER support |
64 | 68 | static bool s_composite; ///< wheter we have Composite support | |
69 | static void init(); | ||
65 | }; | 70 | }; |
66 | 71 | ||
67 | }; // end namespace FbTk | 72 | }; // end namespace FbTk |