30 DLOG(
"new x = %d, y = %d\n", new_x, new_y);
38 xcb_warp_pointer(
conn, XCB_NONE, event->root, 0, 0, 0, 0,
42 xcb_warp_pointer(
conn, XCB_NONE, event->root, 0, 0, 0, 0,
73 DLOG(
"Find two participants for resizing container=%p in direction=%i\n", other,
direction);
74 Con *first = *current;
77 DLOG(
"Current container is NULL, aborting.\n");
84 while (first->
type != CT_WORKSPACE &&
85 first->
type != CT_FLOATING_CON &&
99 if (second == NULL && both_sides ==
true) {
104 if (second == NULL && both_sides ==
true) {
105 second =
TAILQ_PREV(first, nodes_head, nodes);
109 if (second == NULL) {
110 DLOG(
"No second container in this direction found, trying to look further up in the tree...\n");
115 DLOG(
"Found participants: first=%p and second=%p.\n", first, second);
118 if (first == NULL || second == NULL) {
119 DLOG(
"Could not find two participants for this resize request.\n");
135 return ((
double)min_size / (
double)parent_size);
147 assert(px * ppt == 0);
150 double new_first_percent;
151 double new_second_percent;
153 new_first_percent = first->
percent + ((double)ppt / 100.0);
154 new_second_percent = second->
percent - ((double)ppt / 100.0);
158 new_first_percent = first->
percent + pct;
159 new_second_percent = second->
percent - pct;
167 first->
percent = new_first_percent;
168 second->
percent = new_second_percent;
174 const xcb_button_press_event_t *event,
175 bool use_threshold) {
178 DLOG(
"first = %p / %s\n", first, first->
name);
179 DLOG(
"second = %p / %s\n", second, second->
name);
187 mask = XCB_CW_OVERRIDE_REDIRECT;
202 helprect.
x = second->
rect.
x;
203 helprect.
y = second->
rect.
y;
212 const uint32_t ffirst_right = ffirst->
rect.
x + ffirst->
rect.
width;
213 const uint32_t gap = (fsecond->
rect.
x - ffirst_right);
214 const uint32_t middle = fsecond->
rect.
x - (gap / 2);
216 DLOG(
"fsecond->rect = {.x = %u, .width = %u}\n", fsecond->
rect.
x, fsecond->
rect.
width);
217 DLOG(
"gap = %u, middle = %u\n", gap, middle);
218 initial_position = middle;
223 const uint32_t gap = (fsecond->
rect.
y - ffirst_bottom);
224 const uint32_t middle = fsecond->
rect.
y - (gap / 2);
227 DLOG(
"gap = %u, middle = %u\n", gap, middle);
228 initial_position = middle;
231 mask = XCB_CW_BACK_PIXEL;
234 mask |= XCB_CW_OVERRIDE_REDIRECT;
240 if (!use_threshold) {
243 xcb_warp_pointer(
conn, XCB_NONE, event->root, 0, 0, 0, 0,
244 initial_position, event->root_y);
246 xcb_warp_pointer(
conn, XCB_NONE, event->root, 0, 0, 0, 0,
247 event->root_x, initial_position);
251 xcb_circulate_window(
conn, XCB_CIRCULATE_RAISE_LOWEST,
helpwin);
270 xcb_destroy_window(
conn, grabwin);
279 DLOG(
"Done, pixels = %d\n", pixels);
290 DLOG(
"Graphical resize %s: first->percent = %f, second->percent = %f.\n",
291 result ?
"successful" :
"failed", first->
percent, second->
percent);
orientation_t con_orientation(Con *con)
Returns the orientation of the given container (for stacked containers, vertical orientation is used ...
uint32_t con_rect_size_in_orientation(Con *con)
Returns given container's rect size depending on its orientation.
void con_fix_percent(Con *con)
Updates the percent attribute of the children of the given container.
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.
static bool threshold_exceeded(uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2)
drag_result_t drag_pointer(Con *con, const xcb_button_press_event_t *event, xcb_window_t confine_to, int cursor, bool use_threshold, callback_t callback, const void *extra)
This function grabs your pointer and keyboard and lets you drag stuff around (borders).
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)
double percent_for_1px(Con *con)
Calculate the minimum percent needed for the given container to be at least 1 pixel.
bool resize_neighboring_cons(Con *first, Con *second, int px, int ppt)
Resize the two given containers using the given amount of pixels or percentage points.
void tree_render(void)
Renders the tree, that is rendering all outputs using render_con() and pushing the changes to X11 usi...
orientation_t orientation_from_direction(direction_t direction)
Convert a direction to its corresponding orientation.
void x_mask_event_mask(uint32_t mask)
Applies the given mask to the event mask of every i3 window decoration X11 window.
xcb_window_t create_window(xcb_connection_t *conn, Rect dims, uint16_t depth, xcb_visualid_t visual, uint16_t window_class, enum xcursor_cursor_t cursor, bool map, uint32_t mask, uint32_t *values)
Convenience wrapper around xcb_create_window which takes care of depth, generating an ID and checking...
xcb_connection_t * conn
XCB connection and root screen.
#define DRAGGING_CB(name)
Macro to create a callback function for dragging.
drag_result_t
This is the return value of a drag operation like drag_pointer.
int logical_px(const int logical)
Convert a logical amount of pixels (e.g.
#define TAILQ_PREV(elm, headname, field)
#define TAILQ_NEXT(elm, field)
@ XCURSOR_CURSOR_RESIZE_HORIZONTAL
@ XCURSOR_CURSOR_RESIZE_VERTICAL
bool * threshold_exceeded
orientation_t orientation
struct Config::config_client client
struct Colortriple focused
Stores a rectangle, for example the size of a window, the child window etc.
A 'Con' represents everything from the X11 root window down to a single X11 window.