summaryrefslogtreecommitdiff
path: root/src/frame.c
diff options
context:
space:
mode:
authorsabetts <sabetts>2003-04-04 17:17:58 +0000
committersabetts <sabetts>2003-04-04 17:17:58 +0000
commitf42294c8d8d0d8899f256ae9f233d80f09179d33 (patch)
tree69749d5e84f71f9afbf77955ecbe6800d677cfe2 /src/frame.c
parent7eac68127c67d4c007b65548af5901f4e381d512 (diff)
downloadratpoison-f42294c8d8d0d8899f256ae9f233d80f09179d33.zip
* src/actions.c (cmd_setenv): properly parse the environment name
and value using strtok. * src/window.c (add_to_window_list): init the window's frame_number to EMPTY. * src/number.h (numset_clear): new prototype * src/manage.c (unmanage)[AUTO_CLOSE]: code update for new globals. * src/frame.c (frame_new): init f->last_access to 0. (frame_dump): dump the X11 window ID, not the window number. (frame_read): new function * src/events.c (destroy_window): just unmanage the window. * src/actions.h (cmd_fdump): new prototype (cmd_frestore): likewise * src/actions.c (user_commands): new commands "fdump" and "frestore". (cmd_fdump): new function (cmd_frestore): likewise * src/number.c (numset_clear): new function.
Diffstat (limited to 'src/frame.c')
-rw-r--r--src/frame.c59
1 files changed, 57 insertions, 2 deletions
diff --git a/src/frame.c b/src/frame.c
index 6ac0277..8572981 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -114,6 +114,7 @@ frame_new (screen_info *s)
f = xmalloc (sizeof (rp_window_frame));
f->number = numset_request (s->frames_numset);
+ f->last_access = 0;
return f;
}
@@ -147,17 +148,21 @@ frame_copy (rp_window_frame *frame)
char *
frame_dump (rp_window_frame *frame)
{
+ rp_window *win;
char *tmp;
struct sbuf *s;
+ /* rather than use win_number, use the X11 window ID. */
+ win = find_window_number (frame->win_number);
+
s = sbuf_new (0);
- sbuf_printf (s, "%d %d %d %d %d %d %d",
+ sbuf_printf (s, "%d %d %d %d %d %ld %d",
frame->number,
frame->x,
frame->y,
frame->width,
frame->height,
- frame->win_number,
+ win ? win->w:0,
frame->last_access);
/* Extract the string and return it, and don't forget to free s. */
@@ -165,3 +170,53 @@ frame_dump (rp_window_frame *frame)
free (s);
return tmp;
}
+
+rp_window_frame *
+frame_read (char *str)
+{
+ Window w;
+ rp_window *win;
+ rp_window_frame *f;
+
+ f = xmalloc (sizeof (rp_window_frame));
+ if (sscanf (str, "%d %d %d %d %d %ld %d",
+ &f->number,
+ &f->x,
+ &f->y,
+ &f->width,
+ &f->height,
+ &w,
+ &f->last_access) < 7)
+ {
+ free (f);
+ return NULL;
+ }
+
+ /* Perform some integrity checks on what we got and fix any
+ problems. */
+ if (f->number <= 0)
+ f->number = 0;
+ if (f->x <= 0)
+ f->x = 0;
+ if (f->y <= 0)
+ f->y = 0;
+ if (f->width <= defaults.window_border_width*2)
+ f->width = defaults.window_border_width*2 + 1;
+ if (f->height <= defaults.window_border_width*2)
+ f->height = defaults.window_border_width*2 + 1;
+ if (f->last_access < 0)
+ f->last_access = 0;
+
+ /* Find the window with the X11 window ID. */
+ win = find_window_in_list (w, &rp_mapped_window);
+ if (win)
+ {
+ f->win_number = win->number;
+ }
+ else
+ {
+ f->win_number = EMPTY;
+ }
+
+ return f;
+}