summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsabetts <sabetts>2006-03-16 01:41:13 +0000
committersabetts <sabetts>2006-03-16 01:41:13 +0000
commit4e1d3ffcec845b5618f6ac8a2b2c8ad40dadbceb (patch)
tree3bfca1227c7e1017504c1b4ac6f13832c1600764 /src
parent2af887d39f6cba4cbbcaac8b51ffa773be809f23 (diff)
downloadratpoison-4e1d3ffcec845b5618f6ac8a2b2c8ad40dadbceb.zip
2006-03-15 Bernhard R. Link <brlink@debian.org>
* src/screen.c (screen_update): new function (init_screen): listen for screen resizes * src/screen.h: new prototype * src/events.c (configure_notify): new function (delegate_event): call configure_notify for ConfigureNotify events * src/frame.c (frame_dump): remember the size of the screen the frame coordinates are relative to. (frame_restore): adopt coordinates to possible screen resizes. * src/frame.h (frame_fump): take a screen argument (frame_read): likewise * src/actions.c (cmd_tmpwm): listen for screen resizes again (fdump, frestore, cmd_fdump): supply screen to frame_dump, frameread
Diffstat (limited to 'src')
-rw-r--r--src/actions.c9
-rw-r--r--src/events.c16
-rw-r--r--src/frame.c26
-rw-r--r--src/frame.h4
-rw-r--r--src/screen.c33
-rw-r--r--src/screen.h1
6 files changed, 79 insertions, 10 deletions
diff --git a/src/actions.c b/src/actions.c
index 4586e25..666bfb5 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -4278,7 +4278,8 @@ cmd_tmpwm (int interactive, struct cmdarg **args)
{
XSelectInput(dpy, RootWindow (dpy, screens[i].screen_num),
PropertyChangeMask | ColormapChangeMask
- | SubstructureRedirectMask | SubstructureNotifyMask);
+ | SubstructureRedirectMask | SubstructureNotifyMask
+ | StructureNotifyMask);
/* Map its key window */
XMapWindow (dpy, screens[i].key_window);
}
@@ -4329,7 +4330,7 @@ fdump (rp_screen *screen)
{
char *tmp;
- tmp = frame_dump (cur);
+ tmp = frame_dump (cur, screen);
sbuf_concat (s, tmp);
sbuf_concat (s, ",");
free (tmp);
@@ -4391,7 +4392,7 @@ frestore (char *data, rp_screen *s)
/* Build the new frame set. */
while (token != NULL)
{
- new = frame_read (token);
+ new = frame_read (token, s);
if (new == NULL)
{
free (dup);
@@ -4918,7 +4919,7 @@ cmd_sfdump (int interactively, struct cmdarg **args)
{
char *tmp;
- tmp = frame_dump (cur);
+ tmp = frame_dump (cur, &screens[i]);
sbuf_concat (s, tmp);
sbuf_concat (s, tmp2);
free (tmp);
diff --git a/src/events.c b/src/events.c
index 7e6e9ca..ad43cfe 100644
--- a/src/events.c
+++ b/src/events.c
@@ -702,6 +702,18 @@ mapping_notify (XMappingEvent *ev)
grab_keys_all_wins();
}
+static void
+configure_notify (XConfigureEvent *ev)
+{
+ rp_screen *s;
+
+ s = find_screen(ev->window);
+ if (s != NULL)
+ /* This is a root window of a screen,
+ * look if its width or height changed: */
+ screen_update(s,ev->width,ev->height);
+}
+
/* This is called whan an application has requested the
selection. Copied from rxvt. */
static void
@@ -847,6 +859,10 @@ delegate_event (XEvent *ev)
break;
case ConfigureNotify:
+ PRINT_DEBUG (("--- Handling ConfigureNotify ---\n"));
+ configure_notify( &ev->xconfigure );
+ break;
+
case MapNotify:
case Expose:
case MotionNotify:
diff --git a/src/frame.c b/src/frame.c
index 9abd0d9..3a6b82e 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -161,7 +161,7 @@ frame_copy (rp_frame *frame)
}
char *
-frame_dump (rp_frame *frame)
+frame_dump (rp_frame *frame, rp_screen *screen)
{
rp_window *win;
char *tmp;
@@ -171,12 +171,14 @@ frame_dump (rp_frame *frame)
win = find_window_number (frame->win_number);
s = sbuf_new (0);
- sbuf_printf (s, "(frame :number %d :x %d :y %d :width %d :height %d :window %ld :last-access %d :dedicated %d)",
+ sbuf_printf (s, "(frame :number %d :x %d :y %d :width %d :height %d :screenw %d :screenh %d :window %ld :last-access %d :dedicated %d)",
frame->number,
frame->x,
frame->y,
frame->width,
frame->height,
+ screen->width,
+ screen->height,
win ? win->w:0,
frame->last_access,
frame->dedicated);
@@ -191,12 +193,14 @@ frame_dump (rp_frame *frame)
#define read_slot(x) do { tmp = strtok (NULL, " "); x = strtol(tmp,NULL,10); } while(0)
rp_frame *
-frame_read (char *str)
+frame_read (char *str, rp_screen *screen)
{
Window w = 0L;
rp_window *win;
rp_frame *f;
char *tmp, *dup;
+ int screen_width = -1;
+ int screen_height = -1;
/* Create a blank frame. */
f = xmalloc (sizeof (rp_frame));
@@ -229,6 +233,10 @@ frame_read (char *str)
read_slot(f->width);
else if (!strcmp(tmp, ":height"))
read_slot(f->height);
+ else if (!strcmp(tmp, ":screenw"))
+ read_slot(screen_width);
+ else if (!strcmp(tmp, ":screenh"))
+ read_slot(screen_height);
else if (!strcmp(tmp, ":window"))
read_slot(w);
else if (!strcmp(tmp, ":last-access"))
@@ -254,6 +262,18 @@ frame_read (char *str)
PRINT_ERROR(("Frame has trailing garbage\n"));
free (dup);
+ /* adjust x, y, width and height to a possible screen size change */
+ if (screen_width > 0)
+ {
+ f->x = (f->x*screen->width)/screen_width;
+ f->width = (f->width*screen->width)/screen_width;
+ }
+ if (screen_height > 0)
+ {
+ f->y = (f->y*screen->height)/screen_height;
+ f->height = (f->height*screen->height)/screen_height;
+ }
+
/* Perform some integrity checks on what we got and fix any
problems. */
if (f->number <= 0)
diff --git a/src/frame.h b/src/frame.h
index b228c4d..7fad406 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -39,7 +39,7 @@ int frame_left (rp_frame *frame);
rp_frame *frame_new (rp_screen *s);
void frame_free (rp_screen *s, rp_frame *f);
rp_frame *frame_copy (rp_frame *frame);
-char *frame_dump (rp_frame *frame);
-rp_frame *frame_read (char *str);
+char *frame_dump (rp_frame *frame, rp_screen *screen);
+rp_frame *frame_read (char *str, rp_screen *screen);
#endif
diff --git a/src/screen.c b/src/screen.c
index c24d477..e4cc8d3 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -266,7 +266,8 @@ init_screen (rp_screen *s, int screen_num)
it, terminating ratpoison. */
XSelectInput(dpy, RootWindow (dpy, screen_num),
PropertyChangeMask | ColormapChangeMask
- | SubstructureRedirectMask | SubstructureNotifyMask );
+ | SubstructureRedirectMask | SubstructureNotifyMask
+ | StructureNotifyMask);
XSync (dpy, False);
/* Add netwm support. FIXME: I think this is busted. */
@@ -395,3 +396,33 @@ screen_dump (rp_screen *screen)
free (s);
return tmp;
}
+
+void
+screen_update (rp_screen *s, int width, int height)
+{
+ rp_frame *f;
+ int oldwidth,oldheight;
+
+ PRINT_DEBUG (("screen_update(%d,%d)\n", width, height));
+ if (rp_have_xinerama)
+ {
+ /* TODO: how to do this with xinerama? */
+ return;
+ }
+
+ if (s->width == width && s->height == height)
+ /* nothing to do */
+ return;
+
+ oldwidth = s->width; oldheight = s->height;
+ s->width = width; s->height = height;
+
+ list_for_each_entry (f, &s->frames, node)
+ {
+ f->x = (f->x*width)/oldwidth;
+ f->width = (f->width*width)/oldwidth;
+ f->y = (f->y*height)/oldheight;
+ f->height = (f->height*height)/oldheight;
+ maximize_all_windows_in_frame (f);
+ }
+}
diff --git a/src/screen.h b/src/screen.h
index 92f351b..d83ba4b 100644
--- a/src/screen.h
+++ b/src/screen.h
@@ -42,4 +42,5 @@ int is_a_root_window (unsigned int w);
char *screen_dump (rp_screen *screen);
+void screen_update (rp_screen *s, int width, int height);
#endif