summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsabetts <sabetts>2003-03-31 11:22:15 +0000
committersabetts <sabetts>2003-03-31 11:22:15 +0000
commit7eac68127c67d4c007b65548af5901f4e381d512 (patch)
tree6fa02c6817509a5bc912075b409c9562cae1c645 /src
parent1682d69fb5d92e4368b24f3399db4243549b132a (diff)
downloadratpoison-7eac68127c67d4c007b65548af5901f4e381d512.zip
* src/window.c (set_current_window): use current_frame()
* src/split.h (current_frame): new prototype * src/split.c (current_frame): new function (current_window): use current_frame() (split_frame): likewise (remove_all_splits): likewise (set_active_frame): likewise (show_frame_message): likewise (remove_all_splits): use current_screen() * src/actions.c (cmd_prev_frame): use current_frame() (cmd_next_frame): likewise (cmd_select): likewise (cmd_h_split): likewise (cmd_v_split): likewise (cmd_remove): likewise (cmd_shrink): likewise (cmd_resize): likewise (cmd_focusup): likewise (cmd_focusdown): likewise (cmd_focusleft): likewise (cmd_focusright): likewise
Diffstat (limited to 'src')
-rw-r--r--src/actions.c40
-rw-r--r--src/split.c27
-rw-r--r--src/split.h2
-rw-r--r--src/window.c5
4 files changed, 39 insertions, 35 deletions
diff --git a/src/actions.c b/src/actions.c
index 742c623..963d35e 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -674,7 +674,7 @@ cmd_prev_frame (int interactive, void *data)
{
rp_window_frame *frame;
- frame = find_frame_prev (screen_get_frame (current_screen(), current_screen()->current_frame));
+ frame = find_frame_next (current_frame());
if (!frame)
message (MESSAGE_NO_OTHER_FRAME);
else
@@ -716,7 +716,7 @@ cmd_next_frame (int interactive, void *data)
{
rp_window_frame *frame;
- frame = find_frame_next (screen_get_frame (current_screen(), current_screen()->current_frame));
+ frame = find_frame_next (current_frame());
if (!frame)
message (MESSAGE_NO_OTHER_FRAME);
else
@@ -778,7 +778,7 @@ cmd_select (int interactive, void *data)
{
if (strlen (str) == 1 && str[0] == '-')
{
- blank_frame (screen_get_frame (current_screen(), current_screen()->current_frame));
+ blank_frame (current_frame());
}
/* else if ((w = find_window_name (str))) */
/* { */
@@ -1339,7 +1339,7 @@ cmd_h_split (int interactive, void *data)
rp_window_frame *frame;
int pixels;
- frame = screen_get_frame (current_screen(), current_screen()->current_frame);
+ frame = current_frame();
/* Default to dividing the frame in half. */
if (data == NULL)
@@ -1361,7 +1361,7 @@ cmd_v_split (int interactive, void *data)
rp_window_frame *frame;
int pixels;
- frame = screen_get_frame (current_screen(), current_screen()->current_frame);
+ frame = current_frame();
/* Default to dividing the frame in half. */
if (data == NULL)
@@ -1398,11 +1398,11 @@ cmd_remove (int interactive, void *data)
return NULL;
}
- frame = find_frame_next (screen_get_frame (s, s->current_frame));
+ frame = find_frame_next (current_frame());
if (frame)
{
- remove_frame (screen_get_frame (s, s->current_frame));
+ remove_frame (current_frame());
set_active_frame (frame);
}
@@ -1412,9 +1412,7 @@ cmd_remove (int interactive, void *data)
char *
cmd_shrink (int interactive, void *data)
{
- screen_info *s = current_screen ();
-
- resize_shrink_to_window (screen_get_frame (s, s->current_frame));
+ resize_shrink_to_window (current_frame());
return NULL;
}
@@ -1450,16 +1448,16 @@ cmd_resize (int interactive, void *data)
nbytes = read_key (&c, &mod, buffer, sizeof (buffer), 1);
if (c == RESIZE_VGROW_KEY && mod == RESIZE_VGROW_MODIFIER)
- resize_frame_vertically (screen_get_frame (s, s->current_frame), defaults.frame_resize_unit);
+ resize_frame_vertically (current_frame(), defaults.frame_resize_unit);
else if (c == RESIZE_VSHRINK_KEY && mod == RESIZE_VSHRINK_MODIFIER)
- resize_frame_vertically (screen_get_frame (s, s->current_frame), -defaults.frame_resize_unit);
+ resize_frame_vertically (current_frame(), -defaults.frame_resize_unit);
else if (c == RESIZE_HGROW_KEY && mod == RESIZE_HGROW_MODIFIER)
- resize_frame_horizontally (screen_get_frame (s, s->current_frame), defaults.frame_resize_unit);
+ resize_frame_horizontally (current_frame(), defaults.frame_resize_unit);
else if (c == RESIZE_HSHRINK_KEY && mod == RESIZE_HSHRINK_MODIFIER)
- resize_frame_horizontally (screen_get_frame (s, s->current_frame), -defaults.frame_resize_unit);
+ resize_frame_horizontally (current_frame(), -defaults.frame_resize_unit);
else if (c == RESIZE_SHRINK_TO_WINDOW_KEY
&& mod == RESIZE_SHRINK_TO_WINDOW_MODIFIER)
- resize_shrink_to_window (screen_get_frame (s, s->current_frame));
+ resize_shrink_to_window (current_frame());
else if (c == INPUT_ABORT_KEY && mod == INPUT_ABORT_MODIFIER)
{
rp_window_frame *cur;
@@ -1494,8 +1492,8 @@ cmd_resize (int interactive, void *data)
return NULL;
}
- resize_frame_horizontally (screen_get_frame (s, s->current_frame), xdelta);
- resize_frame_vertically (screen_get_frame (s, s->current_frame), ydelta);
+ resize_frame_horizontally (current_frame(), xdelta);
+ resize_frame_vertically (current_frame(), ydelta);
}
return NULL;
@@ -2491,7 +2489,7 @@ cmd_focusup (int interactive, void *data)
{
rp_window_frame *frame;
- if ((frame = find_frame_up (screen_get_frame (current_screen(), current_screen()->current_frame))))
+ if ((frame = find_frame_up (current_frame())))
set_active_frame (frame);
return NULL;
@@ -2502,7 +2500,7 @@ cmd_focusdown (int interactive, void *data)
{
rp_window_frame *frame;
- if ((frame = find_frame_down (screen_get_frame (current_screen(), current_screen()->current_frame))))
+ if ((frame = find_frame_down (current_frame())))
set_active_frame (frame);
return NULL;
@@ -2513,7 +2511,7 @@ cmd_focusleft (int interactive, void *data)
{
rp_window_frame *frame;
- if ((frame = find_frame_left (screen_get_frame (current_screen(), current_screen()->current_frame))))
+ if ((frame = find_frame_left (current_frame())))
set_active_frame (frame);
return NULL;
@@ -2524,7 +2522,7 @@ cmd_focusright (int interactive, void *data)
{
rp_window_frame *frame;
- if ((frame = find_frame_right (screen_get_frame (current_screen(), current_screen()->current_frame))))
+ if ((frame = find_frame_right (current_frame())))
set_active_frame (frame);
return NULL;
diff --git a/src/split.c b/src/split.c
index 7db350a..e62c432 100644
--- a/src/split.c
+++ b/src/split.c
@@ -38,6 +38,13 @@ update_last_access (rp_window_frame *frame)
counter++;
}
+rp_window_frame *
+current_frame ()
+{
+ screen_info *s = current_screen();
+ return screen_get_frame (s, s->current_frame);
+}
+
int
num_frames (screen_info *s)
{
@@ -232,8 +239,7 @@ find_frame_prev (rp_window_frame *frame)
rp_window *
current_window ()
{
- return find_window_number (screen_get_frame (&screens[rp_current_screen],
- screens[rp_current_screen].current_frame)->win_number);
+ return find_window_number (current_frame()->win_number);
}
static int
@@ -296,7 +302,7 @@ split_frame (rp_window_frame *frame, int way, int pixels)
new_frame = frame_new (s);
/* Add the frame to the frameset. */
- list_add (&new_frame->node, &(screen_get_frame (s, s->current_frame)->node));
+ list_add (&new_frame->node, &current_frame()->node);
set_frames_window (new_frame, NULL);
@@ -367,7 +373,7 @@ void
remove_all_splits ()
{
struct list_head *tmp, *iter;
- screen_info *s = &screens[rp_current_screen];
+ screen_info *s = current_screen();
rp_window_frame *frame;
rp_window *win;
@@ -389,8 +395,8 @@ remove_all_splits ()
}
/* Maximize the frame and the windows in the frame. */
- maximize_frame (screen_get_frame (s, s->current_frame));
- maximize_all_windows_in_frame (screen_get_frame (s, s->current_frame));
+ maximize_frame (current_frame());
+ maximize_all_windows_in_frame (current_frame());
}
/* Shrink the size of the frame to fit it's current window. */
@@ -811,10 +817,11 @@ set_active_frame (rp_window_frame *frame)
screen_info *s = frames_screen (frame);
int old = current_screen()->current_frame;
rp_window *win, *old_win;
+ rp_window_frame *old_frame;
win = find_window_number (frame->win_number);
- old_win = find_window_number (screen_get_frame (current_screen(),
- current_screen()->current_frame)->win_number);
+ old_frame = current_frame();
+ old_win = find_window_number (old_frame->win_number);
/* Make the switch */
give_window_focus (win, old_win);
@@ -847,7 +854,7 @@ blank_frame (rp_window_frame *frame)
if (frame->win_number == EMPTY) return;
- win = find_window_number (frame->number);
+ win = find_window_number (frame->win_number);
hide_window (win);
hide_others (win);
@@ -878,7 +885,7 @@ show_frame_message (char *msg)
int width, height;
rp_window_frame *frame;
- frame = screen_get_frame (s, s->current_frame);
+ frame = current_frame();
width = defaults.bar_x_padding * 2 + XTextWidth (defaults.font, msg, strlen (msg));
height = (FONT_HEIGHT (defaults.font) + defaults.bar_y_padding * 2);
diff --git a/src/split.h b/src/split.h
index d7ce710..53661b0 100644
--- a/src/split.h
+++ b/src/split.h
@@ -54,4 +54,6 @@ rp_window_frame *find_frame_up (rp_window_frame *frame);
rp_window_frame *find_last_frame (screen_info *s);
rp_window_frame *find_frame_number (screen_info *s, int num);
+rp_window_frame *current_frame ();
+
#endif
diff --git a/src/window.c b/src/window.c
index a3042ab..692e53e 100644
--- a/src/window.c
+++ b/src/window.c
@@ -178,10 +178,7 @@ find_window (Window w)
void
set_current_window (rp_window *win)
{
- rp_window_frame *frame;
-
- frame = screen_get_frame (current_screen(), current_screen()->current_frame);
- set_frames_window (frame, win);
+ set_frames_window (current_frame(), win);
}
rp_window *