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/Toolbar.cc | |
parent | c39234195a46cece2bdb18dfdde6c91c7a190dc4 (diff) | |
download | fluxbox_pavel-42c1fd3ae3dd058e146b7350c65b74386123c25c.zip fluxbox_pavel-42c1fd3ae3dd058e146b7350c65b74386123c25c.tar.bz2 |
preliminary support for composite/compositing manager. Also general work
for consistency with transparency resources
Diffstat (limited to 'src/Toolbar.cc')
-rw-r--r-- | src/Toolbar.cc | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 19e85db..b1471aa 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.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: Toolbar.cc,v 1.154 2004/09/11 13:34:01 fluxgen Exp $ | 25 | // $Id: Toolbar.cc,v 1.155 2004/09/12 14:56:19 rathnor Exp $ |
26 | 26 | ||
27 | #include "Toolbar.hh" | 27 | #include "Toolbar.hh" |
28 | 28 | ||
@@ -46,6 +46,7 @@ | |||
46 | #include "FbTk/EventManager.hh" | 46 | #include "FbTk/EventManager.hh" |
47 | #include "FbTk/SimpleCommand.hh" | 47 | #include "FbTk/SimpleCommand.hh" |
48 | #include "FbTk/StringUtil.hh" | 48 | #include "FbTk/StringUtil.hh" |
49 | #include "FbTk/Transparent.hh" | ||
49 | 50 | ||
50 | 51 | ||
51 | // use GNU extensions | 52 | // use GNU extensions |
@@ -170,7 +171,7 @@ Toolbar::Frame::Frame(FbTk::EventHandler &evh, int screen_num): | |||
170 | 0, 0, // pos | 171 | 0, 0, // pos |
171 | 10, 10, // size | 172 | 10, 10, // size |
172 | // event mask | 173 | // event mask |
173 | ButtonPressMask | ButtonReleaseMask | | 174 | ButtonPressMask | ButtonReleaseMask | ExposureMask | |
174 | EnterWindowMask | LeaveWindowMask | SubstructureNotifyMask, | 175 | EnterWindowMask | LeaveWindowMask | SubstructureNotifyMask, |
175 | 176 | ||
176 | true) // override redirect | 177 | true) // override redirect |
@@ -216,6 +217,8 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width): | |||
216 | m_rc_visible(scrn.resourceManager(), true, scrn.name() + ".toolbar.visible", scrn.altName() + ".Toolbar.Visible"), | 217 | m_rc_visible(scrn.resourceManager(), true, scrn.name() + ".toolbar.visible", scrn.altName() + ".Toolbar.Visible"), |
217 | m_rc_width_percent(scrn.resourceManager(), 65, | 218 | m_rc_width_percent(scrn.resourceManager(), 65, |
218 | scrn.name() + ".toolbar.widthPercent", scrn.altName() + ".Toolbar.WidthPercent"), | 219 | scrn.name() + ".toolbar.widthPercent", scrn.altName() + ".Toolbar.WidthPercent"), |
220 | m_rc_alpha(scrn.resourceManager(), 255, | ||
221 | scrn.name() + ".toolbar.alpha", scrn.altName() + ".Toolbar.Alpha"), | ||
219 | m_rc_layernum(scrn.resourceManager(), Fluxbox::Layer(Fluxbox::instance()->getDesktopLayer()), | 222 | m_rc_layernum(scrn.resourceManager(), Fluxbox::Layer(Fluxbox::instance()->getDesktopLayer()), |
220 | scrn.name() + ".toolbar.layer", scrn.altName() + ".Toolbar.Layer"), | 223 | scrn.name() + ".toolbar.layer", scrn.altName() + ".Toolbar.Layer"), |
221 | m_rc_on_head(scrn.resourceManager(), 0, | 224 | m_rc_on_head(scrn.resourceManager(), 0, |
@@ -450,7 +453,13 @@ void Toolbar::reconfigure() { | |||
450 | 453 | ||
451 | frame.window.setBorderColor(theme().border().color()); | 454 | frame.window.setBorderColor(theme().border().color()); |
452 | frame.window.setBorderWidth(theme().border().width()); | 455 | frame.window.setBorderWidth(theme().border().width()); |
453 | frame.window.setAlpha(theme().alpha()); | 456 | |
457 | bool have_composite = FbTk::Transparent::haveComposite(); | ||
458 | if (have_composite) { | ||
459 | frame.window.setOpaque(alpha()); | ||
460 | } else { | ||
461 | frame.window.setAlpha(alpha()); | ||
462 | } | ||
454 | frame.window.clear(); | 463 | frame.window.clear(); |
455 | frame.window.updateTransparent(); | 464 | frame.window.updateTransparent(); |
456 | 465 | ||
@@ -466,7 +475,7 @@ void Toolbar::reconfigure() { | |||
466 | rearrangeItems(); | 475 | rearrangeItems(); |
467 | 476 | ||
468 | for (item_it = m_item_list.begin(); item_it != item_it_end; ++item_it) { | 477 | for (item_it = m_item_list.begin(); item_it != item_it_end; ++item_it) { |
469 | (*item_it)->renderTheme(); | 478 | (*item_it)->renderTheme(alpha()); |
470 | } | 479 | } |
471 | 480 | ||
472 | menu().reconfigure(); | 481 | menu().reconfigure(); |
@@ -872,6 +881,22 @@ void Toolbar::setupMenus() { | |||
872 | } | 881 | } |
873 | menu().insert(_FBTEXT(Menu, Placement, "Placement", "Title of Placement menu"), &placementMenu()); | 882 | menu().insert(_FBTEXT(Menu, Placement, "Placement", "Title of Placement menu"), &placementMenu()); |
874 | placementMenu().update(); | 883 | placementMenu().update(); |
884 | |||
885 | |||
886 | // this saves resources and clears the slit window to update alpha value | ||
887 | FbTk::MenuItem *alpha_menuitem = | ||
888 | new IntResMenuItem(_FBTEXT(Common, Alpha, "Alpha", "Transparency level"), | ||
889 | m_rc_alpha, | ||
890 | 0, 255); | ||
891 | // setup command for alpha value | ||
892 | MacroCommand *alpha_macrocmd = new MacroCommand(); | ||
893 | RefCount<Command> alpha_cmd(new SimpleCommand<Toolbar>(*this, &Toolbar::updateAlpha)); | ||
894 | alpha_macrocmd->add(save_resources); | ||
895 | alpha_macrocmd->add(alpha_cmd); | ||
896 | RefCount<Command> set_alpha_cmd(alpha_macrocmd); | ||
897 | alpha_menuitem->setCommand(set_alpha_cmd); | ||
898 | |||
899 | menu().insert(alpha_menuitem); | ||
875 | menu().update(); | 900 | menu().update(); |
876 | } | 901 | } |
877 | 902 | ||
@@ -1012,3 +1037,20 @@ void Toolbar::deleteItems() { | |||
1012 | } | 1037 | } |
1013 | m_tools.clear(); | 1038 | m_tools.clear(); |
1014 | } | 1039 | } |
1040 | |||
1041 | void Toolbar::updateAlpha() { | ||
1042 | // called when the alpha resource is changed | ||
1043 | if (FbTk::Transparent::haveComposite()) { | ||
1044 | frame.window.setOpaque(*m_rc_alpha); | ||
1045 | } else { | ||
1046 | frame.window.setAlpha(*m_rc_alpha); | ||
1047 | frame.window.clear(); | ||
1048 | frame.window.updateTransparent(); | ||
1049 | |||
1050 | ItemList::iterator item_it = m_item_list.begin(); | ||
1051 | ItemList::iterator item_it_end = m_item_list.end(); | ||
1052 | for (item_it = m_item_list.begin(); item_it != item_it_end; ++item_it) { | ||
1053 | (*item_it)->renderTheme(alpha()); | ||
1054 | } | ||
1055 | } | ||
1056 | } | ||