changeset: 2271:28abf570b460
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Fri Feb 01 22:11:06 2008 -0500
summary: Reallocate the screen buffer on RandR resize.
diff -r e8fd3882ed1d -r 28abf570b460 cmd/wmii/fns.h
--- a/cmd/wmii/fns.h Thu Jan 31 19:56:49 2008 -0500
+++ b/cmd/wmii/fns.h Fri Feb 01 22:11:06 2008 -0500
@@ -161,6 +161,9 @@ ulong str2modmask(const char*);
ulong str2modmask(const char*);
void update_keys(void);
+/* main.c */
+void init_screen(WMScreen*);
+
/* map.c */
MapEnt* hash_get(Map*, const char*, int create);
void* hash_rm(Map*, const char*);
diff -r e8fd3882ed1d -r 28abf570b460 cmd/wmii/main.c
--- a/cmd/wmii/main.c Thu Jan 31 19:56:49 2008 -0500
+++ b/cmd/wmii/main.c Fri Feb 01 22:11:06 2008 -0500
@@ -184,13 +184,13 @@ init_cursors(void) {
XFreePixmap(display, pix);
}
-static void
+void
init_screen(WMScreen *screen) {
screen->r = scr.rect;
def.snap = Dy(scr.rect) / 63;
-
- sel_screen = pointerscreen();
+ freeimage(screen->ibuf);
+ screen->ibuf = allocimage(Dx(screen->r), Dy(screen->r), scr.depth);
}
static void
@@ -446,14 +446,14 @@ main(int argc, char *argv[]) {
loadcolor(&def.focuscolor, FOCUSCOLORS);
loadcolor(&def.normcolor, NORMCOLORS);
+ sel_screen = pointerscreen();
+
num_screens = 1;
screens = emallocz(num_screens * sizeof(*screens));
screen = &screens[0];
for(i = 0; i < num_screens; i++) {
s = &screens[i];
init_screen(s);
-
- s->ibuf = allocimage(Dx(s->r), Dy(s->r), scr.depth);
wa.event_mask =
SubstructureRedirectMask
diff -r e8fd3882ed1d -r 28abf570b460 cmd/wmii/x11.c
--- a/cmd/wmii/x11.c Thu Jan 31 19:56:49 2008 -0500
+++ b/cmd/wmii/x11.c Fri Feb 01 22:11:06 2008 -0500
@@ -203,6 +203,9 @@ allocimage(int w, int h, int depth) {
void
freeimage(Image *img) {
+ if(img == nil)
+ return;
+
assert(img->type == WImage);
XFreePixmap(display, img->w);
diff -r e8fd3882ed1d -r 28abf570b460 cmd/wmii/xext.c
--- a/cmd/wmii/xext.c Thu Jan 31 19:56:49 2008 -0500
+++ b/cmd/wmii/xext.c Fri Feb 01 22:11:06 2008 -0500
@@ -45,14 +45,15 @@ randr_screenchange(XRRScreenChangeNotify
Point d;
XRRUpdateConfiguration((XEvent*)ev);
-
+ scr.rect = Rect(0, 0, ev->width, ev->height);
+
d.x = ev->width - Dx(screen->r);
d.y = ev->height - Dy(screen->r);
for(v=view; v; v=v->next) {
v->r.max.x += d.x;
v->r.max.y += d.y;
}
- screen->r = Rect(0, 0, ev->width, ev->height);
+ init_screen(screen);
bar_resize(screen);
}
Received on Sat Feb 02 2008 - 04:14:46 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:59:14 UTC