all repos — fluxbox @ 42c1fd3ae3dd058e146b7350c65b74386123c25c

custom fork of the fluxbox windowmanager

preliminary support for composite/compositing manager. Also general work
for consistency with transparency resources
rathnor rathnor
commit

42c1fd3ae3dd058e146b7350c65b74386123c25c

parent

c39234195a46cece2bdb18dfdde6c91c7a190dc4

M ChangeLogChangeLog

@@ -1,6 +1,24 @@

(Format: Year/Month/Day) Changes for 0.9.11 *04/09/12: + * Preliminary support for Composite extension (Simon) + - Relies on external compositing manager using _NET_WM_WINDOW_OPACITY + - NOTE: Also make alpha resource setting more consistent. + Alpha values are no longer in theme, but are in init file. Possible + values are (all beginning with session.screenN.), * means changed/new: + - menu.alpha (*) + - slit.alpha + - window.focus.alpha (*) + - window.unfocus.alpha (*) + - toolbar.alpha (*) + - Changed menu around a bit. If you don't have/want a compositing + manager, but Composite is enabled, you can override it by setting + session.forcePseudoTransparency: true + - Fix a couple of bugs with transparency in toolbar/buttons + fluxbox.hh/cc Screen.hh/cc FbWinFrame.hh/cc FbWinFrameTheme.hh/cc + Slit.hh/cc Toolbar.hh/cc ToolbarTheme.hh/cc ToolbarItem.hh + ToolFactory.cc *Tool.hh/cc ArrowButton.cc FbTk/FbWindow.hh/cc + FbTk/Transparent.hh/cc FbTk/Menu.cc * Minor cleaning, moved Resource<> from fluxbox.cc to Resources.cc (Henrik) *04/09/11: * The include directive in menu can now take
M src/ArrowButton.ccsrc/ArrowButton.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ArrowButton.cc,v 1.8 2004/08/26 15:09:33 rathnor Exp $ +// $Id: ArrowButton.cc,v 1.9 2004/09/12 14:56:18 rathnor Exp $ #include "ArrowButton.hh" #include "ButtonTheme.hh"

@@ -52,11 +52,13 @@ }

void ArrowButton::clear() { FbTk::Button::clear(); + updateTransparent(); drawArrow(); } void ArrowButton::exposeEvent(XExposeEvent &event) { FbTk::Button::exposeEvent(event); + updateTransparent(event.x, event.y, event.width, event.height); drawArrow(); }
M src/ButtonTool.ccsrc/ButtonTool.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ButtonTool.cc,v 1.5 2004/08/29 08:33:12 rathnor Exp $ +// $Id: ButtonTool.cc,v 1.6 2004/09/12 14:56:18 rathnor Exp $ #include "ButtonTool.hh"

@@ -36,7 +36,6 @@ m_cache_pm(0),

m_cache_pressed_pm(0), m_image_ctrl(img_ctrl) { - renderTheme(); } ButtonTool::~ButtonTool() {

@@ -53,13 +52,13 @@ FbTk::Button &btn = static_cast<FbTk::Button &>(window());

btn.setBorderWidth(theme().border().width()); } -void ButtonTool::renderTheme() { +void ButtonTool::renderTheme(unsigned char alpha) { FbTk::Button &btn = static_cast<FbTk::Button &>(window()); btn.setGC(static_cast<const ButtonTheme &>(theme()).gc()); btn.setBorderColor(theme().border().color()); btn.setBorderWidth(theme().border().width()); - btn.setAlpha(theme().alpha()); + btn.setAlpha(alpha); btn.updateTheme(static_cast<const FbTk::Theme &>(theme())); Pixmap old_pm = m_cache_pm;
M src/ButtonTool.hhsrc/ButtonTool.hh

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ButtonTool.hh,v 1.2 2004/08/29 08:33:12 rathnor Exp $ +// $Id: ButtonTool.hh,v 1.3 2004/09/12 14:56:18 rathnor Exp $ #ifndef BUTTONTOOL_HH #define BUTTONTOOL_HH

@@ -41,7 +41,7 @@ ButtonTheme &theme, FbTk::ImageControl &img_ctrl);

virtual ~ButtonTool(); protected: - void renderTheme(); + void renderTheme(unsigned char alpha); void updateSizing(); Pixmap m_cache_pm, m_cache_pressed_pm; FbTk::ImageControl &m_image_ctrl;
M src/ClockTool.ccsrc/ClockTool.cc

@@ -20,7 +20,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ClockTool.cc,v 1.14 2004/08/31 15:26:38 rathnor Exp $ +// $Id: ClockTool.cc,v 1.15 2004/09/12 14:56:18 rathnor Exp $ #include "ClockTool.hh"

@@ -178,13 +178,15 @@ }

void ClockTool::resize(unsigned int width, unsigned int height) { m_button.resize(width, height); - renderTheme(); + reRender(); + m_button.clear(); } void ClockTool::moveResize(int x, int y, unsigned int width, unsigned int height) { m_button.moveResize(x, y, width, height); - renderTheme(); + reRender(); + m_button.clear(); } void ClockTool::show() {

@@ -255,22 +257,29 @@ void ClockTool::updateSizing() {

m_button.setBorderWidth(m_theme.border().width()); } -void ClockTool::renderTheme() { - Pixmap old_pm = m_pixmap; +void ClockTool::reRender() { + if (m_theme.texture().usePixmap()) { + if (m_pixmap) + m_screen.imageControl().removeImage(m_pixmap); + m_pixmap = m_screen.imageControl().renderImage(width(), height(), + m_theme.texture()); + m_button.setBackgroundPixmap(m_pixmap); + } +} + +void ClockTool::renderTheme(unsigned char alpha) { if (!m_theme.texture().usePixmap()) { + if (m_pixmap) + m_screen.imageControl().removeImage(m_pixmap); m_pixmap = 0; m_button.setBackgroundColor(m_theme.texture().color()); } else { - m_pixmap = m_screen.imageControl().renderImage(m_button.width(), m_button.height(), m_theme.texture()); - m_button.setBackgroundPixmap(m_pixmap); + reRender(); } - if (old_pm) - m_screen.imageControl().removeImage(old_pm); - m_button.setJustify(m_theme.justify()); m_button.setBorderWidth(m_theme.border().width()); m_button.setBorderColor(m_theme.border().color()); - m_button.setAlpha(m_theme.alpha()); + m_button.setAlpha(alpha); m_button.clear(); }
M src/ClockTool.hhsrc/ClockTool.hh

@@ -20,7 +20,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ClockTool.hh,v 1.5 2004/08/29 08:33:12 rathnor Exp $ +// $Id: ClockTool.hh,v 1.6 2004/09/12 14:56:18 rathnor Exp $ #ifndef CLOCKTOOL_HH #define CLOCKTOOL_HH

@@ -65,7 +65,8 @@ inline const std::string &timeFormat() const { return *m_timeformat; }

private: void updateTime(); void update(FbTk::Subject *subj); - void renderTheme(); + void renderTheme(unsigned char alpha); + void reRender(); void updateSizing(); FbTk::TextButton m_button;
M src/FbTk/FbWindow.ccsrc/FbTk/FbWindow.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbWindow.cc,v 1.42 2004/09/11 22:59:15 fluxgen Exp $ +// $Id: FbWindow.cc,v 1.43 2004/09/12 14:56:19 rathnor Exp $ #include "FbWindow.hh" #include "FbPixmap.hh"

@@ -161,6 +161,9 @@ }

void FbWindow::updateTransparent(int the_x, int the_y, unsigned int the_width, unsigned int the_height) { #ifdef HAVE_XRENDER + if (!m_transparent.get()) + return; + if (width() == 0 || height() == 0) return;

@@ -173,9 +176,6 @@ if (the_x < 0 || the_y < 0) {

the_x = 0; the_y = 0; } - - if (!m_transparent.get()) - return; // update source and destination if needed Pixmap root = FbPixmap::getRootPixmap(screenNumber());

@@ -215,7 +215,13 @@ }

void FbWindow::setAlpha(unsigned char alpha) { #ifdef HAVE_XRENDER - if (m_transparent.get() == 0 && alpha < 255) { + if (FbTk::Transparent::haveComposite()) { + if (m_transparent.get() != 0) + m_transparent.reset(0); + + // don't setOpaque, let controlling objects do that + // since it's only needed on toplevel windows + } else if (m_transparent.get() == 0 && alpha < 255) { m_transparent.reset(new Transparent(FbPixmap::getRootPixmap(screenNumber()), window(), alpha, screenNumber())); } else if (alpha < 255 && alpha != m_transparent->alpha()) m_transparent->setAlpha(alpha);

@@ -393,6 +399,14 @@ XGetWindowAttributes(display(), window(),

&attrib); return attrib.your_event_mask; +} + +void FbWindow::setOpaque(unsigned char alpha) { +#ifdef HAVE_XRENDER + static Atom m_alphaatom = XInternAtom(display(), "_NET_WM_WINDOW_OPACITY", False); + unsigned int opacity = alpha << 24; + changeProperty(m_alphaatom, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &opacity, 1l); +#endif // HAVE_XRENDER } void FbWindow::setBufferPixmap(Pixmap pm) {
M src/FbTk/FbWindow.hhsrc/FbTk/FbWindow.hh

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbWindow.hh,v 1.34 2004/09/11 12:33:14 rathnor Exp $ +// $Id: FbWindow.hh,v 1.35 2004/09/12 14:56:19 rathnor Exp $ #ifndef FBTK_FBWINDOW_HH #define FBTK_FBWINDOW_HH

@@ -162,6 +162,9 @@ inline bool operator != (Window win) const { return m_window != win; }

/// compare two windows inline bool operator == (const FbWindow &win) const { return m_window == win.m_window; } inline bool operator != (const FbWindow &win) const { return m_window != win.m_window; } + + // used for composite + void setOpaque(unsigned char alpha); protected: /// creates a window with x window client (m_window = client)
M src/FbTk/Menu.ccsrc/FbTk/Menu.cc

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Menu.cc,v 1.84 2004/09/11 22:59:15 fluxgen Exp $ +// $Id: Menu.cc,v 1.85 2004/09/12 14:56:19 rathnor Exp $ //use GNU extensions #ifndef _GNU_SOURCE

@@ -1379,10 +1379,14 @@

void Menu::reconfigure() { - if (alpha() == 255 && m_transp.get() != 0) { + if (FbTk::Transparent::haveComposite()) { + if (m_transp.get() != 0) + m_transp.reset(0); + + menu.window.setOpaque(alpha()); + } else if (alpha() == 255 && m_transp.get() != 0) { m_transp.reset(0); } else if (alpha () < 255) { - if (m_transp.get() == 0) { m_transp.reset(new Transparent(FbPixmap::getRootPixmap(screenNumber()), m_real_frame_pm.drawable(), alpha(),

@@ -1483,7 +1487,6 @@

Pixmap root = FbPixmap::getRootPixmap(screenNumber()); if (m_transp->source() != root) m_transp->setSource(root, screenNumber()); - if (m_transp->dest() != m_real_frame_pm.drawable()) m_transp->setDest(m_real_frame_pm.drawable(), screenNumber());
M src/FbTk/Transparent.ccsrc/FbTk/Transparent.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Transparent.cc,v 1.8 2004/09/11 15:52:23 rathnor Exp $ +// $Id: Transparent.cc,v 1.9 2004/09/12 14:56:20 rathnor Exp $ #include "Transparent.hh" #include "App.hh"

@@ -99,33 +99,73 @@ namespace FbTk {

bool Transparent::s_init = false; bool Transparent::s_render = false; +bool Transparent::s_composite = false; -Transparent::Transparent(Drawable src, Drawable dest, unsigned char alpha, int screen_num): - m_alpha_pic(0), m_src_pic(0), m_dest_pic(0), - m_source(src), m_dest(dest), m_alpha(alpha) { +void Transparent::init() { + Display *disp = FbTk::App::instance()->display(); - Display *disp = FbTk::App::instance()->display(); + int major_opcode, first_event, first_error; + if (XQueryExtension(disp, "RENDER", + &major_opcode, + &first_event, &first_error) == False) { + s_render = false; + s_composite = false; + } else { // we have RENDER support + s_render = true; - // check for RENDER support - if (!s_init) { - int major_opcode, first_event, first_error; - if (XQueryExtension(disp, "RENDER", + if (XQueryExtension(disp, "Composite", &major_opcode, &first_event, &first_error) == False) { - s_render = false; - } else { // we got RENDER support - s_render = true; + s_composite = false; + } else { // we have Composite support + s_composite = true; } - s_init = true; } + s_init = true; +} +void Transparent::usePseudoTransparent(bool no_composite) { + if (s_composite != no_composite) + return; + + s_init = false; + init(); // only use render if we have it + + if (no_composite) + s_composite = false; +} + +bool Transparent::haveComposite(bool for_real) { + if (for_real) { + Display *disp = FbTk::App::instance()->display(); + int major_opcode, first_event, first_error; + + return (XQueryExtension(disp, "Composite", + &major_opcode, + &first_event, &first_error) == True); + } else { + if (!s_init) + init(); + + return s_composite; + } +} + +Transparent::Transparent(Drawable src, Drawable dest, unsigned char alpha, int screen_num): + m_alpha_pic(0), m_src_pic(0), m_dest_pic(0), + m_source(src), m_dest(dest), m_alpha(alpha) { + + Display *disp = FbTk::App::instance()->display(); + + // check for Extension support + if (!s_init) + init(); #ifdef HAVE_XRENDER if (!s_render) return; allocAlpha(m_alpha); - XRenderPictFormat *format = XRenderFindVisualFormat(disp,
M src/FbTk/Transparent.hhsrc/FbTk/Transparent.hh

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Transparent.hh,v 1.3 2003/05/13 21:16:27 fluxgen Exp $ +// $Id: Transparent.hh,v 1.4 2004/09/12 14:56:20 rathnor Exp $ #ifndef FBTK_TRANSPARENT_HH #define FBTK_TRANSPARENT_HH

@@ -50,6 +50,10 @@ unsigned char alpha() const { return m_alpha; }

Drawable dest() const { return m_dest; } Drawable source() const { return m_source; } + static bool haveComposite(bool for_real = false); + static bool haveRender() { if (!s_init) init(); return s_render; } + static void usePseudoTransparent(bool no_composite); + private: void freeAlpha(); void allocAlpha(unsigned char newval);

@@ -61,7 +65,8 @@ unsigned char m_alpha;

static bool s_init; static bool s_render; ///< wheter we have RENDER support - + static bool s_composite; ///< wheter we have Composite support + static void init(); }; }; // end namespace FbTk
M src/FbWinFrame.ccsrc/FbWinFrame.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbWinFrame.cc,v 1.78 2004/08/11 13:17:56 fluxgen Exp $ +// $Id: FbWinFrame.cc,v 1.79 2004/09/12 14:56:18 rathnor Exp $ #include "FbWinFrame.hh"

@@ -29,6 +29,7 @@ #include "FbTk/TextButton.hh"

#include "FbTk/App.hh" #include "FbTk/SimpleCommand.hh" #include "FbTk/Compose.hh" +#include "FbTk/Transparent.hh" #include "CompareWindow.hh" #include "FbWinFrameTheme.hh"

@@ -215,7 +216,8 @@ m_window.moveResize(x, y, width, height);

} else if (move) { m_window.move(x, y); // this stuff will be caught by reconfigure if resized - if (theme().alpha() != 255) { + unsigned char alpha = (m_focused?theme().focusedAlpha():theme().unfocusedAlpha()); + if (alpha != 255) { // restart update timer m_update_timer.start(); }

@@ -238,6 +240,13 @@ if (newvalue) // focused

renderButtonFocus(*m_current_label); else // unfocused renderButtonActive(*m_current_label); + } + + if (theme().focusedAlpha() != theme().unfocusedAlpha() && FbTk::Transparent::haveComposite()) { + if (m_focused) + m_window.setOpaque(theme().focusedAlpha()); + else + m_window.setOpaque(theme().unfocusedAlpha()); } renderTitlebar();

@@ -894,8 +903,9 @@ m_titlebar.setBackgroundPixmap(title_pm);

else m_titlebar.setBackgroundColor(title_color); - m_titlebar.setAlpha(theme().alpha()); - m_label.setAlpha(theme().alpha()); + unsigned char alpha = (m_focused?theme().focusedAlpha():theme().unfocusedAlpha()); + m_titlebar.setAlpha(alpha); + m_label.setAlpha(alpha); renderLabelButtons(); redrawTitlebar();

@@ -953,9 +963,10 @@ m_grip_right.setBackgroundColor(m_grip_unfocused_color);

} } - m_handle.setAlpha(theme().alpha()); - m_grip_left.setAlpha(theme().alpha()); - m_grip_right.setAlpha(theme().alpha()); + unsigned char alpha = (m_focused?theme().focusedAlpha():theme().unfocusedAlpha()); + m_handle.setAlpha(alpha); + m_grip_left.setAlpha(alpha); + m_grip_right.setAlpha(alpha); m_grip_left.clear(); m_grip_left.updateTransparent();

@@ -999,12 +1010,19 @@ }

void FbWinFrame::init() { - // setup update timer - FbTk::RefCount<FbTk::Command> update_transp(new FbTk::SimpleCommand<FbWinFrame>(*this, - &FbWinFrame::updateTransparent)); - m_update_timer.setCommand(update_transp); - m_update_timer.setTimeout(10L); - m_update_timer.fireOnce(true); + if (FbTk::Transparent::haveComposite()) { + if (m_focused) + m_window.setOpaque(theme().focusedAlpha()); + else + m_window.setOpaque(theme().unfocusedAlpha()); + } else { + // setup update timer + FbTk::RefCount<FbTk::Command> update_transp(new FbTk::SimpleCommand<FbWinFrame>(*this, + &FbWinFrame::updateTransparent)); + m_update_timer.setCommand(update_transp); + m_update_timer.setTimeout(10L); + m_update_timer.fireOnce(true); + } if (theme().handleWidth() == 0) m_use_handle = false;

@@ -1052,6 +1070,7 @@ if (m_button_pm)

btn.setBackgroundPixmap(m_button_pm); else btn.setBackgroundColor(m_button_color); + btn.setAlpha(theme().focusedAlpha()); } else { // unfocused btn.setGC(m_theme.buttonPicUnfocusGC()); if (m_button_unfocused_pm)

@@ -1059,9 +1078,9 @@ btn.setBackgroundPixmap(m_button_unfocused_pm);

else btn.setBackgroundColor(m_button_unfocused_color); + btn.setAlpha(theme().unfocusedAlpha()); } - btn.setAlpha(theme().alpha()); } void FbWinFrame::render(const FbTk::Texture &tex, FbTk::Color &col, Pixmap &pm,

@@ -1182,7 +1201,7 @@

button.setGC(theme().labelTextFocusGC()); button.setJustify(theme().justify()); button.setBorderWidth(1); - button.setAlpha(theme().alpha()); + button.setAlpha(theme().focusedAlpha()); if (m_label_focused_pm != 0) { // already set

@@ -1198,7 +1217,7 @@

button.setGC(theme().labelTextActiveGC()); button.setJustify(theme().justify()); button.setBorderWidth(1); - button.setAlpha(theme().alpha()); + button.setAlpha(theme().focusedAlpha()); if (m_label_active_pm != 0) { // already set

@@ -1214,7 +1233,7 @@

button.setGC(theme().labelTextUnfocusGC()); button.setJustify(theme().justify()); button.setBorderWidth(1); - button.setAlpha(theme().alpha()); + button.setAlpha(theme().unfocusedAlpha()); if (m_label_unfocused_pm != 0) { // already set

@@ -1246,6 +1265,8 @@ };

} void FbWinFrame::updateTransparent() { + if (FbTk::Transparent::haveComposite()) + return; m_label.clear(); m_label.updateTransparent();
M src/FbWinFrameTheme.ccsrc/FbWinFrameTheme.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbWinFrameTheme.cc,v 1.18 2004/05/24 15:30:52 rathnor Exp $ +// $Id: FbWinFrameTheme.cc,v 1.19 2004/09/12 14:56:18 rathnor Exp $ #include "FbWinFrameTheme.hh" #include "App.hh"

@@ -58,7 +58,6 @@

m_font(*this, "window.font", "Window.Font"), m_textjustify(*this, "window.justify", "Window.Justify"), m_shape_place(*this, "window.roundCorners", "Window.RoundCorners"), - m_alpha(*this, "window.alpha", "Window.Alpha"), m_title_height(*this, "window.title.height", "Window.Title.Height"), m_bevel_width(*this, "window.bevelWidth", "Window.BevelWidth"), m_handle_width(*this, "window.handleWidth", "Window.handleWidth"),

@@ -67,12 +66,13 @@ m_label_text_focus_gc(RootWindow(FbTk::App::instance()->display(), screen_num)),

m_label_text_unfocus_gc(RootWindow(FbTk::App::instance()->display(), screen_num)), m_label_text_active_gc(RootWindow(FbTk::App::instance()->display(), screen_num)), m_button_pic_focus_gc(RootWindow(FbTk::App::instance()->display(), screen_num)), - m_button_pic_unfocus_gc(RootWindow(FbTk::App::instance()->display(), screen_num)) { + m_button_pic_unfocus_gc(RootWindow(FbTk::App::instance()->display(), screen_num)), + m_focused_alpha(255), + m_unfocused_alpha(255) { *m_title_height = 0; // set defaults m_font->load("fixed"); - *m_alpha = 255; // create cursors Display *disp = FbTk::App::instance()->display();

@@ -105,20 +105,12 @@ return true;

} else if (item.name() == "window.label.active.textColor") { return FbTk::ThemeManager::instance().loadItem(item, "window.label.unfocus.textColor", "Window.Label.Unfocus.TextColor"); - } else if (item.name() == "window.alpha") { - *m_alpha = 255; - return true; } return false; } void FbWinFrameTheme::reconfigTheme() { - if (*m_alpha > 255) - *m_alpha = 255; - else if (*m_alpha < 0) - *m_alpha = 0; - if (*m_bevel_width > 20) *m_bevel_width = 20; else if (*m_bevel_width < 0)
M src/FbWinFrameTheme.hhsrc/FbWinFrameTheme.hh

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbWinFrameTheme.hh,v 1.15 2004/01/11 16:13:09 fluxgen Exp $ +// $Id: FbWinFrameTheme.hh,v 1.16 2004/09/12 14:56:18 rathnor Exp $ #ifndef FBWINFRAMETHEME_HH #define FBWINFRAMETHEME_HH

@@ -94,12 +94,16 @@ inline Cursor upperRightAngleCursor() const { return m_cursor_upper_right_angle; }

inline Shape::ShapePlace shapePlace() const { return *m_shape_place; } inline const BorderTheme &border() const { return m_border; } - unsigned char alpha() const { return *m_alpha; } unsigned int titleHeight() const { return *m_title_height; } unsigned int bevelWidth() const { return *m_bevel_width; } unsigned int handleWidth() const { return *m_handle_width; } + unsigned char focusedAlpha() const { return m_focused_alpha; } + unsigned char unfocusedAlpha() const { return m_unfocused_alpha; } + void setFocusedAlpha(unsigned char alpha) { m_focused_alpha = alpha; } + void setUnfocusedAlpha(unsigned char alpha) { m_unfocused_alpha = alpha; } + private: FbTk::ThemeItem<FbTk::Texture> m_label_focus, m_label_unfocus, m_label_active; FbTk::ThemeItem<FbTk::Texture> m_title_focus, m_title_unfocus;

@@ -114,7 +118,7 @@ FbTk::ThemeItem<FbTk::Font> m_font;

FbTk::ThemeItem<FbTk::Justify> m_textjustify; FbTk::ThemeItem<Shape::ShapePlace> m_shape_place; - FbTk::ThemeItem<int> m_alpha, m_title_height, m_bevel_width, m_handle_width; + FbTk::ThemeItem<int> m_title_height, m_bevel_width, m_handle_width; BorderTheme m_border; FbTk::GContext m_label_text_focus_gc, m_label_text_unfocus_gc, m_label_text_active_gc;

@@ -125,6 +129,8 @@ Cursor m_cursor_lower_left_angle;

Cursor m_cursor_lower_right_angle; Cursor m_cursor_upper_left_angle; Cursor m_cursor_upper_right_angle; + unsigned char m_focused_alpha; + unsigned char m_unfocused_alpha; }; #endif // FBWINFRAMETHEME_HH
M src/GenericTool.ccsrc/GenericTool.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: GenericTool.cc,v 1.3 2004/01/13 14:41:32 rathnor Exp $ +// $Id: GenericTool.cc,v 1.4 2004/09/12 14:56:18 rathnor Exp $ #include "GenericTool.hh" #include "FbTk/FbWindow.hh"

@@ -76,13 +76,13 @@ unsigned int GenericTool::borderWidth() const {

return m_window->borderWidth(); } - -void GenericTool::renderTheme() { - m_window->setAlpha(theme().alpha()); +void GenericTool::renderTheme(unsigned char alpha) { + m_window->setAlpha(alpha); m_window->clear(); m_window->updateTransparent(); } void GenericTool::update(FbTk::Subject *subj) { - renderTheme(); + m_window->clear(); + m_window->updateTransparent(); }
M src/GenericTool.hhsrc/GenericTool.hh

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: GenericTool.hh,v 1.2 2003/10/26 20:11:27 fluxgen Exp $ +// $Id: GenericTool.hh,v 1.3 2004/09/12 14:56:18 rathnor Exp $ #ifndef GENERICTOOL_HH #define GENERICTOOL_HH

@@ -57,7 +57,7 @@ FbTk::FbWindow &window() { return *m_window; }

const FbTk::FbWindow &window() const { return *m_window; } protected: - virtual void renderTheme(); + virtual void renderTheme(unsigned char alpha); private: void update(FbTk::Subject *subj);
M src/IconbarTool.ccsrc/IconbarTool.cc

@@ -20,7 +20,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: IconbarTool.cc,v 1.45 2004/09/05 00:37:16 fluxgen Exp $ +// $Id: IconbarTool.cc,v 1.46 2004/09/12 14:56:18 rathnor Exp $ #include "IconbarTool.hh"

@@ -309,6 +309,7 @@ screen.clientListSig().attach(this);

screen.iconListSig().attach(this); screen.currentWorkspaceSig().attach(this); // setup focus timer + FbTk::RefCount<FbTk::Command> timer_cmd(new FbTk::SimpleCommand<IconbarTool>(*this, &IconbarTool::timedRender)); timeval to; to.tv_sec = 0;

@@ -557,6 +558,12 @@ }

} +void IconbarTool::renderTheme(unsigned char alpha) { + + m_alpha = alpha; + renderTheme(); +} + void IconbarTool::renderTheme() { // update button sizes before we get max width per client!

@@ -619,7 +626,7 @@

// set to zero so its consistent and not ugly m_icon_container.setBorderWidth(m_theme.border().width()); m_icon_container.setBorderColor(m_theme.border().color()); - m_icon_container.setAlpha(m_theme.alpha()); + m_icon_container.setAlpha(m_alpha); // update buttons IconList::iterator icon_it = m_icon_list.begin();

@@ -632,7 +639,7 @@

void IconbarTool::renderButton(IconButton &button, bool clear) { button.setPixmap(*m_rc_use_pixmap); - button.setAlpha(m_theme.alpha()); + button.setAlpha(m_alpha); // The last button is always the regular width bool wider_button = false;
M src/IconbarTool.hhsrc/IconbarTool.hh

@@ -20,7 +20,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: IconbarTool.hh,v 1.15 2004/08/29 08:33:12 rathnor Exp $ +// $Id: IconbarTool.hh,v 1.16 2004/09/12 14:56:18 rathnor Exp $ #ifndef ICONBARTOOL_HH #define ICONBARTOOL_HH

@@ -87,6 +87,7 @@ /// render single button, and probably apply changes (clear)

void renderButton(IconButton &button, bool clear = true); /// render all buttons void renderTheme(); + void renderTheme(unsigned char alpha); /// destroy all icons void deleteIcons(); /// remove a single window

@@ -121,6 +122,7 @@ FbTk::Resource<int> m_rc_client_width; ///< size of client button in LEFT/RIGHT mode

FbTk::Resource<bool> m_rc_use_pixmap; ///< if iconbar should use win pixmap or not FbTk::Timer m_focus_timer; ///< so we can update current window without flicker while changing attached clients FbMenu m_menu; + unsigned char m_alpha; }; #endif // ICONBARTOOL_HH
M src/Screen.ccsrc/Screen.cc

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.291 2004/09/11 23:01:34 fluxgen Exp $ +// $Id: Screen.cc,v 1.292 2004/09/12 14:56:18 rathnor Exp $ #include "Screen.hh"

@@ -68,6 +68,7 @@ #include "FbTk/MacroCommand.hh"

#include "FbTk/StringUtil.hh" #include "FbTk/ImageControl.hh" #include "FbTk/EventManager.hh" +#include "FbTk/Transparent.hh" //use GNU extensions #ifndef _GNU_SOURCE

@@ -176,7 +177,9 @@ windowmenufile(rm, "", scrname+".windowMenu", altscrname+".WindowMenu"),

focus_model(rm, CLICKTOFOCUS, scrname+".focusModel", altscrname+".FocusModel"), workspaces(rm, 1, scrname+".workspaces", altscrname+".Workspaces"), edge_snap_threshold(rm, 0, scrname+".edgeSnapThreshold", altscrname+".EdgeSnapThreshold"), - menu_alpha(rm, 255, scrname+".menuAlpha", altscrname+".MenuAlpha"), + focused_alpha(rm, 255, scrname+".window.focus.alpha", altscrname+".Window.Focus.Alpha"), + unfocused_alpha(rm, 255, scrname+".window.unfocus.alpha", altscrname+".Window.Unfocus.Alpha"), + menu_alpha(rm, 255, scrname+".menu.alpha", altscrname+".Menu.Alpha"), menu_delay(rm, 0, scrname + ".menuDelay", altscrname+".MenuDelay"), menu_delay_close(rm, 0, scrname + ".menuDelayClose", altscrname+".MenuDelayClose"), menu_mode(rm, FbTk::MenuTheme::DELAY_OPEN, scrname+".menuMode", altscrname+".MenuMode"),

@@ -276,8 +279,8 @@ fluxbox->getCacheLife(), fluxbox->getCacheMax()));

imageControl().installRootColormap(); root_colormap_installed = true; - - + m_windowtheme->setFocusedAlpha(*resource.focused_alpha); + m_windowtheme->setUnfocusedAlpha(*resource.unfocused_alpha); m_menutheme->setAlpha(*resource.menu_alpha); m_menutheme->setMenuMode(*resource.menu_mode); // clamp values

@@ -654,6 +657,8 @@

void BScreen::reconfigure() { + m_windowtheme->setFocusedAlpha(*resource.focused_alpha); + m_windowtheme->setUnfocusedAlpha(*resource.unfocused_alpha); m_menutheme->setAlpha(*resource.menu_alpha); m_menutheme->setMenuMode(*resource.menu_mode);

@@ -1814,14 +1819,41 @@ _BOOLITEM(Configmenu, AntiAlias,

"AntiAlias", "Use Anti-aliased fonts", *resource.antialias, save_and_reconfigure); #endif // USE_XFT -#undef _BOOLITEM #ifdef HAVE_XRENDER - FbTk::MenuItem *menu_alpha_item = new IntResMenuItem("Menu Alpha", resource.menu_alpha, - 0, 255); - menu_alpha_item->setCommand(saverc_cmd); - menu.insert(menu_alpha_item); + if (FbTk::Transparent::haveRender() || + FbTk::Transparent::haveComposite()) { + + const char *alphamenu_label = _FBTEXT(Configmenu, Transparency, + "Transparency", "Menu containing various transparency options"); + FbTk::Menu *alpha_menu = createMenu(alphamenu_label ? alphamenu_label : ""); + + if (FbTk::Transparent::haveComposite(true)) { + alpha_menu->insert(new BoolMenuItem(_FBTEXT(Configmenu, ForcePseudoTrans, + "Force Pseudo-Transparency", "When composite is available, still use old pseudo-transparency"), + Fluxbox::instance()->getPseudoTrans(), save_and_reconfigure)); + } + + FbTk::MenuItem *focused_alpha_item = new IntResMenuItem(_FBTEXT(Configmenu, FocusedAlpha, "Focused Window Alpha", "Transparency level of the focused window"), + resource.focused_alpha, 0, 255); + focused_alpha_item->setCommand(saverc_cmd); + alpha_menu->insert(focused_alpha_item); + + FbTk::MenuItem *unfocused_alpha_item = new IntResMenuItem(_FBTEXT(Configmenu, UnfocusedAlpha, "Unfocused Window Alpha", "Transparency level of unfocused windows"), + resource.unfocused_alpha, 0, 255); + unfocused_alpha_item->setCommand(saverc_cmd); + alpha_menu->insert(unfocused_alpha_item); + + FbTk::MenuItem *menu_alpha_item = new IntResMenuItem(_FBTEXT(Configmenu, MenuAlpha, "Menu Alpha", "Transparency level of menu"), + resource.menu_alpha, 0, 255); + menu_alpha_item->setCommand(saverc_cmd); + alpha_menu->insert(menu_alpha_item); + + alpha_menu->update(); + menu.insert(alphamenu_label, alpha_menu); + } #endif // HAVE_XRENDER +#undef _BOOLITEM // finaly update menu
M src/Screen.hhsrc/Screen.hh

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.hh,v 1.145 2004/09/11 13:29:35 fluxgen Exp $ +// $Id: Screen.hh,v 1.146 2004/09/12 14:56:19 rathnor Exp $ #ifndef SCREEN_HH #define SCREEN_HH

@@ -434,7 +434,8 @@ FbTk::Resource<std::string> resizemode;

FbTk::Resource<std::string> windowmenufile; FbTk::Resource<FocusModel> focus_model; bool ordered_dither; - FbTk::Resource<int> workspaces, edge_snap_threshold, menu_alpha, menu_delay, menu_delay_close; + FbTk::Resource<int> workspaces, edge_snap_threshold, focused_alpha, + unfocused_alpha, menu_alpha, menu_delay, menu_delay_close; FbTk::Resource<FbTk::MenuTheme::MenuMode> menu_mode; FbTk::Resource<PlacementPolicy> placement_policy; FbTk::Resource<RowDirection> row_direction;
M src/Slit.ccsrc/Slit.cc

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Slit.cc,v 1.101 2004/09/11 18:58:27 fluxgen Exp $ +// $Id: Slit.cc,v 1.102 2004/09/12 14:56:19 rathnor Exp $ #include "Slit.hh"

@@ -296,7 +296,12 @@

FbTk::EventManager::instance()->add(*this, frame.window); - frame.window.setAlpha(*m_rc_alpha); + if (FbTk::Transparent::haveComposite()) { + frame.window.setOpaque(*m_rc_alpha); + } else { + frame.window.setAlpha(*m_rc_alpha); + } + m_layeritem.reset(new FbTk::XLayerItem(frame.window, layer)); m_layermenu.reset(new LayerMenu<Slit>(scr.menuTheme(), scr.imageControl(),

@@ -679,7 +684,11 @@

if (tmp) image_ctrl.removeImage(tmp); - frame.window.setAlpha(*m_rc_alpha); + if (FbTk::Transparent::haveComposite()) { + frame.window.setOpaque(*m_rc_alpha); + } else { + frame.window.setAlpha(*m_rc_alpha); + } clearWindow(); int x = 0, y = 0;

@@ -1195,9 +1204,9 @@ m_rc_alpha,

0, 255); // setup command for alpha value MacroCommand *alpha_macrocmd = new MacroCommand(); - RefCount<Command> clear_cmd(new SimpleCommand<Slit>(*this, &Slit::clearWindow)); + RefCount<Command> alpha_cmd(new SimpleCommand<Slit>(*this, &Slit::updateAlpha)); alpha_macrocmd->add(saverc_cmd); - alpha_macrocmd->add(clear_cmd); + alpha_macrocmd->add(alpha_cmd); RefCount<Command> set_alpha_cmd(alpha_macrocmd); alpha_menuitem->setCommand(set_alpha_cmd);

@@ -1263,3 +1272,12 @@ // reposition

reconfigure(); } +void Slit::updateAlpha() { + // called when the alpha resource is changed + if (FbTk::Transparent::haveComposite()) { + frame.window.setOpaque(*m_rc_alpha); + } else { + frame.window.setAlpha(*m_rc_alpha); + clearWindow(); + } +}
M src/Slit.hhsrc/Slit.hh

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -/// $Id: Slit.hh,v 1.42 2004/09/11 18:58:27 fluxgen Exp $ +/// $Id: Slit.hh,v 1.43 2004/09/12 14:56:19 rathnor Exp $ #ifndef SLIT_HH #define SLIT_HH

@@ -120,6 +120,7 @@ inline unsigned int height() const { return frame.height; }

const SlitClients &clients() const { return m_client_list; } SlitClients &clients() { return m_client_list; } private: + void updateAlpha(); void clearWindow(); void setupMenu();
M src/SystemTray.hhsrc/SystemTray.hh

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: SystemTray.hh,v 1.6 2004/08/29 08:33:12 rathnor Exp $ +// $Id: SystemTray.hh,v 1.7 2004/09/12 14:56:19 rathnor Exp $ #ifndef SYSTEMTRAY_HH #define SYSTEMTRAY_HH

@@ -65,7 +65,7 @@

int numClients() const { return m_clients.size(); } const FbTk::FbWindow &window() const { return m_window; } - inline void renderTheme() {} + inline void renderTheme(unsigned char alpha) {} inline void updateSizing() {} private:
M src/ToolFactory.ccsrc/ToolFactory.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ToolFactory.cc,v 1.8 2004/09/11 13:40:57 fluxgen Exp $ +// $Id: ToolFactory.cc,v 1.9 2004/09/12 14:56:19 rathnor Exp $ #include "ToolFactory.hh"

@@ -83,25 +83,26 @@

} ToolbarItem *ToolFactory::create(const std::string &name, const FbTk::FbWindow &parent, Toolbar &tbar) { + ToolbarItem * item; unsigned int button_size = 24; if (tbar.theme().buttonSize() > 0) button_size = tbar.theme().buttonSize(); if (name == "workspacename") { - WorkspaceNameTool *item = new WorkspaceNameTool(parent, + WorkspaceNameTool *witem = new WorkspaceNameTool(parent, *m_workspace_theme, screen()); using namespace FbTk; RefCount<Command> showmenu(new ShowMenuAboveToolbar(tbar)); - item->button().setOnClick(showmenu); - return item; + witem->button().setOnClick(showmenu); + item = witem; } else if (name == "iconbar") { - return new IconbarTool(parent, m_iconbar_theme, + item = new IconbarTool(parent, m_iconbar_theme, screen(), tbar.menu()); } else if (name == "systemtray") { - return new SystemTray(parent); + item = new SystemTray(parent); } else if (name == "clock") { - return new ClockTool(parent, m_clock_theme, screen(), tbar.menu()); + item = new ClockTool(parent, m_clock_theme, screen(), tbar.menu()); } else if (name == "nextworkspace" || name == "prevworkspace") {

@@ -118,7 +119,7 @@ ArrowButton *win = new ArrowButton(arrow_type, parent,

0, 0, button_size, button_size); win->setOnClick(cmd); - return new ButtonTool(win, ToolbarItem::SQUARE, + item = new ButtonTool(win, ToolbarItem::SQUARE, dynamic_cast<ButtonTheme &>(*m_button_theme), screen().imageControl());

@@ -137,13 +138,16 @@ ArrowButton *win = new ArrowButton(arrow_type, parent,

0, 0, button_size, button_size); win->setOnClick(cmd); - return new ButtonTool(win, ToolbarItem::SQUARE, + item = new ButtonTool(win, ToolbarItem::SQUARE, dynamic_cast<ButtonTheme &>(*m_button_theme), screen().imageControl()); } - return 0; + if (item) + item->renderTheme(tbar.alpha()); + + return item; } void ToolFactory::updateThemes() {
M src/ToolTheme.ccsrc/ToolTheme.cc

@@ -20,7 +20,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ToolTheme.cc,v 1.7 2004/08/25 17:16:40 rathnor Exp $ +// $Id: ToolTheme.cc,v 1.8 2004/09/12 14:56:19 rathnor Exp $ #include "ToolTheme.hh"

@@ -29,7 +29,7 @@ FbTk::Theme(screen_num),

TextTheme(*this, name, altname), m_texture(*this, name, altname), m_border(*this, name, altname), - m_alpha(*this, name+".alpha", altname+".Alpha") { + m_alpha(255) { }

@@ -54,12 +54,6 @@ if (item.name().find(".justify") != std::string::npos) {

return FbTk::ThemeManager::instance().loadItem(item, "toolbar.justify", "Toolbar.Justify"); - } else if (item.name().find(".alpha") != std::string::npos) { - if (!FbTk::ThemeManager::instance().loadItem(item, - "toolbar.alpha", - "Toolbar.Alpha")) - *m_alpha = 255; - return true; } return false;
M src/ToolTheme.hhsrc/ToolTheme.hh

@@ -20,7 +20,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ToolTheme.hh,v 1.5 2004/01/13 14:41:32 rathnor Exp $ +// $Id: ToolTheme.hh,v 1.6 2004/09/12 14:56:19 rathnor Exp $ #ifndef TOOLTHEME_HH #define TOOLTHEME_HH

@@ -48,7 +48,8 @@ void reconfigTheme();

// textures const FbTk::Texture &texture() const { return *m_texture; } const BorderTheme &border() const { return m_border; } - inline unsigned char alpha() const { return *m_alpha; } + inline unsigned char alpha() const { return m_alpha; } + inline void setAlpha(unsigned char alpha) { m_alpha = alpha; } protected: FbTk::ThemeItem<FbTk::Texture> &textureTheme() { return m_texture; }

@@ -56,7 +57,7 @@

private: FbTk::ThemeItem<FbTk::Texture> m_texture; BorderTheme m_border; - FbTk::ThemeItem<int> m_alpha; + unsigned char m_alpha; }; #endif // TOOLTHEME_HH
M src/Toolbar.ccsrc/Toolbar.cc

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Toolbar.cc,v 1.154 2004/09/11 13:34:01 fluxgen Exp $ +// $Id: Toolbar.cc,v 1.155 2004/09/12 14:56:19 rathnor Exp $ #include "Toolbar.hh"

@@ -46,6 +46,7 @@ #include "FbTk/MacroCommand.hh"

#include "FbTk/EventManager.hh" #include "FbTk/SimpleCommand.hh" #include "FbTk/StringUtil.hh" +#include "FbTk/Transparent.hh" // use GNU extensions

@@ -170,7 +171,7 @@ window(screen_num, // screen (parent)

0, 0, // pos 10, 10, // size // event mask - ButtonPressMask | ButtonReleaseMask | + ButtonPressMask | ButtonReleaseMask | ExposureMask | EnterWindowMask | LeaveWindowMask | SubstructureNotifyMask, true) // override redirect

@@ -216,6 +217,8 @@ scrn.name() + ".toolbar.maxOver", scrn.altName() + ".Toolbar.MaxOver"),

m_rc_visible(scrn.resourceManager(), true, scrn.name() + ".toolbar.visible", scrn.altName() + ".Toolbar.Visible"), m_rc_width_percent(scrn.resourceManager(), 65, scrn.name() + ".toolbar.widthPercent", scrn.altName() + ".Toolbar.WidthPercent"), + m_rc_alpha(scrn.resourceManager(), 255, + scrn.name() + ".toolbar.alpha", scrn.altName() + ".Toolbar.Alpha"), m_rc_layernum(scrn.resourceManager(), Fluxbox::Layer(Fluxbox::instance()->getDesktopLayer()), scrn.name() + ".toolbar.layer", scrn.altName() + ".Toolbar.Layer"), m_rc_on_head(scrn.resourceManager(), 0,

@@ -450,7 +453,13 @@ screen().imageControl().removeImage(tmp);

frame.window.setBorderColor(theme().border().color()); frame.window.setBorderWidth(theme().border().width()); - frame.window.setAlpha(theme().alpha()); + + bool have_composite = FbTk::Transparent::haveComposite(); + if (have_composite) { + frame.window.setOpaque(alpha()); + } else { + frame.window.setAlpha(alpha()); + } frame.window.clear(); frame.window.updateTransparent();

@@ -466,7 +475,7 @@

rearrangeItems(); for (item_it = m_item_list.begin(); item_it != item_it_end; ++item_it) { - (*item_it)->renderTheme(); + (*item_it)->renderTheme(alpha()); } menu().reconfigure();

@@ -872,6 +881,22 @@ place_menu.pop_front();

} menu().insert(_FBTEXT(Menu, Placement, "Placement", "Title of Placement menu"), &placementMenu()); placementMenu().update(); + + + // this saves resources and clears the slit window to update alpha value + FbTk::MenuItem *alpha_menuitem = + new IntResMenuItem(_FBTEXT(Common, Alpha, "Alpha", "Transparency level"), + m_rc_alpha, + 0, 255); + // setup command for alpha value + MacroCommand *alpha_macrocmd = new MacroCommand(); + RefCount<Command> alpha_cmd(new SimpleCommand<Toolbar>(*this, &Toolbar::updateAlpha)); + alpha_macrocmd->add(save_resources); + alpha_macrocmd->add(alpha_cmd); + RefCount<Command> set_alpha_cmd(alpha_macrocmd); + alpha_menuitem->setCommand(set_alpha_cmd); + + menu().insert(alpha_menuitem); menu().update(); }

@@ -1012,3 +1037,20 @@ m_item_list.pop_back();

} m_tools.clear(); } + +void Toolbar::updateAlpha() { + // called when the alpha resource is changed + if (FbTk::Transparent::haveComposite()) { + frame.window.setOpaque(*m_rc_alpha); + } else { + frame.window.setAlpha(*m_rc_alpha); + frame.window.clear(); + frame.window.updateTransparent(); + + ItemList::iterator item_it = m_item_list.begin(); + ItemList::iterator item_it_end = m_item_list.end(); + for (item_it = m_item_list.begin(); item_it != item_it_end; ++item_it) { + (*item_it)->renderTheme(alpha()); + } + } +}
M src/Toolbar.hhsrc/Toolbar.hh

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Toolbar.hh,v 1.53 2004/06/07 21:32:11 fluxgen Exp $ +// $Id: Toolbar.hh,v 1.54 2004/09/12 14:56:19 rathnor Exp $ #ifndef TOOLBAR_HH #define TOOLBAR_HH

@@ -131,7 +131,8 @@ inline ToolbarTheme &theme() { return m_theme; }

bool isVertical() const; inline int getOnHead() const { return *m_rc_on_head; } - + + inline unsigned char alpha() const { return *m_rc_alpha; } private: void rearrangeItems(); void deleteItems();

@@ -140,6 +141,7 @@ void updateIconbarGraphics();

void setupMenus(); void clearStrut(); void updateStrut(); + void updateAlpha(); bool m_hidden; ///< hidden state

@@ -179,6 +181,7 @@

// resources FbTk::Resource<bool> m_rc_auto_hide, m_rc_maximize_over, m_rc_visible; FbTk::Resource<int> m_rc_width_percent; + FbTk::Resource<int> m_rc_alpha; FbTk::Resource<Fluxbox::Layer> m_rc_layernum; FbTk::Resource<int> m_rc_on_head; FbTk::Resource<Placement> m_rc_placement;
M src/ToolbarItem.hhsrc/ToolbarItem.hh

@@ -20,7 +20,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ToolbarItem.hh,v 1.6 2004/08/29 08:33:13 rathnor Exp $ +// $Id: ToolbarItem.hh,v 1.7 2004/09/12 14:56:19 rathnor Exp $ #ifndef TOOLBARITEM_HH #define TOOLBARITEM_HH

@@ -55,7 +55,7 @@ virtual bool active() { return true; }

// Tools should NOT listen to theme changes - they'll get notified by // the toolbar instead. Otherwise there are ordering problems. - virtual void renderTheme() = 0; + virtual void renderTheme(unsigned char alpha) = 0; // just update theme items that affect the size virtual void updateSizing() = 0;
M src/ToolbarTheme.ccsrc/ToolbarTheme.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ToolbarTheme.cc,v 1.16 2004/08/25 17:16:40 rathnor Exp $ +// $Id: ToolbarTheme.cc,v 1.17 2004/09/12 14:56:19 rathnor Exp $ #include "ToolbarTheme.hh"

@@ -50,7 +50,6 @@ m_toolbar(*this, "toolbar", "Toolbar"),

m_border(*this, "toolbar", "Toolbar"), m_bevel_width(*this, "toolbar.bevelWidth", "Toolbar.BevelWidth"), m_shape(*this, "toolbar.shaped", "Toolbar.Shaped"), - m_alpha(*this, "toolbar.alpha", "Toolbar.Alpha"), m_height(*this, "toolbar.height", "Toolbar.Height"), m_button_size(*this, "toolbar.button.size", "Toolbar.Button.Size") { // set default value

@@ -69,9 +68,6 @@ if (item.name().find(".borderWidth") != std::string::npos) {

return FbTk::ThemeManager::instance().loadItem(item, "borderWidth", "BorderWidth"); } else if (item.name().find(".borderColor") != std::string::npos) { return FbTk::ThemeManager::instance().loadItem(item, "borderColor", "BorderColor"); - } else if (item.name() == "toolbar.alpha") { - *m_alpha = 255; - return true; } else if (item.name() == "toolbar.bevelWidth") { return FbTk::ThemeManager::instance().loadItem(item, "bevelWidth", "BevelWidth"); }

@@ -79,11 +75,6 @@ return false;

} void ToolbarTheme::reconfigTheme() { - if (*m_alpha > 255) - *m_alpha = 255; - else if (*m_alpha < 0) - *m_alpha = 0; - if (*m_bevel_width > 20) *m_bevel_width = 20;
M src/ToolbarTheme.hhsrc/ToolbarTheme.hh

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: ToolbarTheme.hh,v 1.11 2004/05/24 15:30:52 rathnor Exp $ +// $Id: ToolbarTheme.hh,v 1.12 2004/09/12 14:56:19 rathnor Exp $ #ifndef TOOLBARTHEME_HH #define TOOLBARTHEME_HH

@@ -46,7 +46,6 @@ bool fallback(FbTk::ThemeItem_base &item);

inline int bevelWidth() const { return *m_bevel_width; } inline bool shape() const { return *m_shape; } - inline unsigned char alpha() const { return *m_alpha; } inline int height() const { return *m_height; } inline int buttonSize() const { return *m_button_size; } private:

@@ -55,7 +54,7 @@ BorderTheme m_border;

FbTk::ThemeItem<int> m_bevel_width; FbTk::ThemeItem<bool> m_shape; - FbTk::ThemeItem<int> m_alpha, m_height, m_button_size; + FbTk::ThemeItem<int> m_height, m_button_size; }; #endif // TOOLBARTHEME_HH
M src/WorkspaceNameTool.ccsrc/WorkspaceNameTool.cc

@@ -20,7 +20,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: WorkspaceNameTool.cc,v 1.10 2004/08/29 08:33:13 rathnor Exp $ +// $Id: WorkspaceNameTool.cc,v 1.11 2004/09/12 14:56:19 rathnor Exp $ #include "WorkspaceNameTool.hh"

@@ -46,7 +46,6 @@ screen.workspaceNamesSig().attach(this);

screen.currentWorkspaceSig().attach(this); theme.reconfigSig().attach(this); - renderTheme(); } WorkspaceNameTool::~WorkspaceNameTool() {

@@ -74,7 +73,8 @@ if (m_button.width() != width()) {

resize(width(), height()); resizeSig().notify(); } - renderTheme(); + reRender(); + m_button.clear(); } unsigned int WorkspaceNameTool::width() const {

@@ -113,22 +113,29 @@ void WorkspaceNameTool::updateSizing() {

m_button.setBorderWidth(m_theme.border().width()); } -void WorkspaceNameTool::renderTheme() { - Pixmap tmp = m_pixmap; +void WorkspaceNameTool::reRender() { + if (m_theme.texture().usePixmap()) { + if (m_pixmap) + m_screen.imageControl().removeImage(m_pixmap); + m_pixmap = m_screen.imageControl().renderImage(width(), height(), + m_theme.texture()); + m_button.setBackgroundPixmap(m_pixmap); + } +} + +void WorkspaceNameTool::renderTheme(unsigned char alpha) { if (!m_theme.texture().usePixmap()) { + if (m_pixmap) + m_screen.imageControl().removeImage(m_pixmap); m_pixmap = 0; m_button.setBackgroundColor(m_theme.texture().color()); } else { - m_pixmap = m_screen.imageControl().renderImage(width(), height(), - m_theme.texture()); - m_button.setBackgroundPixmap(m_pixmap); + reRender(); } - if (tmp) - m_screen.imageControl().removeImage(tmp); m_button.setJustify(m_theme.justify()); m_button.setBorderWidth(m_theme.border().width()); m_button.setBorderColor(m_theme.border().color()); - m_button.setAlpha(m_theme.alpha()); + m_button.setAlpha(alpha); m_button.clear(); }
M src/WorkspaceNameTool.hhsrc/WorkspaceNameTool.hh

@@ -20,7 +20,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: WorkspaceNameTool.hh,v 1.5 2004/08/29 08:33:13 rathnor Exp $ +// $Id: WorkspaceNameTool.hh,v 1.6 2004/09/12 14:56:19 rathnor Exp $ #ifndef WORKSPACENAMETOOL_HH #define WORKSPACENAMETOOL_HH

@@ -53,7 +53,8 @@ void update(FbTk::Subject *subj);

FbTk::Button &button() { return m_button; } const FbTk::Button &button() const { return m_button; } private: - void renderTheme(); + void renderTheme(unsigned char alpha); + void reRender(); void updateSizing(); FbTk::TextButton m_button; const ToolTheme &m_theme;
M src/fluxbox.ccsrc/fluxbox.cc

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.cc,v 1.256 2004/09/12 14:01:29 fluxgen Exp $ +// $Id: fluxbox.cc,v 1.257 2004/09/12 14:56:19 rathnor Exp $ #include "fluxbox.hh"

@@ -49,6 +49,7 @@ #include "FbTk/Command.hh"

#include "FbTk/RefCount.hh" #include "FbTk/SimpleCommand.hh" #include "FbTk/CompareEqual.hh" +#include "FbTk/Transparent.hh" //Use GNU extensions #ifndef _GNU_SOURCE

@@ -203,6 +204,7 @@ // TODO: shouldn't need a separate one for screen

m_screen_rm(m_resourcemanager), m_rc_tabs(m_resourcemanager, true, "session.tabs", "Session.Tabs"), m_rc_ignoreborder(m_resourcemanager, false, "session.ignoreBorder", "Session.IgnoreBorder"), + m_rc_pseudotrans(m_resourcemanager, false, "session.forcePseudoTransparency", "Session.forcePseudoTransparency"), m_rc_colors_per_channel(m_resourcemanager, 4, "session.colorsPerChannel", "Session.ColorsPerChannel"), m_rc_numlayers(m_resourcemanager, 13, "session.numLayers", "Session.NumLayers"),

@@ -1469,6 +1471,9 @@ }

if (m_rc_menufile->empty()) m_rc_menufile.setDefaultValue(); + + if (FbTk::Transparent::haveComposite()) + FbTk::Transparent::usePseudoTransparent(*m_rc_pseudotrans); if (!m_rc_slitlistfile->empty()) { *m_rc_slitlistfile = StringUtil::expandFilename(*m_rc_slitlistfile);
M src/fluxbox.hhsrc/fluxbox.hh

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.hh,v 1.90 2004/08/31 15:26:39 rathnor Exp $ +// $Id: fluxbox.hh,v 1.91 2004/09/12 14:56:19 rathnor Exp $ #ifndef FLUXBOX_HH #define FLUXBOX_HH

@@ -114,8 +114,8 @@ enum Titlebar{SHADE=0, MINIMIZE, MAXIMIZE, CLOSE, STICK, MENU, EMPTY};

enum TabsAttachArea{ATTACH_AREA_WINDOW= 0, ATTACH_AREA_TITLEBAR}; - inline bool getIgnoreBorder() const { return *m_rc_ignoreborder; } + inline bool &getPseudoTrans() { return *m_rc_pseudotrans; } inline const std::vector<Fluxbox::Titlebar>& getTitlebarRight() const { return *m_rc_titlebar_right; } inline const std::vector<Fluxbox::Titlebar>& getTitlebarLeft() const { return *m_rc_titlebar_left; }

@@ -251,6 +251,7 @@

//--- Resources FbTk::Resource<bool> m_rc_tabs, m_rc_ignoreborder; + FbTk::Resource<bool> m_rc_pseudotrans; FbTk::Resource<int> m_rc_colors_per_channel, m_rc_numlayers, m_rc_double_click_interval, m_rc_update_delay_time; FbTk::Resource<std::string> m_rc_stylefile,