summaryrefslogtreecommitdiff
path: root/src/list.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/list.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/list.c')
-rw-r--r--src/list.c130
1 files changed, 45 insertions, 85 deletions
diff --git a/src/list.c b/src/list.c
index 9225d5a..e4c7680 100644
--- a/src/list.c
+++ b/src/list.c
@@ -28,7 +28,6 @@
rp_window *rp_unmapped_window_sentinel;
rp_window *rp_mapped_window_sentinel;
-rp_window *rp_current_window;
/* Get the mouse position relative to the root of the specified window */
static void
@@ -46,7 +45,6 @@ free_window (rp_window *w)
{
if (w == NULL) return;
- if (w->frame) free (w->frame);
free (w->name);
XFree (w->hints);
@@ -73,7 +71,6 @@ add_to_window_list (screen_info *s, Window w)
new_window->colormap = DefaultColormap (dpy, s->screen_num);
new_window->transient = XGetTransientForHint (dpy, new_window->w, &new_window->transient_for);
PRINT_DEBUG ("transient %d\n", new_window->transient);
- new_window->frame = NULL;
get_mouse_root_position (new_window, &new_window->mouse_x, &new_window->mouse_y);
@@ -120,12 +117,10 @@ find_window (Window w)
return win;
}
-
-
void
set_current_window (rp_window *win)
{
- rp_current_window = win;
+ rp_current_frame->win = win;
}
void
@@ -139,8 +134,6 @@ init_window_list ()
rp_unmapped_window_sentinel->next = rp_unmapped_window_sentinel;
rp_unmapped_window_sentinel->prev = rp_unmapped_window_sentinel;
-
- rp_current_window = NULL;
}
rp_window *
@@ -208,31 +201,7 @@ find_window_prev (rp_window *w)
{
if (cur == rp_mapped_window_sentinel) continue;
- if (!cur->frame)
- {
- return cur;
- }
- }
-
- return NULL;
-}
-
-/* Return the next window that is contained in a frame. Assumes window
- is in the mapped window list. */
-rp_window*
-find_window_prev_with_frame (rp_window *w)
-{
- rp_window *cur;
-
- if (!w) return NULL;
-
- for (cur = w->prev;
- cur != w;
- cur = cur->prev)
- {
- if (cur == rp_mapped_window_sentinel) continue;
-
- if (cur->frame)
+ if (!find_windows_frame (cur))
{
return cur;
}
@@ -256,31 +225,7 @@ find_window_next (rp_window *w)
{
if (cur == rp_mapped_window_sentinel) continue;
- if (!cur->frame)
- {
- return cur;
- }
- }
-
- return NULL;
-}
-
-/* Return the next window that is contained in a frame. Assumes window
- is in the mapped window list. */
-rp_window*
-find_window_next_with_frame (rp_window *w)
-{
- rp_window *cur;
-
- if (!w) return NULL;
-
- for (cur = w->next;
- cur != w;
- cur = cur->next)
- {
- if (cur == rp_mapped_window_sentinel) continue;
-
- if (cur->frame)
+ if (!find_windows_frame (cur))
{
return cur;
}
@@ -289,7 +234,6 @@ find_window_next_with_frame (rp_window *w)
return NULL;
}
-
rp_window *
find_window_other ()
{
@@ -302,8 +246,8 @@ find_window_other ()
cur = cur->next)
{
if (cur->last_access >= last_access
- && cur != rp_current_window
- && !cur->frame)
+ && cur != current_window()
+ && !find_windows_frame (cur))
{
most_recent = cur;
last_access = cur->last_access;
@@ -427,53 +371,69 @@ save_mouse_position (rp_window *win)
}
void
-set_active_window (rp_window *rp_w)
+give_window_focus (rp_window *win)
{
static int counter = 1; /* increments every time this function
is called. This way we can track
which window was last accessed. */
- if (rp_w == NULL) return;
- if (rp_w == rp_current_window) return;
+ if (win == NULL) return;
counter++;
- rp_w->last_access = counter;
+ win->last_access = counter;
- if (rp_w->scr->bar_is_raised) update_window_names (rp_w->scr);
+/* if (win->scr->bar_is_raised) update_window_names (win->scr); */
- if (rp_current_window != NULL)
+ if (current_window() != NULL)
{
- save_mouse_position (rp_current_window);
+ save_mouse_position (current_window());
}
- XWarpPointer (dpy, None, rp_w->scr->root,
- 0, 0, 0, 0, rp_w->mouse_x, rp_w->mouse_y);
+ XWarpPointer (dpy, None, win->scr->root,
+ 0, 0, 0, 0, win->mouse_x, win->mouse_y);
XSync (dpy, False);
- XSetInputFocus (dpy, rp_w->w,
+ XSetInputFocus (dpy, win->w,
RevertToPointerRoot, CurrentTime);
/* Swap colormaps */
- if (rp_current_window != NULL)
+ if (current_window() != NULL)
{
- XUninstallColormap (dpy, rp_current_window->colormap);
+ XUninstallColormap (dpy, current_window()->colormap);
}
- XInstallColormap (dpy, rp_w->colormap);
+ XInstallColormap (dpy, win->colormap);
+}
- /* If the new window doesn't have a frame then it inherits the frame
- of the current window */
- if (!rp_w->frame && rp_current_window)
- {
- rp_w->frame = rp_current_window->frame;
- rp_current_window->frame = NULL;
- }
+void
+set_active_window (rp_window *win)
+{
+ if (win == NULL) return;
- rp_current_window = rp_w;
+ give_window_focus (win);
+ rp_current_frame->win = win;
/* Make sure the window comes up full screen */
- maximize (rp_current_window);
- XRaiseWindow (dpy, rp_w->w);
+ maximize (current_window());
+ XRaiseWindow (dpy, win->w);
/* Make sure the program bar is always on the top */
- update_window_names (rp_w->scr);
+ update_window_names (win->scr);
+}
+
+/* Go to the window, switching frames if the window is already in a
+ frame. */
+void
+goto_window (rp_window *win)
+{
+ rp_window_frame *frame;
+
+ frame = find_windows_frame (win);
+ if (frame)
+ {
+ set_active_frame (frame);
+ }
+ else
+ {
+ set_active_window (win);
+ }
}