summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsabetts <sabetts>2001-12-09 02:04:49 +0000
committersabetts <sabetts>2001-12-09 02:04:49 +0000
commit9c0fbfffd7268ce6a2c0a0263dded6f1fe6e72c9 (patch)
tree41cc210fa1de2f209f84d8ff79589ce3d925d7ab
parent917953c69be92a5be1b3c20f1cf64a3dac3fd40a (diff)
downloadratpoison-9c0fbfffd7268ce6a2c0a0263dded6f1fe6e72c9.zip
* src/events.c (handle_key): revert the focus immediately after
reading the key. * src/list.c (give_window_focus): update rp_current_frame when setting the window focus. * src/main.c (main): scan for windows in a seperate pass after initializing the screen structures. (init_screen): build a display string for each screen. (init_screen): remove the call to scanwins. * src/manage.c (current_screen): return the current screen using rp_current_screen. * src/split.h (init_frame_lists): new function * src/split.c (rp_window_frame_sentinel): remove. (rp_current_frame): remove. (frames_screen): new function (maximize_frame): use the frame's screen to find out the width and height of the display. (create_initial_frame): take a pointer to a screen_info as an argument. (init_frame_lists): new function (init_frame_list): take a pointer to a screen_info as an argument. (find_last_frame): take a pointer to a screen_info as an argument. * src/actions.c (spawn): Set the DISPLAY environment variable to point to the current screen. * src/data.h (struct screen_info): add display_string, rp_window_frame_sentinel, rp_current_frame. (rp_current_screen): new global (rp_current_frame): Remove. Dependant code uses screen_info.rp_current_frame.
-rw-r--r--ChangeLog38
-rw-r--r--src/actions.c36
-rw-r--r--src/data.h19
-rw-r--r--src/events.c10
-rw-r--r--src/list.c5
-rw-r--r--src/main.c36
-rw-r--r--src/manage.c5
-rw-r--r--src/split.c194
-rw-r--r--src/split.h3
9 files changed, 223 insertions, 123 deletions
diff --git a/ChangeLog b/ChangeLog
index 3281b99..95aec17 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,41 @@
+2001-12-08 shawn <sabetts@vcn.bc.ca>
+
+ * src/events.c (handle_key): revert the focus immediately after
+ reading the key.
+
+ * src/list.c (give_window_focus): update rp_current_frame when
+ setting the window focus.
+
+ * src/main.c (main): scan for windows in a seperate pass after
+ initializing the screen structures.
+ (init_screen): build a display string for each screen.
+ (init_screen): remove the call to scanwins.
+
+ * src/manage.c (current_screen): return the current screen using
+ rp_current_screen.
+
+ * src/split.h (init_frame_lists): new function
+
+ * src/split.c (rp_window_frame_sentinel): remove.
+ (rp_current_frame): remove.
+ (frames_screen): new function
+ (maximize_frame): use the frame's screen to find out the width and
+ height of the display.
+ (create_initial_frame): take a pointer to a screen_info as an
+ argument.
+ (init_frame_lists): new function
+ (init_frame_list): take a pointer to a screen_info as an argument.
+ (find_last_frame): take a pointer to a screen_info as an argument.
+
+ * src/actions.c (spawn): Set the DISPLAY environment variable to
+ point to the current screen.
+
+ * src/data.h (struct screen_info): add display_string,
+ rp_window_frame_sentinel, rp_current_frame.
+ (rp_current_screen): new global
+ (rp_current_frame): Remove. Dependant code uses
+ screen_info.rp_current_frame.
+
2001-12-09 Gergely Nagy <algernon@debian.org>
* debian/changelog: Lets have a snapshot release
diff --git a/src/actions.c b/src/actions.c
index 106d715..367968d 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -600,7 +600,7 @@ cmd_prev_frame (int interactive, void *data)
{
rp_window_frame *frame;
- frame = find_frame_prev (rp_current_frame);
+ frame = find_frame_prev (current_screen()->rp_current_frame);
if (!frame)
message (MESSAGE_NO_OTHER_WINDOW);
else
@@ -642,7 +642,7 @@ cmd_next_frame (int interactive, void *data)
{
rp_window_frame *frame;
- frame = find_frame_next (rp_current_frame);
+ frame = find_frame_next (current_screen()->rp_current_frame);
if (!frame)
message (MESSAGE_NO_OTHER_FRAME);
else
@@ -704,7 +704,7 @@ cmd_select (int interactive, void *data)
{
if (strlen (str) == 1 && str[0] == '-')
{
- blank_frame (rp_current_frame);
+ blank_frame (current_screen()->rp_current_frame);
}
/* else if ((w = find_window_name (str))) */
/* { */
@@ -912,17 +912,15 @@ void
spawn(void *data)
{
char *cmd = data;
- /*
- * ugly dance to avoid leaving zombies. Could use SIGCHLD,
- * but it's not very portable.
- */
+ /* Ugly dance to avoid leaving zombies. Could use SIGCHLD, but it's
+ not very portable. */
if (fork() == 0)
{
if (fork() == 0)
{
/* Some process setup to make sure the spawned process runs
in its own session. */
- putenv(DisplayString(dpy));
+ putenv(current_screen()->display_string);
#ifdef HAVE_SETSID
setsid();
#endif
@@ -958,7 +956,7 @@ cmd_newwm(int interactive, void *data)
PRINT_DEBUG ("Switching to %s\n", prog);
- putenv(DisplayString(dpy));
+ putenv(current_screen()->display_string);
execlp(prog, prog, 0);
PRINT_ERROR ("exec %s ", prog);
@@ -1165,14 +1163,14 @@ cmd_echo (int interactive, void *data)
char *
cmd_h_split (int interactive, void *data)
{
- h_split_frame (rp_current_frame);
+ h_split_frame (current_screen()->rp_current_frame);
return NULL;
}
char *
cmd_v_split (int interactive, void *data)
{
- v_split_frame (rp_current_frame);
+ v_split_frame (current_screen()->rp_current_frame);
return NULL;
}
@@ -1190,11 +1188,11 @@ cmd_remove (int interactive, void *data)
{
rp_window_frame *frame;
- frame = find_frame_next (rp_current_frame);
+ frame = find_frame_next (current_screen()->rp_current_frame);
if (frame)
{
- remove_frame (rp_current_frame);
+ remove_frame (current_screen()->rp_current_frame);
set_active_frame (frame);
}
@@ -1604,8 +1602,8 @@ cmd_defpadding (int interactive, void *data)
/* Resize the frames to make sure they are not too big and not too
small. */
- for (frame = rp_window_frame_sentinel->next;
- frame != rp_window_frame_sentinel;
+ for (frame = current_screen()->rp_window_frame_sentinel->next;
+ frame != current_screen()->rp_window_frame_sentinel;
frame = frame->next)
{
int bk_pos, bk_len;
@@ -1942,7 +1940,7 @@ cmd_focusup (int interactive, void *data)
{
rp_window_frame *frame;
- if ((frame = find_frame_up (rp_current_frame)))
+ if ((frame = find_frame_up (current_screen()->rp_current_frame)))
set_active_frame (frame);
return NULL;
@@ -1953,7 +1951,7 @@ cmd_focusdown (int interactive, void *data)
{
rp_window_frame *frame;
- if ((frame = find_frame_down (rp_current_frame)))
+ if ((frame = find_frame_down (current_screen()->rp_current_frame)))
set_active_frame (frame);
return NULL;
@@ -1964,7 +1962,7 @@ cmd_focusleft (int interactive, void *data)
{
rp_window_frame *frame;
- if ((frame = find_frame_left (rp_current_frame)))
+ if ((frame = find_frame_left (current_screen()->rp_current_frame)))
set_active_frame (frame);
return NULL;
@@ -1975,7 +1973,7 @@ cmd_focusright (int interactive, void *data)
{
rp_window_frame *frame;
- if ((frame = find_frame_right (rp_current_frame)))
+ if ((frame = find_frame_right (current_screen()->rp_current_frame)))
set_active_frame (frame);
return NULL;
diff --git a/src/data.h b/src/data.h
index f143230..b427810 100644
--- a/src/data.h
+++ b/src/data.h
@@ -99,6 +99,16 @@ struct screen_info
Colormap def_cmap;
Cursor rat;
unsigned long fg_color, bg_color; /* The pixel color. */
+
+ char *display_string;
+
+ /* A list of frames that may or may not contain windows. There should
+ always be one in the list. */
+ rp_window_frame *rp_window_frame_sentinel;
+
+ /* Pointer to the currently focused frame. One for each screen so
+ when you switch screens the focus doesn't get frobbed. */
+ rp_window_frame *rp_current_frame;
};
struct rp_action
@@ -173,13 +183,7 @@ extern rp_window *rp_mapped_window_sentinel;
assigned to them and are not visible/active. */
extern rp_window *rp_unmapped_window_sentinel;
-/* A list of frames that may or may not contain windows. There should
- always be one in the list. */
-extern rp_window_frame *rp_window_frame_sentinel;
-
-/* Pointer to the currently focused frame. */
-extern rp_window_frame *rp_current_frame;
-
+extern int rp_current_screen;
extern screen_info *screens;
extern int num_screens;
@@ -190,7 +194,6 @@ extern Atom rp_command;
extern Atom rp_command_request;
extern Atom rp_command_result;
-
extern Atom wm_state;
extern Atom wm_change_state;
extern Atom wm_protocols;
diff --git a/src/events.c b/src/events.c
index efdc860..acc936f 100644
--- a/src/events.c
+++ b/src/events.c
@@ -121,7 +121,7 @@ unmap_notify (XEvent *ev)
window. */
frame = find_windows_frame (win);
if (frame) cleanup_frame (frame);
- if (frame == rp_current_frame) set_active_frame (frame);
+ if (frame == win->scr->rp_current_frame) set_active_frame (frame);
withdraw_window (win);
break;
@@ -208,7 +208,7 @@ destroy_window (XDestroyWindowEvent *ev)
case... */
frame = find_windows_frame (win);
if (frame) cleanup_frame (frame);
- if (frame == rp_current_frame) set_active_frame (frame);
+ if (frame == win->scr->rp_current_frame) set_active_frame (frame);
unmanage (win);
@@ -354,7 +354,7 @@ client_msg (XClientMessageEvent *ev)
if (w)
set_active_window (w);
else
- blank_frame (rp_current_frame);
+ blank_frame (win->scr->rp_current_frame);
}
}
else
@@ -411,11 +411,11 @@ handle_key (screen_info *s)
}
read_key (&keysym, &mod, NULL, 0);
+ XSetInputFocus (dpy, fwin, revert, CurrentTime);
if ((key_action = find_keybinding (keysym, x11_mask_to_rp_mask (mod))))
{
char *result;
- XSetInputFocus (dpy, fwin, revert, CurrentTime);
result = command (1, key_action->data);
/* Gobble the result. */
@@ -425,8 +425,6 @@ handle_key (screen_info *s)
else
{
/* No key match, notify user. */
- XSetInputFocus (dpy, fwin, revert, CurrentTime);
-
keysym_name = keysym_to_string (keysym, x11_mask_to_rp_mask (mod));
marked_message_printf (0, 0, " %s unbound key ", keysym_name);
free (keysym_name);
diff --git a/src/list.c b/src/list.c
index f8666ad..d744ef8 100644
--- a/src/list.c
+++ b/src/list.c
@@ -177,7 +177,7 @@ find_window (Window w)
void
set_current_window (rp_window *win)
{
- set_frames_window (rp_current_frame, win);
+ set_frames_window (current_screen()->rp_current_frame, win);
}
void
@@ -452,6 +452,7 @@ give_window_focus (rp_window *win, rp_window *last_win)
XInstallColormap (dpy, win->colormap);
/* Finally, give the window focus */
+ rp_current_screen = win->scr->screen_num;
XSetInputFocus (dpy, win->w,
RevertToPointerRoot, CurrentTime);
@@ -570,7 +571,7 @@ set_active_window (rp_window *win)
if (win == NULL) return;
- last_win = set_frames_window (rp_current_frame, win);
+ last_win = set_frames_window (win->scr->rp_current_frame, win);
if (last_win) PRINT_DEBUG ("last window: %s\n", window_name (last_win));
PRINT_DEBUG ("new window: %s\n", window_name (win));
diff --git a/src/main.c b/src/main.c
index b9ac3e6..9671399 100644
--- a/src/main.c
+++ b/src/main.c
@@ -56,6 +56,7 @@ Atom rp_command;
Atom rp_command_request;
Atom rp_command_result;
+int rp_current_screen;
screen_info *screens;
int num_screens;
Display *dpy;
@@ -156,7 +157,7 @@ handler (Display *d, XErrorEvent *e)
XGetErrorText (d, e->error_code, error_msg + 7, sizeof (error_msg) - 7);
fprintf (stderr, "ratpoison: %s!\n", error_msg);
- marked_message (error_msg, 0, strlen (error_msg));
+ // marked_message (error_msg, 0, strlen (error_msg));
/* exit (EXIT_FAILURE); */
return 0;
@@ -472,22 +473,29 @@ main (int argc, char *argv[])
/* Setup ratpoison's internal structures */
init_defaults();
init_numbers ();
- init_window_list ();
- init_frame_list ();
- update_modifier_map ();
- initialize_default_keybindings ();
+ /* Initialize the screens */
num_screens = ScreenCount (dpy);
screens = (screen_info *)xmalloc (sizeof (screen_info) * num_screens);
-
PRINT_DEBUG ("%d screens.\n", num_screens);
- /* Initialize the screens */
for (i=0; i<num_screens; i++)
{
init_screen (&screens[i], i);
}
+ init_window_list ();
+ init_frame_lists ();
+ update_modifier_map ();
+ initialize_default_keybindings ();
+
+ /* Scan for windows */
+ rp_current_screen = 0;
+ for (i=0; i<num_screens; i++)
+ {
+ scanwins (&screens[i]);
+ }
+
read_startup_files ();
/* Indicate to the user that ratpoison has booted. */
@@ -523,6 +531,18 @@ init_screen (screen_info *s, int screen_num)
| SubstructureRedirectMask | SubstructureNotifyMask );
XSync (dpy, False);
+ /* Build the display string for each screen */
+ s->display_string = xmalloc (strlen(DisplayString (dpy)) + 21);
+ sprintf (s->display_string, "DISPLAY=%s", DisplayString (dpy));
+ if (strrchr (DisplayString (dpy), ':'))
+ {
+ char *dot;
+
+ dot = strrchr(s->display_string, '.');
+ if (dot)
+ sprintf(dot, ".%i", screen_num);
+ }
+
s->screen_num = screen_num;
s->root = RootWindow (dpy, screen_num);
s->def_cmap = DefaultColormap (dpy, screen_num);
@@ -573,8 +593,6 @@ init_screen (screen_info *s, int screen_num)
XSelectInput (dpy, s->help_window, KeyPressMask);
XSync (dpy, 0);
-
- scanwins (s);
}
void
diff --git a/src/manage.c b/src/manage.c
index c389e22..7d14fc9 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -64,10 +64,7 @@ ungrab_prefix_key (Window w)
screen_info*
current_screen ()
{
- if (current_window())
- return current_window()->scr;
- else
- return &screens[0];
+ return &screens[rp_current_screen];
}
void
diff --git a/src/split.c b/src/split.c
index f63412d..7c542d3 100644
--- a/src/split.c
+++ b/src/split.c
@@ -25,9 +25,6 @@
#include "ratpoison.h"
-rp_window_frame *rp_window_frame_sentinel;
-rp_window_frame *rp_current_frame;
-
static void
update_last_access (rp_window_frame *frame)
{
@@ -50,6 +47,26 @@ set_frames_window (rp_window_frame *frame, rp_window *win)
return last_win;
}
+static screen_info *
+frames_screen (rp_window_frame *frame)
+{
+ int i;
+ rp_window_frame *cur;
+
+ for (i=0; i<num_screens; i++)
+ for (cur = screens[i].rp_window_frame_sentinel->next;
+ cur !=screens[i]. rp_window_frame_sentinel;
+ cur = cur->next)
+ {
+ if (frame == cur)
+ return &screens[i];
+ }
+
+ /* This SHOULD be impossible to get to. FIXME: It'll crash higher up if we
+ return NULL. */
+ return NULL;
+}
+
void
maximize_all_windows_in_frame (rp_window_frame *frame)
{
@@ -77,54 +94,64 @@ delete_frame_from_list (rp_window_frame *frame)
static void
maximize_frame (rp_window_frame *frame)
{
+ screen_info *s = frames_screen (frame);
+
frame->x = defaults.padding_left;
frame->y = defaults.padding_top;
- /* FIXME: what about multiple screens? */
- frame->width = DisplayWidth (dpy, 0) - defaults.padding_right - defaults.padding_left;
- frame->height = DisplayHeight (dpy, 0) - defaults.padding_bottom - defaults.padding_top;
+ frame->width = DisplayWidth (dpy, s->screen_num) - defaults.padding_right - defaults.padding_left;
+ frame->height = DisplayHeight (dpy, s->screen_num) - defaults.padding_bottom - defaults.padding_top;
}
/* Create a full screen frame */
static void
-create_initial_frame ()
+create_initial_frame (screen_info *screen)
{
- rp_current_frame = xmalloc (sizeof (rp_window_frame));
+ screen->rp_current_frame = xmalloc (sizeof (rp_window_frame));
- update_last_access (rp_current_frame);
+ update_last_access (screen->rp_current_frame);
- rp_window_frame_sentinel->next = rp_current_frame;
- rp_window_frame_sentinel->prev = rp_current_frame;
- rp_current_frame->next = rp_window_frame_sentinel;
- rp_current_frame->prev = rp_window_frame_sentinel;
+ screen->rp_window_frame_sentinel->next = screen->rp_current_frame;
+ screen->rp_window_frame_sentinel->prev = screen->rp_current_frame;
+ screen->rp_current_frame->next = screen->rp_window_frame_sentinel;
+ screen->rp_current_frame->prev = screen->rp_window_frame_sentinel;
- maximize_frame (rp_current_frame);
+ maximize_frame (screen->rp_current_frame);
- set_frames_window (rp_current_frame, NULL);
+ set_frames_window (screen->rp_current_frame, NULL);
}
void
-init_frame_list ()
+init_frame_lists ()
{
- rp_window_frame_sentinel = xmalloc (sizeof (rp_window_frame));
+ int i;
- rp_window_frame_sentinel->next = rp_window_frame_sentinel;
- rp_window_frame_sentinel->prev = rp_window_frame_sentinel;
+ for (i=0; i<num_screens; i++)
+ init_frame_list (&screens[i]);
+}
- create_initial_frame();
+void
+init_frame_list (screen_info *screen)
+{
+ screen->rp_window_frame_sentinel = xmalloc (sizeof (rp_window_frame));
+
+ screen->rp_window_frame_sentinel->next = screen->rp_window_frame_sentinel;
+ screen->rp_window_frame_sentinel->prev = screen->rp_window_frame_sentinel;
+
+ create_initial_frame(screen);
}
rp_window_frame *
-find_last_frame ()
+find_last_frame (screen_info *s)
{
rp_window_frame *cur, *last = NULL;
int last_access = -1;
- for (cur = rp_window_frame_sentinel->next;
- cur != rp_window_frame_sentinel;
+ for (cur = s->rp_window_frame_sentinel->next;
+ cur != s->rp_window_frame_sentinel;
cur = cur->next)
{
- if (cur != rp_current_frame
+ if (cur != s->rp_current_frame
&& cur->last_access > last_access)
{
last_access = cur->last_access;
@@ -139,10 +166,13 @@ find_last_frame ()
rp_window_frame *
find_windows_frame (rp_window *win)
{
+ screen_info *s;
rp_window_frame *cur;
- for (cur = rp_window_frame_sentinel->next;
- cur != rp_window_frame_sentinel;
+ s = win->scr;
+
+ for (cur = s->rp_window_frame_sentinel->next;
+ cur != s->rp_window_frame_sentinel;
cur = cur->next)
{
if (cur->win == win) return cur;
@@ -159,7 +189,7 @@ find_frame_next (rp_window_frame *frame)
if (frame == NULL) return NULL;
cur = frame;
- if (cur->next == rp_window_frame_sentinel)
+ if (cur->next == frames_screen (frame)->rp_window_frame_sentinel)
{
cur = cur->next;
if (cur->next == frame) return NULL;
@@ -176,7 +206,7 @@ find_frame_prev (rp_window_frame *frame)
if (frame == NULL) return NULL;
cur = frame;
- if (cur->prev == rp_window_frame_sentinel)
+ if (cur->prev == frames_screen (frame)->rp_window_frame_sentinel)
{
cur = cur->prev;
if (cur->prev == frame) return NULL;
@@ -188,10 +218,7 @@ find_frame_prev (rp_window_frame *frame)
rp_window *
current_window ()
{
- if (rp_current_frame) return rp_current_frame->win;
-
- PRINT_ERROR ("BUG: There should always be a current frame\n");
- return NULL;
+ return screens[rp_current_screen].rp_current_frame->win;
}
static int
@@ -217,6 +244,7 @@ window_fits_in_frame (rp_window *win, rp_window_frame *frame)
rp_window *
find_window_for_frame (rp_window_frame *frame)
{
+ screen_info *s = frames_screen (frame);
int last_access = 0;
rp_window *most_recent = NULL;
rp_window *cur;
@@ -225,7 +253,8 @@ find_window_for_frame (rp_window_frame *frame)
cur != rp_mapped_window_sentinel;
cur = cur->next)
{
- if (cur != current_window()
+ if (cur->scr == s
+ && cur != current_window()
&& !find_windows_frame (cur)
&& cur->last_access >= last_access
&& window_fits_in_frame (cur, frame)
@@ -244,9 +273,12 @@ find_window_for_frame (rp_window_frame *frame)
static void
split_frame (rp_window_frame *frame, int way)
{
+ screen_info *s;
rp_window *win;
rp_window_frame *new_frame;
+ s = frames_screen (frame);
+
new_frame = xmalloc (sizeof (rp_window_frame));
/* It seems intuitive to make the last frame the newly created
@@ -254,10 +286,10 @@ split_frame (rp_window_frame *frame, int way)
update_last_access (new_frame);
/* append the new frame to the list */
- new_frame->prev = rp_window_frame_sentinel->prev;
- rp_window_frame_sentinel->prev->next = new_frame;
- rp_window_frame_sentinel->prev = new_frame;
- new_frame->next = rp_window_frame_sentinel;
+ new_frame->prev = s->rp_window_frame_sentinel->prev;
+ s->rp_window_frame_sentinel->prev->next = new_frame;
+ s->rp_window_frame_sentinel->prev = new_frame;
+ new_frame->next = s->rp_window_frame_sentinel;
set_frames_window (new_frame, NULL);
@@ -325,18 +357,19 @@ h_split_frame (rp_window_frame *frame)
void
remove_all_splits ()
{
+ screen_info *s = &screens[rp_current_screen];
rp_window *cur_window;
rp_window_frame *frame, *cur_frame;
rp_window *win;
cur_window = current_window();
- cur_frame = rp_current_frame;
+ cur_frame = s->rp_current_frame;
- while (rp_window_frame_sentinel->next != rp_window_frame_sentinel)
+ while (s->rp_window_frame_sentinel->next != s->rp_window_frame_sentinel)
{
- frame = rp_window_frame_sentinel->next;
+ frame = s->rp_window_frame_sentinel->next;
delete_frame_from_list (frame);
- if (frame != rp_current_frame)
+ if (frame != s->rp_current_frame)
{
for (win = rp_mapped_window_sentinel->next;
win != rp_mapped_window_sentinel;
@@ -349,7 +382,7 @@ remove_all_splits ()
free (frame);
}
- create_initial_frame ();
+ create_initial_frame (s);
/* Maximize all the windows that were in the current frame. */
for (win = rp_mapped_window_sentinel->next;
@@ -358,12 +391,12 @@ remove_all_splits ()
{
if (win->frame == cur_frame)
{
- set_frames_window (rp_current_frame, win);
+ set_frames_window (win->scr->rp_current_frame, win);
maximize (win);
}
}
- set_frames_window (rp_current_frame, cur_window);
+ set_frames_window (s->rp_current_frame, cur_window);
}
static int
@@ -395,13 +428,13 @@ frame_is_right (rp_window_frame *src, rp_window_frame *frame)
}
static int
-total_frame_area ()
+total_frame_area (screen_info *s)
{
int area = 0;
rp_window_frame *cur;
- for (cur = rp_window_frame_sentinel->next;
- cur != rp_window_frame_sentinel;
+ for (cur = s->rp_window_frame_sentinel->next;
+ cur != s->rp_window_frame_sentinel;
cur = cur->next)
{
area += cur->width * cur->height;
@@ -411,13 +444,13 @@ total_frame_area ()
}
static int
-num_frames ()
+num_frames (screen_info *s)
{
int count = 0;
rp_window_frame *cur;
- for (cur = rp_window_frame_sentinel->next;
- cur != rp_window_frame_sentinel;
+ for (cur = s->rp_window_frame_sentinel->next;
+ cur != s->rp_window_frame_sentinel;
cur = cur->next)
{
count++;
@@ -444,10 +477,13 @@ frames_overlap (rp_window_frame *f1, rp_window_frame *f2)
static int
frame_overlaps (rp_window_frame *frame)
{
+ screen_info *s;
rp_window_frame *cur;
- for (cur = rp_window_frame_sentinel->next;
- cur != rp_window_frame_sentinel;
+ s = frames_screen (frame);
+
+ for (cur = s->rp_window_frame_sentinel->next;
+ cur != s->rp_window_frame_sentinel;
cur = cur->next)
{
if (cur != frame && frames_overlap (cur, frame))
@@ -461,20 +497,23 @@ frame_overlaps (rp_window_frame *frame)
void
remove_frame (rp_window_frame *frame)
{
+ screen_info *s;
int area;
rp_window_frame *cur;
if (frame == NULL) return;
- area = total_frame_area();
+ s = frames_screen (frame);
+
+ area = total_frame_area(s);
PRINT_DEBUG ("Total Area: %d\n", area);
delete_frame_from_list (frame);
hide_window (frame->win);
hide_others (frame->win);
- for (cur = rp_window_frame_sentinel->next;
- cur != rp_window_frame_sentinel;
+ for (cur = s->rp_window_frame_sentinel->next;
+ cur != s->rp_window_frame_sentinel;
cur = cur->next)
{
rp_window_frame tmp_frame;
@@ -501,7 +540,7 @@ remove_frame (rp_window_frame *frame)
}
PRINT_DEBUG ("Attempting vertical Frame y=%d height=%d\n", cur->y, cur->height);
- PRINT_DEBUG ("New Total Area: %d\n", total_frame_area());
+ PRINT_DEBUG ("New Total Area: %d\n", total_frame_area(s));
/* If the area is bigger than before, the frame takes up too
much space. If the current frame and the deleted frame DON'T
@@ -510,7 +549,7 @@ remove_frame (rp_window_frame *frame)
deleted window. If any active frames overlap, it could have
taken up the right amount of space, overlaps with the deleted
frame but obviously didn't fit. */
- if (total_frame_area() > area || !frames_overlap (cur, frame) || frame_overlaps (cur))
+ if (total_frame_area(s) > area || !frames_overlap (cur, frame) || frame_overlaps (cur))
{
PRINT_DEBUG ("Didn't fit vertically\n");
@@ -535,10 +574,10 @@ remove_frame (rp_window_frame *frame)
}
PRINT_DEBUG ("Attempting horizontal Frame x=%d width=%d\n", cur->x, cur->width);
- PRINT_DEBUG ("New Total Area: %d\n", total_frame_area());
+ PRINT_DEBUG ("New Total Area: %d\n", total_frame_area(s));
/* Same test as the vertical test, above. */
- if (total_frame_area() > area || !frames_overlap (cur, frame) || frame_overlaps (cur))
+ if (total_frame_area(s) > area || !frames_overlap (cur, frame) || frame_overlaps (cur))
{
PRINT_DEBUG ("Didn't fit horizontally\n");
@@ -574,13 +613,14 @@ remove_frame (rp_window_frame *frame)
void
set_active_frame (rp_window_frame *frame)
{
- rp_window_frame *old = rp_current_frame;
+ screen_info *s = frames_screen (frame);
+ rp_window_frame *old = s->rp_current_frame;
- give_window_focus (frame->win, rp_current_frame->win);
+ give_window_focus (frame->win, s->rp_current_frame->win);
update_last_access (frame);
- rp_current_frame = frame;
+ s->rp_current_frame = frame;
- if (old != rp_current_frame && num_frames() > 1)
+ if (old != s->rp_current_frame && num_frames(s) > 1)
{
show_frame_indicator();
}
@@ -589,7 +629,7 @@ set_active_frame (rp_window_frame *frame)
focus. */
if( !frame->win )
{
- XSetInputFocus (dpy, current_screen()->key_window,
+ XSetInputFocus (dpy, s->key_window,
RevertToPointerRoot, CurrentTime);
}
}
@@ -625,8 +665,10 @@ show_frame_indicator ()
height = (FONT_HEIGHT (defaults.font) + defaults.bar_y_padding * 2);
XMoveResizeWindow (dpy, current_screen()->frame_window,
- rp_current_frame->x + rp_current_frame->width / 2 - width / 2,
- rp_current_frame->y + rp_current_frame->height / 2 - height / 2,
+ current_screen()->rp_current_frame->x
+ + current_screen()->rp_current_frame->width / 2 - width / 2,
+ current_screen()->rp_current_frame->y
+ + current_screen()->rp_current_frame->height / 2 - height / 2,
width, height);
XMapRaised (dpy, current_screen()->frame_window);
@@ -644,10 +686,11 @@ show_frame_indicator ()
rp_window_frame *
find_frame_up (rp_window_frame *frame)
{
+ screen_info *s = frames_screen (frame);
rp_window_frame *cur;
- for (cur = rp_window_frame_sentinel->next;
- cur != rp_window_frame_sentinel;
+ for (cur = s->rp_window_frame_sentinel->next;
+ cur != s->rp_window_frame_sentinel;
cur = cur->next)
{
if (frame->y == cur->y + cur->height)
@@ -663,10 +706,11 @@ find_frame_up (rp_window_frame *frame)
rp_window_frame *
find_frame_down (rp_window_frame *frame)
{
+ screen_info *s = frames_screen (frame);
rp_window_frame *cur;
- for (cur = rp_window_frame_sentinel->next;
- cur != rp_window_frame_sentinel;
+ for (cur = s->rp_window_frame_sentinel->next;
+ cur != s->rp_window_frame_sentinel;
cur = cur->next)
{
if (frame->y + frame->height == cur->y)
@@ -682,10 +726,11 @@ find_frame_down (rp_window_frame *frame)
rp_window_frame *
find_frame_left (rp_window_frame *frame)
{
+ screen_info *s = frames_screen (frame);
rp_window_frame *cur;
- for (cur = rp_window_frame_sentinel->next;
- cur != rp_window_frame_sentinel;
+ for (cur = s->rp_window_frame_sentinel->next;
+ cur != s->rp_window_frame_sentinel;
cur = cur->next)
{
if (frame->x == cur->x + cur->width)
@@ -701,10 +746,11 @@ find_frame_left (rp_window_frame *frame)
rp_window_frame *
find_frame_right (rp_window_frame *frame)
{
+ screen_info *s = frames_screen (frame);
rp_window_frame *cur;
- for (cur = rp_window_frame_sentinel->next;
- cur != rp_window_frame_sentinel;
+ for (cur = s->rp_window_frame_sentinel->next;
+ cur != s->rp_window_frame_sentinel;
cur = cur->next)
{
if (frame->x + frame->width == cur->x)
diff --git a/src/split.h b/src/split.h
index eb166ca..3cc5cb2 100644
--- a/src/split.h
+++ b/src/split.h
@@ -33,7 +33,8 @@ rp_window_frame *find_windows_frame (rp_window *win);
rp_window_frame *find_frame_next (rp_window_frame *frame);
rp_window_frame *find_frame_prev (rp_window_frame *frame);
rp_window *current_window ();
-void init_frame_list ();
+void init_frame_lists ();
+void init_frame_list (screen_info *screen);
void set_active_frame (rp_window_frame *frame);
void blank_frame (rp_window_frame *frame);
void show_frame_indicator ();