2 #define I3__FILE__ "resize.c"
31 DLOG(
"new x = %d, y = %d\n", new_x, new_y);
35 new_x < (output->
rect.
x + 25))
42 new_y < (output->
rect.
y + 25))
53 DLOG(
"Find two participants for resizing container=%p in direction=%i\n", other, direction);
54 Con *first = *current;
57 DLOG(
"Current container is NULL, aborting.\n");
63 const bool dir_backwards = (direction ==
D_UP || direction ==
D_LEFT);
64 while (first->
type != CT_WORKSPACE &&
65 first->
type != CT_FLOATING_CON &&
84 DLOG(
"No second container in this direction found, trying to look further up in the tree...\n");
89 DLOG(
"Found participants: first=%p and second=%p.\n", first, second);
92 if (first == NULL || second == NULL) {
93 DLOG(
"Could not find two participants for this resize request.\n");
101 DLOG(
"resize handler\n");
113 mask = XCB_CW_OVERRIDE_REDIRECT;
128 if (orientation ==
HORIZ) {
129 helprect.
x = second->
rect.
x;
130 helprect.
y = second->
rect.
y;
133 initial_position = second->
rect.
x;
134 xcb_warp_pointer(
conn, XCB_NONE, event->root, 0, 0, 0, 0,
135 second->
rect.
x, event->root_y);
137 helprect.
x = second->
rect.
x;
138 helprect.
y = second->
rect.
y;
141 initial_position = second->
rect.
y;
142 xcb_warp_pointer(
conn, XCB_NONE, event->root, 0, 0, 0, 0,
143 event->root_x, second->
rect.
y);
146 mask = XCB_CW_BACK_PIXEL;
149 mask |= XCB_CW_OVERRIDE_REDIRECT;
155 xcb_circulate_window(
conn, XCB_CIRCULATE_RAISE_LOWEST, helpwin);
160 new_position = initial_position;
167 xcb_destroy_window(
conn, helpwin);
168 xcb_destroy_window(
conn, grabwin);
175 int pixels = (new_position - initial_position);
177 DLOG(
"Done, pixels = %d\n", pixels);
185 double new_percent, difference;
186 double percent = first->
percent;
187 DLOG(
"percent = %f\n", percent);
189 DLOG(
"original = %d\n", original);
190 new_percent = (original + pixels) * (percent / original);
191 difference = percent - new_percent;
192 DLOG(
"difference = %f\n", difference);
193 DLOG(
"new percent = %f\n", new_percent);
197 double s_percent = second->
percent;
198 second->
percent = s_percent + difference;
drag_result_t drag_pointer(Con *con, const xcb_button_press_event_t *event, xcb_window_t confine_to, border_t border, int cursor, callback_t callback, const void *extra)
This function grabs your pointer and keyboard and lets you drag stuff around (borders).
void x_mask_event_mask(uint32_t mask)
Applies the given mask to the event mask of every i3 window decoration X11 window.
int resize_graphical_handler(Con *first, Con *second, orientation_t orientation, const xcb_button_press_event_t *event)
struct Config::config_client client
xcb_connection_t * conn
XCB connection and root screen.
#define TAILQ_NEXT(elm, field)
Con * con_get_output(Con *con)
Gets the output container (first container with CT_OUTPUT in hierarchy) this node is on...
#define DRAGGING_CB(name)
Macro to create a callback function for dragging.
Stores a rectangle, for example the size of a window, the child window etc.
orientation_t orientation
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...
drag_result_t
This is the return value of a drag operation like drag_pointer.
orientation_t con_orientation(Con *con)
Returns the orientation of the given container (for stacked containers, vertical orientation is used ...
bool resize_find_tiling_participants(Con **current, Con **other, direction_t direction)
A 'Con' represents everything from the X11 root window down to a single X11 window.
void con_fix_percent(Con *con)
Updates the percent attribute of the children of the given container.
int logical_px(const int logical)
Convert a logical amount of pixels (e.g.
struct Colortriple focused
#define TAILQ_PREV(elm, headname, field)