25 DLOG(
"border = %d, con = %p\n", border, con);
37 search_direction =
D_UP;
43 ELOG(
"BUG: invalid border value %d\n", border);
49 DLOG(
"No second container in this direction found.\n");
57 assert(first != second);
61 if (search_direction ==
D_UP || search_direction ==
D_LEFT) {
71 DLOG(
"After resize handler, rendering\n");
88 int to_right = con->
rect.
width -
event->event_x,
89 to_left =
event->event_x,
90 to_top =
event->event_y,
93 DLOG(
"click was %d px to the right, %d px to the left, %d px to top, %d px to bottom\n",
94 to_right, to_left, to_top, to_bottom);
96 if (to_right < to_left &&
98 to_right < to_bottom) {
102 if (to_left < to_right &&
104 to_left < to_bottom) {
108 if (to_top < to_right &&
110 to_top < to_bottom) {
114 if (to_bottom < to_right &&
115 to_bottom < to_left &&
116 to_bottom < to_top) {
130 DLOG(
"BORDER x = %d, y = %d for con %p, window 0x%08x\n",
131 event->event_x, event->event_y, con, event->event);
136 if (event->event_y >= 0 && event->event_y <= (int32_t)bsr.
y &&
137 event->event_x >= (int32_t)bsr.
x && event->event_x <= (int32_t)(con->
rect.
width + bsr.
width)) {
141 if (event->event_x >= 0 && event->event_x <= (int32_t)bsr.
x &&
142 event->event_y >= (int32_t)bsr.
y && event->event_y <= (int32_t)(con->
rect.
height + bsr.
height)) {
147 event->event_y >= (int32_t)bsr.
y && event->event_y <= (int32_t)(con->
rect.
height + bsr.
height)) {
159 xcb_allow_events(
conn, XCB_ALLOW_REPLAY_POINTER, time);
171 const bool mod_pressed = (mod != 0 && (
event->state & mod) == mod);
173 DLOG(
"--> click properties: mod = %d, destination = %d\n", mod_pressed, dest);
174 DLOG(
"--> OUTCOME = %p\n", con);
192 xcb_allow_events(
conn, XCB_ALLOW_ASYNC_POINTER, event->time);
200 if (event->response_type == XCB_BUTTON_RELEASE) {
221 const bool proportional = (
event->state & XCB_KEY_BUT_MASK_SHIFT) == XCB_KEY_BUT_MASK_SHIFT;
223 const bool was_focused =
focused == con;
226 const bool is_left_or_right_click = (is_left_click || is_right_click);
234 DLOG(
"Scrolling on a window decoration\n");
251 if (mod_pressed && is_left_click && !floatingcon &&
255 const bool use_threshold = !mod_pressed;
262 Con *con_to_focus = con;
269 while (!
TAILQ_EMPTY(&(con_to_focus->focus_head))) {
270 con_to_focus =
TAILQ_FIRST(&(con_to_focus->focus_head));
274 if (ws != focused_workspace) {
282 if (floatingcon != NULL && fs != con) {
284 if (mod_pressed && is_left_click) {
292 if (mod_pressed && is_right_click) {
293 DLOG(
"floating resize due to floatingmodifier\n");
299 is_left_or_right_click) {
301 DLOG(
"tiling resize with fallback\n");
309 DLOG(
"floating resize due to decoration right click\n");
315 DLOG(
"floating resize due to border click\n");
338 const bool use_threshold = !mod_pressed;
344 if (dest ==
CLICK_INSIDE && mod_pressed && is_right_click) {
350 xcb_allow_events(
conn, XCB_ALLOW_ASYNC_POINTER, event->time);
356 is_left_or_right_click) {
357 DLOG(
"Trying to resize (tiling)\n");
374 DLOG(
"Button %d (state %d) %s on window 0x%08x (child 0x%08x) at (%d, %d) (root %d, %d)\n",
375 event->detail, event->state, (event->response_type == XCB_BUTTON_PRESS ?
"press" :
"release"),
376 event->event, event->child, event->event_x, event->event_y, event->root_x,
390 if (event->event ==
root) {
400 if (event->event ==
root && event->response_type == XCB_BUTTON_PRESS) {
418 ELOG(
"Clicked into unknown window?!\n");
419 xcb_allow_events(
conn, XCB_ALLOW_REPLAY_POINTER, event->time);
425 if (con->
window != NULL) {
442 if (event->child != XCB_NONE) {
443 DLOG(
"event->child not XCB_NONE, so this is an event which originated from a click into the application, but the application did not handle it.\n");
Binding * get_binding_from_xcb_event(xcb_generic_event_t *event)
Returns a pointer to the Binding that matches the given xcb event or NULL if no such binding exists.
CommandResult * run_binding(Binding *bind, Con *con)
Runs the given binding and handles parse errors.
static bool floating_mod_on_tiled_client(Con *con, xcb_button_press_event_t *event)
static bool tiling_resize_for_border(Con *con, border_t border, xcb_button_press_event_t *event, bool use_threshold)
void handle_button_press(xcb_button_press_event_t *event)
The button press X callback.
static void allow_replay_pointer(xcb_timestamp_t time)
static bool tiling_resize(Con *con, xcb_button_press_event_t *event, const click_destination_t dest, bool use_threshold)
static void route_click(Con *con, xcb_button_press_event_t *event, const click_destination_t dest)
void command_result_free(CommandResult *result)
Frees a CommandResult.
Con * con_get_workspace(Con *con)
Gets the workspace container this node is on.
Con * con_by_window_id(xcb_window_t window)
Returns the container with the given client window ID or NULL if no such container exists.
Rect con_border_style_rect(Con *con)
Returns a "relative" Rect which contains the amount of pixels that need to be added to the original R...
Con * con_get_fullscreen_covering_ws(Con *ws)
Returns the fullscreen node that covers the given workspace if it exists.
Con * con_inside_floating(Con *con)
Checks if the given container is either floating or inside some floating container.
bool con_is_internal(Con *con)
Returns true if the container is internal, such as __i3_scratch.
Con * con_by_frame_id(xcb_window_t frame)
Returns the container with the given frame ID or NULL if no such container exists.
void con_activate(Con *con)
Sets input focus to the given container and raises it to the top.
bool con_has_parent(Con *con, Con *parent)
Checks if the container has the given parent as an actual parent.
Con * con_get_output(Con *con)
Gets the output container (first container with CT_OUTPUT in hierarchy) this node is on.
Con * con_descend_focused(Con *con)
Returns the focused con inside this client, descending the tree as far as possible.
void floating_resize_window(Con *con, const bool proportional, const xcb_button_press_event_t *event)
Called when the user clicked on a floating window while holding the floating_modifier and the right m...
void floating_drag_window(Con *con, const xcb_button_press_event_t *event, bool use_threshold)
Called when the user clicked on the titlebar of a floating window.
Con * output_get_content(Con *output)
Returns the output container below the given output container.
bool resize_find_tiling_participants(Con **current, Con **other, direction_t direction, bool both_sides)
void resize_graphical_handler(Con *first, Con *second, orientation_t orientation, const xcb_button_press_event_t *event, bool use_threshold)
void tiling_drag(Con *con, xcb_button_press_event_t *event, bool use_threshold)
Initiates a mouse drag operation on a tiled window.
bool has_drop_targets(void)
Returns whether there currently are any drop targets.
void tree_render(void)
Renders the tree, that is rendering all outputs using render_con() and pushing the changes to X11 usi...
Con * get_tree_next_sibling(Con *con, position_t direction)
Get the previous / next sibling.
bool rect_contains(Rect rect, uint32_t x, uint32_t y)
void workspace_show(Con *workspace)
Switches to the given workspace.
xcb_timestamp_t last_timestamp
The last timestamp we got from X11 (timestamps are included in some events and are used for some thin...
xcb_connection_t * conn
XCB connection and root screen.
border_t
On which border was the dragging initiated?
#define XCB_BUTTON_CLICK_LEFT
Mouse buttons.
#define XCB_BUTTON_SCROLL_UP
#define XCB_BUTTON_SCROLL_LEFT
#define XCB_BUTTON_SCROLL_RIGHT
#define XCB_BUTTON_CLICK_RIGHT
#define XCB_BUTTON_SCROLL_DOWN
#define TAILQ_FOREACH(var, head, field)
#define TAILQ_FIRST(head)
#define TAILQ_FOREACH_REVERSE(var, head, headname, field)
#define TAILQ_EMPTY(head)
@ TILING_DRAG_MODIFIER_OR_TITLEBAR
A struct that contains useful information about the result of a command as a whole (e....
tiling_drag_t tiling_drag
uint32_t floating_modifier
The modifier which needs to be pressed in combination with your mouse buttons to do things with float...
Stores a rectangle, for example the size of a window, the child window etc.
Holds a keybinding, consisting of a keycode combined with modifiers and the command which is executed...
bool whole_window
If this is true for a mouse binding, the binding should be executed when the button is pressed over a...
bool border
If this is true for a mouse binding, the binding should be executed when the button is pressed over t...
bool exclude_titlebar
If this is true for a mouse binding, the binding should only be executed if the button press was not ...
A 'Con' represents everything from the X11 root window down to a single X11 window.
fullscreen_mode_t fullscreen_mode