all repos — fluxbox @ 8294b04f5e044e1fa506cc1ce87f9c70e39d1ef4

custom fork of the fluxbox windowmanager

using menu as observer, cleaning in menu theme
fluxgen fluxgen
commit

8294b04f5e044e1fa506cc1ce87f9c70e39d1ef4

parent

90ff80f89b990fcdf98d8c28b4d85a4420a8e213

5 files changed, 18 insertions(+), 34 deletions(-)

jump to
M src/FbTk/Menu.ccsrc/FbTk/Menu.cc

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Menu.cc,v 1.49 2003/12/16 17:06:51 fluxgen Exp $ +// $Id: Menu.cc,v 1.50 2003/12/17 00:43:22 fluxgen Exp $ //use GNU extensions #ifndef _GNU_SOURCE

@@ -63,7 +63,6 @@ m_screen_width(DisplayWidth(FbTk::App::instance()->display(), tm.screenNum())),

m_screen_height(DisplayHeight(FbTk::App::instance()->display(), tm.screenNum())), m_alignment(ALIGNDONTCARE), m_border_width(0), - m_themeobserver(*this), m_need_update(true) { // setup timers

@@ -78,7 +77,7 @@ m_hide_timer.setCommand(hide_cmd);

m_hide_timer.fireOnce(true); // make sure we get updated when the theme is reloaded - tm.addListener(m_themeobserver); + tm.reconfigSig().attach(this); title_vis = movable =

@@ -1188,7 +1187,7 @@ if (theme().menuMode() == MenuTheme::DELAY_OPEN) {

// setup show menu timer timeval timeout; timeout.tv_sec = 0; - timeout.tv_usec = theme().delayOpen(); + timeout.tv_usec = theme().delayOpen() * 1000; // transformed to usec m_submenu_timer.setTimeout(timeout); m_submenu_timer.start();

@@ -1400,7 +1399,7 @@

void Menu::startHide() { timeval timeout; timeout.tv_sec = 0; - timeout.tv_usec = theme().delayClose(); + timeout.tv_usec = theme().delayClose() * 1000; // transformed to usec m_hide_timer.setTimeout(timeout); m_hide_timer.start(); }
M src/FbTk/Menu.hhsrc/FbTk/Menu.hh

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Menu.hh,v 1.27 2003/12/16 17:06:52 fluxgen Exp $ +// $Id: Menu.hh,v 1.28 2003/12/17 00:43:22 fluxgen Exp $ #ifndef FBTK_MENU_HH #define FBTK_MENU_HH

@@ -48,7 +48,7 @@ class ImageControl;

class Transparent; /// Base class for menus -class Menu: public FbTk::EventHandler { +class Menu: public FbTk::EventHandler, protected FbTk::Observer { public: enum Alignment{ ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM }; enum { RIGHT = 1, LEFT };

@@ -174,7 +174,10 @@ virtual void internal_hide();

inline Menu *parent() { return m_parent; } inline const Menu *parent() const { return m_parent; } + void update(FbTk::Subject *) { reconfigure(); } + private: + void openSubmenu(); void closeMenu(); void startHide();

@@ -206,17 +209,6 @@ unsigned int title_h, frame_h, item_w, item_h, bevel_w,

bevel_h; } menu; - class ThemeObserver:public Observer { - public: - ThemeObserver(FbTk::Menu &menu):m_menu(menu) { } - void update(FbTk::Subject *subj) { - m_menu.reconfigure(); - } - private: - Menu &m_menu; - }; - - ThemeObserver m_themeobserver; Drawable m_root_pm; static Menu *s_focused; ///< holds current input focused menu, so one can determine if a menu is focused FbPixmap m_frame_pm;
M src/FbTk/MenuTheme.ccsrc/FbTk/MenuTheme.cc

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: MenuTheme.cc,v 1.12 2003/12/12 18:18:49 fluxgen Exp $ +// $Id: MenuTheme.cc,v 1.13 2003/12/17 00:43:22 fluxgen Exp $ #include "MenuTheme.hh"

@@ -100,9 +100,6 @@ f_text_gc.setForeground(*f_text);

h_text_gc.setForeground(*h_text); d_text_gc.setForeground(*d_text); hilite_gc.setForeground(hilite->color()); - - // notify any listeners - m_theme_change_sig.notify(); } bool MenuTheme::fallback(ThemeItem_base &item) {
M src/FbTk/MenuTheme.hhsrc/FbTk/MenuTheme.hh

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: MenuTheme.hh,v 1.12 2003/12/16 17:06:52 fluxgen Exp $ +// $Id: MenuTheme.hh,v 1.13 2003/12/17 00:43:22 fluxgen Exp $ #ifndef FBTK_MENUTHEME_HH #define FBTK_MENUTHEME_HH

@@ -112,17 +112,13 @@ // but we'll let it be here for now, until there's a better way to

// get resources into menu void setMenuMode(MenuMode mode) { m_menumode = mode; } MenuMode menuMode() const { return m_menumode; } - void setDelayOpen(int usec) { m_delayopen = usec; } - void setDelayClose(int usec) { m_delayclose = usec; } + void setDelayOpen(int msec) { m_delayopen = msec; } + void setDelayClose(int msec) { m_delayclose = msec; } int delayOpen() const { return m_delayopen; } int delayClose() const { return m_delayclose; } const FbTk::Color &borderColor() const { return *m_border_color; } - FbTk::Subject &themeChangeSig() { return m_theme_change_sig; } - /// attach observer - void addListener(FbTk::Observer &obs) { m_theme_change_sig.attach(&obs); } - /// detach observer - void removeListener(FbTk::Observer &obs) { m_theme_change_sig.detach(&obs); } + private: FbTk::ThemeItem<FbTk::Color> t_text, f_text, h_text, d_text; FbTk::ThemeItem<FbTk::Texture> title, frame, hilite;

@@ -137,12 +133,11 @@ FbTk::ThemeItem<FbTk::PixmapWithMask> m_bullet_pixmap, m_selected_pixmap, m_unselected_pixmap;

Display *m_display; FbTk::GContext t_text_gc, f_text_gc, h_text_gc, d_text_gc, hilite_gc; - FbTk::Subject m_theme_change_sig; unsigned char m_alpha; MenuMode m_menumode; - unsigned int m_delayopen; ///< in usec - unsigned int m_delayclose; ///< in usec + unsigned int m_delayopen; ///< in msec + unsigned int m_delayclose; ///< in msec };
M src/FbTk/Theme.hhsrc/FbTk/Theme.hh

@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Theme.hh,v 1.12 2003/12/16 17:06:52 fluxgen Exp $ +// $Id: Theme.hh,v 1.13 2003/12/17 00:43:22 fluxgen Exp $ /** @file holds ThemeItem<T>, Theme and ThemeManager which is the base for any theme

@@ -106,6 +106,7 @@ template <typename T>

void remove(ThemeItem<T> &item); virtual bool fallback(ThemeItem_base &) { return false; } FbTk::Subject &reconfigSig() { return m_reconfig_sig; } + const FbTk::Subject &reconfigSig() const { return m_reconfig_sig; } private: