diff options
Diffstat (limited to 'src/Window.cc')
-rw-r--r-- | src/Window.cc | 149 |
1 files changed, 73 insertions, 76 deletions
diff --git a/src/Window.cc b/src/Window.cc index c9ab1b2..d99d1c1 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -2611,11 +2611,10 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { | |||
2611 | me.window = frame().window().window(); | 2611 | me.window = frame().window().window(); |
2612 | } | 2612 | } |
2613 | 2613 | ||
2614 | bool inside_titlebar = (frame().titlebar() == me.window | 2614 | bool inside_titlebar = frame().gripLeft().window() != me.window && |
2615 | || frame().label() == me.window | 2615 | frame().gripRight().window() != me.window && |
2616 | || frame().tabcontainer() == me.window | 2616 | frame().clientArea().window() != me.window && |
2617 | || frame().handle() == me.window | 2617 | frame().window() != me.window; |
2618 | || frame().window() == me.window); | ||
2619 | 2618 | ||
2620 | if (Fluxbox::instance()->getIgnoreBorder() && m_attaching_tab == 0 | 2619 | if (Fluxbox::instance()->getIgnoreBorder() && m_attaching_tab == 0 |
2621 | && !(isMoving() || isResizing())) { | 2620 | && !(isMoving() || isResizing())) { |
@@ -2650,24 +2649,8 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { | |||
2650 | return; | 2649 | return; |
2651 | } | 2650 | } |
2652 | 2651 | ||
2653 | WinClient *client = 0; | 2652 | if (moving || (me.state & Button1Mask) && functions.move && |
2654 | if (!inside_titlebar) { | 2653 | inside_titlebar && !isResizing() && m_attaching_tab == 0) { |
2655 | // determine if we're in titlebar | ||
2656 | Client2ButtonMap::iterator it = | ||
2657 | find_if(m_labelbuttons.begin(), | ||
2658 | m_labelbuttons.end(), | ||
2659 | Compose(bind2nd(equal_to<Window>(), me.window), | ||
2660 | Compose(mem_fun(&TextButton::window), | ||
2661 | Select2nd<Client2ButtonMap::value_type>()))); | ||
2662 | if (it != m_labelbuttons.end()) { | ||
2663 | inside_titlebar = true; | ||
2664 | client = (*it).first; | ||
2665 | } | ||
2666 | } | ||
2667 | |||
2668 | if ((me.state & Button1Mask) && functions.move && | ||
2669 | inside_titlebar && | ||
2670 | !isResizing()) { | ||
2671 | 2654 | ||
2672 | if (! isMoving()) { | 2655 | if (! isMoving()) { |
2673 | startMoving(me.x_root, me.y_root); | 2656 | startMoving(me.x_root, me.y_root); |
@@ -2741,7 +2724,7 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { | |||
2741 | 2724 | ||
2742 | screen().showPosition(dx, dy); | 2725 | screen().showPosition(dx, dy); |
2743 | } // end if moving | 2726 | } // end if moving |
2744 | } else if (functions.resize && | 2727 | } else if (resizing || m_attaching_tab == 0 && functions.resize && |
2745 | (((me.state & Button1Mask) && | 2728 | (((me.state & Button1Mask) && |
2746 | (me.window == frame().gripRight() || | 2729 | (me.window == frame().gripRight() || |
2747 | me.window == frame().gripLeft())) || | 2730 | me.window == frame().gripLeft())) || |
@@ -2833,61 +2816,25 @@ void FluxboxWindow::motionNotifyEvent(XMotionEvent &me) { | |||
2833 | screen().showGeometry(gx, gy); | 2816 | screen().showGeometry(gx, gy); |
2834 | } | 2817 | } |
2835 | } | 2818 | } |
2836 | } else if (functions.tabable && | 2819 | } else if (m_attaching_tab != 0) { |
2837 | (me.state & Button2Mask) && inside_titlebar && (client != 0 || m_attaching_tab != 0)) { | ||
2838 | // | 2820 | // |
2839 | // drag'n'drop code for tabs | 2821 | // drag'n'drop code for tabs |
2840 | // | 2822 | // |
2841 | FbTk::TextButton &active_button = *m_labelbuttons[(m_attaching_tab==0)?client:m_attaching_tab]; | ||
2842 | 2823 | ||
2843 | if (m_attaching_tab == 0) { | 2824 | // we already grabed and started to drag'n'drop tab |
2844 | if (s_num_grabs > 0) | 2825 | // so we update drag'n'drop-rectangle |
2845 | return; | 2826 | int dx = me.x_root - m_button_grab_x, dy = me.y_root - m_button_grab_y; |
2846 | // start drag'n'drop for tab | ||
2847 | m_attaching_tab = client; | ||
2848 | grabPointer(me.window, False, ButtonMotionMask | | ||
2849 | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, | ||
2850 | None, frame(). theme().moveCursor(), CurrentTime); | ||
2851 | // relative position on button | ||
2852 | m_button_grab_x = me.x; | ||
2853 | m_button_grab_y = me.y; | ||
2854 | // last known root mouse position | ||
2855 | m_last_move_x = me.x_root - me.x; | ||
2856 | m_last_move_y = me.y_root - me.y; | ||
2857 | // hijack extra vars for initial grab location | ||
2858 | m_last_resize_x = me.x_root; | ||
2859 | m_last_resize_y = me.y_root; | ||
2860 | |||
2861 | Fluxbox::instance()->grab(); | ||
2862 | |||
2863 | parent().drawRectangle(screen().rootTheme().opGC(), | ||
2864 | m_last_move_x, m_last_move_y, | ||
2865 | active_button.width(), | ||
2866 | active_button.height()); | ||
2867 | |||
2868 | menu().hide(); | ||
2869 | } else { | ||
2870 | // we already grabed and started to drag'n'drop tab | ||
2871 | // so we update drag'n'drop-rectangle | ||
2872 | int dx = me.x_root - m_button_grab_x, dy = me.y_root - m_button_grab_y; | ||
2873 | |||
2874 | //erase rectangle | ||
2875 | parent().drawRectangle(screen().rootTheme().opGC(), | ||
2876 | m_last_move_x, m_last_move_y, | ||
2877 | active_button.width(), | ||
2878 | active_button.height()); | ||
2879 | |||
2880 | |||
2881 | // redraw rectangle at new pos | ||
2882 | m_last_move_x = dx; | ||
2883 | m_last_move_y = dy; | ||
2884 | parent().drawRectangle(screen().rootTheme().opGC(), | ||
2885 | m_last_move_x, m_last_move_y, | ||
2886 | active_button.width(), | ||
2887 | active_button.height()); | ||
2888 | 2827 | ||
2828 | parent().drawRectangle(screen().rootTheme().opGC(), | ||
2829 | m_last_move_x, m_last_move_y, | ||
2830 | m_last_resize_w, m_last_resize_h); | ||
2831 | parent().drawRectangle(screen().rootTheme().opGC(), | ||
2832 | dx, dy, | ||
2833 | m_last_resize_w, m_last_resize_h); | ||
2889 | 2834 | ||
2890 | } | 2835 | // change remembered position of rectangle |
2836 | m_last_move_x = dx; | ||
2837 | m_last_move_y = dy; | ||
2891 | } | 2838 | } |
2892 | 2839 | ||
2893 | } | 2840 | } |
@@ -3116,7 +3063,7 @@ void FluxboxWindow::startMoving(int x, int y) { | |||
3116 | Fluxbox *fluxbox = Fluxbox::instance(); | 3063 | Fluxbox *fluxbox = Fluxbox::instance(); |
3117 | // grabbing (and masking) on the root window allows us to | 3064 | // grabbing (and masking) on the root window allows us to |
3118 | // freely map and unmap the window we're moving. | 3065 | // freely map and unmap the window we're moving. |
3119 | grabPointer(screen().rootWindow().window(), False, Button1MotionMask | | 3066 | grabPointer(screen().rootWindow().window(), False, ButtonMotionMask | |
3120 | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, | 3067 | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, |
3121 | screen().rootWindow().window(), frame().theme().moveCursor(), CurrentTime); | 3068 | screen().rootWindow().window(), frame().theme().moveCursor(), CurrentTime); |
3122 | 3069 | ||
@@ -3467,14 +3414,64 @@ void FluxboxWindow::stopResizing(bool interrupted) { | |||
3467 | ungrabPointer(CurrentTime); | 3414 | ungrabPointer(CurrentTime); |
3468 | } | 3415 | } |
3469 | 3416 | ||
3417 | void FluxboxWindow::startTabbing(const XButtonEvent &be) { | ||
3418 | |||
3419 | if (s_num_grabs > 0) | ||
3420 | return; | ||
3421 | |||
3422 | m_attaching_tab = 0; | ||
3423 | // determine if we're in titlebar | ||
3424 | Client2ButtonMap::iterator it = | ||
3425 | find_if(m_labelbuttons.begin(), | ||
3426 | m_labelbuttons.end(), | ||
3427 | Compose(bind2nd(equal_to<Window>(), be.window), | ||
3428 | Compose(mem_fun(&TextButton::window), | ||
3429 | Select2nd<Client2ButtonMap::value_type>()))); | ||
3430 | if (it != m_labelbuttons.end()) | ||
3431 | m_attaching_tab = it->first; | ||
3432 | |||
3433 | // start drag'n'drop for tab | ||
3434 | grabPointer(be.window, False, ButtonMotionMask | | ||
3435 | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, | ||
3436 | None, frame().theme().moveCursor(), CurrentTime); | ||
3437 | |||
3438 | // relative position on the button | ||
3439 | m_button_grab_x = be.x; | ||
3440 | m_button_grab_y = be.y; | ||
3441 | // position of the button | ||
3442 | m_last_move_x = be.x_root - be.x; | ||
3443 | m_last_move_y = be.y_root - be.y; | ||
3444 | // hijack extra vars for initial grab location | ||
3445 | m_last_resize_x = be.x_root; | ||
3446 | m_last_resize_y = be.y_root; | ||
3447 | |||
3448 | Fluxbox::instance()->grab(); | ||
3449 | |||
3450 | if (m_attaching_tab) { | ||
3451 | FbTk::TextButton &active_button = *m_labelbuttons[m_attaching_tab]; | ||
3452 | m_last_resize_w = active_button.width(); | ||
3453 | m_last_resize_h = active_button.height(); | ||
3454 | } else { | ||
3455 | m_attaching_tab = m_client; | ||
3456 | unsigned int bw = 2*frame().window().borderWidth()-1; | ||
3457 | m_last_resize_w = frame().width() + bw; | ||
3458 | m_last_resize_h = frame().height() + bw; | ||
3459 | } | ||
3460 | |||
3461 | parent().drawRectangle(screen().rootTheme().opGC(), | ||
3462 | m_last_move_x, m_last_move_y, | ||
3463 | m_last_resize_w, m_last_resize_h); | ||
3464 | |||
3465 | menu().hide(); | ||
3466 | } | ||
3467 | |||
3470 | void FluxboxWindow::attachTo(int x, int y, bool interrupted) { | 3468 | void FluxboxWindow::attachTo(int x, int y, bool interrupted) { |
3471 | if (m_attaching_tab == 0) | 3469 | if (m_attaching_tab == 0) |
3472 | return; | 3470 | return; |
3473 | 3471 | ||
3474 | parent().drawRectangle(screen().rootTheme().opGC(), | 3472 | parent().drawRectangle(screen().rootTheme().opGC(), |
3475 | m_last_move_x, m_last_move_y, | 3473 | m_last_move_x, m_last_move_y, |
3476 | m_labelbuttons[m_attaching_tab]->width(), | 3474 | m_last_resize_w, m_last_resize_h); |
3477 | m_labelbuttons[m_attaching_tab]->height()); | ||
3478 | 3475 | ||
3479 | ungrabPointer(CurrentTime); | 3476 | ungrabPointer(CurrentTime); |
3480 | 3477 | ||