15 #include <xcb/xcb_icccm.h> 17 #include <X11/XKBlib.h> 30 DLOG(
"border = %d, con = %p\n", border, con);
42 search_direction =
D_UP;
54 LOG(
"No second container in this direction found.\n");
58 assert(first != second);
62 if (search_direction ==
D_UP || search_direction ==
D_LEFT) {
72 DLOG(
"After resize handler, rendering\n");
89 int to_right = con->
rect.
width -
event->event_x,
90 to_left =
event->event_x,
91 to_top =
event->event_y,
94 DLOG(
"click was %d px to the right, %d px to the left, %d px to top, %d px to bottom\n",
95 to_right, to_left, to_top, to_bottom);
97 if (to_right < to_left &&
102 if (to_left < to_right &&
107 if (to_top < to_right &&
112 if (to_bottom < to_right &&
113 to_bottom < to_left &&
127 DLOG(
"BORDER x = %d, y = %d for con %p, window 0x%08x\n",
128 event->event_x, event->event_y, con, event->event);
139 Con *check_con = con;
141 check_con = check_con->
parent;
147 DLOG(
"Not handling this resize, this container has > 1 child.\n");
153 if (event->event_x >= 0 && event->event_x <= (int32_t)bsr.
x &&
154 event->event_y >= (int32_t)bsr.
y && event->event_y <= (int32_t)(con->
rect.
height + bsr.
height))
158 event->event_y >= (int32_t)bsr.
y && event->event_y <= (int32_t)(con->
rect.
height + bsr.
height))
173 DLOG(
"--> click properties: mod = %d, destination = %d\n", mod_pressed, dest);
174 DLOG(
"--> OUTCOME = %p\n", con);
195 xcb_allow_events(
conn, XCB_ALLOW_ASYNC_POINTER, event->time);
204 if (event->response_type == XCB_BUTTON_RELEASE) {
220 if (ws != focused_workspace)
225 const bool proportional = (
event->state & XCB_KEY_BUT_MASK_SHIFT) == XCB_KEY_BUT_MASK_SHIFT;
235 DLOG(
"Scrolling on a window decoration\n");
247 bool scroll_prev_possible = (
TAILQ_PREV(focused, nodes_head, nodes) != NULL);
248 bool scroll_next_possible = (
TAILQ_NEXT(focused, nodes) != NULL);
264 if (floatingcon != NULL && fs != con) {
275 DLOG(
"floating resize due to floatingmodifier\n");
281 is_left_or_right_click) {
283 DLOG(
"tiling resize with fallback\n");
289 DLOG(
"floating resize due to decoration right click\n");
295 DLOG(
"floating resize due to border click\n");
324 is_left_or_right_click) {
325 DLOG(
"Trying to resize (tiling)\n");
330 xcb_allow_events(
conn, XCB_ALLOW_REPLAY_POINTER, event->time);
347 DLOG(
"Button %d (state %d) %s on window 0x%08x (child 0x%08x) at (%d, %d) (root %d, %d)\n",
348 event->detail, event->state, (event->response_type == XCB_BUTTON_PRESS ?
"press" :
"release"),
349 event->event, event->child, event->event_x, event->event_y, event->root_x,
355 const bool mod_pressed = (mod != 0 && (
event->state & mod) == mod);
356 DLOG(
"floating_mod = %d, detail = %d\n", mod_pressed, event->detail);
364 if (event->event ==
root) {
374 if (event->event ==
root && event->response_type == XCB_BUTTON_PRESS) {
391 ELOG(
"Clicked into unknown window?!\n");
392 xcb_allow_events(
conn, XCB_ALLOW_REPLAY_POINTER, event->time);
406 if (event->child != XCB_NONE) {
407 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");
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...
uint32_t floating_modifier
The modifier which needs to be pressed in combination with your mouse buttons to do things with float...
static int route_click(Con *con, xcb_button_press_event_t *event, const bool mod_pressed, const click_destination_t dest)
static bool tiling_resize(Con *con, xcb_button_press_event_t *event, const click_destination_t dest)
A 'Con' represents everything from the X11 root window down to a single X11 window.
#define TAILQ_PREV(elm, headname, field)
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.
int handle_button_press(xcb_button_press_event_t *event)
The button press X callback.
xcb_connection_t * conn
XCB connection and root screen.
void workspace_show(Con *workspace)
Switches to the given workspace.
int resize_graphical_handler(Con *first, Con *second, orientation_t orientation, const xcb_button_press_event_t *event)
void con_focus(Con *con)
Sets input focus to the given container.
bool con_is_leaf(Con *con)
Returns true when this node is a leaf node (has no children)
Con * con_inside_floating(Con *con)
Checks if the given container is either floating or inside some floating container.
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...
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...
CommandResult * run_binding(Binding *bind, Con *con)
Runs the given binding and handles parse errors.
#define XCB_BUTTON_CLICK_LEFT
Mouse buttons.
#define XCB_BUTTON_SCROLL_UP
Con * con_get_workspace(Con *con)
Gets the workspace container this node is on.
Con * con_get_output(Con *con)
Gets the output container (first container with CT_OUTPUT in hierarchy) this node is on...
bool resize_find_tiling_participants(Con **current, Con **other, direction_t direction)
int con_num_children(Con *con)
Returns the number of children of this container.
#define TAILQ_FOREACH(var, head, field)
bool exclude_titlebar
If this is true for a mouse binding, the binding should only be executed if the button press was not ...
void command_result_free(CommandResult *result)
Frees a CommandResult.
#define TAILQ_FIRST(head)
orientation_t con_orientation(Con *con)
Returns the orientation of the given container (for stacked containers, vertical orientation is used ...
Con * con_by_frame_id(xcb_window_t frame)
Returns the container with the given frame ID or NULL if no such container exists.
border_t
On which border was the dragging initiated?
bool con_is_internal(Con *con)
Returns true if the container is internal, such as __i3_scratch.
Con * output_get_content(Con *output)
Returns the output container below the given output container.
static bool floating_mod_on_tiled_client(Con *con, xcb_button_press_event_t *event)
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_next(char way, orientation_t orientation)
Changes focus in the given way (next/previous) and given orientation (horizontal/vertical).
bool whole_window
If this is true for a mouse binding, the binding should be executed when the button is pressed over a...
A struct that contains useful information about the result of a command as a whole (e...
Holds a keybinding, consisting of a keycode combined with modifiers and the command which is executed...
#define XCB_BUTTON_CLICK_RIGHT
#define TAILQ_NEXT(elm, field)
Con * con_get_fullscreen_con(Con *con, fullscreen_mode_t fullscreen_mode)
Returns the first fullscreen node below this node.
static bool tiling_resize_for_border(Con *con, border_t border, xcb_button_press_event_t *event)
#define XCB_BUTTON_SCROLL_RIGHT
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 XCB_BUTTON_SCROLL_LEFT
void tree_render(void)
Renders the tree, that is rendering all outputs using render_con() and pushing the changes to X11 usi...
Stores a rectangle, for example the size of a window, the child window etc.
#define XCB_BUTTON_SCROLL_DOWN
bool rect_contains(Rect rect, uint32_t x, uint32_t y)
bool border
If this is true for a mouse binding, the binding should be executed when the button is pressed over t...