Have wmiimenu take colors from WMII_(NORM FOCUS)COLORS. Get rid of 'extern' from function decls.

This commit is contained in:
Kris Maglione 2007-02-23 23:09:58 -05:00
parent e4cf02d8f4
commit 2c387d4d99
12 changed files with 165 additions and 162 deletions

2
bar.c
View File

@ -31,7 +31,7 @@ create_bar(Bar **b_link, char *name) {
break; break;
b->next = *i; b->next = *i;
*i = b; *i = b;
return b; return b;
} }

View File

@ -254,7 +254,7 @@ unmap_client(Client *c, int state) {
void void
set_cursor(Client *c, Cursor cur) { set_cursor(Client *c, Cursor cur) {
XSetWindowAttributes wa; XSetWindowAttributes wa;
if(c->cursor != cur) { if(c->cursor != cur) {
c->cursor = cur; c->cursor = cur;
wa.cursor = cur; wa.cursor = cur;
@ -413,13 +413,15 @@ prop_client(Client *c, XPropertyEvent *e) {
void void
gravitate_client(Client *c, Bool invert) { gravitate_client(Client *c, Bool invert) {
int dx = 0, dy = 0; int dx, dy;
int gravity = NorthWestGravity; int gravity;
gravity = NorthWestGravity;
if(c->size.flags & PWinGravity) { if(c->size.flags & PWinGravity) {
gravity = c->size.win_gravity; gravity = c->size.win_gravity;
} }
/* y */
dy = 0;
switch (gravity) { switch (gravity) {
case StaticGravity: case StaticGravity:
case NorthWestGravity: case NorthWestGravity:
@ -440,7 +442,8 @@ gravitate_client(Client *c, Bool invert) {
default: default:
break; break;
} }
/* x */
dx = 0;
switch (gravity) { switch (gravity) {
case StaticGravity: case StaticGravity:
case NorthWestGravity: case NorthWestGravity:

View File

@ -44,7 +44,7 @@ buttonpress(XEvent *e) {
Frame *f; Frame *f;
Bool inclient; Bool inclient;
XButtonPressedEvent *ev; XButtonPressedEvent *ev;
ev = &e->xbutton; ev = &e->xbutton;
if((f = frame_of_win(ev->window))) { if((f = frame_of_win(ev->window))) {
inclient = (ev->subwindow == f->client->win); inclient = (ev->subwindow == f->client->win);
@ -344,7 +344,7 @@ static void
motionnotify(XEvent *e) { motionnotify(XEvent *e) {
XMotionEvent *ev = &e->xmotion; XMotionEvent *ev = &e->xmotion;
Frame *f; Frame *f;
if((f = frame_of_win(ev->window))) if((f = frame_of_win(ev->window)))
set_frame_cursor(f, ev->x, ev->y); set_frame_cursor(f, ev->x, ev->y);
} }

View File

@ -78,16 +78,16 @@ resize_frame(Frame *f, XRectangle *r) {
f->rect = *r; f->rect = *r;
f->crect = *r; f->crect = *r;
match_sizehints(c, &f->crect, f->area->floating, stickycorner); match_sizehints(c, &f->crect, f->area->floating, stickycorner);
if(f->area->floating) if(f->area->floating)
f->rect = f->crect; f->rect = f->crect;
if(f->rect.height < frame_delta_h() + labelh(&def.font)) { if(f->rect.height < frame_delta_h() + labelh(&def.font)) {
f->rect.height = frame_delta_h(); f->rect.height = frame_delta_h();
f->collapsed = True; f->collapsed = True;
}else }else
f->collapsed = False; f->collapsed = False;
if(f->rect.width < labelh(&def.font)) { if(f->rect.width < labelh(&def.font)) {
f->rect.width = frame_delta_h(); f->rect.width = frame_delta_h();
f->collapsed = True; f->collapsed = True;
@ -251,7 +251,7 @@ draw_frame(Frame *f) {
br.rect.width -= br.rect.x; br.rect.width -= br.rect.x;
br.rect.height = labelh(&def.font); br.rect.height = labelh(&def.font);
draw_label(&br, f->client->name); draw_label(&br, f->client->name);
br.border = 1; br.border = 1;
br.rect.width += br.rect.x; br.rect.width += br.rect.x;
br.rect.x = 0; br.rect.x = 0;

4
fs.c
View File

@ -202,12 +202,12 @@ write_to_buf(P9Req *r, void *buf, uint *len, uint max) {
count = max - offset; count = max - offset;
*len = offset + count; *len = offset + count;
if(max == 0) { if(max == 0) {
*(void **)buf = erealloc(*(void **)buf, *len + 1); *(void **)buf = erealloc(*(void **)buf, *len + 1);
buf = *(void **)buf; buf = *(void **)buf;
} }
memcpy(buf + offset, r->ifcall.data, count); memcpy(buf + offset, r->ifcall.data, count);
r->ofcall.count = count; r->ofcall.count = count;
((char *)buf)[offset+count] = '\0'; ((char *)buf)[offset+count] = '\0';

3
key.c
View File

@ -195,7 +195,8 @@ void
kpress(Window w, ulong mod, KeyCode keycode) { kpress(Window w, ulong mod, KeyCode keycode) {
Key *k, *found; Key *k, *found;
for(k=key; k; k->tnext=k->lnext, k=k->lnext); for(k=key; k; k=k->lnext)
k->tnext=k->lnext;
found = match_keys(key, mod, keycode, False); found = match_keys(key, mod, keycode, False);
if(!found) { if(!found) {
XBell(blz.dpy, 0); XBell(blz.dpy, 0);

3
main.c
View File

@ -18,9 +18,6 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h> #include <unistd.h>
Bool verbose;
Bool starting;
Client c_magic = { 0 };
static Bool check_other_wm; static Bool check_other_wm;
static int (*x_error_handler) (Display *, XErrorEvent *); static int (*x_error_handler) (Display *, XErrorEvent *);
static char version[] = "wmiiwm - " VERSION ", (C)opyright MMIV-MMVI Anselm R. Garbe\n"; static char version[] = "wmiiwm - " VERSION ", (C)opyright MMIV-MMVI Anselm R. Garbe\n";

14
mouse.c
View File

@ -67,16 +67,16 @@ typedef struct {
static void static void
snap_line(SnapArgs *a) { snap_line(SnapArgs *a) {
int i, t_xy; int i, t_xy;
/* horizontal */ /* horizontal */
if(a->y1 == a->y2 && (a->mask & (NORTH|SOUTH))) { if(a->y1 == a->y2 && (a->mask & (NORTH|SOUTH))) {
for(i=0; i < a->num; i++) { for(i=0; i < a->num; i++) {
if(!(r_east(&a->rects[i]) < a->x1) || if(!(r_east(&a->rects[i]) < a->x1) ||
(a->rects[i].x > a->x2)) { (a->rects[i].x > a->x2)) {
if(abs(a->rects[i].y - a->y1) <= abs(*a->delta)) if(abs(a->rects[i].y - a->y1) <= abs(*a->delta))
*a->delta = a->rects[i].y - a->y1; *a->delta = a->rects[i].y - a->y1;
t_xy = r_south(&a->rects[i]); t_xy = r_south(&a->rects[i]);
if(abs(t_xy - a->y1) < abs(*a->delta)) if(abs(t_xy - a->y1) < abs(*a->delta))
*a->delta = t_xy - a->y1; *a->delta = t_xy - a->y1;
@ -89,10 +89,10 @@ snap_line(SnapArgs *a) {
for(i=0; i < a->num; i++) { for(i=0; i < a->num; i++) {
if(!(r_south(&a->rects[i]) < a->y1) || if(!(r_south(&a->rects[i]) < a->y1) ||
(a->rects[i].y > a->y2)) { (a->rects[i].y > a->y2)) {
if(abs(a->rects[i].x - a->x1) <= abs(*a->delta)) if(abs(a->rects[i].x - a->x1) <= abs(*a->delta))
*a->delta = a->rects[i].x - a->x1; *a->delta = a->rects[i].x - a->x1;
t_xy = r_east(&a->rects[i]); t_xy = r_east(&a->rects[i]);
if(abs(t_xy - a->x1) < abs(*a->delta)) if(abs(t_xy - a->x1) < abs(*a->delta))
*a->delta = t_xy - a->x1; *a->delta = t_xy - a->x1;
@ -120,7 +120,7 @@ snap_rect(XRectangle *rects, int num, XRectangle *current,
a.y2 = a.y1 = r_south(current); a.y2 = a.y1 = r_south(current);
snap_line(&a); snap_line(&a);
} }
a.y1 = current->y; a.y1 = current->y;
a.y2 = r_south(current); a.y2 = r_south(current);
a.delta = &dx; a.delta = &dx;
@ -132,7 +132,7 @@ snap_rect(XRectangle *rects, int num, XRectangle *current,
a.x1 = a.x2 = current->x; a.x1 = a.x2 = current->x;
snap_line(&a); snap_line(&a);
} }
rect_morph_xy(current, abs(dx) <= snap ? dx : 0, rect_morph_xy(current, abs(dx) <= snap ? dx : 0,
abs(dy) <= snap ? dy : 0, mask); abs(dy) <= snap ? dy : 0, mask);

View File

@ -130,7 +130,7 @@ ServerTime(Time time)
if(0) if(0)
sprintf(buffer, "%lu day%s %02lu:%02lu:%02lu.%03lu", sprintf(buffer, "%lu day%s %02lu:%02lu:%02lu.%03lu",
day, day == 1 ? "" : "(s)", hr, min, sec, msec); day, day == 1 ? "" : "(s)", hr, min, sec, msec);
sprintf(buffer, "%lud%luh%lum%lu.%03lds", day, hr, min, sec, msec); sprintf(buffer, "%lud%luh%lum%lu.%03lds", day, hr, min, sec, msec);
return (buffer); return (buffer);
} }
@ -773,7 +773,7 @@ VerbVisibility(XVisibilityEvent *ev)
char *eventtype(XEvent *ev) char *eventtype(XEvent *ev)
{ {
static char buffer[20]; static char buffer[20];
switch (ev->type) { switch (ev->type) {
case KeyPress: case KeyPress:
return ("KeyPress"); return ("KeyPress");

View File

@ -11,14 +11,16 @@ LEFT=h
RIGHT=l RIGHT=l
WMII_FONT='fixed' WMII_FONT='fixed'
WMII_NORMCOLORS='#222222 #5FBF77 #2A7F3F' WMII_NORMCOLORS=('#222222' '#5FBF77' '#2A7F3F')
WMII_FOCUSCOLORS='#ffffff #153F1F #2A7F3F' WMII_FOCUSCOLORS=('#ffffff' '#153F1F' '#2A7F3F')
WMII_BACKGROUND='#333333' WMII_BACKGROUND='#333333'
WMII_TERM=(xterm) WMII_TERM=(xterm)
fn wmiimenu { fn wmiimenu {
dmenu -b -fn $WMII_FONT -nb '#5FBF7e' -nf '#222222' -sb '#153F1F' -sf '#ffffff' dmenu -b -fn $WMII_FONT \
-nf $WMII_NORMCOLORS(1) -nb $WMII_NORMCOLORS(2) \
-sf $WMII_FOCUSCOLORS(1) -sb $WMII_FOCUSCOLORS(2)
} }
# Column Rules # Column Rules

2
rule.c
View File

@ -20,7 +20,7 @@ void
trim(char *str, const char *chars) { trim(char *str, const char *chars) {
const char *cp; const char *cp;
char *sp, *sn; char *sp, *sn;
for(cp = chars; *cp; cp++) { for(cp = chars; *cp; cp++) {
for(sp = sn = str; *sn; sn++) { for(sp = sn = str; *sn; sn++) {
if(*sn != *cp) if(*sn != *cp)

262
wmii.h
View File

@ -260,172 +260,172 @@ Pixmap pmap;
void (*handler[LASTEvent]) (XEvent *); void (*handler[LASTEvent]) (XEvent *);
/* Misc */ /* Misc */
extern Bool starting; Bool starting;
extern Bool verbose; Bool verbose;
/* wm.c */ /* wm.c */
extern char *message_root(char *message); char *message_root(char *message);
/* area.c */ /* area.c */
extern Area *create_area(View *v, Area *pos, uint w); Area *create_area(View *v, Area *pos, uint w);
extern void destroy_area(Area *a); void destroy_area(Area *a);
extern Area *area_of_id(View *t, ushort id); Area *area_of_id(View *t, ushort id);
extern void focus_area(Area *a); void focus_area(Area *a);
extern char *select_area(Area *a, char *arg); char *select_area(Area *a, char *arg);
extern void send_to_area(Area *to, Frame *f); void send_to_area(Area *to, Frame *f);
extern void attach_to_area(Area *a, Frame *f, Bool send); void attach_to_area(Area *a, Frame *f, Bool send);
extern void detach_from_area(Frame *f); void detach_from_area(Frame *f);
extern Client *sel_client_of_area(Area *a); Client *sel_client_of_area(Area *a);
/* bar.c */ /* bar.c */
extern Bar *create_bar(Bar **b_link, char *name); Bar *create_bar(Bar **b_link, char *name);
extern void destroy_bar(Bar **b_link, Bar *b); void destroy_bar(Bar **b_link, Bar *b);
extern void draw_bar(WMScreen *s); void draw_bar(WMScreen *s);
void draw_border(BlitzBrush *b); void draw_border(BlitzBrush *b);
extern void resize_bar(); void resize_bar();
extern Bar *bar_of_name(Bar *b_link, const char *name); Bar *bar_of_name(Bar *b_link, const char *name);
/* client.c */ /* client.c */
extern Client *create_client(Window w, XWindowAttributes *wa); Client *create_client(Window w, XWindowAttributes *wa);
extern void destroy_client(Client *c); void destroy_client(Client *c);
extern void configure_client(Client *c); void configure_client(Client *c);
extern void prop_client(Client *c, XPropertyEvent *e); void prop_client(Client *c, XPropertyEvent *e);
extern void kill_client(Client *c); void kill_client(Client *c);
extern void gravitate_client(Client *c, Bool invert); void gravitate_client(Client *c, Bool invert);
extern void map_client(Client *c); void map_client(Client *c);
extern void unmap_client(Client *c, int state); void unmap_client(Client *c, int state);
extern void map_frame(Client *c); void map_frame(Client *c);
extern void unmap_frame(Client *c); void unmap_frame(Client *c);
extern void set_cursor(Client *c, Cursor cur); void set_cursor(Client *c, Cursor cur);
extern void focus_frame(Frame *f, Bool restack); void focus_frame(Frame *f, Bool restack);
extern void reparent_client(Client *c, Window w, int x, int y); void reparent_client(Client *c, Window w, int x, int y);
extern void manage_client(Client *c); void manage_client(Client *c);
extern void focus(Client *c, Bool restack); void focus(Client *c, Bool restack);
extern void focus_client(Client *c); void focus_client(Client *c);
extern void resize_client(Client *c, XRectangle *r); void resize_client(Client *c, XRectangle *r);
extern void match_sizehints(Client *c, XRectangle *r, Bool floating, BlitzAlign sticky); void match_sizehints(Client *c, XRectangle *r, Bool floating, BlitzAlign sticky);
extern char *send_client(Frame *f, char *arg, Bool swap); char *send_client(Frame *f, char *arg, Bool swap);
extern char * message_client(Client *c, char *message); char * message_client(Client *c, char *message);
extern void move_client(Client *c, char *arg); void move_client(Client *c, char *arg);
extern void size_client(Client *c, char *arg); void size_client(Client *c, char *arg);
extern Client *sel_client(); Client *sel_client();
extern Frame *frame_of_win(Window w); Frame *frame_of_win(Window w);
extern Client *client_of_win(Window w); Client *client_of_win(Window w);
extern void update_client_grab(Client *c); void update_client_grab(Client *c);
extern void apply_rules(Client *c); void apply_rules(Client *c);
extern void apply_tags(Client *c, const char *tags); void apply_tags(Client *c, const char *tags);
/* column.c */ /* column.c */
extern void arrange_column(Area *a, Bool dirty); void arrange_column(Area *a, Bool dirty);
extern void resize_column(Client *c, XRectangle *r); void resize_column(Client *c, XRectangle *r);
extern int column_mode_of_str(char *arg); int column_mode_of_str(char *arg);
extern char *str_of_column_mode(int mode); char *str_of_column_mode(int mode);
extern Area *new_column(View *v, Area *pos, uint w); Area *new_column(View *v, Area *pos, uint w);
/* draw.c */ /* draw.c */
extern int loadcolor(Blitz *blitz, BlitzColor *c); int loadcolor(Blitz *blitz, BlitzColor *c);
extern void draw_label(BlitzBrush *b, char *text); void draw_label(BlitzBrush *b, char *text);
extern void draw_tile(BlitzBrush *b); void draw_tile(BlitzBrush *b);
extern void draw_rect(BlitzBrush *b); void draw_rect(BlitzBrush *b);
extern void drawbg(Display *dpy, Drawable drawable, GC gc, void drawbg(Display *dpy, Drawable drawable, GC gc,
XRectangle *rect, BlitzColor c, Bool fill, Bool border); XRectangle *rect, BlitzColor c, Bool fill, Bool border);
extern void drawcursor(Display *dpy, Drawable drawable, GC gc, void drawcursor(Display *dpy, Drawable drawable, GC gc,
int x, int y, uint h, BlitzColor c); int x, int y, uint h, BlitzColor c);
extern uint textwidth(BlitzFont *font, char *text); uint textwidth(BlitzFont *font, char *text);
extern uint textwidth_l(BlitzFont *font, char *text, uint len); uint textwidth_l(BlitzFont *font, char *text, uint len);
extern void loadfont(Blitz *blitz, BlitzFont *font); void loadfont(Blitz *blitz, BlitzFont *font);
extern uint labelh(BlitzFont *font); uint labelh(BlitzFont *font);
extern char *parse_colors(char **buf, int *buflen, BlitzColor *col); char *parse_colors(char **buf, int *buflen, BlitzColor *col);
/* event.c */ /* event.c */
extern void check_x_event(IXPConn *c); void check_x_event(IXPConn *c);
extern uint flush_masked_events(long even_mask); uint flush_masked_events(long even_mask);
/* frame.c */ /* frame.c */
extern Frame *create_frame(Client *c, View *v); Frame *create_frame(Client *c, View *v);
extern void remove_frame(Frame *f); void remove_frame(Frame *f);
extern void insert_frame(Frame *pos, Frame *f, Bool before); void insert_frame(Frame *pos, Frame *f, Bool before);
extern void resize_frame(Frame *f, XRectangle *r); void resize_frame(Frame *f, XRectangle *r);
extern Bool frame_to_top(Frame *f); Bool frame_to_top(Frame *f);
extern void set_frame_cursor(Frame *f, int x, int y); void set_frame_cursor(Frame *f, int x, int y);
extern void swap_frames(Frame *fa, Frame *fb); void swap_frames(Frame *fa, Frame *fb);
extern int frame_delta_h(); int frame_delta_h();
extern void draw_frame(Frame *f); void draw_frame(Frame *f);
extern void draw_frames(); void draw_frames();
extern void update_frame_widget_colors(Frame *f); void update_frame_widget_colors(Frame *f);
void check_frame_constraints(XRectangle *rect); void check_frame_constraints(XRectangle *rect);
/* fs.c */ /* fs.c */
extern void fs_attach(P9Req *r); void fs_attach(P9Req *r);
extern void fs_clunk(P9Req *r); void fs_clunk(P9Req *r);
extern void fs_create(P9Req *r); void fs_create(P9Req *r);
extern void fs_flush(P9Req *r); void fs_flush(P9Req *r);
extern void fs_freefid(Fid *f); void fs_freefid(Fid *f);
extern void fs_open(P9Req *r); void fs_open(P9Req *r);
extern void fs_read(P9Req *r); void fs_read(P9Req *r);
extern void fs_remove(P9Req *r); void fs_remove(P9Req *r);
extern void fs_stat(P9Req *r); void fs_stat(P9Req *r);
extern void fs_walk(P9Req *r); void fs_walk(P9Req *r);
extern void fs_write(P9Req *r); void fs_write(P9Req *r);
extern void write_event(char *format, ...); void write_event(char *format, ...);
/* geom.c */ /* geom.c */
extern Bool ispointinrect(int x, int y, XRectangle * r); Bool ispointinrect(int x, int y, XRectangle * r);
extern BlitzAlign quadofcoord(XRectangle *rect, int x, int y); BlitzAlign quadofcoord(XRectangle *rect, int x, int y);
extern Cursor cursor_of_quad(BlitzAlign align); Cursor cursor_of_quad(BlitzAlign align);
extern int strtorect(XRectangle *r, const char *val); int strtorect(XRectangle *r, const char *val);
extern BlitzAlign get_sticky(XRectangle *src, XRectangle *dst); BlitzAlign get_sticky(XRectangle *src, XRectangle *dst);
extern int r_east(XRectangle *r); int r_east(XRectangle *r);
extern int r_south(XRectangle *r); int r_south(XRectangle *r);
/* key.c */ /* key.c */
extern void kpress(Window w, ulong mod, KeyCode keycode); void kpress(Window w, ulong mod, KeyCode keycode);
extern void update_keys(); void update_keys();
extern void init_lock_keys(); void init_lock_keys();
extern ulong mod_key_of_str(char *val); ulong mod_key_of_str(char *val);
/* mouse.c */ /* mouse.c */
extern void do_mouse_resize(Client *c, Bool grabbox, BlitzAlign align); void do_mouse_resize(Client *c, Bool grabbox, BlitzAlign align);
extern void grab_mouse(Window w, ulong mod, ulong button); void grab_mouse(Window w, ulong mod, ulong button);
extern void ungrab_mouse(Window w, ulong mod, uint button); void ungrab_mouse(Window w, ulong mod, uint button);
extern BlitzAlign snap_rect(XRectangle *rects, int num, XRectangle *current, BlitzAlign snap_rect(XRectangle *rects, int num, XRectangle *current,
BlitzAlign *mask, int snap); BlitzAlign *mask, int snap);
extern void grab_button(Window w, uint button, ulong mod); void grab_button(Window w, uint button, ulong mod);
/* rule.c */ /* rule.c */
extern void update_rules(Rule **rule, const char *data); void update_rules(Rule **rule, const char *data);
extern void trim(char *str, const char *chars); void trim(char *str, const char *chars);
/* util.c */ /* util.c */
extern uint tokenize(char *res[], uint reslen, char *str, char delim); uint tokenize(char *res[], uint reslen, char *str, char delim);
extern char *estrdup(const char *str); char *estrdup(const char *str);
extern void *erealloc(void *ptr, uint size); void *erealloc(void *ptr, uint size);
extern void *emallocz(uint size); void *emallocz(uint size);
extern void *emalloc(uint size); void *emalloc(uint size);
extern void fatal(const char *fmt, ...); void fatal(const char *fmt, ...);
extern int max(int a, int b); int max(int a, int b);
extern char *str_nil(char *s); char *str_nil(char *s);
/* view.c */ /* view.c */
extern void arrange_view(View *v); void arrange_view(View *v);
extern void scale_view(View *v, float w); void scale_view(View *v, float w);
extern View *get_view(const char *name); View *get_view(const char *name);
extern View *create_view(const char *name); View *create_view(const char *name);
extern void focus_view(WMScreen *s, View *v); void focus_view(WMScreen *s, View *v);
extern void update_client_views(Client *c, char **tags); void update_client_views(Client *c, char **tags);
extern XRectangle *rects_of_view(View *v, uint *num, Frame *ignore); XRectangle *rects_of_view(View *v, uint *num, Frame *ignore);
extern View *view_of_id(ushort id); View *view_of_id(ushort id);
extern void select_view(const char *arg); void select_view(const char *arg);
extern void attach_to_view(View *v, Frame *f); void attach_to_view(View *v, Frame *f);
extern Client *sel_client_of_view(View *v); Client *sel_client_of_view(View *v);
extern char *message_view(View *v, char *message); char *message_view(View *v, char *message);
extern void restack_view(View *v); void restack_view(View *v);
extern uchar *view_index(View *v); uchar *view_index(View *v);
extern void destroy_view(View *v); void destroy_view(View *v);
extern void update_views(); void update_views();
extern uint newcolw_of_view(View *v); uint newcolw_of_view(View *v);
/* wm.c */ /* wm.c */
extern int wmii_error_handler(Display *dpy, XErrorEvent *error); int wmii_error_handler(Display *dpy, XErrorEvent *error);
extern int win_proto(Window w); int win_proto(Window w);