summaryrefslogtreecommitdiff
path: root/src/actions.c
diff options
context:
space:
mode:
authorsabetts <sabetts>2001-04-06 07:43:17 +0000
committersabetts <sabetts>2001-04-06 07:43:17 +0000
commit4ef01dc374bd76295e7a46140591e516187e33df (patch)
tree0534514c60d47f7ed7640091840516bef51273a0 /src/actions.c
parentb5272706dbd9346033add6edee2aaa519f11b182 (diff)
downloadratpoison-4ef01dc374bd76295e7a46140591e516187e33df.zip
* src/split.h (h_split_frame): renamed frome h_split_window
(v_split_frame): renamed frome v_split_window (split_frame): renamed frome split_window (remove_all_splits): renamed frome remove_all_frames (find_windows_frame): new prototype (find_frame_next): likewise (find_frame_prev): likewise (current_window): likewise (init_frame_list): likewise (set_active_frame): likewise * src/split.c (create_initial_frame): new function (init_frame_list): likewise (find_windows_frame): likewise (find_frame_next): likewise (find_frame_prev): likewise (current_window): likewise (update_frame_indicator): likewise (set_active_frame): likewise (split_frame): rename from split_window (v_split_frame): rename from v_split_window (h_split_frame): rename from h_split_window (remove_all_splits): renamed frome remove_all_frames (total_frame_area): traverses rp_window_frame list (num_frames): likewise (frame_overlaps): likewise (remove_frame): likewise (remove_frame): calls delete_frame_from_list * src/manage.c (scanwins): skips the frame_window (maximize_transient): finds the window's frame (maximize_normal): likewise * src/main.c (main): calls init_frame_list (init_screen): create and map the frame_window * src/list.c (give_window_focus): new function (goto_window): likewise (set_active_window): calls give_window_focus * src/list.h (give_window_focus): new prototype (goto_window): likewise * src/events.c (new_window): the screen's frame_window is not managed (cleanup_frame): new function (unmap_notify): calls cleanup_frame if window exists in a frame (destroy_window): likewise * src/data.h (struct screen_info): remove frame field (struct rp_window_frame): new fields win, prev, next (rp_window_frame_sentinel): new global * src/actions.c (cmd_prev): jumps to last accessed window if current frame is empty. (cmd_next): likewise (cmd_remove): nothing is done if only 1 frame exists * src/data.h (struct screen_info): new field frame_window (rp_current_frame): new global (rp_current_window): removed. All dependant code updated.
Diffstat (limited to 'src/actions.c')
-rw-r--r--src/actions.c132
1 files changed, 65 insertions, 67 deletions
diff --git a/src/actions.c b/src/actions.c
index 537fbfc..ced4c8e 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -1,5 +1,4 @@
-/* ratpoison actions
- * Copyright (C) 2000, 2001 Shawn Betts
+/* Copyright (C) 2000, 2001 Shawn Betts
*
* This file is part of ratpoison.
*
@@ -326,7 +325,7 @@ cmd_generate (void *data)
/* ev1.xkey.send_event = */
ev1.xkey.display = dpy;
/* ev1.xkey.root = */
- ev1.xkey.window = rp_current_window->w;
+ ev1.xkey.window = current_window()->w;
/* ev1.xkey.subwindow = */
/* ev1.xkey.time = ev.xkey.time; */
/* ev1.xkey.x == */
@@ -337,7 +336,7 @@ cmd_generate (void *data)
ev1.xkey.state = prefix_key.state;
ev1.xkey.keycode = XKeysymToKeycode (dpy, prefix_key.sym);
- XSendEvent (dpy, rp_current_window->w, False, KeyPressMask, &ev1);
+ XSendEvent (dpy, current_window()->w, False, KeyPressMask, &ev1);
/* XTestFakeKeyEvent (dpy, XKeysymToKeycode (dpy, 't'), True, 0); */
@@ -349,11 +348,19 @@ cmd_prev (void *data)
{
rp_window *w;
- if (!rp_current_window)
- message (MESSAGE_NO_MANAGED_WINDOWS);
- else
+ /* If the current frame is empty find the last accessed window and
+ put it in the frame */
+ if (!current_window())
+ {
+ set_active_window (find_window_other());
+ if (!current_window())
+ message (MESSAGE_NO_MANAGED_WINDOWS);
+
+ return;
+ }
+ else
{
- w = find_window_prev (rp_current_window);
+ w = find_window_prev (current_window());
if (!w)
message (MESSAGE_NO_OTHER_WINDOW);
@@ -365,19 +372,13 @@ cmd_prev (void *data)
void
cmd_prev_frame (void *data)
{
- rp_window *w;
-
- if (!rp_current_window)
- message (MESSAGE_NO_MANAGED_WINDOWS);
- else
- {
- w = find_window_prev_with_frame (rp_current_window);
+ rp_window_frame *frame;
- if (!w)
- message (MESSAGE_NO_OTHER_WINDOW);
- else
- set_active_window (w);
- }
+ frame = find_frame_prev (rp_current_frame);
+ if (!frame)
+ message (MESSAGE_NO_OTHER_WINDOW);
+ else
+ set_active_frame (frame);
}
void
@@ -385,11 +386,19 @@ cmd_next (void *data)
{
rp_window *w;
- if (!rp_current_window)
- message (MESSAGE_NO_MANAGED_WINDOWS);
+ /* If the current frame is empty find the last accessed window and
+ put it in the frame */
+ if (!current_window())
+ {
+ set_active_window (find_window_other());
+ if (!current_window())
+ message (MESSAGE_NO_MANAGED_WINDOWS);
+
+ return;
+ }
else
{
- w = find_window_next (rp_current_window);
+ w = find_window_next (current_window());
if (!w)
message (MESSAGE_NO_OTHER_WINDOW);
@@ -401,19 +410,14 @@ cmd_next (void *data)
void
cmd_next_frame (void *data)
{
- rp_window *w;
+ rp_window_frame *frame;
- if (!rp_current_window)
- message (MESSAGE_NO_MANAGED_WINDOWS);
- else
- {
- w = find_window_next_with_frame (rp_current_window);
+ frame = find_frame_next (rp_current_frame);
+ if (!frame)
+ message (MESSAGE_NO_OTHER_WINDOW);
+ else
+ set_active_frame (frame);
- if (!w)
- message (MESSAGE_NO_OTHER_WINDOW);
- else
- set_active_window (w);
- }
}
void
@@ -462,13 +466,13 @@ cmd_select (void *data)
if (strlen (str) > 0)
{
if ((w = find_window_name (str)))
- set_active_window (w);
+ goto_window (w);
/* try by number */
if ((n = string_to_window_number (str)) >= 0)
{
if ((w = find_window_number (n)))
- set_active_window (w);
+ goto_window (w);
else
/* show the window list as feedback */
show_bar (current_screen ());
@@ -477,7 +481,7 @@ cmd_select (void *data)
/* try by name */
{
if ((w = find_window_name (str)))
- set_active_window (w);
+ goto_window (w);
else
/* we need to format a string that includes the str */
message (" no window by that name ");
@@ -492,7 +496,7 @@ cmd_rename (void *data)
{
char *winname;
- if (rp_current_window == NULL) return;
+ if (current_window() == NULL) return;
if (data == NULL)
winname = get_input (MESSAGE_PROMPT_NEW_WINDOW_NAME);
@@ -501,15 +505,15 @@ cmd_rename (void *data)
if (*winname)
{
- free (rp_current_window->name);
- rp_current_window->name = xmalloc (sizeof (char) * strlen (winname) + 1);
+ free (current_window()->name);
+ current_window()->name = xmalloc (sizeof (char) * strlen (winname) + 1);
- strcpy (rp_current_window->name, winname);
+ strcpy (current_window()->name, winname);
- rp_current_window->named = 1;
+ current_window()->named = 1;
/* Update the program bar. */
- update_window_names (rp_current_window->scr);
+ update_window_names (current_window()->scr);
}
free (winname);
@@ -522,25 +526,25 @@ cmd_delete (void *data)
XEvent ev;
int status;
- if (rp_current_window == NULL) return;
+ if (current_window() == NULL) return;
ev.xclient.type = ClientMessage;
- ev.xclient.window = rp_current_window->w;
+ ev.xclient.window = current_window()->w;
ev.xclient.message_type = wm_protocols;
ev.xclient.format = 32;
ev.xclient.data.l[0] = wm_delete;
ev.xclient.data.l[1] = CurrentTime;
- status = XSendEvent(dpy, rp_current_window->w, False, 0, &ev);
+ status = XSendEvent(dpy, current_window()->w, False, 0, &ev);
if (status == 0) fprintf(stderr, "ratpoison: delete window failed\n");
}
void
cmd_kill (void *data)
{
- if (rp_current_window == NULL) return;
+ if (current_window() == NULL) return;
- XKillClient(dpy, rp_current_window->w);
+ XKillClient(dpy, current_window()->w);
}
void
@@ -736,9 +740,9 @@ cmd_abort (void *data)
/* XEvent ev; */
/* ev = *rp_current_event; */
-/* ev.xkey.window = rp_current_window->w; */
+/* ev.xkey.window = current_window()->w; */
/* ev.xkey.state = MODIFIER_PREFIX; */
-/* XSendEvent (dpy, rp_current_window->w, False, KeyPressMask, &ev); */
+/* XSendEvent (dpy, current_window()->w, False, KeyPressMask, &ev); */
/* XSync (dpy, False); */
/* } */
@@ -746,7 +750,7 @@ cmd_abort (void *data)
void
cmd_maximize (void *data)
{
- force_maximize (rp_current_window);
+ force_maximize (current_window());
}
/* Reassign the prefix key. */
@@ -813,41 +817,35 @@ cmd_echo (void *data)
void
cmd_h_split (void *data)
{
- h_split_window (rp_current_window);
+ h_split_frame (find_windows_frame (current_window()));
}
void
cmd_v_split (void *data)
{
- v_split_window (rp_current_window);
+ v_split_frame (find_windows_frame (current_window()));
}
void
cmd_only (void *data)
{
- if (!rp_current_window) return;
+ if (!current_window()) return;
- remove_all_frames();
- maximize (rp_current_window);
+ remove_all_splits();
+ maximize (current_window());
}
void
cmd_remove (void *data)
{
- rp_window *win;
-
- if (!rp_current_window) return;
+ rp_window_frame *frame;
- remove_frame (rp_current_window);
+ frame = find_frame_next (rp_current_frame);
- win = find_window_next_with_frame (rp_current_window);
- if (win)
+ if (frame)
{
- set_active_window (win);
- }
- else
- {
- set_active_window (find_window_other());
+ remove_frame (rp_current_frame);
+ set_active_frame (frame);
}
}