all repos — fluxbox @ 885ddd9322ea4a175e992e4a6fe757d19e8e86e2

custom fork of the fluxbox windowmanager

using number for buttons and max five buttons
fluxgen fluxgen
commit

885ddd9322ea4a175e992e4a6fe757d19e8e86e2

parent

2202914053a7fe1d586dfed19ad41965b51fa4b1

2 files changed, 18 insertions(+), 29 deletions(-)

jump to
M src/FbTk/Button.ccsrc/FbTk/Button.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: Button.cc,v 1.2 2002/12/16 11:05:35 fluxgen Exp $ +// $Id: Button.cc,v 1.3 2002/12/25 11:27:29 fluxgen Exp $ #include "Button.hh"

@@ -54,6 +54,14 @@ }

Button::~Button() { FbTk::EventManager::instance()->remove(m_win); +} + +void Button::setOnClick(RefCount<Command> &cmd, int button) { + // we only handle buttons 1 to 5 + if (button > 5 || button == 0) + return; + //set on click command for the button + m_onclick[button - 1] = cmd; } void Button::move(int x, int y) {

@@ -124,23 +132,9 @@ if (event.x < 0 || event.y < 0 ||

event.x > width() || event.y > height()) return; - // call commands - switch (event.button) { - case Button1: - if (*m_onclick_left != 0) - m_onclick_left->execute(); - break; - case Button2: - if (*m_onclick_middle != 0) - m_onclick_middle->execute(); - break; - case Button3: - if (*m_onclick_right != 0) - m_onclick_right->execute(); - break; - }; - - + if (event.button > 0 && event.button <= 5) + m_onclick[event.button - 1]->execute(); + } void Button::exposeEvent(XExposeEvent &event) {
M src/FbTk/Button.hhsrc/FbTk/Button.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: Button.hh,v 1.2 2002/12/16 11:02:41 fluxgen Exp $ +// $Id: Button.hh,v 1.3 2002/12/25 11:28:43 fluxgen Exp $ #ifndef FBTK_BUTTON_HH #define FBTK_BUTTON_HH

@@ -41,13 +41,10 @@ private NotCopyable {

public: Button(int screen_num, int x, int y, unsigned int width, unsigned int height); Button(const FbWindow &parent, int x, int y, unsigned int width, unsigned int height); - virtual ~Button(); - /// sets action when the button is clicked with left mouse btn - void setOnClick(RefCount<Command> &com) { m_onclick_left = com; } - /// sets action when the button is clicked with middle mouse btn - void setOnClickMiddle(RefCount<Command> &com) { m_onclick_middle = com; } - /// sets action when the button is clicked with right mouse btn - void setOnClickRight(RefCount<Command> &com) { m_onclick_right = com; } + virtual ~Button(); + + /// sets action when the button is clicked with #button mouse btn + void setOnClick(RefCount<Command> &com, int button = 1); void move(int x, int y); void resize(unsigned int width, unsigned int height);

@@ -100,9 +97,7 @@ Color m_background_color; ///< background color

Pixmap m_pressed_pm; ///< pressed pixmap GC m_gc; ///< graphic context for button bool m_pressed; ///< if the button is pressed - RefCount<Command> m_onclick_left; ///< what to do when this button is clicked with lmb - RefCount<Command> m_onclick_middle; ///< what to do when this button is clicked with mmb - RefCount<Command> m_onclick_right; ///< what to do when this button is clicked with rmb + RefCount<Command> m_onclick[5]; ///< what to do when this button is clicked with button num }; };