[dwm] sselp or X11 Bug? XInternAtom

2009-03-02 Thread Stefan Kuttler
Hi,


there is some odd bug which probably nobody will care about in sselp:
It is somewhat cosmetic, searching ML on this didn't revealed anything useful. 
(please point me to threads, if im wrong)


Select the *String* NULL or make the selection a newline:

Selection=

./sselp 
Selection=NULL
,./sselp 


Using XInternAtom seems to fix the Symptom:



# lit. NULL 
,./sselp 
NULL
,diff -Naub sselp
sselp sselp.c   sselp.c.orig  sselp.o   
,diff -Naub sselp.c.orig sselp.c
--- sselp.c.origMon Mar  2 00:24:56 2009
+++ sselp.c Mon Mar  2 00:45:16 2009
@@ -11,6 +11,7 @@
Display *dpy;
Atom utf8_string;
Atom xa_clip_string;
+   Atom lit_null_string;
Window w;
XEvent ev;
Atom typeret;
@@ -23,6 +24,7 @@
return NULL;
utf8_string = XInternAtom(dpy, UTF8_STRING, False);
xa_clip_string = XInternAtom(dpy, _SSELP_STRING, False);
+   lit_null_string = XInternAtom(dpy, NULL, True);
w = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10, 200, 200,
1, CopyFromParent, CopyFromParent);
XConvertSelection(dpy, XA_PRIMARY, utf8_string, xa_clip_string,


I believe, there must be a better solution to this.


As a completly different question I noted that the data pointer is not 
initialized to NULL:

,grep '*data' sselp.c
unsigned char *data;
unsigned char *data;

Shouldn't this look like unsigned char *data = NULL;  ?


regards
Stefan
-- 
Computer Bild Tarifsieger! GMX FreeDSL - Telefonanschluss + DSL
für nur 17,95 ¿/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a



[dwm] [OT] xss bugfix

2009-03-02 Thread Neale Pickett

I've fixed a bug in xss that would cause the included magic hack to
die after running for a few days straight.  My 4-year-old daughter asked
me to explain it to her, and it's such a good explanation that you're
going to get it too.

Every time I wanted to draw a new line, I would ask for a new color of
crayon.  Then there's this guy who you can tell I'm done with this
crayon and will come pick it off of the floor.  But I told the guy I
was done with the crayon before I put it down on the floor, so when he
came by to pick it up, he didn't see it and went away.  Over time, I
wound up taking every crayon in the box, and then the teacher noticed
and gave me a timeout for not sharing crayons.

Her first question: how many crayons did you take, daddy?

My answer: oh, probably a couple million.


Download available at http://woozle.org/~neale/src/xss/

Neale



[dwm] [PATCH] remove sizehints argument in resize()

2009-03-02 Thread Enno Boland (Gottox)
Hi!

I wrote a patch which removes the last argument from resize(). This is
handled now directly in applysizehints(). What do you think about it?

regards
Gottox
-- 
http://www.gnuffy.chaotika.org - Real Community Distro
diff -r b4e7c220422d dwm.c
--- a/dwm.c Sat Feb 21 19:20:11 2009 +
+++ b/dwm.c Mon Mar 02 20:55:27 2009 +0100
@@ -129,6 +129,7 @@
 
 /* function declarations */
 static void applyrules(Client *c);
+static void applysizehints(Client *c, int *w, int *h);
 static void arrange(void);
 static void attach(Client *c);
 static void attachstack(Client *c);
@@ -169,7 +170,7 @@
 static Client *nexttiled(Client *c);
 static void propertynotify(XEvent *e);
 static void quit(const Arg *arg);
-static void resize(Client *c, int x, int y, int w, int h, Bool sizehints);
+static void resize(Client *c, int x, int y, int w, int h);
 static void resizemouse(const Arg *arg);
 static void restack(void);
 static void run(void);
@@ -271,6 +272,58 @@
 }
 
 void
+applysizehints(Client *c, int *w, int *h) {
+   Bool baseismin;
+
+   if(!resizehints  !c-isfloating)
+   return;
+
+   /* see last two sentences in ICCCM 4.1.2.3 */
+   baseismin = c-basew == c-minw  c-baseh == c-minh;
+
+   /* set minimum possible */
+   *w = MAX(1, *w);
+   *h = MAX(1, *h);
+
+   if(!baseismin) { /* temporarily remove base dimensions */
+   *w -= c-basew;
+   *h -= c-baseh;
+   }
+
+   /* adjust for aspect limits */
+   if(c-mina  0  c-maxa  0) {
+   if(c-maxa  (float)*w / *h)
+   *w = *h * c-maxa;
+   else if(c-mina  (float)*h / *w)
+   *h = *w * c-mina;
+   }
+
+   if(baseismin) { /* increment calculation requires this */
+   *w -= c-basew;
+   *h -= c-baseh;
+   }
+
+   /* adjust for increment value */
+   if(c-incw)
+   *w -= *w % c-incw;
+   if(c-inch)
+   *h -= *h % c-inch;
+
+   /* restore base dimensions */
+   *w += c-basew;
+   *h += c-baseh;
+
+   *w = MAX(*w, c-minw);
+   *h = MAX(*h, c-minh);
+
+   if(c-maxw)
+   *w = MIN(*w, c-maxw);
+
+   if(c-maxh)
+   *h = MIN(*h, c-maxh);
+}
+
+void
 arrange(void) {
unsigned int nt;
Client *c;
@@ -931,7 +984,7 @@
Client *c;
 
for(c = nexttiled(clients); c; c = nexttiled(c-next)) {
-   resize(c, wx, wy, ww - 2 * c-bw, wh - 2 * c-bw, resizehints);
+   resize(c, wx, wy, ww - 2 * c-bw, wh - 2 * c-bw);
}
 }
 
@@ -979,7 +1032,7 @@
togglefloating(NULL);
}
if(!lt[sellt]-arrange || c-isfloating)
-   resize(c, nx, ny, c-w, c-h, False);
+   resize(c, nx, ny, c-w, c-h);
break;
}
}
@@ -1035,54 +1088,10 @@
 }
 
 void
-resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
+resize(Client *c, int x, int y, int w, int h) {
XWindowChanges wc;
 
-   if(sizehints) {
-   /* see last two sentences in ICCCM 4.1.2.3 */
-   Bool baseismin = c-basew == c-minw  c-baseh == c-minh;
-
-   /* set minimum possible */
-   w = MAX(1, w);
-   h = MAX(1, h);
-
-   if(!baseismin) { /* temporarily remove base dimensions */
-   w -= c-basew;
-   h -= c-baseh;
-   }
-
-   /* adjust for aspect limits */
-   if(c-mina  0  c-maxa  0) {
-   if(c-maxa  (float)w / h)
-   w = h * c-maxa;
-   else if(c-mina  (float)h / w)
-   h = w * c-mina;
-   }
-
-   if(baseismin) { /* increment calculation requires this */
-   w -= c-basew;
-   h -= c-baseh;
-   }
-
-   /* adjust for increment value */
-   if(c-incw)
-   w -= w % c-incw;
-   if(c-inch)
-   h -= h % c-inch;
-
-   /* restore base dimensions */
-   w += c-basew;
-   h += c-baseh;
-
-   w = MAX(w, c-minw);
-   h = MAX(h, c-minh);
-
-   if(c-maxw)
-   w = MIN(w, c-maxw);
-
-   if(c-maxh)
-   h = MIN(h, c-maxh);
-   }
+   applysizehints(c, w, h);
if(w = 0 || h = 0)
return;
if(x  sx + sw)
@@ -1147,7 +1156,7 @@
togglefloating(NULL);
}
if(!lt[sellt]-arrange || c-isfloating)
-   resize(c, c-x, c-y, nw, nh, True);
+   resize(c, c-x, c-y, nw, nh);
 

Re: [dwm] [PATCH] remove sizehints argument in resize()

2009-03-02 Thread yy
2009/3/2 Enno Boland (Gottox) got...@gmail.com:

 I wrote a patch which removes the last argument from resize(). This is
 handled now directly in applysizehints(). What do you think about it?


I love this patch. It looks like the right thing.


-- 
- yiyus || JGL .