Take advantage of strlcat in libixp

This commit is contained in:
Kris Maglione 2007-02-17 02:20:11 -05:00
parent 9b063ff160
commit c1ad5c2585
3 changed files with 22 additions and 17 deletions

View File

@ -576,7 +576,9 @@ resize_client(Client *c, XRectangle *r) {
return;
}
c->rect = f->rect;
c->rect = f->crect;
c->rect.x += f->rect.x;
c->rect.y += f->rect.y;
if(f->area->mode == Colmax
&& f->area->sel != f) {
unmap_frame(c);
@ -782,7 +784,6 @@ compare_tags(const void *a, const void *b) {
void
apply_tags(Client *c, const char *tags) {
uint i, j, k, n;
int len;
Bool add;
char buf[512], last;
char *toks[32], *cur;
@ -792,7 +793,7 @@ apply_tags(Client *c, const char *tags) {
if(tags[n] != ' ' && tags[n] != '\t') break;
if(tags[n] == '+' || tags[n] == '-')
strncpy(buf, c->tags, sizeof(c->tags));
strncat(buf, &tags[n], sizeof(buf) - strlen(buf));
ixp_strlcat(buf, &tags[n], sizeof(buf));
trim(buf, " \t/");
n = 0;
@ -849,15 +850,12 @@ apply_tags(Client *c, const char *tags) {
}
c->tags[0] = '\0';
qsort(toks, j, sizeof(char *), compare_tags);
len = sizeof(c->tags);
if(!j) return;
for(i=0, n=0; i < j && len > 1; i++)
for(i=0, n=0; i < j; i++)
if(!n || strcmp(toks[i], toks[n-1])) {
if(i)
strncat(c->tags, "+", len);
len -= strlen(c->tags);
strncat(c->tags, toks[i], len);
len -= strlen(c->tags);
ixp_strlcat(c->tags, "+", sizeof(c->tags));
ixp_strlcat(c->tags, toks[i], sizeof(c->tags));
toks[n++] = toks[i];
}
toks[n] = nil;

14
event.c
View File

@ -58,7 +58,7 @@ buttonpress(XEvent *e) {
break;
case Button3:
do_mouse_resize(f->client, False,
quadofcoord(&f->client->rect, ev->x, ev->y));
quadofcoord(&f->rect, ev->x, ev->y));
frame_to_top(f);
focus(f->client, True);
break;
@ -74,7 +74,7 @@ buttonpress(XEvent *e) {
else if(!ev->subwindow
&& !ispointinrect(ev->x, ev->y, &f->titlebar.rect))
do_mouse_resize(f->client, False,
quadofcoord(&f->client->rect, ev->x, ev->y));
quadofcoord(&f->rect, ev->x, ev->y));
if(f->client != sel_client())
focus(f->client, True);
}
@ -100,6 +100,9 @@ configurerequest(XEvent *e) {
fprintf(stderr, "Configure: %s\n\ta: x=%d y=%d w=%d h=%d\n",
c->name, c->rect.x, c->rect.y, c->rect.width, c->rect.height);
gravitate_client(c, True);
if(verbose)
fprintf(stderr, "\tb: x=%d y=%d w=%d h=%d\n",
c->rect.x, c->rect.y, c->rect.width, c->rect.height);
if(ev->value_mask & CWX)
c->rect.x = ev->x;
if(ev->value_mask & CWY)
@ -110,6 +113,9 @@ configurerequest(XEvent *e) {
c->rect.height = ev->height;
if(ev->value_mask & CWBorderWidth)
c->border = ev->border_width;
if(verbose)
fprintf(stderr, "\tb: x=%d y=%d w=%d h=%d\n",
c->rect.x, c->rect.y, c->rect.width, c->rect.height);
gravitate_client(c, False);
if(verbose)
fprintf(stderr, "\tb: x=%d y=%d w=%d h=%d\n",
@ -125,7 +131,9 @@ configurerequest(XEvent *e) {
frect->x -= def.border;
frect->width += 2 * def.border;
frect->height += frame_delta_h();
c->rect = f->crect;
if(verbose)
fprintf(stderr, "\tb: x=%d y=%d w=%d h=%d\n",
frect->x, frect->y, frect->width, frect->height);
if(c->sel->area->floating)
resize_client(c, frect);

9
main.c
View File

@ -2,6 +2,10 @@
* See LICENSE file for license details.
*/
#include "wmii.h"
#include <X11/Xatom.h>
#include <X11/Xproto.h>
#include <X11/cursorfont.h>
#include <X11/keysym.h>
#include <errno.h>
#include <fcntl.h>
#include <locale.h>
@ -13,11 +17,6 @@
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
#include <X11/cursorfont.h>
#include <X11/Xproto.h>
#include <X11/keysym.h>
#include <X11/Xatom.h>
#include <X11/Xproto.h>
Bool verbose;
Bool starting;