diff options
-rw-r--r-- | src/FbTk/EventHandler.hh | 1 | ||||
-rw-r--r-- | src/FbWinFrame.cc | 66 | ||||
-rw-r--r-- | src/FbWinFrame.hh | 14 | ||||
-rw-r--r-- | src/FocusableList.cc | 4 | ||||
-rw-r--r-- | src/Keys.cc | 12 | ||||
-rw-r--r-- | src/Keys.hh | 8 | ||||
-rw-r--r-- | src/Screen.cc | 2 | ||||
-rw-r--r-- | src/Toolbar.cc | 2 | ||||
-rw-r--r-- | src/Window.cc | 117 |
9 files changed, 73 insertions, 153 deletions
diff --git a/src/FbTk/EventHandler.hh b/src/FbTk/EventHandler.hh index 45c7a2a..96ecd79 100644 --- a/src/FbTk/EventHandler.hh +++ b/src/FbTk/EventHandler.hh | |||
@@ -59,6 +59,7 @@ public: | |||
59 | virtual void enterNotifyEvent(XCrossingEvent &) { } | 59 | virtual void enterNotifyEvent(XCrossingEvent &) { } |
60 | 60 | ||
61 | virtual void notifyUngrabKeyboard() { } | 61 | virtual void notifyUngrabKeyboard() { } |
62 | virtual void grabButtons() { } | ||
62 | }; | 63 | }; |
63 | 64 | ||
64 | } // end namespace FbTk | 65 | } // end namespace FbTk |
diff --git a/src/FbWinFrame.cc b/src/FbWinFrame.cc index cc7d379..83610ea 100644 --- a/src/FbWinFrame.cc +++ b/src/FbWinFrame.cc | |||
@@ -96,7 +96,6 @@ FbWinFrame::FbWinFrame(BScreen &screen, FbWinFrameTheme &theme, FbTk::ImageContr | |||
96 | m_shaded(false), | 96 | m_shaded(false), |
97 | m_focused_alpha(0), | 97 | m_focused_alpha(0), |
98 | m_unfocused_alpha(0), | 98 | m_unfocused_alpha(0), |
99 | m_double_click_time(0), | ||
100 | m_themelistener(*this), | 99 | m_themelistener(*this), |
101 | m_shape(m_window, theme.shapePlace()), | 100 | m_shape(m_window, theme.shapePlace()), |
102 | m_disable_themeshape(false) { | 101 | m_disable_themeshape(false) { |
@@ -109,23 +108,6 @@ FbWinFrame::~FbWinFrame() { | |||
109 | removeAllButtons(); | 108 | removeAllButtons(); |
110 | } | 109 | } |
111 | 110 | ||
112 | bool FbWinFrame::setOnClickTitlebar(FbTk::RefCount<FbTk::Command> &ref, int mousebutton_num, | ||
113 | bool double_click, bool pressed) { | ||
114 | // find mousebutton_num | ||
115 | if (mousebutton_num < 1 || mousebutton_num > 5) | ||
116 | return false; | ||
117 | if (double_click) | ||
118 | m_commands[mousebutton_num - 1].double_click = ref; | ||
119 | else { | ||
120 | if (pressed) | ||
121 | m_commands[mousebutton_num - 1].click_pressed = ref; | ||
122 | else | ||
123 | m_commands[mousebutton_num - 1].click = ref; | ||
124 | } | ||
125 | |||
126 | return true; | ||
127 | } | ||
128 | |||
129 | bool FbWinFrame::setTabMode(TabMode tabmode) { | 111 | bool FbWinFrame::setTabMode(TabMode tabmode) { |
130 | if (m_tabmode == tabmode) | 112 | if (m_tabmode == tabmode) |
131 | return false; | 113 | return false; |
@@ -570,10 +552,6 @@ void FbWinFrame::setUseDefaultAlpha(bool default_alpha) | |||
570 | } | 552 | } |
571 | } | 553 | } |
572 | 554 | ||
573 | void FbWinFrame::setDoubleClickTime(unsigned int time) { | ||
574 | m_double_click_time = time; | ||
575 | } | ||
576 | |||
577 | void FbWinFrame::addLeftButton(FbTk::Button *btn) { | 555 | void FbWinFrame::addLeftButton(FbTk::Button *btn) { |
578 | if (btn == 0) // valid button? | 556 | if (btn == 0) // valid button? |
579 | return; | 557 | return; |
@@ -685,7 +663,7 @@ void FbWinFrame::setClientWindow(FbTk::FbWindow &win) { | |||
685 | win.reparent(m_window, 0, clientArea().y()); | 663 | win.reparent(m_window, 0, clientArea().y()); |
686 | // remask window so we get events | 664 | // remask window so we get events |
687 | win.setEventMask(PropertyChangeMask | StructureNotifyMask | | 665 | win.setEventMask(PropertyChangeMask | StructureNotifyMask | |
688 | FocusChangeMask); | 666 | FocusChangeMask | KeyPressMask); |
689 | 667 | ||
690 | m_window.setEventMask(ButtonPressMask | ButtonReleaseMask | | 668 | m_window.setEventMask(ButtonPressMask | ButtonReleaseMask | |
691 | ButtonMotionMask | EnterWindowMask | SubstructureRedirectMask); | 669 | ButtonMotionMask | EnterWindowMask | SubstructureRedirectMask); |
@@ -855,47 +833,6 @@ void FbWinFrame::removeEventHandler() { | |||
855 | evm.remove(m_clientarea); | 833 | evm.remove(m_clientarea); |
856 | } | 834 | } |
857 | 835 | ||
858 | void FbWinFrame::buttonPressEvent(XButtonEvent &event) { | ||
859 | m_tab_container.tryButtonPressEvent(event); | ||
860 | if (event.window == m_grip_right.window() || | ||
861 | event.window == m_grip_left.window() || | ||
862 | event.window == m_clientarea.window() || | ||
863 | event.window == m_window.window()) | ||
864 | return; | ||
865 | // we handle only buttons 0 to 5 | ||
866 | if (event.button > 5 || event.button < 1) | ||
867 | return; | ||
868 | |||
869 | if (*m_commands[event.button - 1].click_pressed) | ||
870 | m_commands[event.button - 1].click_pressed->execute(); | ||
871 | } | ||
872 | |||
873 | void FbWinFrame::buttonReleaseEvent(XButtonEvent &event) { | ||
874 | // we continue even if a button got the event | ||
875 | m_tab_container.tryButtonReleaseEvent(event); | ||
876 | |||
877 | if (event.window == m_grip_right.window() || | ||
878 | event.window == m_grip_left.window() || | ||
879 | event.window == m_clientarea.window() || | ||
880 | event.window == m_handle.window() || | ||
881 | event.window == m_window.window()) | ||
882 | return; | ||
883 | |||
884 | if (event.button < 1 || event.button > 5) | ||
885 | return; | ||
886 | |||
887 | static Time last_release_time = 0; | ||
888 | bool double_click = (event.time - last_release_time <= m_double_click_time); | ||
889 | last_release_time = event.time; | ||
890 | int real_button = event.button - 1; | ||
891 | |||
892 | if (double_click && *m_commands[real_button].double_click) | ||
893 | m_commands[real_button].double_click->execute(); | ||
894 | else if (*m_commands[real_button].click) | ||
895 | m_commands[real_button].click->execute(); | ||
896 | |||
897 | } | ||
898 | |||
899 | void FbWinFrame::exposeEvent(XExposeEvent &event) { | 836 | void FbWinFrame::exposeEvent(XExposeEvent &event) { |
900 | if (m_titlebar == event.window) { | 837 | if (m_titlebar == event.window) { |
901 | m_titlebar.clearArea(event.x, event.y, event.width, event.height); | 838 | m_titlebar.clearArea(event.x, event.y, event.width, event.height); |
@@ -1409,7 +1346,6 @@ void FbWinFrame::init() { | |||
1409 | m_button_pm = m_button_unfocused_pm = m_button_pressed_pm = 0; | 1346 | m_button_pm = m_button_unfocused_pm = m_button_pressed_pm = 0; |
1410 | m_grip_unfocused_pm = m_grip_focused_pm = 0; | 1347 | m_grip_unfocused_pm = m_grip_focused_pm = 0; |
1411 | 1348 | ||
1412 | m_double_click_time = 200; | ||
1413 | m_button_size = 26; | 1349 | m_button_size = 26; |
1414 | 1350 | ||
1415 | m_clientarea.setBorderWidth(0); | 1351 | m_clientarea.setBorderWidth(0); |
diff --git a/src/FbWinFrame.hh b/src/FbWinFrame.hh index bdc2add..9bd29dd 100644 --- a/src/FbWinFrame.hh +++ b/src/FbWinFrame.hh | |||
@@ -88,10 +88,6 @@ public: | |||
88 | /// destroy frame | 88 | /// destroy frame |
89 | ~FbWinFrame(); | 89 | ~FbWinFrame(); |
90 | 90 | ||
91 | /// setup actions for titlebar | ||
92 | bool setOnClickTitlebar(FbTk::RefCount<FbTk::Command> &cmd, int button_num, | ||
93 | bool double_click=false, bool pressed=false); | ||
94 | |||
95 | void hide(); | 91 | void hide(); |
96 | void show(); | 92 | void show(); |
97 | inline bool isVisible() const { return m_visible; } | 93 | inline bool isVisible() const { return m_visible; } |
@@ -124,7 +120,6 @@ public: | |||
124 | /// set focus/unfocus style | 120 | /// set focus/unfocus style |
125 | void setFocus(bool newvalue); | 121 | void setFocus(bool newvalue); |
126 | inline void setFocusTitle(const std::string &str) { m_label.setText(str); } | 122 | inline void setFocusTitle(const std::string &str) { m_label.setText(str); } |
127 | void setDoubleClickTime(unsigned int time); | ||
128 | bool setTabMode(TabMode tabmode); | 123 | bool setTabMode(TabMode tabmode); |
129 | inline void updateTabProperties() { alignTabs(); } | 124 | inline void updateTabProperties() { alignTabs(); } |
130 | 125 | ||
@@ -186,8 +181,6 @@ public: | |||
186 | @name Event handlers | 181 | @name Event handlers |
187 | */ | 182 | */ |
188 | //@{ | 183 | //@{ |
189 | void buttonPressEvent(XButtonEvent &event); | ||
190 | void buttonReleaseEvent(XButtonEvent &event); | ||
191 | void exposeEvent(XExposeEvent &event); | 184 | void exposeEvent(XExposeEvent &event); |
192 | void configureNotifyEvent(XConfigureEvent &event); | 185 | void configureNotifyEvent(XConfigureEvent &event); |
193 | void handleEvent(XEvent &event); | 186 | void handleEvent(XEvent &event); |
@@ -377,13 +370,6 @@ private: | |||
377 | bool m_shaded; ///< wheter we're shaded or not | 370 | bool m_shaded; ///< wheter we're shaded or not |
378 | unsigned char m_focused_alpha; ///< focused alpha value | 371 | unsigned char m_focused_alpha; ///< focused alpha value |
379 | unsigned char m_unfocused_alpha; ///< unfocused alpha value | 372 | unsigned char m_unfocused_alpha; ///< unfocused alpha value |
380 | unsigned int m_double_click_time; ///< the time period that's considerd to be a double click | ||
381 | struct MouseButtonAction { | ||
382 | FbTk::RefCount<FbTk::Command> click; ///< what to do when we release mouse button | ||
383 | FbTk::RefCount<FbTk::Command> click_pressed; ///< what to do when we press mouse button | ||
384 | FbTk::RefCount<FbTk::Command> double_click; ///< what to do when we double click | ||
385 | }; | ||
386 | MouseButtonAction m_commands[5]; ///< hardcoded to five ... //!! TODO, change this | ||
387 | 373 | ||
388 | class ThemeListener: public FbTk::Observer { | 374 | class ThemeListener: public FbTk::Observer { |
389 | public: | 375 | public: |
diff --git a/src/FocusableList.cc b/src/FocusableList.cc index 8a5c8f7..8c43181 100644 --- a/src/FocusableList.cc +++ b/src/FocusableList.cc | |||
@@ -126,11 +126,11 @@ void FocusableList::update(FbTk::Subject *subj) { | |||
126 | FocusableListSubject *fsubj = | 126 | FocusableListSubject *fsubj = |
127 | static_cast<FocusableListSubject *>(subj); | 127 | static_cast<FocusableListSubject *>(subj); |
128 | if (subj == &m_parent->addSig()) { | 128 | if (subj == &m_parent->addSig()) { |
129 | attachSignals(*fsubj->win()); | ||
129 | if (m_pat->match(*fsubj->win())) { | 130 | if (m_pat->match(*fsubj->win())) { |
130 | insertFromParent(*fsubj->win()); | 131 | insertFromParent(*fsubj->win()); |
131 | m_addsig.notify(fsubj->win()); | 132 | m_addsig.notify(fsubj->win()); |
132 | } else // we still want to watch it, in case it changes to match | 133 | } |
133 | attachSignals(*fsubj->win()); | ||
134 | } else if (subj == &m_parent->removeSig()) | 134 | } else if (subj == &m_parent->removeSig()) |
135 | remove(*fsubj->win()); | 135 | remove(*fsubj->win()); |
136 | else if (subj == &m_parent->resetSig()) | 136 | else if (subj == &m_parent->resetSig()) |
diff --git a/src/Keys.cc b/src/Keys.cc index 7e6c93e..2d26ab8 100644 --- a/src/Keys.cc +++ b/src/Keys.cc | |||
@@ -168,6 +168,7 @@ void Keys::grabWindow(Window win) { | |||
168 | if (win_it == m_window_map.end()) | 168 | if (win_it == m_window_map.end()) |
169 | return; | 169 | return; |
170 | 170 | ||
171 | m_handler_map[win]->grabButtons(); | ||
171 | keylist_t::iterator it = m_keylist->keylist.begin(); | 172 | keylist_t::iterator it = m_keylist->keylist.begin(); |
172 | keylist_t::iterator it_end = m_keylist->keylist.end(); | 173 | keylist_t::iterator it_end = m_keylist->keylist.end(); |
173 | for (; it != it_end; ++it) { | 174 | for (; it != it_end; ++it) { |
@@ -428,8 +429,9 @@ bool Keys::doAction(int type, unsigned int mods, unsigned int key, | |||
428 | } | 429 | } |
429 | 430 | ||
430 | /// adds the window to m_window_map, so we know to grab buttons on it | 431 | /// adds the window to m_window_map, so we know to grab buttons on it |
431 | void Keys::registerWindow(Window win, int context) { | 432 | void Keys::registerWindow(Window win, FbTk::EventHandler &h, int context) { |
432 | m_window_map[win] = context; | 433 | m_window_map[win] = context; |
434 | m_handler_map[win] = &h; | ||
433 | grabWindow(win); | 435 | grabWindow(win); |
434 | } | 436 | } |
435 | 437 | ||
@@ -437,6 +439,7 @@ void Keys::registerWindow(Window win, int context) { | |||
437 | void Keys::unregisterWindow(Window win) { | 439 | void Keys::unregisterWindow(Window win) { |
438 | FbTk::KeyUtil::ungrabKeys(win); | 440 | FbTk::KeyUtil::ungrabKeys(win); |
439 | FbTk::KeyUtil::ungrabButtons(win); | 441 | FbTk::KeyUtil::ungrabButtons(win); |
442 | m_handler_map.erase(win); | ||
440 | m_window_map.erase(win); | 443 | m_window_map.erase(win); |
441 | } | 444 | } |
442 | 445 | ||
@@ -459,6 +462,13 @@ void Keys::keyMode(string keyMode) { | |||
459 | void Keys::setKeyMode(t_key *keyMode) { | 462 | void Keys::setKeyMode(t_key *keyMode) { |
460 | ungrabKeys(); | 463 | ungrabKeys(); |
461 | ungrabButtons(); | 464 | ungrabButtons(); |
465 | |||
466 | // notify handlers that their buttons have been ungrabbed | ||
467 | HandlerMap::iterator h_it = m_handler_map.begin(), | ||
468 | h_it_end = m_handler_map.end(); | ||
469 | for (; h_it != h_it_end; ++h_it) | ||
470 | h_it->second->grabButtons(); | ||
471 | |||
462 | keylist_t::iterator it = keyMode->keylist.begin(); | 472 | keylist_t::iterator it = keyMode->keylist.begin(); |
463 | keylist_t::iterator it_end = keyMode->keylist.end(); | 473 | keylist_t::iterator it_end = keyMode->keylist.end(); |
464 | for (; it != it_end; ++it) { | 474 | for (; it != it_end; ++it) { |
diff --git a/src/Keys.hh b/src/Keys.hh index 2fca460..a8684ed 100644 --- a/src/Keys.hh +++ b/src/Keys.hh | |||
@@ -34,6 +34,10 @@ | |||
34 | #include "FbTk/Command.hh" | 34 | #include "FbTk/Command.hh" |
35 | #include "FbTk/KeyUtil.hh" | 35 | #include "FbTk/KeyUtil.hh" |
36 | 36 | ||
37 | namespace FbTk { | ||
38 | class EventHandler; | ||
39 | } | ||
40 | |||
37 | class Keys:private FbTk::NotCopyable { | 41 | class Keys:private FbTk::NotCopyable { |
38 | public: | 42 | public: |
39 | 43 | ||
@@ -78,7 +82,7 @@ public: | |||
78 | bool doAction(int type, unsigned int mods, unsigned int key, int context); | 82 | bool doAction(int type, unsigned int mods, unsigned int key, int context); |
79 | 83 | ||
80 | /// register a window so that proper keys/buttons get grabbed on it | 84 | /// register a window so that proper keys/buttons get grabbed on it |
81 | void registerWindow(Window win, int context); | 85 | void registerWindow(Window win, FbTk::EventHandler &handler, int context); |
82 | /// unregister window | 86 | /// unregister window |
83 | void unregisterWindow(Window win); | 87 | void unregisterWindow(Window win); |
84 | 88 | ||
@@ -145,7 +149,9 @@ private: | |||
145 | Display *m_display; ///< display connection | 149 | Display *m_display; ///< display connection |
146 | 150 | ||
147 | typedef std::map<Window, int> WindowMap; | 151 | typedef std::map<Window, int> WindowMap; |
152 | typedef std::map<Window, FbTk::EventHandler*> HandlerMap; | ||
148 | WindowMap m_window_map; | 153 | WindowMap m_window_map; |
154 | HandlerMap m_handler_map; | ||
149 | }; | 155 | }; |
150 | 156 | ||
151 | #endif // KEYS_HH | 157 | #endif // KEYS_HH |
diff --git a/src/Screen.cc b/src/Screen.cc index 1557409..0c26a70 100644 --- a/src/Screen.cc +++ b/src/Screen.cc | |||
@@ -431,7 +431,7 @@ BScreen::BScreen(FbTk::ResourceManager &rm, | |||
431 | evm->add(*this, rootWindow()); | 431 | evm->add(*this, rootWindow()); |
432 | Keys *keys = Fluxbox::instance()->keys(); | 432 | Keys *keys = Fluxbox::instance()->keys(); |
433 | if (keys) | 433 | if (keys) |
434 | keys->registerWindow(rootWindow().window(), | 434 | keys->registerWindow(rootWindow().window(), *this, |
435 | Keys::GLOBAL|Keys::ON_DESKTOP); | 435 | Keys::GLOBAL|Keys::ON_DESKTOP); |
436 | rootWindow().setCursor(XCreateFontCursor(disp, XC_left_ptr)); | 436 | rootWindow().setCursor(XCreateFontCursor(disp, XC_left_ptr)); |
437 | 437 | ||
diff --git a/src/Toolbar.cc b/src/Toolbar.cc index 54ee239..32925de 100644 --- a/src/Toolbar.cc +++ b/src/Toolbar.cc | |||
@@ -280,7 +280,7 @@ Toolbar::Toolbar(BScreen &scrn, FbTk::XLayer &layer, size_t width): | |||
280 | scrn.resourceManager().unlock(); | 280 | scrn.resourceManager().unlock(); |
281 | // setup to listen to child events | 281 | // setup to listen to child events |
282 | FbTk::EventManager::instance()->addParent(*this, window()); | 282 | FbTk::EventManager::instance()->addParent(*this, window()); |
283 | Fluxbox::instance()->keys()->registerWindow(window().window(), | 283 | Fluxbox::instance()->keys()->registerWindow(window().window(), *this, |
284 | Keys::ON_TOOLBAR); | 284 | Keys::ON_TOOLBAR); |
285 | // get everything together | 285 | // get everything together |
286 | reconfigure(); | 286 | reconfigure(); |
diff --git a/src/Window.cc b/src/Window.cc index 78b30c2..0fb8673 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -289,7 +289,7 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbWinFrameTheme &tm, | |||
289 | screen().focusControl().addFocusWinBack(*this); | 289 | screen().focusControl().addFocusWinBack(*this); |
290 | 290 | ||
291 | Fluxbox::instance()->keys()->registerWindow(frame().window().window(), | 291 | Fluxbox::instance()->keys()->registerWindow(frame().window().window(), |
292 | Keys::ON_WINDOW); | 292 | *this, Keys::ON_WINDOW); |
293 | 293 | ||
294 | } | 294 | } |
295 | 295 | ||
@@ -479,8 +479,6 @@ void FluxboxWindow::init() { | |||
479 | 479 | ||
480 | applyDecorations(true); | 480 | applyDecorations(true); |
481 | 481 | ||
482 | grabButtons(); | ||
483 | |||
484 | restoreAttributes(); | 482 | restoreAttributes(); |
485 | 483 | ||
486 | if (m_workspace_number >= screen().numberOfWorkspaces()) | 484 | if (m_workspace_number >= screen().numberOfWorkspaces()) |
@@ -1062,9 +1060,6 @@ void FluxboxWindow::reconfigure() { | |||
1062 | 1060 | ||
1063 | moveResize(frame().x(), frame().y(), frame().width(), frame().height()); | 1061 | moveResize(frame().x(), frame().y(), frame().width(), frame().height()); |
1064 | 1062 | ||
1065 | grabButtons(); | ||
1066 | |||
1067 | frame().setDoubleClickTime(Fluxbox::instance()->getDoubleClickInterval()); | ||
1068 | m_timer.setTimeout(Fluxbox::instance()->getAutoRaiseDelay()); | 1063 | m_timer.setTimeout(Fluxbox::instance()->getAutoRaiseDelay()); |
1069 | 1064 | ||
1070 | updateButtons(); | 1065 | updateButtons(); |
@@ -1072,29 +1067,6 @@ void FluxboxWindow::reconfigure() { | |||
1072 | 1067 | ||
1073 | menu().reconfigure(); | 1068 | menu().reconfigure(); |
1074 | 1069 | ||
1075 | typedef FbTk::RefCount<FbTk::Command> CommandRef; | ||
1076 | typedef FbTk::SimpleCommand<FluxboxWindow> WindowCmd; | ||
1077 | CommandRef shade_on_cmd(new WindowCmd(*this, &FluxboxWindow::shadeOn)); | ||
1078 | CommandRef shade_off_cmd(new WindowCmd(*this, &FluxboxWindow::shadeOff)); | ||
1079 | CommandRef next_tab_cmd(new WindowCmd(*this, &FluxboxWindow::nextClient)); | ||
1080 | CommandRef prev_tab_cmd(new WindowCmd(*this, &FluxboxWindow::prevClient)); | ||
1081 | CommandRef null_cmd; | ||
1082 | |||
1083 | int reverse = 0; | ||
1084 | if (screen().getScrollReverse()) | ||
1085 | reverse = 1; | ||
1086 | |||
1087 | if (StringUtil::toLower(screen().getScrollAction()) == string("shade")) { | ||
1088 | frame().setOnClickTitlebar(shade_on_cmd, 5 - reverse); // shade on mouse roll | ||
1089 | frame().setOnClickTitlebar(shade_off_cmd, 4 + reverse); // unshade if rolled oposite direction | ||
1090 | } else if (StringUtil::toLower(screen().getScrollAction()) == string("nexttab")) { | ||
1091 | frame().setOnClickTitlebar(next_tab_cmd, 5 - reverse); // next tab | ||
1092 | frame().setOnClickTitlebar(prev_tab_cmd, 4 + reverse); // previous tab | ||
1093 | } else { | ||
1094 | frame().setOnClickTitlebar(null_cmd, 4); | ||
1095 | frame().setOnClickTitlebar(null_cmd, 5); | ||
1096 | } | ||
1097 | |||
1098 | Client2ButtonMap::iterator it = m_labelbuttons.begin(), | 1070 | Client2ButtonMap::iterator it = m_labelbuttons.begin(), |
1099 | it_end = m_labelbuttons.end(); | 1071 | it_end = m_labelbuttons.end(); |
1100 | for (; it != it_end; ++it) | 1072 | for (; it != it_end; ++it) |
@@ -2584,14 +2556,20 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent &be) { | |||
2584 | return; | 2556 | return; |
2585 | } | 2557 | } |
2586 | 2558 | ||
2587 | // check frame events first | 2559 | frame().tabcontainer().tryButtonPressEvent(be); |
2588 | frame().buttonPressEvent(be); | ||
2589 | |||
2590 | if (be.button == 1) { | 2560 | if (be.button == 1) { |
2591 | if (!m_focused && acceptsFocus()) //check focus | 2561 | if (!m_focused && acceptsFocus()) //check focus |
2592 | focus(); | 2562 | focus(); |
2593 | 2563 | ||
2594 | if (frame().window().window() == be.window || frame().tabcontainer().window() == be.window) { | 2564 | // click on titlebar |
2565 | if (frame().gripLeft().window() != be.window && | ||
2566 | frame().gripRight().window() != be.window && | ||
2567 | frame().clientArea().window() != be.window && | ||
2568 | frame().window() != be.window) | ||
2569 | raise(); | ||
2570 | |||
2571 | if (frame().window().window() == be.window || | ||
2572 | frame().tabcontainer().window() == be.window) { | ||
2595 | if (screen().clickRaises()) | 2573 | if (screen().clickRaises()) |
2596 | raise(); | 2574 | raise(); |
2597 | #ifdef DEBUG | 2575 | #ifdef DEBUG |
@@ -2618,8 +2596,44 @@ void FluxboxWindow::buttonReleaseEvent(XButtonEvent &re) { | |||
2618 | stopResizing(); | 2596 | stopResizing(); |
2619 | else if (m_attaching_tab) | 2597 | else if (m_attaching_tab) |
2620 | attachTo(re.x_root, re.y_root); | 2598 | attachTo(re.x_root, re.y_root); |
2621 | else | 2599 | else { |
2622 | frame().buttonReleaseEvent(re); | 2600 | frame().tabcontainer().tryButtonReleaseEvent(re); |
2601 | if (frame().gripLeft().window() == re.window || | ||
2602 | frame().gripRight().window() == re.window || | ||
2603 | frame().clientArea().window() == re.window || | ||
2604 | frame().handle().window() == re.window || | ||
2605 | frame().window() == re.window) | ||
2606 | return; | ||
2607 | |||
2608 | static Time last_release_time = 0; | ||
2609 | bool double_click = (re.time - last_release_time <= | ||
2610 | Fluxbox::instance()->getDoubleClickInterval()); | ||
2611 | last_release_time = re.time; | ||
2612 | |||
2613 | if (re.button == 1 && double_click) | ||
2614 | shade(); | ||
2615 | if (re.button == 3) | ||
2616 | popupMenu(); | ||
2617 | if (re.button == 2) | ||
2618 | lower(); | ||
2619 | |||
2620 | unsigned int reverse = (screen().getScrollReverse() ? 1 : 0); | ||
2621 | if (re.button == 4 || re.button == 5) { | ||
2622 | if (StringUtil::toLower(screen().getScrollAction()) == "shade") { | ||
2623 | if (re.button == 5 - reverse) | ||
2624 | shadeOn(); | ||
2625 | else | ||
2626 | shadeOff(); | ||
2627 | } | ||
2628 | if (StringUtil::toLower(screen().getScrollAction()) == "nexttab") { | ||
2629 | if (re.button == 5 - reverse) | ||
2630 | nextClient(); | ||
2631 | else | ||
2632 | prevClient(); | ||
2633 | } | ||
2634 | } | ||
2635 | } | ||
2636 | |||
2623 | } | 2637 | } |
2624 | 2638 | ||
2625 | 2639 | ||
@@ -3774,19 +3788,6 @@ void FluxboxWindow::setupWindow() { | |||
3774 | // we allow both to be done at once to share the commands | 3788 | // we allow both to be done at once to share the commands |
3775 | 3789 | ||
3776 | using namespace FbTk; | 3790 | using namespace FbTk; |
3777 | typedef RefCount<Command> CommandRef; | ||
3778 | typedef SimpleCommand<FluxboxWindow> WindowCmd; | ||
3779 | |||
3780 | CommandRef shade_cmd(new WindowCmd(*this, &FluxboxWindow::shade)); | ||
3781 | CommandRef shade_on_cmd(new WindowCmd(*this, &FluxboxWindow::shadeOn)); | ||
3782 | CommandRef shade_off_cmd(new WindowCmd(*this, &FluxboxWindow::shadeOff)); | ||
3783 | CommandRef next_tab_cmd(new WindowCmd(*this, &FluxboxWindow::nextClient)); | ||
3784 | CommandRef prev_tab_cmd(new WindowCmd(*this, &FluxboxWindow::prevClient)); | ||
3785 | CommandRef lower_cmd(new WindowCmd(*this, &FluxboxWindow::lower)); | ||
3786 | CommandRef raise_and_focus_cmd(new WindowCmd(*this, &FluxboxWindow::raiseAndFocus)); | ||
3787 | CommandRef stick_cmd(new WindowCmd(*this, &FluxboxWindow::stick)); | ||
3788 | CommandRef show_menu_cmd(new WindowCmd(*this, &FluxboxWindow::popupMenu)); | ||
3789 | |||
3790 | typedef FbTk::Resource<vector<WinButton::Type> > WinButtonsResource; | 3791 | typedef FbTk::Resource<vector<WinButton::Type> > WinButtonsResource; |
3791 | 3792 | ||
3792 | string titlebar_name[2]; | 3793 | string titlebar_name[2]; |
@@ -3842,26 +3843,6 @@ void FluxboxWindow::setupWindow() { | |||
3842 | 3843 | ||
3843 | updateButtons(); | 3844 | updateButtons(); |
3844 | 3845 | ||
3845 | // setup titlebar | ||
3846 | frame().setOnClickTitlebar(raise_and_focus_cmd, 1, false, true); // on press with button 1 | ||
3847 | frame().setOnClickTitlebar(shade_cmd, 1, true); // doubleclick with button 1 | ||
3848 | frame().setOnClickTitlebar(show_menu_cmd, 3); // on release with button 3 | ||
3849 | frame().setOnClickTitlebar(lower_cmd, 2); // on release with button 2 | ||
3850 | |||
3851 | int reverse = 0; | ||
3852 | if (screen().getScrollReverse()) | ||
3853 | reverse = 1; | ||
3854 | |||
3855 | if (StringUtil::toLower(screen().getScrollAction()) == string("shade")) { | ||
3856 | frame().setOnClickTitlebar(shade_on_cmd, 5 - reverse); // shade on mouse roll | ||
3857 | frame().setOnClickTitlebar(shade_off_cmd, 4 + reverse); // unshade if rolled oposite direction | ||
3858 | } else if (StringUtil::toLower(screen().getScrollAction()) == string("nexttab")) { | ||
3859 | frame().setOnClickTitlebar(next_tab_cmd, 5 - reverse); // next tab | ||
3860 | frame().setOnClickTitlebar(prev_tab_cmd, 4 + reverse); // previous tab | ||
3861 | } | ||
3862 | |||
3863 | frame().setDoubleClickTime(Fluxbox::instance()->getDoubleClickInterval()); | ||
3864 | |||
3865 | // end setup frame | 3846 | // end setup frame |
3866 | 3847 | ||
3867 | } | 3848 | } |