make "force pseudotransparency" menu item work immediately
This commit is contained in:
parent
8db2d4f26e
commit
94e2c89053
8 changed files with 53 additions and 44 deletions
|
@ -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)
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue