summaryrefslogtreecommitdiff
path: root/src/Window.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Window.cc')
-rw-r--r--src/Window.cc117
1 files changed, 49 insertions, 68 deletions
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}