2 #define I3__FILE__ "resize.c"
14 extern xcb_connection_t *
conn;
33 DLOG(
"new x = %d, y = %d\n", new_x, new_y);
37 new_x < (output->
rect.
x + 25))
44 new_y < (output->
rect.
y + 25))
55 DLOG(
"Find two participants for resizing container=%p in direction=%i\n", other, direction);
56 Con *first = *current;
59 DLOG(
"Current container is NULL, aborting.\n");
65 const bool dir_backwards = (direction ==
D_UP || direction ==
D_LEFT);
66 while (first->
type != CT_WORKSPACE &&
67 first->
type != CT_FLOATING_CON &&
86 DLOG(
"No second container in this direction found, trying to look further up in the tree...\n");
91 DLOG(
"Found participants: first=%p and second=%p.", first, second);
94 if (first == NULL || second == NULL) {
95 DLOG(
"Could not find two participants for this resize request.\n");
103 DLOG(
"resize handler\n");
117 mask = XCB_CW_OVERRIDE_REDIRECT;
126 if (orientation ==
HORIZ) {
127 helprect.
x =
event->root_x;
128 helprect.
y = output->
rect.
y;
131 new_position =
event->root_x;
133 helprect.
x = output->
rect.
x;
134 helprect.
y =
event->root_y;
137 new_position =
event->root_y;
140 mask = XCB_CW_BACK_PIXEL;
143 mask |= XCB_CW_OVERRIDE_REDIRECT;
147 XCB_WINDOW_CLASS_INPUT_OUTPUT, (orientation ==
HORIZ ?
151 xcb_circulate_window(
conn, XCB_CIRCULATE_RAISE_LOWEST, helpwin);
159 xcb_destroy_window(
conn, helpwin);
160 xcb_destroy_window(
conn, grabwin);
168 if (orientation ==
HORIZ)
169 pixels = (new_position -
event->root_x);
170 else pixels = (new_position -
event->root_y);
172 DLOG(
"Done, pixels = %d\n", pixels);
180 double new_percent, difference;
181 double percent = first->
percent;
182 DLOG(
"percent = %f\n", percent);
184 DLOG(
"original = %d\n", original);
185 new_percent = (original + pixels) * (percent / original);
186 difference = percent - new_percent;
187 DLOG(
"difference = %f\n", difference);
188 DLOG(
"new percent = %f\n", new_percent);
192 double s_percent = second->
percent;
193 second->
percent = s_percent + difference;