From 4bb6a027e31cd91b06eecd1cd942f7a2d8cd8fa2 Mon Sep 17 00:00:00 2001 From: markt Date: Tue, 16 Jan 2007 16:19:48 +0000 Subject: automatically reconfigure after changing alpha from menu, using a timer --- ChangeLog | 5 +++++ src/Screen.cc | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 20ea2e9..a9b89ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ (Format: Year/Month/Day) Changes for 1.0rc3: +*07/01/16: + * Don't force user to reconfigure manually in order to apply menu and + default window transparency changes; instead, in order to conserve system + resources, do it a half-second after the user stops changing them (Mark) + Screen.cc *07/01/15: * Prevent per-window alpha menu from scrolling past 0 or 255 (Mark) IntResMenuItem.hh 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: FbWinFrame::TabPlacement m_place; }; +// this might be useful elsewhere, but I'll leave it here for now +class DelayedCmd: public FbTk::Command { +public: + DelayedCmd(FbTk::RefCount &cmd) { + timeval to; + to.tv_sec = 0; + to.tv_usec = 500000; // 1/2 second + m_timer.setTimeout(to); + m_timer.setCommand(cmd); + m_timer.fireOnce(true); + } + void execute() { + // if it's already started, restart it; otherwise, just start it + // we want this to execute 1/2 second after the last click + if (m_timer.isTiming()) + m_timer.stop(); + m_timer.start(); + } +private: + FbTk::Timer m_timer; +}; + } // end anonymous namespace @@ -818,8 +840,6 @@ void BScreen::hideWindowMenus(const FluxboxWindow* except) { } } - - void BScreen::reconfigure() { Fluxbox *fluxbox = Fluxbox::instance(); @@ -1758,12 +1778,17 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { Fluxbox::instance()->getPseudoTrans(), save_and_reconfigure)); } + // in order to save system resources, don't save or reconfigure alpha + // settings until after the user is done changing them + FbTk::RefCount delayed_save_and_reconf( + new ::DelayedCmd(save_and_reconfigure)); + FbTk::MenuItem *focused_alpha_item = new IntResMenuItem< FbTk::Resource >(_FB_XTEXT(Configmenu, FocusedAlpha, "Focused Window Alpha", "Transparency level of the focused window"), resource.focused_alpha, 0, 255, *alpha_menu); - focused_alpha_item->setCommand(saverc_cmd); + focused_alpha_item->setCommand(delayed_save_and_reconf); alpha_menu->insert(focused_alpha_item); FbTk::MenuItem *unfocused_alpha_item = @@ -1773,14 +1798,14 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { "Transparency level of unfocused windows"), resource.unfocused_alpha, 0, 255, *alpha_menu); - unfocused_alpha_item->setCommand(saverc_cmd); + unfocused_alpha_item->setCommand(delayed_save_and_reconf); alpha_menu->insert(unfocused_alpha_item); FbTk::MenuItem *menu_alpha_item = new IntResMenuItem< FbTk::Resource >(_FB_XTEXT(Configmenu, MenuAlpha, "Menu Alpha", "Transparency level of menu"), resource.menu_alpha, 0, 255, *alpha_menu); - menu_alpha_item->setCommand(saverc_cmd); + menu_alpha_item->setCommand(delayed_save_and_reconf); alpha_menu->insert(menu_alpha_item); alpha_menu->updateMenu(); -- cgit v0.11.2