Index: src/actions.c =================================================================== RCS file: /cvsroot/ratpoison/ratpoison/src/actions.c,v retrieving revision 1.125 diff -u -b -u -r1.125 actions.c --- src/actions.c 6 Jul 2002 21:28:05 -0000 1.125 +++ src/actions.c 9 Aug 2002 11:07:40 -0000 @@ -86,6 +86,10 @@ {"unalias", cmd_unalias, arg_STRING}, {"prevscreen", cmd_prevscreen, arg_VOID}, {"nextscreen", cmd_nextscreen, arg_VOID}, + {"hgrow", cmd_h_grow, arg_VOID}, + {"hshrink", cmd_h_shrink, arg_VOID}, + {"vgrow", cmd_v_grow, arg_VOID}, + {"vshrink", cmd_v_shrink, arg_VOID}, /address@hidden (tag required for genrpbindings) */ /* Commands to set default behavior. */ @@ -1302,6 +1306,36 @@ return NULL; } + +char * +cmd_h_grow (int interactive, void *data) +{ + resize_frame_horizontally (current_screen()->rp_current_frame, 0); + return NULL; +} + +char * +cmd_h_shrink (int interactive, void *data) +{ + resize_frame_horizontally (current_screen()->rp_current_frame, 1); + return NULL; +} + +char * +cmd_v_grow (int interactive, void *data) +{ + resize_frame_vertically (current_screen()->rp_current_frame, 0); + return NULL; +} + +char * +cmd_v_shrink (int interactive, void *data) +{ + resize_frame_vertically (current_screen()->rp_current_frame, 1); + return NULL; +} + + /* banish the rat pointer */ char * cmd_banish (int interactive, void *data) Index: src/actions.h =================================================================== RCS file: /cvsroot/ratpoison/ratpoison/src/actions.h,v retrieving revision 1.49 diff -u -b -u -r1.49 actions.h --- src/actions.h 24 Mar 2002 06:05:03 -0000 1.49 +++ src/actions.h 9 Aug 2002 11:07:41 -0000 @@ -68,6 +68,10 @@ char * cmd_v_split (int interactive, void *data); char * cmd_only (int interactive, void *data); char * cmd_remove (int interactive, void *data); +char * cmd_h_grow (int interactive, void *data); +char * cmd_h_shrink (int interactive, void *data); +char * cmd_v_grow (int interactive, void *data); +char * cmd_v_shrink (int interactive, void *data); char * cmd_banish (int interactive, void *data); char * cmd_curframe (int interactive, void *data); char * cmd_help (int interactive, void *data); Index: src/conf.h =================================================================== RCS file: /cvsroot/ratpoison/ratpoison/src/conf.h,v retrieving revision 1.29 diff -u -b -u -r1.29 conf.h --- src/conf.h 28 Jul 2002 23:07:04 -0000 1.29 +++ src/conf.h 9 Aug 2002 11:07:41 -0000 @@ -67,6 +67,9 @@ /* Maximum depth of a link. Used in the 'link' command. */ #define MAX_LINK_DEPTH 16 + +/* How many pixels a frame should grow or shrink when resizing it. */ +#define RESIZE_UNIT 10 /* Bad window messages can be safely ignored now that ratpoison has become stable enough. Comment this line if you wish to be notified Index: src/split.c =================================================================== RCS file: /cvsroot/ratpoison/ratpoison/src/split.c,v retrieving revision 1.23 diff -u -b -u -r1.23 split.c --- src/split.c 13 Mar 2002 08:23:30 -0000 1.23 +++ src/split.c 9 Aug 2002 11:07:41 -0000 @@ -26,6 +26,8 @@ #include "ratpoison.h" +static int num_frames (screen_info *s); + static void update_last_access (rp_window_frame *frame) { @@ -400,6 +402,259 @@ set_frames_window (s->rp_current_frame, cur_window); } + +/* Resize FRAME horizontally by one resize unit. if SHRINK is non-zero + then enlarge the frame, otherwise shrink it. */ + +void +resize_frame_horizontally (rp_window_frame *frame, int shrink) +{ + screen_info *s = frames_screen (frame); + int found_adjacent_frames = 0; + int max_bound, min_bound; + int orig_y; + rp_window_frame *cur; + + /* If there's only one frame don't do anything. */ + if (num_frames (s) < 2) + return; + + max_bound = frame->x + frame->width; + min_bound = frame->x; + orig_y = frame->y; + + /* Look for frames below that needs to be resized. */ + for (cur = s->rp_window_frame_sentinel->next; + cur != s->rp_window_frame_sentinel; + cur = cur->next) + { + if (cur->y == (frame->y + frame->height) + && (cur->x + cur->width) > frame->x + && cur->x < (frame->x + frame->width)) + { + if (shrink) + { + cur->height += RESIZE_UNIT; + cur->y -= RESIZE_UNIT; + } + else + { + cur->height -= RESIZE_UNIT; + cur->y += RESIZE_UNIT; + } + + if ((cur->x + cur->width) > max_bound) + max_bound = cur->x + cur->width; + + if (cur->x < min_bound) + min_bound = cur->x; + + if (cur->win) + maximize_all_windows_in_frame (cur); + + found_adjacent_frames = 1; + } + } + + /* Found no frames below, look for some above. */ + if (!found_adjacent_frames) + { + for (cur = s->rp_window_frame_sentinel->next; + cur != s->rp_window_frame_sentinel; + cur = cur->next) + { + if (cur->y == (frame->y - cur->height) + && (cur->x + cur->width) > frame->x + && cur->x < (frame->x + frame->width)) + { + if (shrink) + cur->height += RESIZE_UNIT; + else + cur->height -= RESIZE_UNIT; + + if ((cur->x + cur->width) > max_bound) + max_bound = cur->x + cur->width; + + if (cur->x < min_bound) + min_bound = cur->x; + + if (cur->win) + maximize_all_windows_in_frame (cur); + + found_adjacent_frames = 1; + } + } + + /* If we found any frames, move the current frame. */ + if (found_adjacent_frames) + { + if (shrink) + frame->y += RESIZE_UNIT; + else + frame->y -= RESIZE_UNIT; + } + } + + /* Resize current frame. */ + if (found_adjacent_frames) + { + if (shrink) + frame->height -= RESIZE_UNIT; + else + frame->height += RESIZE_UNIT; + + /* If we left any gaps, take care of them too. */ + for (cur = s->rp_window_frame_sentinel->next; + cur != s->rp_window_frame_sentinel; + cur = cur->next) + { + if (cur->y == orig_y && cur->x >= min_bound + && cur->x + cur->width <= max_bound + && cur != frame) + { + cur->height = frame->height; + cur->y = frame->y; + + if (cur->win) + maximize_all_windows_in_frame (cur); + } + } + + if (frame->win) + { + maximize_all_windows_in_frame (frame); + XRaiseWindow (dpy, frame->win->w); + } + } +} + + +/* Resize FRAME vertically by one resize unit. if SHRINK is non-zero + then enlarge the frame, otherwise shrink it. */ + +void +resize_frame_vertically (rp_window_frame *frame, int shrink) +{ + screen_info *s = frames_screen (frame); + int found_adjacent_frames = 0; + int max_bound, min_bound; + int orig_x; + rp_window_frame *cur; + + /* If there's only one frame don't do anything. */ + if (num_frames (s) < 2) + return; + + max_bound = frame->y + frame->height; + min_bound = frame->y; + orig_x = frame->x; + + /* Look for frames on the right that needs to be resized. */ + for (cur = s->rp_window_frame_sentinel->next; + cur != s->rp_window_frame_sentinel; + cur = cur->next) + { + if (cur->x == (frame->x + frame->width) + && (cur->y + cur->height) > frame->y + && cur->y < (frame->y + frame->height)) + { + if (shrink) + { + cur->width += RESIZE_UNIT; + cur->x -= RESIZE_UNIT; + } + else + { + cur->width -= RESIZE_UNIT; + cur->x += RESIZE_UNIT; + } + + if ((cur->y + cur->height) > max_bound) + max_bound = cur->y + cur->height; + + if (cur->y < min_bound) + min_bound = cur->y; + + if (cur->win) + maximize_all_windows_in_frame (cur); + + found_adjacent_frames = 1; + } + } + + /* Found no frames to the right, look for some to the left. */ + if (!found_adjacent_frames) + { + for (cur = s->rp_window_frame_sentinel->next; + cur != s->rp_window_frame_sentinel; + cur = cur->next) + { + if (cur->x == (frame->x - cur->width) + && (cur->y + cur->height) > frame->y + && cur->y < (frame->y + frame->height)) + { + if (shrink) + cur->width += RESIZE_UNIT; + else + cur->width -= RESIZE_UNIT; + + if ((cur->y + cur->height) > max_bound) + max_bound = cur->y + cur->height; + + if (cur->y < min_bound) + min_bound = cur->y; + + if (cur->win) + maximize_all_windows_in_frame (cur); + + found_adjacent_frames = 1; + } + } + + /* If we found any frames, move the current frame. */ + if (found_adjacent_frames) + { + if (shrink) + frame->x += RESIZE_UNIT; + else + frame->x -= RESIZE_UNIT; + } + } + + /* Resize current frame. */ + if (found_adjacent_frames) + { + if (shrink) + frame->width -= RESIZE_UNIT; + else + frame->width += RESIZE_UNIT; + + /* If we left any gaps, take care of them too. */ + for (cur = s->rp_window_frame_sentinel->next; + cur != s->rp_window_frame_sentinel; + cur = cur->next) + { + if (cur->x == orig_x && cur->y >= min_bound + && cur->y + cur->height <= max_bound + && cur != frame) + { + cur->width = frame->width; + cur->x = frame->x; + + if (cur->win) + maximize_all_windows_in_frame (cur); + } + } + + if (frame->win) + { + maximize_all_windows_in_frame (frame); + XRaiseWindow (dpy, frame->win->w); + } + } +} + + static int frame_is_below (rp_window_frame *src, rp_window_frame *frame) { Index: src/split.h =================================================================== RCS file: /cvsroot/ratpoison/ratpoison/src/split.h,v retrieving revision 1.9 diff -u -b -u -r1.9 split.h --- src/split.h 8 Feb 2002 02:46:00 -0000 1.9 +++ src/split.h 9 Aug 2002 11:07:41 -0000 @@ -27,6 +27,8 @@ void h_split_frame (rp_window_frame *frame); void v_split_frame (rp_window_frame *frame); void remove_all_splits (); +void resize_frame_horizontally (rp_window_frame *frame, int shrink); +void resize_frame_vertically (rp_window_frame *frame, int shrink); void remove_frame (rp_window_frame *frame); rp_window *find_window_for_frame (rp_window_frame *frame); rp_window_frame *find_windows_frame (rp_window *win);