diff options
author | simonb <simonb> | 2006-04-14 14:22:16 (GMT) |
---|---|---|
committer | simonb <simonb> | 2006-04-14 14:22:16 (GMT) |
commit | 0780952b102b48e4448bbd514dad6297899be1e4 (patch) | |
tree | ec2213d7843b82ff8d03d6d2bcc2079970896ca4 /src | |
parent | 33079d2593a7a598446cc837fc39eb2a914ebb1f (diff) | |
download | fluxbox_pavel-0780952b102b48e4448bbd514dad6297899be1e4.zip fluxbox_pavel-0780952b102b48e4448bbd514dad6297899be1e4.tar.bz2 |
fix window button image updates
Diffstat (limited to 'src')
-rw-r--r-- | src/FbTk/Button.cc | 43 | ||||
-rw-r--r-- | src/FbTk/Button.hh | 1 | ||||
-rw-r--r-- | src/WinButton.cc | 4 | ||||
-rw-r--r-- | src/Window.cc | 1 |
4 files changed, 31 insertions, 18 deletions
diff --git a/src/FbTk/Button.cc b/src/FbTk/Button.cc index e2ba7b5..8dba936 100644 --- a/src/FbTk/Button.cc +++ b/src/FbTk/Button.cc | |||
@@ -37,7 +37,8 @@ Button::Button(int screen_num, int x, int y, | |||
37 | m_pressed_pm(0), | 37 | m_pressed_pm(0), |
38 | m_pressed_color(), | 38 | m_pressed_color(), |
39 | m_gc(DefaultGC(FbTk::App::instance()->display(), screen_num)), | 39 | m_gc(DefaultGC(FbTk::App::instance()->display(), screen_num)), |
40 | m_pressed(false) { | 40 | m_pressed(false), |
41 | mark_if_deleted(0) { | ||
41 | 42 | ||
42 | // add this to eventmanager | 43 | // add this to eventmanager |
43 | FbTk::EventManager::instance()->add(*this, *this); | 44 | FbTk::EventManager::instance()->add(*this, *this); |
@@ -51,13 +52,16 @@ Button::Button(const FbWindow &parent, int x, int y, | |||
51 | m_pressed_pm(0), | 52 | m_pressed_pm(0), |
52 | m_pressed_color(), | 53 | m_pressed_color(), |
53 | m_gc(DefaultGC(FbTk::App::instance()->display(), screenNumber())), | 54 | m_gc(DefaultGC(FbTk::App::instance()->display(), screenNumber())), |
54 | m_pressed(false) { | 55 | m_pressed(false), |
56 | mark_if_deleted(0) { | ||
55 | // add this to eventmanager | 57 | // add this to eventmanager |
56 | FbTk::EventManager::instance()->add(*this, *this); | 58 | FbTk::EventManager::instance()->add(*this, *this); |
57 | } | 59 | } |
58 | 60 | ||
59 | Button::~Button() { | 61 | Button::~Button() { |
60 | 62 | if (mark_if_deleted) { | |
63 | *mark_if_deleted = true; | ||
64 | } | ||
61 | } | 65 | } |
62 | 66 | ||
63 | void Button::setOnClick(RefCount<Command> &cmd, int button) { | 67 | void Button::setOnClick(RefCount<Command> &cmd, int button) { |
@@ -107,26 +111,33 @@ void Button::buttonPressEvent(XButtonEvent &event) { | |||
107 | void Button::buttonReleaseEvent(XButtonEvent &event) { | 111 | void Button::buttonReleaseEvent(XButtonEvent &event) { |
108 | m_pressed = false; | 112 | m_pressed = false; |
109 | bool update = false; | 113 | bool update = false; |
110 | if (m_background_pm) { | 114 | bool been_deleted = false; |
111 | if (m_pressed_pm != 0) { | 115 | mark_if_deleted = &been_deleted; |
112 | update = true; | ||
113 | setBackgroundPixmap(m_background_pm); | ||
114 | } | ||
115 | } else if (m_pressed_color.isAllocated()) { | ||
116 | update = true; | ||
117 | setBackgroundColor(m_background_color); | ||
118 | } | ||
119 | |||
120 | if (update) | ||
121 | clear(); // clear background | ||
122 | 116 | ||
123 | // finaly, execute command (this must be done last since this object might be deleted by the command) | 117 | // This command may result in this object being deleted |
118 | // hence the mark_if_deleted mechanism so that we can | ||
119 | // update our state after the command | ||
124 | if (event.button > 0 && event.button <= 5 && | 120 | if (event.button > 0 && event.button <= 5 && |
125 | event.x > 0 && event.x < static_cast<signed>(width()) && | 121 | event.x > 0 && event.x < static_cast<signed>(width()) && |
126 | event.y > 0 && event.y < static_cast<signed>(height()) && | 122 | event.y > 0 && event.y < static_cast<signed>(height()) && |
127 | m_onclick[event.button -1].get() != 0) | 123 | m_onclick[event.button -1].get() != 0) |
128 | m_onclick[event.button - 1]->execute(); | 124 | m_onclick[event.button - 1]->execute(); |
129 | 125 | ||
126 | if (!been_deleted) { | ||
127 | mark_if_deleted = 0; | ||
128 | if (m_background_pm) { | ||
129 | if (m_pressed_pm != 0) { | ||
130 | update = true; | ||
131 | setBackgroundPixmap(m_background_pm); | ||
132 | } | ||
133 | } else if (m_pressed_color.isAllocated()) { | ||
134 | update = true; | ||
135 | setBackgroundColor(m_background_color); | ||
136 | } | ||
137 | |||
138 | if (update) | ||
139 | clear(); // clear background | ||
140 | } | ||
130 | 141 | ||
131 | } | 142 | } |
132 | 143 | ||
diff --git a/src/FbTk/Button.hh b/src/FbTk/Button.hh index fe65f1b..89a754c 100644 --- a/src/FbTk/Button.hh +++ b/src/FbTk/Button.hh | |||
@@ -87,6 +87,7 @@ private: | |||
87 | Color m_pressed_color; | 87 | Color m_pressed_color; |
88 | GC m_gc; ///< graphic context for button | 88 | GC m_gc; ///< graphic context for button |
89 | bool m_pressed; ///< if the button is pressed | 89 | bool m_pressed; ///< if the button is pressed |
90 | bool *mark_if_deleted; ///< if the button is deleted and this is set, make it true | ||
90 | RefCount<Command> m_onclick[5]; ///< what to do when this button is clicked with button num | 91 | RefCount<Command> m_onclick[5]; ///< what to do when this button is clicked with button num |
91 | }; | 92 | }; |
92 | 93 | ||
diff --git a/src/WinButton.cc b/src/WinButton.cc index 6c51a6d..afdfb7f 100644 --- a/src/WinButton.cc +++ b/src/WinButton.cc | |||
@@ -187,9 +187,9 @@ Pixmap WinButton::getPressedPixmap() const { | |||
187 | return m_theme.closePressedPixmap().pixmap().drawable(); | 187 | return m_theme.closePressedPixmap().pixmap().drawable(); |
188 | case SHADE: | 188 | case SHADE: |
189 | if (m_listen_to.isShaded()) | 189 | if (m_listen_to.isShaded()) |
190 | return m_theme.unshadePressedPixmap().pixmap().drawable(); | ||
191 | else | ||
192 | return m_theme.shadePressedPixmap().pixmap().drawable(); | 190 | return m_theme.shadePressedPixmap().pixmap().drawable(); |
191 | else | ||
192 | return m_theme.unshadePressedPixmap().pixmap().drawable(); | ||
193 | case MENUICON: | 193 | case MENUICON: |
194 | if (m_icon_pixmap.drawable()) | 194 | if (m_icon_pixmap.drawable()) |
195 | if (m_listen_to.isFocused()) | 195 | if (m_listen_to.isFocused()) |
diff --git a/src/Window.cc b/src/Window.cc index 6330da5..0504deb 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -4008,6 +4008,7 @@ void FluxboxWindow::setupWindow() { | |||
4008 | frame().titlebar(), | 4008 | frame().titlebar(), |
4009 | 0, 0, 10, 10); | 4009 | 0, 0, 10, 10); |
4010 | 4010 | ||
4011 | stateSig().attach(winbtn); | ||
4011 | winbtn->setOnClick(stick_cmd); | 4012 | winbtn->setOnClick(stick_cmd); |
4012 | break; | 4013 | break; |
4013 | case WinButton::SHADE: | 4014 | case WinButton::SHADE: |