Beispiel #1
0
int main(int argc, char **argv) {
    int ch;                     /* Option character */

    while (1) {
        ch = getopt(argc, argv, "c");
        if (-1 == ch) {
            /* No more options, break out of while loop. */
            break;
        }
        switch (ch) {
        case 'c':
            printcommand = true;
            break;

        default:
            printhelp();
            exit(0);
        } /* switch ch */
    } /* while 1 */

    init();
    wm_state = getatom("WM_STATE");
    findhidden();
    cleanup();
    exit(0);
}
Beispiel #2
0
void
find(Client *c, const Arg *arg) {
	const char *s;

	s = getatom(c, findprop);
	gboolean forward = *(gboolean *)arg;
	webkit_web_view_search_text(c->view, s, FALSE, forward, TRUE);
}
Beispiel #3
0
void list_clients(void *buf, fuse_fill_dir_t filler)
{
    Window *list;
    int i;
    long unsigned int nclients;
    char name[10];
    list = getatom(root, atoms[ClientList], &nclients);
    for(i = 0; i < nclients; i++) {
        sprintf(name, "0x%x", (unsigned int)list[i]);
        filler(buf, name, NULL, 0);
    }
}
Beispiel #4
0
Bool
checkatom(Window win, Atom bigatom, Atom smallatom) {
	Atom *state;
	unsigned long i, n;
	Bool ret = False;

	state = (Atom*)getatom(win, bigatom, &n);
	for (i = 0; i < n; i++) {
		if (state[i] == smallatom)
			ret = True;
	}
	XFree(state);
	return ret;
}
Beispiel #5
0
Window valid_client(const char *name) {
    Window *list;
    Window w;
    int i;
    long unsigned int nclients;
    sscanf(name, "0x%x", (unsigned int*)&w);

    list = getatom(root, atoms[ClientList], &nclients);
    for(i = 0; i <= nclients; i++) {
        if(w == list[i])
            return w;
    }
    return 0;
}
Beispiel #6
0
long get_desktop()
{
    Atom atom;
    Atom type;
    int size;
    long length;
    long *c;
    long desktop;

    atom = XInternAtom(my_display, "_NET_CURRENT_DESKTOP", 0);
    c = (long *) getatom(DefaultRootWindow(my_display),
			 atom, &length, &type, &size);
    if (c) {
	desktop = *c;
	XFree(c);
    }
    return desktop;
}
Beispiel #7
0
int
getstrut(Client *c, Atom strut) {
	unsigned long *state;
	int ret = 0;
	Monitor *m;
	unsigned long i, n;

	if (!(m = clientmonitor(c)))
		return ret;

	state = (unsigned long*)getatom(c->win, strut, &n);
	if (n) {
		for (i = LeftStrut; i < LastStrut; i++)
			m->struts[i] = max(state[i], m->struts[i]);
		ret = 1;
	}
	XFree(state);
	return ret;
}
Beispiel #8
0
void
drawindicator(Client *c) {
	gint width;
	const char *uri;
	GtkWidget *w;
	GdkGC *gc;
	GdkColor fg;

	uri = getatom(c, uriprop);
	w = c->indicator;
	width = c->progress * w->allocation.width / 100;
	gc = gdk_gc_new(w->window);
	gdk_color_parse(strstr(uri, "https://") == uri ?
			progress_trust : progress, &fg);
	gdk_gc_set_rgb_fg_color(gc, &fg);
	gdk_draw_rectangle(w->window,
			w->style->bg_gc[GTK_WIDGET_STATE(w)],
			TRUE, 0, 0, w->allocation.width, w->allocation.height);
	gdk_draw_rectangle(w->window, gc, TRUE, 0, 0, width,
			w->allocation.height);
	g_object_unref(gc);
}
Beispiel #9
0
GdkFilterReturn
processx(GdkXEvent *e, GdkEvent *event, gpointer d) {
	Client *c = (Client *)d;
	XPropertyEvent *ev;
	Arg arg;

	if(((XEvent *)e)->type == PropertyNotify) {
		ev = &((XEvent *)e)->xproperty;
		if(ev->state == PropertyNewValue) {
			if(ev->atom == atoms[AtomFind]) {
				arg.b = TRUE;
				find(c, &arg);
				return GDK_FILTER_REMOVE;
			}
			else if(ev->atom == atoms[AtomGo]) {
				arg.v = getatom(c, AtomGo);
				loaduri(c, &arg);
				return GDK_FILTER_REMOVE;
			}
		}
	}
	return GDK_FILTER_CONTINUE;
}
Beispiel #10
0
int get_desktops(char **strings, int max)
{
    Atom atom;
    Atom type;
    int size;
    long length;
    char *string;
    long desktop;
    int i = 0;
    int x = 0;
    int n = 0;
    int win_workspace = 0;

    {
	Atom *a;
	atom = XInternAtom(my_display, "_NET_SUPPORTED", 0);
	a = (Atom *) getatom(DefaultRootWindow(my_display),
			     atom, &length, &type, &size);
	if (a) {
	    Atom xatom =
		XInternAtom(my_display, "_WIN_WORKSPACE_NAMES", 0);
	    Atom yatom = XInternAtom(my_display, "_NET_DESKTOP_NAMES", 0);
	    for (i = 0; i < size; i++, a++) {
		if (yatom == *a) {
		    win_workspace |= 1;
		}
		if (xatom == *a) {
		    win_workspace |= 2;
		}
	    }
	} else {
	}
	i = 0;
    }

    if (win_workspace & 2) {
	atom = XInternAtom(my_display, "_WIN_WORKSPACE_NAMES", 1);
    } else if (win_workspace & 1) {
	atom = XInternAtom(my_display, "_NET_DESKTOP_NAMES", 1);
    } else {
	if (desktop_string) {
	    int x;
	    printf("free string");
	    XFree(desktop_string);
	    desktop_string = NULL;
	    for (x = 0; x < max; x++) {
		strings[x] = NULL;
	    }
	    return 0;
	}
    }
    if (win_workspace) {
	char *string;
	string = (char *) getatom(DefaultRootWindow(my_display),
				  atom, &length, &type, &size);
	if (string) {
	    if (string != desktop_string) {
		XFree(desktop_string);
		bzero(strings, sizeof(strings) * max);
		desktop_string = string;
	    }
	    char *ptr = string;
	    while (i < length) {
		strings[n] = ptr + i;
		i += strlen(ptr + i) + 1;
		if (n++ >= max) {
		    fprintf(stderr, "too many desktops");
		    return max;
		}
	    }
	}
    } else {
	printf("No desktop names\n");
    }
    for (x = n; x < max; x++) {
	strings[x] = NULL;
    }
    return n;
}
lispval
Lsetsyn()
{
	register lispval s, c;
	register struct argent *mynp;
	register index;
	lispval x   /*  ,debugmode  */;
	extern unsigned char *ctable;
	extern lispval Istsrch();

	switch(np-lbot) {
	case 2:
		x= nil;			/* only 2 args given */
	case 3:
		x = lbot[2].val;	/* all three args given */
		break;
	default:
		argerr("setsyntax");
	}
	s = Vreadtable->a.clb;
	chkrtab(s);
	/* debugging code 
	debugmode = Istsrch(matom("debugging"))->d.cdr->d.cdr->d.cdr;
	if(debugmode)  printf("Readtable addr: %x\n",ctable);
	  end debugging code */
	mynp = lbot;
	c = (mynp++)->val;
	s = (mynp++)->val;

	switch(TYPE(c)) {
	default:
		error("neither fixnum, atom or string as char to setsyntax",FALSE);

	case ATOM:
		index = *(c->a.pname);
		if((c->a.pname)[1])
		    errorh1(Vermisc,"Only 1 char atoms to setsyntax",
		         nil,FALSE,0,c);
		break;

	case INT:
		index = c->i;
		break;

	case STRNG:
		index = (int) *((char *) c);
	}
	switch(TYPE(s)) {
	case ATOM:
		if(s==splice || s==macro) {
		    if(s==splice)
			    ctable[index] = VSPL;
		    else if(s==macro)
			    ctable[index] = VMAC;
		    if(TYPE(c)!=ATOM) {
			    strbuf[0] = index;
			    strbuf[1] = 0;
			    c = (getatom(TRUE));
		    }
		    Iputprop(c,x,lastrtab);
		    return(tatom);
		}

		/* ... fall into */
	default:  errorh1(Vermisc,"int:setsyntax : illegal second argument ",
				nil,FALSE,0,s);
		/* not reached */
		
	case INT:
		switch(synclass(s->i)) {
		case CESC: Xesc = (char) index; break;
		case CDQ: Xdqc = (char) index; break;
		case CSD: Xsdc = (char) index;	/* string */
		}

		if(synclass(ctable[index])==CESC   /* if we changed the current esc */
		  && (synclass(s->i)!=CESC)          /* to something else, pick current */
		  && Xesc == (char) index) {
	       		ctable[index] = s->i;
			rpltab(CESC,&Xesc);
		}
		else if(synclass(ctable[index])==CDQ   /*  likewise for double quote */
		       && synclass(s->i) != CDQ
		       && Xdqc == (char) index)  {
			ctable[index] = s->i;
			rpltab(CDQ,&Xdqc);
		}
		else if(synclass(ctable[index]) == CSD  /* and for string delimiter */
			&& synclass(s->i) != CSD
			&& Xsdc == (char) index) {
			 ctable[index] = s->i;
			 rpltab(CSD,&Xsdc);
		}
		else ctable[index] = s->i;

		break;

	}
	return(tatom);
}