From a827c24e36aa3cf42566fe44dde5848df7679d14 Mon Sep 17 00:00:00 2001 From: rathnor Date: Sat, 19 Jul 2003 03:59:56 +0000 Subject: fix alpha setting for menus when multiple screens by moving from static in menu to part of MenuTheme --- BUGS | 8 +++++--- ChangeLog | 3 +++ src/FbTk/Menu.cc | 19 +++++++++---------- src/FbTk/Menu.hh | 9 +++------ src/FbTk/MenuTheme.cc | 6 ++++-- src/FbTk/MenuTheme.hh | 8 +++++++- src/Screen.cc | 6 +++--- 7 files changed, 34 insertions(+), 25 deletions(-) diff --git a/BUGS b/BUGS index ae9fbc3..edb347f 100644 --- a/BUGS +++ b/BUGS @@ -5,9 +5,6 @@ BUGS: * Remember menu sometimes isn't present in window menu. Probably need to add a signal for menu reconfigures (Screen::setupWindowActions) - * MenuAlpha (at least) isn't 'per-screen' - takes the value of the - highest numbered screen. - * Window handle is invisible sometimes. * KDE support needs attention (e.g. klipper). @@ -74,3 +71,8 @@ Fixed bugs (or not-our-fault bugs): => Fixed by reorganising the way ResourceManager works. Fluxbox::Layer is used so that we can give some layers names + * MenuAlpha (at least) isn't 'per-screen' - takes the value of the + highest numbered screen. + => Fixed, moved alpha setting into MenuTheme rather than static value + + diff --git a/ChangeLog b/ChangeLog index 2b8c050..10a82f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ (Format: Year/Month/Day) Changes for 0.9.5: *03/07/19: + * Move menu alpha setting into MenuTheme (Simon) + - fixes alpha init on multi-screened machines + MenuTheme.hh/cc Menu.hh/cc Screen.cc * Add compiled-in defaults to fluxbox -info (thanks Matt Hope) main.cc * Redo ResourceManager so that it loads resources on registration, and diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc index c9943b3..3674ae1 100644 --- a/src/FbTk/Menu.cc +++ b/src/FbTk/Menu.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Menu.cc,v 1.28 2003/07/10 11:57:37 fluxgen Exp $ +// $Id: Menu.cc,v 1.29 2003/07/19 03:59:56 rathnor Exp $ //use GNU extensions #ifndef _GNU_SOURCE @@ -77,7 +77,6 @@ namespace FbTk { static Menu *shown = 0; -unsigned char Menu::s_alpha = 255; Menu *Menu::s_focused = 0; Menu::Menu(MenuTheme &tm, int screen_num, ImageControl &imgctrl): @@ -92,7 +91,7 @@ Menu::Menu(MenuTheme &tm, int screen_num, ImageControl &imgctrl): m_border_width(0), m_themeobserver(*this), m_trans(new Transparent(getRootPixmap(screen_num), 0, - s_alpha, screen_num)), + tm.alpha(), screen_num)), m_need_update(true) { // make sure we get updated when the theme is reloaded @@ -139,7 +138,7 @@ Menu::Menu(MenuTheme &tm, int screen_num, ImageControl &imgctrl): m_root_pm = getRootPixmap(screen_num); m_trans->setSource(m_root_pm, screen_num); - m_trans->setAlpha(s_alpha); + m_trans->setAlpha(alpha()); //set attributes for menu window unsigned long attrib_mask = CWOverrideRedirect | CWEventMask; @@ -952,8 +951,8 @@ void Menu::drawItem(unsigned int index, bool highlight, bool clear, bool render_ item_x, item_y, menu.item_w, menu.item_h, False); - if (m_trans->alpha() != s_alpha) - m_trans->setAlpha(s_alpha); + if (m_trans->alpha() != alpha()) + m_trans->setAlpha(alpha()); if (m_trans.get() && render_trans) { if (m_trans->alpha() != 255) { @@ -1338,8 +1337,8 @@ void Menu::reconfigure() { menu.window.setBorderWidth(m_border_width); menu.title.setBorderWidth(m_border_width); - if (m_trans.get() && m_trans->alpha() != s_alpha) - m_trans->setAlpha(s_alpha); + if (m_trans.get() && m_trans->alpha() != alpha()) + m_trans->setAlpha(alpha()); update(); } @@ -1348,8 +1347,8 @@ void Menu::renderTransFrame() { if (m_trans.get() == 0 || moving) return; - if (m_trans->alpha() != s_alpha) - m_trans->setAlpha(s_alpha); + if (m_trans->alpha() != alpha()) + m_trans->setAlpha(alpha()); if (m_trans->alpha() != 255) { diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index 5ddd617..013c478 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Menu.hh,v 1.18 2003/07/10 11:55:49 fluxgen Exp $ +// $Id: Menu.hh,v 1.19 2003/07/19 03:59:56 rathnor Exp $ #ifndef FBTK_MENU_HH #define FBTK_MENU_HH @@ -39,11 +39,11 @@ #include "Observer.hh" #include "XLayerItem.hh" #include "FbPixmap.hh" +#include "MenuTheme.hh" namespace FbTk { class MenuItem; -class MenuTheme; class ImageControl; class Transparent; @@ -95,8 +95,6 @@ public: void disableTitle(); void enableTitle(); - static void setAlpha(unsigned char alpha) { s_alpha = alpha; } - /** @name event handlers */ @@ -153,7 +151,7 @@ public: bool isItemSelected(unsigned int index) const; bool isItemEnabled(unsigned int index) const; const MenuTheme &theme() const { return m_theme; } - static unsigned char alpha() { return s_alpha; } + inline unsigned char alpha() const { return m_theme.alpha(); } static Menu *focused() { return s_focused; } /// @return menuitem at index inline const MenuItem *find(unsigned int index) const { return menuitems[index]; } @@ -218,7 +216,6 @@ private: ThemeObserver m_themeobserver; std::auto_ptr m_trans; Drawable m_root_pm; - static unsigned char s_alpha; static Menu *s_focused; ///< holds current input focused menu, so one can determine if a menu is focused FbPixmap m_frame_pm; bool m_need_update; diff --git a/src/FbTk/MenuTheme.cc b/src/FbTk/MenuTheme.cc index 640a408..7035dca 100644 --- a/src/FbTk/MenuTheme.cc +++ b/src/FbTk/MenuTheme.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: MenuTheme.cc,v 1.7 2003/04/26 22:10:53 fluxgen Exp $ +// $Id: MenuTheme.cc,v 1.8 2003/07/19 03:59:56 rathnor Exp $ #include "MenuTheme.hh" @@ -51,7 +51,9 @@ MenuTheme::MenuTheme(int screen_num): m_border_width(*this, "borderWidth", "BorderWidth"), m_bevel_width(*this, "bevelWidth", "BevelWidth"), m_border_color(*this, "borderColor", "BorderColor"), - m_display(FbTk::App::instance()->display()) { + m_display(FbTk::App::instance()->display()), + m_alpha(255) +{ Window rootwindow = RootWindow(m_display, screen_num); diff --git a/src/FbTk/MenuTheme.hh b/src/FbTk/MenuTheme.hh index b39b824..dd03910 100644 --- a/src/FbTk/MenuTheme.hh +++ b/src/FbTk/MenuTheme.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: MenuTheme.hh,v 1.6 2003/05/04 21:01:43 fluxgen Exp $ +// $Id: MenuTheme.hh,v 1.7 2003/07/19 03:59:56 rathnor Exp $ #ifndef FBTK_MENUTHEME_HH #define FBTK_MENUTHEME_HH @@ -86,6 +86,10 @@ public: unsigned int borderWidth() const { return *m_border_width; } unsigned int bevelWidth() const { return *m_bevel_width; } + + inline unsigned char alpha() const { return m_alpha; } + void setAlpha(unsigned char alpha) { m_alpha = alpha; } + const FbTk::Color &borderColor() const { return *m_border_color; } FbTk::Subject &themeChangeSig() { return m_theme_change_sig; } /// attach observer @@ -107,6 +111,8 @@ private: Display *m_display; GC t_text_gc, f_text_gc, h_text_gc, d_text_gc, hilite_gc; FbTk::Subject m_theme_change_sig; + + unsigned char m_alpha; }; }; // end namespace FbTk diff --git a/src/Screen.cc b/src/Screen.cc index 64ce672..2e05b9c 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Screen.cc,v 1.203 2003/07/18 15:40:55 rathnor Exp $ +// $Id: Screen.cc,v 1.204 2003/07/19 03:59:55 rathnor Exp $ #include "Screen.hh" @@ -341,7 +341,7 @@ BScreen::BScreen(FbTk::ResourceManager &rm, // load this screens resources fluxbox->load_rc(*this); - FbTk::Menu::setAlpha(*resource.menu_alpha); + m_menutheme->setAlpha(*resource.menu_alpha); imageControl().setDither(*resource.image_dither); @@ -594,7 +594,7 @@ void BScreen::reconfigure() { #ifdef DEBUG cerr<<__FILE__<<"("<<__LINE__<<"): BScreen::reconfigure"<setAlpha(*resource.menu_alpha); Fluxbox::instance()->loadRootCommand(*this); // setup windowtheme, toolbartheme for antialias -- cgit v0.11.2