mirror of
https://github.com/0intro/wmii
synced 2025-03-27 09:03:12 +03:00
Removed a bunch of unused functions
This commit is contained in:
parent
ab2ff71e8f
commit
23a10f4541
@ -9,35 +9,6 @@
|
||||
|
||||
#include "wm.h"
|
||||
|
||||
Bool
|
||||
is_of_area(Area *a, Client *c)
|
||||
{
|
||||
Frame *f;
|
||||
for(f=a->frame; f; f=f->anext)
|
||||
if(f->client == c)
|
||||
return True;
|
||||
return False;
|
||||
}
|
||||
|
||||
int
|
||||
idx_of_area(Area *a)
|
||||
{
|
||||
Area *t;
|
||||
int i = 0;
|
||||
for(t=a->view->area; t && t != a; t=t->next)
|
||||
i++;
|
||||
return t ? i : -1;
|
||||
}
|
||||
|
||||
Area *
|
||||
area_of_id(View *v, unsigned short id)
|
||||
{
|
||||
Area *a;
|
||||
for(a=v->area; a; a=a->next)
|
||||
if(a->id == id) break;
|
||||
return a;
|
||||
}
|
||||
|
||||
Client *
|
||||
sel_client_of_area(Area *a)
|
||||
{
|
||||
|
145
cmd/wm/client.c
145
cmd/wm/client.c
@ -14,6 +14,29 @@ static char *Ebadcmd = "bad command",
|
||||
|
||||
#define CLIENT_MASK (StructureNotifyMask | PropertyChangeMask | EnterWindowMask)
|
||||
|
||||
Client *
|
||||
sel_client()
|
||||
{
|
||||
return sel && sel->sel->sel ? sel->sel->sel->client : nil;
|
||||
}
|
||||
|
||||
int
|
||||
idx_of_client(Client *c)
|
||||
{
|
||||
Client *cl;
|
||||
int i = 0;
|
||||
for(cl=client; cl && cl != c; cl=cl->next, i++);
|
||||
return cl ? i : -1;
|
||||
}
|
||||
|
||||
Client *
|
||||
client_of_win(Window w)
|
||||
{
|
||||
Client *c;
|
||||
for(c=client; c && c->win != w; c=c->next);
|
||||
return c;
|
||||
}
|
||||
|
||||
static void
|
||||
update_client_name(Client *c)
|
||||
{
|
||||
@ -410,12 +433,6 @@ destroy_client(Client *c)
|
||||
flush_masked_events(EnterWindowMask);
|
||||
}
|
||||
|
||||
Client *
|
||||
sel_client()
|
||||
{
|
||||
return sel && sel->sel->sel ? sel->sel->sel->client : nil;
|
||||
}
|
||||
|
||||
void
|
||||
match_sizehints(Client *c, XRectangle *r, Bool floating, BlitzAlign sticky)
|
||||
{
|
||||
@ -570,7 +587,7 @@ move_client(Client *c, char *arg)
|
||||
return;
|
||||
new.x += x;
|
||||
new.y += y;
|
||||
if(idx_of_area(f->area))
|
||||
if(!f->area->floating)
|
||||
resize_column(f->client, &new, nil);
|
||||
else
|
||||
resize_client(f->client, &new, False);
|
||||
@ -600,37 +617,13 @@ send_client(Frame *f, char *arg)
|
||||
Client *c;
|
||||
Frame *tf;
|
||||
View *v;
|
||||
int i, j;
|
||||
int j;
|
||||
|
||||
a = f->area;
|
||||
v = a->view;
|
||||
c = f->client;
|
||||
i = idx_of_area(a);
|
||||
j = idx_of_frame(f);
|
||||
|
||||
if((i == -1) || (j == -1))
|
||||
return 0;
|
||||
|
||||
if(i && !strncmp(arg, "left", 5)) {
|
||||
if(a->floating)
|
||||
return Ebadvalue;
|
||||
for(to=v->area->next; to && a != to->next; to=to->next);
|
||||
if(!to && (f->anext || f != a->frame))
|
||||
to=new_column(v, v->area, 0);
|
||||
if(!to)
|
||||
return Ebadvalue;
|
||||
send_to_area(to, a, f);
|
||||
}
|
||||
else if(i && !strncmp(arg, "right", 5)) {
|
||||
if(a->floating)
|
||||
return Ebadvalue;
|
||||
if(!(to = a->next) && (f->anext || f!= a->frame))
|
||||
to = new_column(v, a, 0);
|
||||
if(!to)
|
||||
return Ebadvalue;
|
||||
send_to_area(to, a, f);
|
||||
}
|
||||
else if(!strncmp(arg, "toggle", 7)) {
|
||||
if(!strncmp(arg, "toggle", 7)) {
|
||||
if(!a->floating)
|
||||
to = v->area;
|
||||
else if(c->revert && !c->revert->floating)
|
||||
@ -638,31 +631,50 @@ send_client(Frame *f, char *arg)
|
||||
else
|
||||
to = v->area->next;
|
||||
send_to_area(to, a, f);
|
||||
}
|
||||
else if(i && !strncmp(arg, "up", 3)) {
|
||||
for(tf=a->frame; tf && tf->anext != f; tf=tf->anext);
|
||||
if(!tf)
|
||||
return Ebadvalue;
|
||||
remove_frame(f);
|
||||
insert_frame(tf, f, True);
|
||||
arrange_column(a, False);
|
||||
focus_client(c, True);
|
||||
}
|
||||
else if(i && !strncmp(arg, "down", 5)) {
|
||||
if(!f->anext)
|
||||
return Ebadvalue;
|
||||
remove_frame(f);
|
||||
insert_frame(f->anext, f, False);
|
||||
arrange_column(a, False);
|
||||
focus_client(c, True);
|
||||
}
|
||||
else if(i) {
|
||||
if(sscanf(arg, "%d", &j) != 1)
|
||||
return Ebadvalue;
|
||||
for(to=v->area; to && j; to=to->next, j--);
|
||||
send_to_area(to, a, f);
|
||||
}
|
||||
else
|
||||
}else if(!a->floating) {
|
||||
if(!strncmp(arg, "left", 5)) {
|
||||
if(a->floating)
|
||||
return Ebadvalue;
|
||||
for(to=v->area->next; to && a != to->next; to=to->next);
|
||||
if(!to && (f->anext || f != a->frame))
|
||||
to=new_column(v, v->area, 0);
|
||||
if(!to)
|
||||
return Ebadvalue;
|
||||
send_to_area(to, a, f);
|
||||
}
|
||||
else if(!strncmp(arg, "right", 5)) {
|
||||
if(a->floating)
|
||||
return Ebadvalue;
|
||||
if(!(to = a->next) && (f->anext || f!= a->frame))
|
||||
to = new_column(v, a, 0);
|
||||
if(!to)
|
||||
return Ebadvalue;
|
||||
send_to_area(to, a, f);
|
||||
}
|
||||
else if(!strncmp(arg, "up", 3)) {
|
||||
for(tf=a->frame; tf && tf->anext != f; tf=tf->anext);
|
||||
if(!tf)
|
||||
return Ebadvalue;
|
||||
remove_frame(f);
|
||||
insert_frame(tf, f, True);
|
||||
arrange_column(a, False);
|
||||
focus_client(c, True);
|
||||
}
|
||||
else if(!strncmp(arg, "down", 5)) {
|
||||
if(!f->anext)
|
||||
return Ebadvalue;
|
||||
remove_frame(f);
|
||||
insert_frame(f->anext, f, False);
|
||||
arrange_column(a, False);
|
||||
focus_client(c, True);
|
||||
}
|
||||
else {
|
||||
if(sscanf(arg, "%d", &j) != 1)
|
||||
return Ebadvalue;
|
||||
for(to=v->area; to && j; to=to->next, j--);
|
||||
send_to_area(to, a, f);
|
||||
}
|
||||
}else
|
||||
return Ebadvalue;
|
||||
flush_masked_events(EnterWindowMask);
|
||||
update_views();
|
||||
@ -684,23 +696,6 @@ focus(Client *c, Bool restack)
|
||||
focus_view(v);
|
||||
}
|
||||
|
||||
int
|
||||
idx_of_client(Client *c)
|
||||
{
|
||||
Client *cl;
|
||||
int i = 0;
|
||||
for(cl=client; cl && cl != c; cl=cl->next, i++);
|
||||
return cl ? i : -1;
|
||||
}
|
||||
|
||||
Client *
|
||||
client_of_win(Window w)
|
||||
{
|
||||
Client *c;
|
||||
for(c=client; c && c->win != w; c=c->next);
|
||||
return c;
|
||||
}
|
||||
|
||||
void
|
||||
update_client_views(Client *c, char **tags)
|
||||
{
|
||||
|
@ -79,7 +79,7 @@ handle_buttonrelease(XEvent *e)
|
||||
return write_event("RightBarClick %d %s\n",
|
||||
ev->button, b->name);
|
||||
}
|
||||
else if((c = frame_of_win(ev->window)) && c->frame) {
|
||||
else if((c = client_of_win(ev->window)) && c->frame) {
|
||||
if(ispointinrect(ev->x, ev->y, &c->sel->tagbar.rect)) {
|
||||
c->sel->tagbar.curend = blitz_charof(&c->sel->tagbar, ev->x, ev->y);
|
||||
draw_frame(c->sel);
|
||||
@ -98,7 +98,7 @@ handle_motionnotify(XEvent *e)
|
||||
if(!drag)
|
||||
return;
|
||||
|
||||
if((c = frame_of_win(ev->window))) {
|
||||
if((c = client_of_win(ev->window))) {
|
||||
if(ispointinrect(ev->x, ev->y, &c->sel->tagbar.rect)) {
|
||||
c->sel->tagbar.curend = blitz_charof(&c->sel->tagbar, ev->x, ev->y);
|
||||
if(c->sel->tagbar.curend < c->sel->tagbar.curstart) {
|
||||
@ -117,7 +117,7 @@ handle_buttonpress(XEvent *e)
|
||||
Client *c;
|
||||
XButtonPressedEvent *ev = &e->xbutton;
|
||||
|
||||
if((c = frame_of_win(ev->window))) {
|
||||
if((c = client_of_win(ev->window))) {
|
||||
ev->state &= valid_mask;
|
||||
if(ispointinrect(ev->x, ev->y, &c->sel->tagbar.rect)) {
|
||||
c->sel->tagbar.curstart = c->sel->tagbar.curend
|
||||
@ -270,7 +270,7 @@ handle_expose(XEvent *e)
|
||||
if(ev->count == 0) {
|
||||
if(ev->window == barwin)
|
||||
draw_bar();
|
||||
else if((c = frame_of_win(ev->window)))
|
||||
else if((c = client_of_win(ev->window)))
|
||||
draw_frame(c->sel);
|
||||
}
|
||||
}
|
||||
|
@ -72,31 +72,6 @@ insert_frame(Frame *pos, Frame *f, Bool before)
|
||||
*p = f;
|
||||
}
|
||||
|
||||
Frame *
|
||||
frame_of_id(Area *a, unsigned short id)
|
||||
{
|
||||
Frame *f;
|
||||
for(f=a->frame; f && f->id != id; f=f->anext);
|
||||
return f;
|
||||
}
|
||||
|
||||
int
|
||||
idx_of_frame(Frame *f)
|
||||
{
|
||||
Frame *t;
|
||||
int i = 0;
|
||||
for(t=f->area->frame; t && t != f; t=t->anext);
|
||||
return t ? i : -1;
|
||||
}
|
||||
|
||||
Client *
|
||||
frame_of_win(Window w)
|
||||
{
|
||||
Client *c;
|
||||
for(c=client; c && c->framewin != w; c=c->next);
|
||||
return c;
|
||||
}
|
||||
|
||||
void
|
||||
update_frame_widget_colors(Frame *f)
|
||||
{
|
||||
|
@ -19,12 +19,30 @@ is_empty(View *v)
|
||||
return True;
|
||||
}
|
||||
|
||||
View *
|
||||
view_of_id(unsigned short id) {
|
||||
View *v;
|
||||
for(v = view; v; v=v->next)
|
||||
if(v->id == id) break;
|
||||
return v;
|
||||
Frame *
|
||||
clientframe_of_view(View *v, Client *c)
|
||||
{
|
||||
Frame *f;
|
||||
for(f=c->frame; f; f=f->cnext)
|
||||
if(f->area->view == v)
|
||||
break;
|
||||
return f;
|
||||
}
|
||||
|
||||
static void
|
||||
assign_sel_view(View *v)
|
||||
{
|
||||
if(sel != v) {
|
||||
if(sel)
|
||||
write_event("UnfocusTag %s\n", sel->name);
|
||||
sel = v;
|
||||
write_event("FocusTag %s\n", sel->name);
|
||||
}
|
||||
}
|
||||
|
||||
Client *
|
||||
sel_client_of_view(View *v) {
|
||||
return v->sel && v->sel->sel ? v->sel->sel->client : nil;
|
||||
}
|
||||
|
||||
View *
|
||||
@ -40,17 +58,6 @@ get_view(const char *name)
|
||||
return v;
|
||||
}
|
||||
|
||||
static void
|
||||
assign_sel_view(View *v)
|
||||
{
|
||||
if(sel != v) {
|
||||
if(sel)
|
||||
write_event("UnfocusTag %s\n", sel->name);
|
||||
sel = v;
|
||||
write_event("FocusTag %s\n", sel->name);
|
||||
}
|
||||
}
|
||||
|
||||
View *
|
||||
create_view(const char *name)
|
||||
{
|
||||
@ -260,11 +267,6 @@ arrange_view(View *v)
|
||||
}
|
||||
}
|
||||
|
||||
Client *
|
||||
sel_client_of_view(View *v) {
|
||||
return v->sel && v->sel->sel ? v->sel->sel->client : nil;
|
||||
}
|
||||
|
||||
XRectangle *
|
||||
rects_of_view(View *v, unsigned int *num)
|
||||
{
|
||||
@ -347,16 +349,6 @@ area_of_message(View *v, char *message, unsigned int *next) {
|
||||
return a;
|
||||
}
|
||||
|
||||
Frame *
|
||||
clientframe_of_view(View *v, Client *c)
|
||||
{
|
||||
Frame *f;
|
||||
for(f=c->frame; f; f=f->cnext)
|
||||
if(f->area->view == v)
|
||||
break;
|
||||
return f;
|
||||
}
|
||||
|
||||
char *
|
||||
message_view(View *v, char *message) {
|
||||
unsigned int n, i;
|
||||
|
71
cmd/wm/wm.c
71
cmd/wm/wm.c
@ -27,7 +27,7 @@ static char version[] = "wmiiwm - " VERSION ", (C)opyright MMIV-MMVI Anselm R. G
|
||||
static void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr, "%s", "usage: wmiiwm -a <address> [-r <wmiirc>] [-c] [-v]\n");
|
||||
fputs("usage: wmiiwm -a <address> [-r <wmiirc>] [-c] [-v]\n", stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -232,42 +232,38 @@ main(int argc, char *argv[])
|
||||
XSetWindowAttributes wa;
|
||||
|
||||
/* command line args */
|
||||
if(argc > 1) {
|
||||
for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
|
||||
switch (argv[i][1]) {
|
||||
case 'v':
|
||||
fprintf(stdout, "%s", version);
|
||||
exit(0);
|
||||
break;
|
||||
case 'c':
|
||||
checkwm = 1;
|
||||
break;
|
||||
case 'a':
|
||||
if(i + 1 < argc)
|
||||
address = argv[++i];
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
case 'r':
|
||||
if(i + 1 < argc)
|
||||
wmiirc = argv[++i];
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
default:
|
||||
for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
|
||||
switch (argv[i][1]) {
|
||||
case 'v':
|
||||
fprintf(stdout, "%s", version);
|
||||
exit(0);
|
||||
break;
|
||||
case 'c':
|
||||
checkwm = 1;
|
||||
break;
|
||||
case 'a':
|
||||
if(i + 1 < argc)
|
||||
address = argv[++i];
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'r':
|
||||
if(i + 1 < argc)
|
||||
wmiirc = argv[++i];
|
||||
else
|
||||
usage();
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
starting = True;
|
||||
|
||||
blz.display = XOpenDisplay(0);
|
||||
if(!blz.display) {
|
||||
fputs("wmiiwm: cannot open display\n", stderr);
|
||||
exit(1);
|
||||
}
|
||||
if(!blz.display)
|
||||
error("wmiiwm: cannot open display\n");
|
||||
blz.screen = DefaultScreen(blz.display);
|
||||
blz.root = RootWindow(blz.display, blz.screen);
|
||||
|
||||
@ -314,23 +310,23 @@ main(int argc, char *argv[])
|
||||
errstr = nil;
|
||||
i = ixp_create_sock(address, &errstr);
|
||||
if(i < 0)
|
||||
error("wmii: fatal: %s\n", errstr);
|
||||
error("wmiiwm: fatal: %s\n", errstr);
|
||||
|
||||
/* start wmiirc */
|
||||
if(wmiirc) {
|
||||
int name_len = strlen(wmiirc) + 6;
|
||||
char execstr[name_len];
|
||||
switch(fork()) {
|
||||
case 0:
|
||||
if(setsid() == -1)
|
||||
error("wmiim: can't setsid: %s\n", strerror(errno));
|
||||
/* This is only necessary because I can't get the fileno of
|
||||
* the X socket */
|
||||
j = getdtablesize();
|
||||
for(i = 3; i < j; i++)
|
||||
close(i);
|
||||
{
|
||||
char execstr[name_len];
|
||||
snprintf(execstr, name_len, "exec %s", wmiirc);
|
||||
execl("/bin/sh", "sh", "-c", execstr, nil);
|
||||
}
|
||||
snprintf(execstr, name_len, "exec %s", wmiirc);
|
||||
execl("/bin/sh", "sh", "-c", execstr, nil);
|
||||
error("wmiiwm: can't exec \"%s\": %s\n", wmiirc, strerror(errno));
|
||||
case -1:
|
||||
perror("wmiiwm: cannot fork wmiirc");
|
||||
@ -406,7 +402,6 @@ main(int argc, char *argv[])
|
||||
bbrush.font = &def.font;
|
||||
bbrush.border = True;
|
||||
|
||||
|
||||
XMapRaised(blz.display, barwin);
|
||||
draw_bar();
|
||||
scan_wins();
|
||||
@ -419,7 +414,7 @@ main(int argc, char *argv[])
|
||||
if(errstr)
|
||||
fprintf(stderr, "wmii: fatal: %s\n", errstr);
|
||||
|
||||
free(client); /* shut up leak detector */
|
||||
free(user); /* shut up leak detector */
|
||||
ixp_server_close(&srv);
|
||||
cleanup();
|
||||
XCloseDisplay(blz.display);
|
||||
|
@ -208,8 +208,6 @@ char *select_area(Area *a, char *arg);
|
||||
void send_to_area(Area *to, Area *from, Frame *f);
|
||||
void attach_to_area(Area *a, Frame *f, Bool send);
|
||||
void detach_from_area(Area *a, Frame *f);
|
||||
Bool is_of_area(Area *a, Client *c);
|
||||
int idx_of_area(Area *a);
|
||||
Client *sel_client_of_area(Area *a);
|
||||
|
||||
/* bar.c */
|
||||
@ -263,9 +261,6 @@ unsigned int flush_masked_events(long even_mask);
|
||||
Frame *create_frame(Client *c, View *v);
|
||||
void remove_frame(Frame *f);
|
||||
void insert_frame(Frame *pos, Frame *f, Bool before);
|
||||
int idx_of_frame(Frame *f);
|
||||
Frame *frame_of_id(Area *a, unsigned short id);
|
||||
Client *frame_of_win(Window w);
|
||||
void draw_frame(Frame *f);
|
||||
void draw_frames();
|
||||
void update_frame_widget_colors(Frame *f);
|
||||
|
Loading…
x
Reference in New Issue
Block a user