aboutsummaryrefslogtreecommitdiff
path: root/src/Screen.cc
diff options
context:
space:
mode:
authormarkt <markt>2007-01-16 16:19:48 (GMT)
committermarkt <markt>2007-01-16 16:19:48 (GMT)
commit4bb6a027e31cd91b06eecd1cd942f7a2d8cd8fa2 (patch)
tree0e798dd64689f8662c988ed8be2e73653e880988 /src/Screen.cc
parenta2804705db7259109232c23e9cd1ef86093237b1 (diff)
downloadfluxbox-4bb6a027e31cd91b06eecd1cd942f7a2d8cd8fa2.zip
fluxbox-4bb6a027e31cd91b06eecd1cd942f7a2d8cd8fa2.tar.bz2
automatically reconfigure after changing alpha from menu, using a timer
Diffstat (limited to 'src/Screen.cc')
-rw-r--r--src/Screen.cc35
1 files changed, 30 insertions, 5 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index ab1d718..2bb243f 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -193,6 +193,28 @@ private:
193 FbWinFrame::TabPlacement m_place; 193 FbWinFrame::TabPlacement m_place;
194}; 194};
195 195
196// this might be useful elsewhere, but I'll leave it here for now
197class DelayedCmd: public FbTk::Command {
198public:
199 DelayedCmd(FbTk::RefCount<FbTk::Command> &cmd) {
200 timeval to;
201 to.tv_sec = 0;
202 to.tv_usec = 500000; // 1/2 second
203 m_timer.setTimeout(to);
204 m_timer.setCommand(cmd);
205 m_timer.fireOnce(true);
206 }
207 void execute() {
208 // if it's already started, restart it; otherwise, just start it
209 // we want this to execute 1/2 second after the last click
210 if (m_timer.isTiming())
211 m_timer.stop();
212 m_timer.start();
213 }
214private:
215 FbTk::Timer m_timer;
216};
217
196} // end anonymous namespace 218} // end anonymous namespace
197 219
198 220
@@ -818,8 +840,6 @@ void BScreen::hideWindowMenus(const FluxboxWindow* except) {
818 } 840 }
819} 841}
820 842
821
822
823void BScreen::reconfigure() { 843void BScreen::reconfigure() {
824 Fluxbox *fluxbox = Fluxbox::instance(); 844 Fluxbox *fluxbox = Fluxbox::instance();
825 845
@@ -1758,12 +1778,17 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) {
1758 Fluxbox::instance()->getPseudoTrans(), save_and_reconfigure)); 1778 Fluxbox::instance()->getPseudoTrans(), save_and_reconfigure));
1759 } 1779 }
1760 1780
1781 // in order to save system resources, don't save or reconfigure alpha
1782 // settings until after the user is done changing them
1783 FbTk::RefCount<FbTk::Command> delayed_save_and_reconf(
1784 new ::DelayedCmd(save_and_reconfigure));
1785
1761 FbTk::MenuItem *focused_alpha_item = 1786 FbTk::MenuItem *focused_alpha_item =
1762 new IntResMenuItem< FbTk::Resource<int> >(_FB_XTEXT(Configmenu, FocusedAlpha, 1787 new IntResMenuItem< FbTk::Resource<int> >(_FB_XTEXT(Configmenu, FocusedAlpha,
1763 "Focused Window Alpha", 1788 "Focused Window Alpha",
1764 "Transparency level of the focused window"), 1789 "Transparency level of the focused window"),
1765 resource.focused_alpha, 0, 255, *alpha_menu); 1790 resource.focused_alpha, 0, 255, *alpha_menu);
1766 focused_alpha_item->setCommand(saverc_cmd); 1791 focused_alpha_item->setCommand(delayed_save_and_reconf);
1767 alpha_menu->insert(focused_alpha_item); 1792 alpha_menu->insert(focused_alpha_item);
1768 1793
1769 FbTk::MenuItem *unfocused_alpha_item = 1794 FbTk::MenuItem *unfocused_alpha_item =
@@ -1773,14 +1798,14 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) {
1773 "Transparency level of unfocused windows"), 1798 "Transparency level of unfocused windows"),
1774 1799
1775 resource.unfocused_alpha, 0, 255, *alpha_menu); 1800 resource.unfocused_alpha, 0, 255, *alpha_menu);
1776 unfocused_alpha_item->setCommand(saverc_cmd); 1801 unfocused_alpha_item->setCommand(delayed_save_and_reconf);
1777 alpha_menu->insert(unfocused_alpha_item); 1802 alpha_menu->insert(unfocused_alpha_item);
1778 1803
1779 FbTk::MenuItem *menu_alpha_item = 1804 FbTk::MenuItem *menu_alpha_item =
1780 new IntResMenuItem< FbTk::Resource<int> >(_FB_XTEXT(Configmenu, MenuAlpha, 1805 new IntResMenuItem< FbTk::Resource<int> >(_FB_XTEXT(Configmenu, MenuAlpha,
1781 "Menu Alpha", "Transparency level of menu"), 1806 "Menu Alpha", "Transparency level of menu"),
1782 resource.menu_alpha, 0, 255, *alpha_menu); 1807 resource.menu_alpha, 0, 255, *alpha_menu);
1783 menu_alpha_item->setCommand(saverc_cmd); 1808 menu_alpha_item->setCommand(delayed_save_and_reconf);
1784 alpha_menu->insert(menu_alpha_item); 1809 alpha_menu->insert(menu_alpha_item);
1785 1810
1786 alpha_menu->updateMenu(); 1811 alpha_menu->updateMenu();