1 /* 2 * vim:ts=4:sw=4:expandtab 3 * 4 * i3 - an improved dynamic tiling window manager 5 * © 2009 Michael Stapelberg and contributors (see also: LICENSE) 6 * 7 * drag.c: click and drag. 8 * 9 */ 10 #pragma once 11 12 #include <config.h> 13 14 /** Callback for dragging */ 15 typedef void (*callback_t)(Con *, Rect *, uint32_t, uint32_t, 16 const xcb_button_press_event_t *, const void *); 17 18 /** Macro to create a callback function for dragging */ 19 #define DRAGGING_CB(name) \ 20 static void name(Con *con, Rect *old_rect, uint32_t new_x, uint32_t new_y, \ 21 const xcb_button_press_event_t *event, const void *extra) 22 23 /** 24 * This is the return value of a drag operation like drag_pointer. 25 * 26 * DRAGGING will indicate the drag action is still in progress and can be 27 * continued or resolved. 28 * 29 * DRAG_SUCCESS will indicate the intention of the drag action should be 30 * carried out. 31 * 32 * DRAG_REVERT will indicate an attempt should be made to restore the state of 33 * the involved windows to their condition before the drag. 34 * 35 * DRAG_ABORT will indicate that the intention of the drag action cannot be 36 * carried out (e.g. because the window has been unmapped). 37 * 38 */ 39 typedef enum { 40 DRAGGING = 0, 41 DRAG_SUCCESS, 42 DRAG_REVERT, 43 DRAG_ABORT 44 } drag_result_t; 45 46 /** 47 * This function grabs your pointer and keyboard and lets you drag stuff around 48 * (borders). Every time you move your mouse, an XCB_MOTION_NOTIFY event will 49 * be received and the given callback will be called with the parameters 50 * specified (client, the original event), the original rect of the client, 51 * and the new coordinates (x, y). 52 * 53 * If use_threshold is set, dragging only starts after the user moves the 54 * pointer past a certain threshold. That is, the cursor will not be set and the 55 * callback will not be called until then. 56 * 57 */ 58 drag_result_t drag_pointer(Con *con, const xcb_button_press_event_t *event, 59 xcb_window_t confine_to, int cursor, 60 bool use_threshold, callback_t callback, 61 const void *extra); 62