diff options
Diffstat (limited to 'src/Window.cc')
-rw-r--r-- | src/Window.cc | 101 |
1 files changed, 30 insertions, 71 deletions
diff --git a/src/Window.cc b/src/Window.cc index 56cbd96..bf100e2 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -812,16 +812,10 @@ FluxboxWindow::ClientList::iterator FluxboxWindow::getClientInsertPosition(int x | |||
812 | &labelbutton)) | 812 | &labelbutton)) |
813 | return m_clientlist.end(); | 813 | return m_clientlist.end(); |
814 | 814 | ||
815 | Client2ButtonMap::iterator it = | 815 | WinClient* c = winClientOfLabelButtonWindow(labelbutton); |
816 | find_if(m_labelbuttons.begin(), | ||
817 | m_labelbuttons.end(), | ||
818 | Compose(bind2nd(equal_to<Window>(), labelbutton), | ||
819 | Compose(mem_fun(&TextButton::window), | ||
820 | Select2nd<Client2ButtonMap::value_type>()))); | ||
821 | |||
822 | 816 | ||
823 | // label button not found | 817 | // label button not found |
824 | if (it == m_labelbuttons.end()) | 818 | if (!c) |
825 | return m_clientlist.end(); | 819 | return m_clientlist.end(); |
826 | 820 | ||
827 | Window child_return=0; | 821 | Window child_return=0; |
@@ -834,8 +828,8 @@ FluxboxWindow::ClientList::iterator FluxboxWindow::getClientInsertPosition(int x | |||
834 | 828 | ||
835 | ClientList::iterator client = find(m_clientlist.begin(), | 829 | ClientList::iterator client = find(m_clientlist.begin(), |
836 | m_clientlist.end(), | 830 | m_clientlist.end(), |
837 | it->first); | 831 | c); |
838 | if (x > static_cast<signed>((*it).second->width()) / 2) | 832 | if (x > static_cast<signed>(m_labelbuttons[c]->width()) / 2) |
839 | client++; | 833 | client++; |
840 | 834 | ||
841 | return client; | 835 | return client; |
@@ -853,15 +847,9 @@ void FluxboxWindow::moveClientTo(WinClient &win, int x, int y) { | |||
853 | &labelbutton)) | 847 | &labelbutton)) |
854 | return; | 848 | return; |
855 | 849 | ||
856 | Client2ButtonMap::iterator it = | 850 | WinClient* client = winClientOfLabelButtonWindow(labelbutton); |
857 | find_if(m_labelbuttons.begin(), | ||
858 | m_labelbuttons.end(), | ||
859 | Compose(bind2nd(equal_to<Window>(), labelbutton), | ||
860 | Compose(mem_fun(&TextButton::window), | ||
861 | Select2nd<Client2ButtonMap::value_type>()))); | ||
862 | 851 | ||
863 | // label button not found | 852 | if (!client) |
864 | if (it == m_labelbuttons.end()) | ||
865 | return; | 853 | return; |
866 | 854 | ||
867 | Window child_return = 0; | 855 | Window child_return = 0; |
@@ -871,10 +859,10 @@ void FluxboxWindow::moveClientTo(WinClient &win, int x, int y) { | |||
871 | dest_x, dest_y, &x, &y, | 859 | dest_x, dest_y, &x, &y, |
872 | &child_return)) | 860 | &child_return)) |
873 | return; | 861 | return; |
874 | if (x > static_cast<signed>((*it).second->width()) / 2) | 862 | if (x > static_cast<signed>(m_labelbuttons[client]->width()) / 2) |
875 | moveClientRightOf(win, *it->first); | 863 | moveClientRightOf(win, *client); |
876 | else | 864 | else |
877 | moveClientLeftOf(win, *it->first); | 865 | moveClientLeftOf(win, *client); |
878 | 866 | ||
879 | } | 867 | } |
880 | 868 | ||
@@ -2360,40 +2348,15 @@ void FluxboxWindow::buttonPressEvent(XButtonEvent &be) { | |||
2360 | frame().insideTitlebar( be.window ) && | 2348 | frame().insideTitlebar( be.window ) && |
2361 | frame().handle().window() != be.window; | 2349 | frame().handle().window() != be.window; |
2362 | 2350 | ||
2363 | #if 0 // disabled | ||
2364 | if (onTitlebar && be.button == 1) | ||
2365 | raise(); | ||
2366 | #endif | ||
2367 | |||
2368 | // check keys file first | ||
2369 | Keys *k = Fluxbox::instance()->keys(); | 2351 | Keys *k = Fluxbox::instance()->keys(); |
2370 | if ((onTitlebar && k->doAction(be.type, be.state, be.button, | 2352 | if ((onTitlebar && k->doAction(be.type, be.state, be.button, Keys::ON_TITLEBAR, &winClient(), be.time)) || |
2371 | Keys::ON_TITLEBAR, m_client, be.time)) || | 2353 | k->doAction(be.type, be.state, be.button, Keys::ON_WINDOW, &winClient(), be.time)) { |
2372 | k->doAction(be.type, be.state, be.button, Keys::ON_WINDOW, m_client, | 2354 | |
2373 | be.time)) { | ||
2374 | return; | 2355 | return; |
2375 | } | 2356 | } |
2376 | 2357 | ||
2377 | frame().tabcontainer().tryButtonPressEvent(be); | ||
2378 | if (be.button == 1) { | ||
2379 | if (frame().window().window() == be.window || | ||
2380 | frame().tabcontainer().window() == be.window) { | ||
2381 | if (screen().clickRaises()) | ||
2382 | raise(); | ||
2383 | |||
2384 | fbdbg<<"FluxboxWindow::buttonPressEvent: AllowEvent"<<endl; | ||
2385 | |||
2386 | XAllowEvents(display, ReplayPointer, be.time); | ||
2387 | |||
2388 | m_button_grab_x = be.x_root - frame().x() - frame().window().borderWidth(); | ||
2389 | m_button_grab_y = be.y_root - frame().y() - frame().window().borderWidth(); | ||
2390 | } else if (frame().handle() == be.window) | ||
2391 | raise(); | ||
2392 | 2358 | ||
2393 | FbTk::Menu::hideShownMenu(); | 2359 | XAllowEvents(display, ReplayPointer, be.time); |
2394 | if (!m_focused && acceptsFocus() && m_click_focus) //check focus | ||
2395 | focus(); | ||
2396 | } | ||
2397 | } | 2360 | } |
2398 | 2361 | ||
2399 | void FluxboxWindow::buttonReleaseEvent(XButtonEvent &re) { | 2362 | void FluxboxWindow::buttonReleaseEvent(XButtonEvent &re) { |
@@ -2650,15 +2613,7 @@ void FluxboxWindow::enterNotifyEvent(XCrossingEvent &ev) { | |||
2650 | WinClient *client = 0; | 2613 | WinClient *client = 0; |
2651 | if (screen().focusControl().isMouseTabFocus()) { | 2614 | if (screen().focusControl().isMouseTabFocus()) { |
2652 | // determine if we're in a label button (tab) | 2615 | // determine if we're in a label button (tab) |
2653 | Client2ButtonMap::iterator it = | 2616 | client = winClientOfLabelButtonWindow(ev.window); |
2654 | find_if(m_labelbuttons.begin(), | ||
2655 | m_labelbuttons.end(), | ||
2656 | Compose(bind2nd(equal_to<Window>(), ev.window), | ||
2657 | Compose(mem_fun(&TextButton::window), | ||
2658 | Select2nd<Client2ButtonMap::value_type>()))); | ||
2659 | if (it != m_labelbuttons.end()) | ||
2660 | client = (*it).first; | ||
2661 | |||
2662 | } | 2617 | } |
2663 | 2618 | ||
2664 | if (ev.window == frame().window() || | 2619 | if (ev.window == frame().window() || |
@@ -3149,21 +3104,26 @@ void FluxboxWindow::stopResizing(bool interrupted) { | |||
3149 | ungrabPointer(CurrentTime); | 3104 | ungrabPointer(CurrentTime); |
3150 | } | 3105 | } |
3151 | 3106 | ||
3152 | void FluxboxWindow::startTabbing(const XButtonEvent &be) { | 3107 | WinClient* FluxboxWindow::winClientOfLabelButtonWindow(Window window) { |
3153 | 3108 | WinClient* result = 0; | |
3154 | if (s_num_grabs > 0) | ||
3155 | return; | ||
3156 | |||
3157 | m_attaching_tab = 0; | ||
3158 | // determine if we're in titlebar | ||
3159 | Client2ButtonMap::iterator it = | 3109 | Client2ButtonMap::iterator it = |
3160 | find_if(m_labelbuttons.begin(), | 3110 | find_if(m_labelbuttons.begin(), |
3161 | m_labelbuttons.end(), | 3111 | m_labelbuttons.end(), |
3162 | Compose(bind2nd(equal_to<Window>(), be.window), | 3112 | Compose(bind2nd(equal_to<Window>(), window), |
3163 | Compose(mem_fun(&TextButton::window), | 3113 | Compose(mem_fun(&FbTk::Button::window), |
3164 | Select2nd<Client2ButtonMap::value_type>()))); | 3114 | Select2nd<Client2ButtonMap::value_type>()))); |
3165 | if (it != m_labelbuttons.end()) | 3115 | if (it != m_labelbuttons.end()) |
3166 | m_attaching_tab = it->first; | 3116 | result = it->first; |
3117 | |||
3118 | return result; | ||
3119 | } | ||
3120 | |||
3121 | void FluxboxWindow::startTabbing(const XButtonEvent &be) { | ||
3122 | |||
3123 | if (s_num_grabs > 0) | ||
3124 | return; | ||
3125 | |||
3126 | m_attaching_tab = winClientOfLabelButtonWindow(be.window); | ||
3167 | 3127 | ||
3168 | // start drag'n'drop for tab | 3128 | // start drag'n'drop for tab |
3169 | grabPointer(be.window, False, ButtonMotionMask | | 3129 | grabPointer(be.window, False, ButtonMotionMask | |
@@ -3704,8 +3664,6 @@ void FluxboxWindow::associateClient(WinClient &client) { | |||
3704 | frame().theme().unfocusedTheme()->iconbarTheme(), client); | 3664 | frame().theme().unfocusedTheme()->iconbarTheme(), client); |
3705 | frame().createTab(*btn); | 3665 | frame().createTab(*btn); |
3706 | 3666 | ||
3707 | FbTk::RefCount<FbTk::Command<void> > setcmd(new SetClientCmd(client)); | ||
3708 | btn->setOnClick(setcmd, 1); | ||
3709 | btn->setTextPadding(Fluxbox::instance()->getTabsPadding()); | 3667 | btn->setTextPadding(Fluxbox::instance()->getTabsPadding()); |
3710 | btn->setPixmap(screen().getTabsUsePixmap()); | 3668 | btn->setPixmap(screen().getTabsUsePixmap()); |
3711 | 3669 | ||
@@ -3715,6 +3673,7 @@ void FluxboxWindow::associateClient(WinClient &client) { | |||
3715 | 3673 | ||
3716 | evm.add(*this, btn->window()); // we take care of button events for this | 3674 | evm.add(*this, btn->window()); // we take care of button events for this |
3717 | evm.add(*this, client.window()); | 3675 | evm.add(*this, client.window()); |
3676 | |||
3718 | client.setFluxboxWindow(this); | 3677 | client.setFluxboxWindow(this); |
3719 | join(client.titleSig(), | 3678 | join(client.titleSig(), |
3720 | FbTk::MemFun(*this, &FluxboxWindow::setTitle)); | 3679 | FbTk::MemFun(*this, &FluxboxWindow::setTitle)); |