diff --git a/include/floating.h b/include/floating.h index 4b66eef7..4af434cf 100644 --- a/include/floating.h +++ b/include/floating.h @@ -75,7 +75,7 @@ void floating_move_to_pointer(Con *con); * Calls the drag_pointer function with the drag_window callback * */ -void floating_drag_window(Con *con, const xcb_button_press_event_t *event); +void floating_drag_window(Con *con, const xcb_button_press_event_t *event, bool use_threshold); /** * Called when the user clicked on a floating window while holding the diff --git a/src/click.c b/src/click.c index 58ebbf3d..4fcc22ec 100644 --- a/src/click.c +++ b/src/click.c @@ -221,6 +221,7 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod Con *floatingcon = con_inside_floating(con); const bool proportional = (event->state & XCB_KEY_BUT_MASK_SHIFT) == XCB_KEY_BUT_MASK_SHIFT; const bool in_stacked = (con->parent->layout == L_STACKED || con->parent->layout == L_TABBED); + const bool was_focused = focused == con; /* 1: see if the user scrolled on the decoration of a stacked/tabbed con */ if (in_stacked && @@ -258,7 +259,7 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod if (floatingcon != NULL && fs != con) { /* 4: floating_modifier plus left mouse button drags */ if (mod_pressed && event->detail == XCB_BUTTON_CLICK_LEFT) { - floating_drag_window(floatingcon, event); + floating_drag_window(floatingcon, event, false); return 1; } @@ -293,9 +294,8 @@ static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod /* 6: dragging, if this was a click on a decoration (which did not lead * to a resize) */ - if (!in_stacked && dest == CLICK_DECORATION && - (event->detail == XCB_BUTTON_CLICK_LEFT)) { - floating_drag_window(floatingcon, event); + if (dest == CLICK_DECORATION && event->detail == XCB_BUTTON_CLICK_LEFT) { + floating_drag_window(floatingcon, event, !was_focused); return 1; } diff --git a/src/floating.c b/src/floating.c index 59c8c797..719cc194 100644 --- a/src/floating.c +++ b/src/floating.c @@ -582,7 +582,7 @@ DRAGGING_CB(drag_window_callback) { * Calls the drag_pointer function with the drag_window callback * */ -void floating_drag_window(Con *con, const xcb_button_press_event_t *event) { +void floating_drag_window(Con *con, const xcb_button_press_event_t *event, bool use_threshold) { DLOG("floating_drag_window\n"); /* Push changes before dragging, so that the window gets raised now and not @@ -593,7 +593,7 @@ void floating_drag_window(Con *con, const xcb_button_press_event_t *event) { Rect initial_rect = con->rect; /* Drag the window */ - drag_result_t drag_result = drag_pointer(con, event, XCB_NONE, XCURSOR_CURSOR_MOVE, false, drag_window_callback, NULL); + drag_result_t drag_result = drag_pointer(con, event, XCB_NONE, XCURSOR_CURSOR_MOVE, use_threshold, drag_window_callback, NULL); if (!con_exists(con)) { DLOG("The container has been closed in the meantime.\n"); diff --git a/src/handlers.c b/src/handlers.c index 7a334978..e177c8fa 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -913,7 +913,7 @@ static void handle_client_message(xcb_client_message_event_t *event) { .event_y = y_root - (con->rect.y)}; switch (direction) { case _NET_WM_MOVERESIZE_MOVE: - floating_drag_window(con->parent, &fake); + floating_drag_window(con->parent, &fake, false); break; case _NET_WM_MOVERESIZE_SIZE_TOPLEFT ... _NET_WM_MOVERESIZE_SIZE_LEFT: floating_resize_window(con->parent, false, &fake);