From 94e2c89053325beeb9f79d2e682adf614f636ca8 Mon Sep 17 00:00:00 2001 From: markt Date: Sat, 6 Jan 2007 19:03:33 +0000 Subject: make "force pseudotransparency" menu item work immediately --- ChangeLog | 4 ++++ src/FbTk/Menu.cc | 12 ++++++++---- src/FbTk/Transparent.cc | 42 +++++++++++++++--------------------------- src/FbTk/Transparent.hh | 3 ++- src/FbWinFrame.cc | 25 +++++++++++++++---------- src/Slit.cc | 3 +++ src/Toolbar.cc | 3 +++ src/fluxbox.cc | 5 +++-- 8 files changed, 53 insertions(+), 44 deletions(-) diff --git a/ChangeLog b/ChangeLog index cf1727a..2ccb7b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ (Format: Year/Month/Day) Changes for 1.0rc3: *07/01/06: + * Changing session.forcePseudotransparency no longer requires restart, + also a little code cleanup in FbTk/Transparent.cc/hh + (Mark) + Slit.cc Menu.cc Toolbar.cc FbWinFrame.cc fluxbox.cc * Move triangle drawing into a generic function in FbDrawable (Simon) Make submenu triangles in MenuItems proportional to the icon size (alternate implementation of sf.net patch #1526813) diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index 9206ade..e7fc6d8 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -1099,14 +1099,18 @@ void Menu::keyPressEvent(XKeyEvent &event) { void Menu::reconfigure() { - if (FbTk::Transparent::haveComposite()) + if (FbTk::Transparent::haveComposite()) { menu.window.setOpaque(alpha()); + menu.title.setAlpha(255); + menu.frame.setAlpha(255); + } else { + menu.window.setOpaque(255); + menu.title.setAlpha(alpha()); + menu.frame.setAlpha(alpha()); + } m_need_update = true; // redraw items - menu.title.setAlpha(alpha()); - menu.frame.setAlpha(alpha()); - menu.window.setBorderColor(theme().borderColor()); menu.title.setBorderColor(theme().borderColor()); menu.frame.setBorderColor(theme().borderColor()); diff --git a/src/FbTk/Transparent.cc b/src/FbTk/Transparent.cc index 6563d5a..d80b2b2 100644 --- a/src/FbTk/Transparent.cc +++ b/src/FbTk/Transparent.cc @@ -112,6 +112,7 @@ namespace FbTk { bool Transparent::s_init = false; bool Transparent::s_render = false; bool Transparent::s_composite = false; +bool Transparent::s_use_composite = false; void Transparent::init() { Display *disp = FbTk::App::instance()->display(); @@ -119,48 +120,35 @@ void Transparent::init() { 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 + &first_event, &first_error)) { + // we have XRENDER support s_render = true; if (XQueryExtension(disp, "Composite", &major_opcode, - &first_event, &first_error) == False) { - s_composite = false; - } else { // we have Composite support + &first_event, &first_error)) { + // we have Composite support s_composite = true; + s_use_composite = 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; +void Transparent::usePseudoTransparent(bool force) { + if (!s_init) + init(); + s_use_composite = (!force && s_composite); } 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(); + if (!s_init) + init(); + if (for_real) return s_composite; - } + else + return s_use_composite; } Transparent::Transparent(Drawable src, Drawable dest, unsigned char alpha, int screen_num): diff --git a/src/FbTk/Transparent.hh b/src/FbTk/Transparent.hh index 77e09c5..3720b33 100644 --- a/src/FbTk/Transparent.hh +++ b/src/FbTk/Transparent.hh @@ -53,7 +53,7 @@ public: static bool haveComposite(bool for_real = false); static bool haveRender() { if (!s_init) init(); return s_render; } - static void usePseudoTransparent(bool no_composite); + static void usePseudoTransparent(bool force); private: void freeAlpha(); @@ -67,6 +67,7 @@ private: static bool s_init; static bool s_render; ///< wheter we have RENDER support static bool s_composite; ///< wheter we have Composite support + static bool s_use_composite; ///< whether or not to use Composite static void init(); }; diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index b7f2e6b..e41d1df 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc @@ -508,9 +508,11 @@ void FbWinFrame::setFocus(bool newvalue) { if (FbTk::Transparent::haveRender() && theme().focusedAlpha() != theme().unfocusedAlpha()) { unsigned char alpha = (m_focused?theme().focusedAlpha():theme().unfocusedAlpha()); if (FbTk::Transparent::haveComposite()) { + m_tab_container.setAlpha(255); m_window.setOpaque(alpha); } else { m_tab_container.setAlpha(alpha); + m_window.setOpaque(255); } } @@ -521,9 +523,7 @@ void FbWinFrame::setFocus(bool newvalue) { applyActiveLabel(*m_current_label); } - applyTitlebar(); - applyHandles(); - applyTabContainer(); + applyAll(); clearAll(); } @@ -1053,6 +1053,18 @@ void FbWinFrame::reconfigure() { // render the theme if (isVisible()) { + // update transparency settings + if (FbTk::Transparent::haveRender()) { + unsigned char alpha = + (m_focused ? theme().focusedAlpha() : theme().unfocusedAlpha()); + if (FbTk::Transparent::haveComposite()) { + m_tab_container.setAlpha(255); + m_window.setOpaque(alpha); + } else { + m_tab_container.setAlpha(alpha); + m_window.setOpaque(255); + } + } renderAll(); applyAll(); clearAll(); @@ -1391,13 +1403,6 @@ void FbWinFrame::applyButtons() { void FbWinFrame::init() { - if (FbTk::Transparent::haveComposite()) { - if (m_focused) - m_window.setOpaque(theme().focusedAlpha()); - else - m_window.setOpaque(theme().unfocusedAlpha()); - } - if (theme().handleWidth() == 0) m_use_handle = false; diff --git a/src/Slit.cc b/src/Slit.cc index 8542dca..e95708e 100644 --- a/src/Slit.cc +++ b/src/Slit.cc @@ -707,10 +707,13 @@ void Slit::reconfigure() { if (tmp) image_ctrl.removeImage(tmp); + // could have changed types, so we must set both if (FbTk::Transparent::haveComposite()) { + frame.window.setAlpha(255); frame.window.setOpaque(*m_rc_alpha); } else { frame.window.setAlpha(*m_rc_alpha); + frame.window.setOpaque(255); } // reposition clears the bg reposition(); diff --git a/src/Toolbar.cc b/src/Toolbar.cc index df5bf44..c0d3f88 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc @@ -477,9 +477,12 @@ void Toolbar::reconfigure() { frame.window.setBorderWidth(theme().border().width()); bool have_composite = FbTk::Transparent::haveComposite(); + // have_composite could have changed, so we need to change both if (have_composite) { frame.window.setOpaque(alpha()); + frame.window.setAlpha(255); } else { + frame.window.setOpaque(255); frame.window.setAlpha(alpha()); } frame.window.clear(); diff --git a/src/fluxbox.cc b/src/fluxbox.cc index a8290e5..723c6e0 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -1569,8 +1569,7 @@ void Fluxbox::load_rc() { if (m_rc_menufile->empty()) m_rc_menufile.setDefaultValue(); - if (FbTk::Transparent::haveComposite()) - FbTk::Transparent::usePseudoTransparent(*m_rc_pseudotrans); + FbTk::Transparent::usePseudoTransparent(*m_rc_pseudotrans); if (!m_rc_slitlistfile->empty()) { *m_rc_slitlistfile = StringUtil::expandFilename(*m_rc_slitlistfile); @@ -1670,6 +1669,8 @@ void Fluxbox::reconfigure() { void Fluxbox::real_reconfigure() { + FbTk::Transparent::usePseudoTransparent(*m_rc_pseudotrans); + ScreenList::iterator screen_it = m_screen_list.begin(); ScreenList::iterator screen_it_end = m_screen_list.end(); for (; screen_it != screen_it_end; ++screen_it) -- cgit v0.11.2