summaryrefslogtreecommitdiff
path: root/src/screen.c
diff options
context:
space:
mode:
authorsabetts <sabetts>2003-03-31 07:06:22 +0000
committersabetts <sabetts>2003-03-31 07:06:22 +0000
commiteac6dda17283fe9f312d0c8576f4370f82fc5c0a (patch)
treeb21d6e62bee0b6e4374e240537dfb975fd8a6680 /src/screen.c
parent84ee56d66b889363903eddd81a8b2a07f180656f (diff)
downloadratpoison-eac6dda17283fe9f312d0c8576f4370f82fc5c0a.zip
* src/split.c (current_window): call screen_get_frame.
(split_frame): call screen_get_frame to get appropriate structure. (split_frame): call find_window_number to get appropriate structure. (remove_all_splits): call screen_get_frame to get appropriate structure. (resize_frame): make sure all frames that will be resized are big enough for the resize. (resize_frame): return int (resize_shrink_to_window): call find_window_number to get the appropriate structure. (resize_frame_right): return int (resize_frame_left): likewise (resize_frame_top): likewise (resize_frame_bottom): likewise (resize_frame_horizontally): backup the frameset and restore it if the resize fails. Do not allow a frame to be resized too small or too big. (resize_frame_vertically): likewise (remove_frame): call find_window_number to get the appropriate structure. (set_active_frame): likewise (blank_frame): likewise (show_frame_message): call screen_get_frame to get the appropriate structure. * src/screen.c (screen_width): new function (and prototype) (screen_height): likewise (screen_left): likewise (screen_right): likewise (screen_top): likewise (screen_bottom): likewise (screen_copy_frameset): likewise (screen_restore_frameset): likewise (frameset_free): likewise (screen_get_frame): likewise * src/split.c (maximize_frame): call screen_width and screen_height to get the size for the frame. * src/ratpoison.h: include screen.h * src/manage.c (move_window): * src/frame.h (frame_copy): new prototype (frame_dump): likewise * src/frame.c (frame_copy): new function (frame_dump): likewise * src/events.c (unmap_notify): compare frame numbers, not pointers. (client_msg): call screen_get_frame when blanking the frame. * src/data.h (EMPTY): new define (struct rp_window_frame): replace the win field with win_number. Dependant code updated. (struct rp_window): replace frame with frame_number. Dependant code updated. (struct screen_info): replace rp_current_frame with current_frame and change type to int. Dependant code updated. * src/Makefile.am (ratpoison_SOURCES): added screen.h and screen.c
Diffstat (limited to 'src/screen.c')
-rw-r--r--src/screen.c118
1 files changed, 118 insertions, 0 deletions
diff --git a/src/screen.c b/src/screen.c
new file mode 100644
index 0000000..aa7b1df
--- /dev/null
+++ b/src/screen.c
@@ -0,0 +1,118 @@
+/* Copyright (C) 2000-2003 Shawn Betts
+ *
+ * This file is part of ratpoison.
+ *
+ * ratpoison is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * ratpoison is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; see the file COPYING. If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307 USA
+ */
+
+#include "ratpoison.h"
+
+int
+screen_width (screen_info *s)
+{
+ return DisplayWidth (dpy, s->screen_num) - defaults.padding_right - defaults.padding_left;
+}
+
+int
+screen_height (screen_info *s)
+{
+ return DisplayHeight (dpy, s->screen_num) - defaults.padding_bottom - defaults.padding_top;
+}
+
+int
+screen_left (screen_info *s)
+{
+ return defaults.padding_left;
+}
+
+int
+screen_right (screen_info *s)
+{
+ return screen_left (s) + screen_width (s);
+}
+
+int
+screen_top (screen_info *s)
+{
+ return defaults.padding_top;
+}
+
+int
+screen_bottom (screen_info *s)
+{
+ return screen_top (s) + screen_height (s);
+}
+
+/* Returns a pointer to a list of frames. */
+struct list_head *
+screen_copy_frameset (screen_info *s)
+{
+ struct list_head *head;
+ rp_window_frame *cur;
+
+ /* Init our new list. */
+ head = xmalloc (sizeof (struct list_head));
+ INIT_LIST_HEAD (head);
+
+ /* Copy each frame to our new list. */
+ list_for_each_entry (cur, &s->rp_window_frames, node)
+ {
+ list_add_tail (&(frame_copy (cur))->node, head);
+ }
+
+ return head;
+}
+
+/* Set head as the frameset, deleting the existing one. */
+void
+screen_restore_frameset (screen_info *s, struct list_head *head)
+{
+ frameset_free (&s->rp_window_frames);
+ INIT_LIST_HEAD (&s->rp_window_frames);
+
+ /* Hook in our new frameset. */
+ list_splice (head, &s->rp_window_frames);
+}
+
+/* Given a list of frames, free them, but don't remove their numbers
+ from the numset. */
+void
+frameset_free (struct list_head *head)
+{
+ rp_window_frame *frame;
+ struct list_head *iter, *tmp;
+
+ list_for_each_safe_entry (frame, iter, tmp, head, node)
+ {
+ /* FIXME: what if rp_window_frames has memory inside its struct
+ that needs to be freed? */
+ free (frame);
+ }
+}
+
+rp_window_frame *
+screen_get_frame (screen_info *s, int frame_num)
+{
+ rp_window_frame *cur;
+
+ list_for_each_entry (cur, &s->rp_window_frames, node)
+ {
+ if (cur->number == frame_num)
+ return cur;
+ }
+
+ return NULL;
+}