diff options
author | sabetts <sabetts> | 2003-02-10 13:43:23 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2003-02-10 13:43:23 +0000 |
commit | 8a2994e78d00efda379242387d955a42afc10330 (patch) | |
tree | 42ff26d9f6761a0f16f44d9558eb5d61aa82c55d /src/actions.c | |
parent | 3aec26ec206dad19fa859f020c384c5dab339ce2 (diff) | |
download | ratpoison-8a2994e78d00efda379242387d955a42afc10330.zip |
* src/split.h (num_frames): new prototype
(resize_shrink_to_window): likewise
(resize_frame_vertically): likewise
(resize_frame_horizontally): likewise
* src/split.c (num_frames): no longer a static function
(resize_shrink_to_window): new function
(resize_frame_vertically): likewise
(resize_frame_horizontally): likewise
* src/main.c (init_defaults): init frame_resize_unit.
* src/data.h (struct rp_defaults): new member frame_resize_unit.
* src/conf.h (RESIZE_VGROW_KEY): new define
(RESIZE_VGROW_MODIFIER): likewise
(RESIZE_VSHRINK_KEY): likewise
(RESIZE_VSHRINK_MODIFIER): likewise
(RESIZE_HGROW_KEY): likewise
(RESIZE_HGROW_MODIFIER): likewise
(RESIZE_HSHRINK_KEY): likewise
(RESIZE_HSHRINK_MODIFIER): likewise
(RESIZE_SHRINK_TO_WINDOW_KEY): likewise
(RESIZE_SHRINK_TO_WINDOW_MODIFIER): likewise
(RESIZE_END_KEY): likewise
(RESIZE_END_MODIFIER): likewise
* src/actions.h (cmd_shrink): new prototype
(cmd_resize): likewise
(cmd_defresizeunit): likewise
* src/actions.c (user_commands): add commands cmd_resize and
cmd_shrink, and cmd_defresizeunit.
(cmd_shrink): new function
(cmd_resize): likewise
(cmd_defresizeunit): likewise
Diffstat (limited to 'src/actions.c')
-rw-r--r-- | src/actions.c | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/src/actions.c b/src/actions.c index 623ca40..17a1db2 100644 --- a/src/actions.c +++ b/src/actions.c @@ -88,6 +88,8 @@ static user_command user_commands[] = {"prevscreen", cmd_prevscreen, arg_VOID}, {"nextscreen", cmd_nextscreen, arg_VOID}, {"warp", cmd_warp, arg_STRING}, + {"resize", cmd_resize, arg_STRING}, + {"shrink", cmd_shrink, arg_VOID}, /*@end (tag required for genrpbindings) */ /* Commands to set default behavior. */ @@ -107,6 +109,7 @@ static user_command user_commands[] = {"deffgcolor", cmd_deffgcolor, arg_STRING}, {"defbgcolor", cmd_defbgcolor, arg_STRING}, {"defbarpadding", cmd_defbarpadding, arg_STRING}, + {"defresizeunit", cmd_defresizeunit, arg_STRING}, /* Commands to help debug ratpoison. */ #ifdef DEBUG @@ -1356,6 +1359,98 @@ cmd_remove (int interactive, void *data) return NULL; } +char * +cmd_shrink (int interactive, void *data) +{ + screen_info *s = current_screen (); + + resize_shrink_to_window (s->rp_current_frame); + return NULL; +} + +char * +cmd_resize (int interactive, void *data) +{ + screen_info *s = current_screen (); + + /* If the user calls resize with arguments, treat it like the + non-interactive version. */ + if (interactive && data == NULL) + { + int nbytes, revert; + char buffer[513]; + unsigned int mod; + KeySym c; + Window fwin; + + /* If we haven't got at least 2 frames, there isn't anything to + scale. */ + if (num_frames (s) < 2) return NULL; + + XGetInputFocus (dpy, &fwin, &revert); + XSetInputFocus (dpy, s->key_window, RevertToPointerRoot, CurrentTime); + + nbytes = read_key (&c, &mod, buffer, sizeof (buffer)); + while (1) + { + if (c == RESIZE_VGROW_KEY && mod == RESIZE_VGROW_MODIFIER) + resize_frame_vertically (s->rp_current_frame, defaults.frame_resize_unit); + else if (c == RESIZE_VSHRINK_KEY && mod == RESIZE_VSHRINK_MODIFIER) + resize_frame_vertically (s->rp_current_frame, -defaults.frame_resize_unit); + else if (c == RESIZE_HGROW_KEY && mod == RESIZE_HGROW_MODIFIER) + resize_frame_horizontally (s->rp_current_frame, defaults.frame_resize_unit); + else if (c == RESIZE_HSHRINK_KEY && mod == RESIZE_HSHRINK_MODIFIER) + resize_frame_horizontally (s->rp_current_frame, -defaults.frame_resize_unit); + else if (c == RESIZE_SHRINK_TO_WINDOW_KEY + && mod == RESIZE_SHRINK_TO_WINDOW_MODIFIER) + resize_shrink_to_window (s->rp_current_frame); + else if (c == RESIZE_END_KEY && mod == RESIZE_END_MODIFIER) + break; + + nbytes = read_key (&c, &mod, buffer, sizeof (buffer)); + } + + XSetInputFocus (dpy, fwin, RevertToPointerRoot, CurrentTime); + } + else + { + int xdelta, ydelta; + + if (sscanf (data, "%d %d", &xdelta, &ydelta) < 2) + { + message (" resize: Two numeric arguments required "); + return NULL; + } + + resize_frame_horizontally (s->rp_current_frame, xdelta); + resize_frame_vertically (s->rp_current_frame, ydelta); + } + + return NULL; +} + +char * +cmd_defresizeunit (int interactive, void *data) +{ + int tmp; + + if (data == NULL && !interactive) + return xsprintf ("%d", defaults.frame_resize_unit); + + if (data == NULL || sscanf (data, "%d", &tmp) < 1) + { + message (" defresizeunit: One argument required "); + return NULL; + } + + if (tmp >= 0) + defaults.frame_resize_unit = tmp; + else + message (" defresizeunit: Bad argument "); + + return NULL; +} + /* banish the rat pointer */ char * cmd_banish (int interactive, void *data) |