Re: [PATCH] Make focus* commands screen aware.
Joseph Mingrone <[email protected]> Sun, 11 Dec 2016 20:15:34 -0400
| Newsgroups | gmane.comp.window-managers.ratpoison.devel |
|---|---|
| Message-ID | <[email protected]> |
Pedro Silva <psilva-P1A6hWqLyZ+kUZHOYISyRg-XMD5yJDbdMReXY1tMh2IBg@public.gmane.org> writes: > focusright, focusleft, focusup, and focusdown previously worked solely > within the frame's screen, because their underlying handling logic in > split.c strictly did not consider their screen offsets. > This patch introduces 4 new functions, frame_*_abs, which instead report > the 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. > --- > doc/ratpoison.texi | 4 +++- > src/frame.c | 27 ++++++++++++++++++++++++ > src/frame.h | 4 ++++ > src/split.c | 62 +++++++++++++++++++++++++++++++++++------------------- > 4 files changed, 74 insertions(+), 23 deletions(-) This is a nice idea. It makes ratpoison behave similar to StumpWM with respect to multiple screens, which I find more intuitive. I've attached an updated patch, which applies against the xrandr branch. _______________________________________________ Ratpoison-devel mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/ratpoison-devel
0001-Update-screen-aware-focus-commands.patch
(text/x-patch, 5.6 KB)
From cb7ffe6b056e3d579bfbb81a17e96aacc20fd9e2 Mon Sep 17 00:00:00 2001 From: Joseph Mingrone <[email protected]> Date: Sun, 11 Dec 2016 19:03:29 -0400 Subject: [PATCH] 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. --- doc/ratpoison.texi | 4 +++- src/frame.c | 27 +++++++++++++++++++++++++++ src/frame.h | 4 ++++ src/split.c | 44 ++++++++++++++++++++++++-------------------- 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; } } -- 2.11.0
signature.asc
(application/pgp-signature, 930 B)
-----BEGIN PGP SIGNATURE----- iQJ8BAEBCgBmBQJYTewmXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ1NUIwOTNBNzI2QzM4ODU1NzEyMkJBRDUz NkE0MEM4M0IwRDZFRjlFAAoJEDakDIOw1u+e+4AP/3Bx/pLwVS3VxgW7iTQI7G0L uuc9e2xnURYyKq5mj1I3evYERpAv/LFL19b0dXFZ5wxeNs9KH81Jb2sbednuqjgu dkZZE4wdoSjDP96TJdI17ckYNc8LuBmaansz0NxFQmz+pJOx4vk2NWZ0Z0wcxLBc 51wFbLWpd6crERJ2RjZ/rAEOyaU1D4DIJVoD5C6aFwiBlqAJDEojNCaHMHoKNCvs CxEtP/dMHrq7klT84Xg51ikW3G31UScOpbCjnofsjsiqAPgMbGuHcngxsMREf9Wb dlJJVsD7DoECttWuuXyj9ukT1fsDT57uwsoDO2TyiJUIk+xE0pG6RB2aUh6Hk/uw QXVBmg1H8nsPjD9b+WV6pTOG5BsLqhr6rXqfgW4LUEn9/yMm5tcWLI/RAgstU3vW LAqJoyfQVXy/4b0ohhHCA4jWAhUIpmIkshJpzY9mBVFNJzXKIT77rEiCwEzJH1dg x+sLQnLmMhpw7+QiaT6oA5S43984bbjsjVZ1oCxlkFgXdD4DkEVl3HnIPKhCFfHT 30eiQyq+xKrFeT6NwGG1WY+LMY0kjnI9EwVRSYt+VB6BeXasZy7Tg+/JlS4TCsA4 /GOkkreus5Za49CW58MBBsUo3tWrYB6yw8PUlDFt+lV588zrTLHv5MxnJByVTIY0 Vj8JaxEgT+vxdIctptFs =QqCK -----END PGP SIGNATURE-----