2 #define I3__FILE__ "click.c"
17 #include <xcb/xcb_icccm.h>
19 #include <X11/XKBlib.h>
32 DLOG(
"border = %d, con = %p\n", border, con);
44 search_direction =
D_UP;
53 LOG(
"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 &&
101 if (to_left < to_right &&
106 if (to_top < to_right &&
111 if (to_bottom < to_right &&
112 to_bottom < to_left &&
126 DLOG(
"BORDER x = %d, y = %d for con %p, window 0x%08x\n",
127 event->event_x, event->event_y, con, event->event);
138 Con *check_con = con;
140 check_con = check_con->
parent;
146 DLOG(
"Not handling this resize, this container has > 1 child.\n");
152 if (event->event_x >= 0 && event->event_x <= (int32_t)bsr.
x &&
153 event->event_y >= (int32_t)bsr.
y && event->event_y <= (int32_t)(con->
rect.
height + bsr.
height))
157 event->event_y >= (int32_t)bsr.
y && event->event_y <= (int32_t)(con->
rect.
height + bsr.
height))
172 DLOG(
"--> click properties: mod = %d, destination = %d\n", mod_pressed, dest);
173 DLOG(
"--> OUTCOME = %p\n", con);
192 if (ws != focused_workspace)
198 const bool proportional = (
event->state &
BIND_SHIFT);
204 (event->detail == XCB_BUTTON_INDEX_4 ||
205 event->detail == XCB_BUTTON_INDEX_5)) {
206 DLOG(
"Scrolling on a window decoration\n");
218 bool scroll_prev_possible = (
TAILQ_PREV(focused, nodes_head, nodes) != NULL);
219 bool scroll_next_possible = (
TAILQ_NEXT(focused, nodes) != NULL);
220 if (event->detail == XCB_BUTTON_INDEX_4 && scroll_prev_possible)
222 else if (event->detail == XCB_BUTTON_INDEX_5 && scroll_next_possible)
233 if (floatingcon != NULL && fs != con) {
237 if (mod_pressed && event->detail == XCB_BUTTON_INDEX_1) {
245 if (mod_pressed && event->detail == XCB_BUTTON_INDEX_3) {
246 DLOG(
"floating resize due to floatingmodifier\n");
253 DLOG(
"tiling resize with fallback\n");
259 DLOG(
"floating resize due to decoration right click\n");
265 DLOG(
"floating resize due to border click\n");
287 if (dest ==
CLICK_INSIDE && mod_pressed && event->detail == XCB_BUTTON_INDEX_3) {
293 (event->detail == XCB_BUTTON_INDEX_1 ||
294 event->detail == XCB_BUTTON_INDEX_3)) {
295 DLOG(
"Trying to resize (tiling)\n");
300 xcb_allow_events(
conn, XCB_ALLOW_REPLAY_POINTER, event->time);
316 DLOG(
"Button %d pressed on window 0x%08x (child 0x%08x) at (%d, %d) (root %d, %d)\n",
317 event->state, event->event, event->child, event->event_x, event->event_y,
318 event->root_x, event->root_y);
323 const bool mod_pressed = (mod != 0 && (
event->state & mod) == mod);
324 DLOG(
"floating_mod = %d, detail = %d\n", mod_pressed, event->detail);
331 if (event->event ==
root) {
348 ELOG(
"Clicked into unknown window?!\n");
349 xcb_allow_events(
conn, XCB_ALLOW_REPLAY_POINTER, event->time);
354 if (event->child != XCB_NONE) {
355 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");
void tree_next(char way, orientation_t orientation)
Changes focus in the given way (next/previous) and given orientation (horizontal/vertical).
static bool tiling_resize(Con *con, xcb_button_press_event_t *event, const click_destination_t dest)
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 tree_render(void)
Renders the tree, that is rendering all outputs using render_con() and pushing the changes to X11 usi...
Con * con_get_workspace(Con *con)
Gets the workspace container this node is on.
int resize_graphical_handler(Con *first, Con *second, orientation_t orientation, const xcb_button_press_event_t *event)
Stores a rectangle, for example the size of a window, the child window etc.
int handle_button_press(xcb_button_press_event_t *event)
The button press X callback.
void floating_drag_window(Con *con, const xcb_button_press_event_t *event)
Called when the user clicked on the titlebar of a floating window.
void workspace_show(Con *workspace)
Switches to the given workspace.
#define TAILQ_FIRST(head)
xcb_timestamp_t last_timestamp
The last timestamp we got from X11 (timestamps are included in some events and are used for some thin...
#define TAILQ_NEXT(elm, field)
bool con_is_internal(Con *con)
Returns true if the container is internal, such as __i3_scratch.
bool rect_contains(Rect rect, uint32_t x, uint32_t y)
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...
border_t
On which border was the dragging initiated?
void floating_raise_con(Con *con)
Raises the given container in the list of floating containers.
Con * con_get_fullscreen_con(Con *con, fullscreen_mode_t fullscreen_mode)
Returns the first fullscreen node below this node.
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...
bool con_is_leaf(Con *con)
Returns true when this node is a leaf node (has no children)
static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod_pressed, const click_destination_t dest)
void con_focus(Con *con)
Sets input focus to the given container.
Con * con_by_frame_id(xcb_window_t frame)
Returns the container with the given frame ID or NULL if no such container exists.
int con_num_children(Con *con)
Returns the number of children of this container.
#define TAILQ_PREV(elm, headname, field)
orientation_t con_orientation(Con *con)
Returns the orientation of the given container (for stacked containers, vertical orientation is used ...
A 'Con' represents everything from the X11 root window down to a single X11 window.
bool resize_find_tiling_participants(Con **current, Con **other, direction_t direction)
Con * output_get_content(Con *output)
Returns the output container below the given output container.
Con * con_get_output(Con *con)
Gets the output container (first container with CT_OUTPUT in hierarchy) this node is on...
Con * con_inside_floating(Con *con)
Checks if the given container is either floating or inside some floating container.
uint32_t floating_modifier
The modifier which needs to be pressed in combination with your mouse buttons to do things with float...
#define TAILQ_FOREACH(var, head, field)
static bool tiling_resize_for_border(Con *con, border_t border, xcb_button_press_event_t *event)
static bool floating_mod_on_tiled_client(Con *con, xcb_button_press_event_t *event)
xcb_window_t focused_id
Stores the X11 window ID of the currently focused window.