Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Floating move drag: use threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
xzfc committed Oct 3, 2019
1 parent 551ec20 commit c6b56b0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion include/floating.h
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/click.c
Expand Up @@ -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 &&
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/floating.c
Expand Up @@ -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
Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/handlers.c
Expand Up @@ -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);
Expand Down

0 comments on commit c6b56b0

Please sign in to comment.