all repos — fluxbox @ 0780952b102b48e4448bbd514dad6297899be1e4

custom fork of the fluxbox windowmanager

fix window button image updates
simonb simonb
commit

0780952b102b48e4448bbd514dad6297899be1e4

parent

33079d2593a7a598446cc837fc39eb2a914ebb1f

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

jump to
M ChangeLogChangeLog

@@ -1,5 +1,9 @@

(Format: Year/Month/Day) Changes for 0.9.16: +*06/04/14: + * Fix updating of button state (esp stick/shade) (Simon) + (sf.net #1281724, #1213257) + FbTk/Button.hh/cc WinButton.cc Window.cc *06/04/13: * Provide "Key Modes" (Thanks Mark Tiefenbruck, mark at tiefenbruck dot org) - New action in keys file:
M src/FbTk/Button.ccsrc/FbTk/Button.cc

@@ -37,7 +37,8 @@ m_background_pm(0),

m_pressed_pm(0), m_pressed_color(), m_gc(DefaultGC(FbTk::App::instance()->display(), screen_num)), - m_pressed(false) { + m_pressed(false), + mark_if_deleted(0) { // add this to eventmanager FbTk::EventManager::instance()->add(*this, *this);

@@ -51,13 +52,16 @@ m_background_pm(0),

m_pressed_pm(0), m_pressed_color(), m_gc(DefaultGC(FbTk::App::instance()->display(), screenNumber())), - m_pressed(false) { + m_pressed(false), + mark_if_deleted(0) { // add this to eventmanager FbTk::EventManager::instance()->add(*this, *this); } Button::~Button() { - + if (mark_if_deleted) { + *mark_if_deleted = true; + } } void Button::setOnClick(RefCount<Command> &cmd, int button) {

@@ -107,26 +111,33 @@

void Button::buttonReleaseEvent(XButtonEvent &event) { m_pressed = false; bool update = false; - if (m_background_pm) { - if (m_pressed_pm != 0) { - update = true; - setBackgroundPixmap(m_background_pm); - } - } else if (m_pressed_color.isAllocated()) { - update = true; - setBackgroundColor(m_background_color); - } + bool been_deleted = false; + mark_if_deleted = &been_deleted; - if (update) - clear(); // clear background - - // finaly, execute command (this must be done last since this object might be deleted by the command) + // This command may result in this object being deleted + // hence the mark_if_deleted mechanism so that we can + // update our state after the command if (event.button > 0 && event.button <= 5 && event.x > 0 && event.x < static_cast<signed>(width()) && event.y > 0 && event.y < static_cast<signed>(height()) && m_onclick[event.button -1].get() != 0) m_onclick[event.button - 1]->execute(); + if (!been_deleted) { + mark_if_deleted = 0; + if (m_background_pm) { + if (m_pressed_pm != 0) { + update = true; + setBackgroundPixmap(m_background_pm); + } + } else if (m_pressed_color.isAllocated()) { + update = true; + setBackgroundColor(m_background_color); + } + + if (update) + clear(); // clear background + } }
M src/FbTk/Button.hhsrc/FbTk/Button.hh

@@ -87,6 +87,7 @@ Pixmap m_pressed_pm; ///< pressed pixmap

Color m_pressed_color; GC m_gc; ///< graphic context for button bool m_pressed; ///< if the button is pressed + bool *mark_if_deleted; ///< if the button is deleted and this is set, make it true RefCount<Command> m_onclick[5]; ///< what to do when this button is clicked with button num };
M src/WinButton.ccsrc/WinButton.cc

@@ -187,9 +187,9 @@ case CLOSE:

return m_theme.closePressedPixmap().pixmap().drawable(); case SHADE: if (m_listen_to.isShaded()) - return m_theme.unshadePressedPixmap().pixmap().drawable(); - else return m_theme.shadePressedPixmap().pixmap().drawable(); + else + return m_theme.unshadePressedPixmap().pixmap().drawable(); case MENUICON: if (m_icon_pixmap.drawable()) if (m_listen_to.isFocused())
M src/Window.ccsrc/Window.cc

@@ -4008,6 +4008,7 @@ dir[i],

frame().titlebar(), 0, 0, 10, 10); + stateSig().attach(winbtn); winbtn->setOnClick(stick_cmd); break; case WinButton::SHADE: