all repos — fluxbox @ 06f63eec84fa37e0832fee0432cd398f55f7aeba

custom fork of the fluxbox windowmanager

added double click interval, fixed actions on titlebar, added hide/show decorations
fluxgen fluxgen
commit

06f63eec84fa37e0832fee0432cd398f55f7aeba

parent

65fe7c36750f0c8418acbdc2732e0095eb344344

2 files changed, 128 insertions(+), 19 deletions(-)

jump to
M src/FbWinFrame.ccsrc/FbWinFrame.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: FbWinFrame.cc,v 1.1 2003/01/05 22:14:10 fluxgen Exp $ +// $Id: FbWinFrame.cc,v 1.2 2003/01/07 01:30:57 fluxgen Exp $ #include "FbWinFrame.hh" #include "ImageControl.hh"

@@ -62,7 +62,7 @@ EnterWindowMask | LeaveWindowMask),

m_clientwin(0), m_bevel(1), m_use_titlebar(true), - m_use_handles(true), + m_use_handle(true), m_button_pm(0) { init(); }

@@ -96,6 +96,23 @@ removeAllButtons();

} +bool FbWinFrame::setOnClickTitlebar(FbTk::RefCount<FbTk::Command> &ref, int mousebutton_num, + bool double_click, bool pressed) { + // find mousebutton_num + if (mousebutton_num < 1 || mousebutton_num > 5) + return false; + if (double_click) + m_commands[mousebutton_num - 1].double_click = ref; + else { + if (pressed) + m_commands[mousebutton_num - 1].click_pressed = ref; + else + m_commands[mousebutton_num - 1].click = ref; + } + + return true; +} + void FbWinFrame::hide() { m_window.hide(); }

@@ -146,6 +163,10 @@ void FbWinFrame::resizeForClient(unsigned int width, unsigned int height) {

// total height for frame without client unsigned int total_height = m_handle.height() + m_titlebar.height(); // resize frame height with total height + specified height + if (!m_use_titlebar) + total_height -= m_titlebar.height(); + if (!m_use_handle) + total_height -= m_handle.height(); resize(width, total_height + height); }

@@ -165,6 +186,10 @@ return;

m_focused = newvalue; reconfigure(); // reconfigure rendering for new focus value +} + +void FbWinFrame::setDoubleClickTime(unsigned int time) { + m_double_click_time = time; } void FbWinFrame::setBevel(int bevel) {

@@ -238,18 +263,41 @@ }

void FbWinFrame::hideTitlebar() { m_titlebar.hide(); + m_use_titlebar = false; } void FbWinFrame::showTitlebar() { m_titlebar.show(); + m_use_titlebar = true; } void FbWinFrame::hideHandle() { m_handle.hide(); + m_grip_left.hide(); + m_grip_right.hide(); + m_use_handle = false; } void FbWinFrame::showHandle() { m_handle.show(); + m_grip_left.show(); + m_grip_right.show(); + m_use_handle = true; +} + +void FbWinFrame::hideAllDecorations() { + hideHandle(); + hideTitlebar(); + resizeForClient(m_clientarea.width(), m_clientarea.height() - m_window.borderWidth()); + reconfigure(); +} + +void FbWinFrame::showAllDecorations() { + if (!m_use_handle) + showHandle(); + if (!m_use_titlebar) + showTitlebar(); + resizeForClient(m_clientarea.width(), m_clientarea.height() - m_window.borderWidth()); } /**

@@ -282,7 +330,37 @@ evm.remove(m_clientarea);

} void FbWinFrame::buttonPressEvent(XButtonEvent &event) { - m_window.raise(); + if (event.window != m_titlebar.window() && + event.window != m_label.window()) + return; + + if (event.button > 5 || event.button < 1) + return; + + if (*m_commands[event.button - 1].click_pressed) { + cerr<<"Pressed event button = "<<event.button<<endl; + m_commands[event.button - 1].click_pressed->execute(); + } +} + +void FbWinFrame::buttonReleaseEvent(XButtonEvent &event) { + if (event.window != m_titlebar.window() && + event.window != m_label.window()) + return; + + if (event.button < 1 || event.button > 5) + return; + + static int last_release_time = 0; + bool double_click = (event.time - last_release_time <= m_double_click_time); + last_release_time = event.time; + int real_button = event.button - 1; + + if (double_click && *m_commands[real_button].double_click) + m_commands[real_button].double_click->execute(); + else if (*m_commands[real_button].click) + m_commands[real_button].click->execute(); + } void FbWinFrame::exposeEvent(XExposeEvent &event) {

@@ -305,17 +383,31 @@ void FbWinFrame::reconfigure() {

m_window.clear(); // align titlebar and render it - reconfigureTitlebar(); + if (m_use_titlebar) + reconfigureTitlebar(); + // setup client area size/pos + int next_y = m_titlebar.height() + 2*m_titlebar.borderWidth(); + unsigned int client_height = m_window.height() - m_titlebar.height() - m_handle.height(); + + if (!m_use_titlebar) { + next_y = 0; + if (!m_use_handle) + client_height = m_window.height(); + else + client_height = m_window.height() - m_handle.height(); + } - m_clientarea.moveResize(0, m_titlebar.height() + 2*m_titlebar.borderWidth(), - m_window.width(), - m_window.height() - m_titlebar.height() - m_handle.height()); + m_clientarea.moveResize(0, next_y, + m_window.width(), client_height); if (m_clientwin != 0) { XMoveResizeWindow(FbTk::App::instance()->display(), m_clientwin, 0, 0, m_clientarea.width(), m_clientarea.height()); } + + if (!m_use_handle) // no need to do anything more + return; // align handle and grips const int grip_height = m_handle.height();

@@ -336,7 +428,6 @@

// render the theme renderButtons(); renderHandles(); - } unsigned int FbWinFrame::titleHeight() const {

@@ -476,7 +567,7 @@ }

void FbWinFrame::renderHandles() { - if (!m_use_handles) + if (!m_use_handle) return; render(m_theme.handleFocusTexture(), m_handle_focused_color, m_handle_focused_pm,

@@ -559,7 +650,7 @@ // clear pixmaps

m_title_focused_pm = m_title_unfocused_pm = 0; m_label_focused_pm = m_label_unfocused_pm = 0; m_button_unfocused_pm = m_button_pressed_pm = 0; - + m_double_click_time = 200; m_button_pm = 0; m_button_size = 26; m_handle_focused_pm =

@@ -567,12 +658,10 @@ m_handle_unfocused_pm = 0;

m_grip_unfocused_pm = m_grip_focused_pm = 0; m_shaded = false; - m_label.show(); - m_titlebar.show(); - m_handle.show(); - m_grip_right.show(); - m_grip_left.show(); + + showHandle(); + showTitlebar(); // note: we don't show clientarea yet setEventHandler(*this);
M src/FbWinFrame.hhsrc/FbWinFrame.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: FbWinFrame.hh,v 1.1 2003/01/05 22:14:10 fluxgen Exp $ +// $Id: FbWinFrame.hh,v 1.2 2003/01/07 01:28:16 fluxgen Exp $ #ifndef FBWINFRAME_HH #define FBWINFRAME_HH

@@ -30,14 +30,17 @@ #include "EventHandler.hh"

#include "Font.hh" #include "Text.hh" #include "FbWinFrameTheme.hh" +#include "RefCount.hh" +#include "Command.hh" #include <vector> #include <string> + class FbWinFrameTheme; class BImageControl; -/// holds a window frame with a client window +/// holds a window frame with a client window (see: <a href="fluxbox_fbwinframe.png">image</a>) class FbWinFrame:public FbTk::EventHandler { public:

@@ -53,6 +56,10 @@

/// destroy frame ~FbWinFrame(); + /// setup actions for titlebar + bool setOnClickTitlebar(FbTk::RefCount<FbTk::Command> &cmd, int button_num, + bool double_click=false, bool pressed=false); + void hide(); void show(); /// shade frame (ie resize to titlebar size)

@@ -66,6 +73,7 @@ /// sets title on the titlebar label

void setTitle(const std::string &title); /// set focus/unfocus style void setFocus(bool newvalue); + void setDoubleClickTime(unsigned int time); void setBevel(int bevel); /// add a button to the left of the label void addLeftButton(FbTk::Button *btn);

@@ -88,12 +96,15 @@ void hideTitlebar();

void showTitlebar(); void hideHandle(); void showHandle(); + void hideAllDecorations(); + void showAllDecorations(); /** @name Event handlers */ //@{ void buttonPressEvent(XButtonEvent &event); + void buttonReleaseEvent(XButtonEvent &event); void exposeEvent(XExposeEvent &event); void configureNotifyEvent(XConfigureEvent &event); void handleEvent(XEvent &event);

@@ -128,7 +139,9 @@ inline const FbTk::FbWindow &gripRight() const { return m_grip_right; }

inline FbTk::FbWindow &gripRight() { return m_grip_right; } inline bool focused() const { return m_focused; } inline bool isShaded() const { return m_shaded; } + /// @return titlebar height unsigned int titleHeight() const; + /// @return size of button unsigned int buttonHeight() const; //@}

@@ -178,8 +191,9 @@

std::string m_titletext; ///< text to be displayed int m_label int m_bevel; ///< bevel between titlebar items and titlebar bool m_use_titlebar; ///< if we should use titlebar - bool m_use_handles; ///< if we should use handles + bool m_use_handle; ///< if we should use handle bool m_focused; ///< focused/unfocused mode + /** @name pixmaps and colors for rendering */

@@ -215,7 +229,13 @@ int m_button_size; ///< size for all titlebar buttons

unsigned int m_width_before_shade, ///< width before shade, so we can restore it when we unshade m_height_before_shade; ///< height before shade, so we can restore it when we unshade bool m_shaded; ///< wheter we're shaded or not - + unsigned int m_double_click_time; ///< the time period that's considerd to be a double click + struct MouseButtonAction { + FbTk::RefCount<FbTk::Command> click; ///< what to do when we release mouse button + FbTk::RefCount<FbTk::Command> click_pressed; ///< what to do when we press mouse button + FbTk::RefCount<FbTk::Command> double_click; ///< what to do when we double click + }; + MouseButtonAction m_commands[5]; ///< hardcoded to five ...TODO, change this }; #endif // FBWINFRAME_HH