version 1.35, 2018/03/23 07:44:44 |
version 1.36, 2018/06/08 20:54:22 |
|
|
} |
} |
} |
} |
|
|
|
struct layout_cell * |
|
layout_search_by_border(struct layout_cell *lc, u_int x, u_int y) |
|
{ |
|
struct layout_cell *lcchild, *last = NULL; |
|
|
|
TAILQ_FOREACH(lcchild, &lc->cells, entry) { |
|
if (x >= lcchild->xoff && x < lcchild->xoff + lcchild->sx && |
|
y >= lcchild->yoff && y < lcchild->yoff + lcchild->sy) { |
|
/* Inside the cell - recurse. */ |
|
return (layout_search_by_border(lcchild, x, y)); |
|
} |
|
|
|
if (last == NULL) { |
|
last = lcchild; |
|
continue; |
|
} |
|
|
|
switch (lc->type) { |
|
case LAYOUT_LEFTRIGHT: |
|
if (x < lcchild->xoff && x >= last->xoff + last->sx) |
|
return (last); |
|
break; |
|
case LAYOUT_TOPBOTTOM: |
|
if (y < lcchild->yoff && y >= last->yoff + last->sy) |
|
return (last); |
|
break; |
|
case LAYOUT_WINDOWPANE: |
|
break; |
|
} |
|
|
|
last = lcchild; |
|
} |
|
|
|
return (NULL); |
|
} |
|
|
void |
void |
layout_set_size(struct layout_cell *lc, u_int sx, u_int sy, u_int xoff, |
layout_set_size(struct layout_cell *lc, u_int sx, u_int sy, u_int xoff, |
u_int yoff) |
u_int yoff) |
|
|
layout_resize_pane(wp, type, change, 1); |
layout_resize_pane(wp, type, change, 1); |
} |
} |
|
|
|
void |
|
layout_resize_layout(struct window *w, struct layout_cell *lc, |
|
enum layout_type type, int change, int opposite) |
|
{ |
|
int needed, size; |
|
|
|
/* Grow or shrink the cell. */ |
|
needed = change; |
|
while (needed != 0) { |
|
if (change > 0) { |
|
size = layout_resize_pane_grow(w, lc, type, needed, |
|
opposite); |
|
needed -= size; |
|
} else { |
|
size = layout_resize_pane_shrink(w, lc, type, needed); |
|
needed += size; |
|
} |
|
|
|
if (size == 0) /* no more change possible */ |
|
break; |
|
} |
|
|
|
/* Fix cell offsets. */ |
|
layout_fix_offsets(w->layout_root); |
|
layout_fix_panes(w, w->sx, w->sy); |
|
notify_window("window-layout-changed", w); |
|
} |
|
|
/* Resize a single pane within the layout. */ |
/* Resize a single pane within the layout. */ |
void |
void |
layout_resize_pane(struct window_pane *wp, enum layout_type type, int change, |
layout_resize_pane(struct window_pane *wp, enum layout_type type, int change, |
int opposite) |
int opposite) |
{ |
{ |
struct window *w = wp->window; |
|
struct layout_cell *lc, *lcparent; |
struct layout_cell *lc, *lcparent; |
int needed, size; |
|
|
|
lc = wp->layout_cell; |
lc = wp->layout_cell; |
|
|
|
|
if (lc == TAILQ_LAST(&lcparent->cells, layout_cells)) |
if (lc == TAILQ_LAST(&lcparent->cells, layout_cells)) |
lc = TAILQ_PREV(lc, layout_cells, entry); |
lc = TAILQ_PREV(lc, layout_cells, entry); |
|
|
/* Grow or shrink the cell. */ |
layout_resize_layout(wp->window, lc, type, change, opposite); |
needed = change; |
|
while (needed != 0) { |
|
if (change > 0) { |
|
size = layout_resize_pane_grow(w, lc, type, needed, |
|
opposite); |
|
needed -= size; |
|
} else { |
|
size = layout_resize_pane_shrink(w, lc, type, needed); |
|
needed += size; |
|
} |
|
|
|
if (size == 0) /* no more change possible */ |
|
break; |
|
} |
|
|
|
/* Fix cell offsets. */ |
|
layout_fix_offsets(wp->window->layout_root); |
|
layout_fix_panes(wp->window, wp->window->sx, wp->window->sy); |
|
notify_window("window-layout-changed", wp->window); |
|
} |
} |
|
|
/* Helper function to grow pane. */ |
/* Helper function to grow pane. */ |