summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Mingrone <jrm@ftfl.ca>2016-12-11 19:03:29 -0400
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2016-12-12 18:44:19 +0100
commit5318f014451620f32a264d01f620562e973f3a64 (patch)
tree60ca7a6d55d31a4c5d6d64a97c25a282fcf3838d
parent31d4ca8f900d0d8db2a3ac6123c3c445cfa6346a (diff)
downloadratpoison-5318f014451620f32a264d01f620562e973f3a64.zip
Update screen-aware focus* commands after changes to support XRandR
This is an update to Pedro Silva's patch, so that it applies against the xrandr branch. That patch introduced four new functions, frame_*_abs, which report a frame's left, right, top, and bottom coordinates offset by it's screen arrangement. This allows the use of the focus* commands as additional screen navigation tools, and has the added benefit of making the find_frame_* functions clearer.
-rw-r--r--doc/ratpoison.texi4
-rw-r--r--src/frame.c27
-rw-r--r--src/frame.h4
-rw-r--r--src/split.c44
4 files changed, 58 insertions, 21 deletions
diff --git a/doc/ratpoison.texi b/doc/ratpoison.texi
index da9da16..8876db1 100644
--- a/doc/ratpoison.texi
+++ b/doc/ratpoison.texi
@@ -904,7 +904,9 @@ window.'' ratpoison means there's no other window to switch to in the
current screen. If you want to switch to the other xterm you can
switch to it by name (use @command{select} or @kbd{C-t '}), by number,
or you can use @command{nextscreen}, @command{prevscreen}, and
-@command{sselect}.
+@command{sselect}. Note, however, that the commands
+@command{focusright}, @command{focusleft}, @command{focusup}, and
+@command{focusdown} do work across screens.
@deffn Command nextscreen
This jumps you to the next X11 screen. @command{nextscreen} is
diff --git a/src/frame.c b/src/frame.c
index c42e2ab..95e4952 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -47,6 +47,33 @@ frame_bottom (rp_frame *frame)
return frame->y + frame->height;
}
+
+int
+frame_left_abs (rp_frame *frame)
+{
+ rp_screen *s = frames_screen (frame);
+ return s->left + frame->x;
+}
+
+int
+frame_top_abs (rp_frame *frame)
+{
+ rp_screen *s = frames_screen (frame);
+ return s->top + frame->y;
+}
+
+int
+frame_right_abs (rp_frame *frame)
+{
+ return frame_left_abs (frame) + frame->width;
+}
+
+int
+frame_bottom_abs (rp_frame *frame)
+{
+ return frame_top_abs (frame) + frame->height;
+}
+
int
frame_width(rp_frame *frame)
{
diff --git a/src/frame.h b/src/frame.h
index 611ecc0..f78f86c 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -35,6 +35,10 @@ int frame_bottom (rp_frame *frame);
int frame_right (rp_frame *frame);
int frame_top (rp_frame *frame);
int frame_left (rp_frame *frame);
+int frame_bottom_abs (rp_frame *frame);
+int frame_right_abs (rp_frame *frame);
+int frame_top_abs (rp_frame *frame);
+int frame_left_abs (rp_frame *frame);
rp_frame *frame_new (rp_screen *s);
void frame_free (rp_screen *s, rp_frame *f);
diff --git a/src/split.c b/src/split.c
index 5f74777..7042a55 100644
--- a/src/split.c
+++ b/src/split.c
@@ -997,15 +997,16 @@ show_frame_message (char *msg)
rp_frame *
find_frame_up (rp_frame *frame)
{
- rp_screen *s = frames_screen (frame);
+ rp_screen *s;
rp_frame *cur;
- list_for_each_entry (cur, &s->frames, node)
+ list_for_each_entry (s, &rp_screens, node)
{
- if (frame->y == cur->y + cur->height)
+ list_for_each_entry (cur, &s->frames, node)
{
- if (frame->x >= cur->x && frame->x < cur->x + cur->width)
- return cur;
+ if (frame_top_abs (frame) == frame_bottom_abs (cur))
+ if (frame_right_abs (frame) >= frame_left_abs (cur) && frame_left_abs (frame) <= frame_right_abs (cur))
+ return cur;
}
}
@@ -1015,15 +1016,16 @@ find_frame_up (rp_frame *frame)
rp_frame *
find_frame_down (rp_frame *frame)
{
- rp_screen *s = frames_screen (frame);
+ rp_screen *s;
rp_frame *cur;
- list_for_each_entry (cur, &s->frames, node)
+ list_for_each_entry (s, &rp_screens, node)
{
- if (frame->y + frame->height == cur->y)
+ list_for_each_entry (cur, &s->frames, node)
{
- if (frame->x >= cur->x && frame->x < cur->x + cur->width)
- return cur;
+ if (frame_bottom_abs (frame) == frame_top_abs (cur))
+ if (frame_right_abs (frame) >= frame_left_abs (cur) && frame_left_abs (frame) <= frame_right_abs (cur))
+ return cur;
}
}
@@ -1033,15 +1035,16 @@ find_frame_down (rp_frame *frame)
rp_frame *
find_frame_left (rp_frame *frame)
{
- rp_screen *s = frames_screen (frame);
+ rp_screen *s;
rp_frame *cur;
- list_for_each_entry (cur, &s->frames, node)
+ list_for_each_entry (s, &rp_screens, node)
{
- if (frame->x == cur->x + cur->width)
+ list_for_each_entry (cur, &s->frames, node)
{
- if (frame->y >= cur->y && frame->y < cur->y + cur->height)
- return cur;
+ if (frame_left_abs (frame) == frame_right_abs (cur))
+ if (frame_top_abs (frame) >= frame_top_abs (cur) && frame_top_abs (frame) < frame_bottom_abs (cur))
+ return cur;
}
}
@@ -1051,15 +1054,16 @@ find_frame_left (rp_frame *frame)
rp_frame *
find_frame_right (rp_frame *frame)
{
- rp_screen *s = frames_screen (frame);
+ rp_screen *s;
rp_frame *cur;
- list_for_each_entry (cur, &s->frames, node)
+ list_for_each_entry (s, &rp_screens, node)
{
- if (frame->x + frame->width == cur->x)
+ list_for_each_entry (cur, &s->frames, node)
{
- if (frame->y >= cur->y && frame->y < cur->y + cur->height)
- return cur;
+ if (frame_right_abs (frame) == frame_left_abs (cur))
+ if (frame_top_abs (frame) >= frame_top_abs (cur) && frame_top_abs (frame) < frame_bottom_abs (cur))
+ return cur;
}
}