2006-10-12 18:10:57 +04:00
|
|
|
/* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
2005-11-18 18:54:58 +03:00
|
|
|
* See LICENSE file for license details.
|
|
|
|
*/
|
2006-10-20 12:07:55 +04:00
|
|
|
#include "wmii.h"
|
2006-06-27 13:44:54 +04:00
|
|
|
#include <errno.h>
|
2005-11-18 18:54:58 +03:00
|
|
|
#include <fcntl.h>
|
2006-12-13 12:55:19 +03:00
|
|
|
#include <locale.h>
|
2006-06-27 13:44:54 +04:00
|
|
|
#include <pwd.h>
|
2007-02-04 21:31:12 +03:00
|
|
|
#include <signal.h>
|
2006-06-27 13:44:54 +04:00
|
|
|
#include <stdarg.h>
|
2005-11-18 18:54:58 +03:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/wait.h>
|
2006-02-02 00:24:07 +03:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <X11/cursorfont.h>
|
2005-11-18 18:54:58 +03:00
|
|
|
#include <X11/Xproto.h>
|
2005-12-21 18:18:11 +03:00
|
|
|
#include <X11/keysym.h>
|
2005-12-05 04:15:25 +03:00
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/Xproto.h>
|
2005-11-18 18:54:58 +03:00
|
|
|
|
2005-12-05 01:45:59 +03:00
|
|
|
static int other_wm_running;
|
|
|
|
static int (*x_error_handler) (Display *, XErrorEvent *);
|
2006-02-04 17:31:52 +03:00
|
|
|
static char version[] = "wmiiwm - " VERSION ", (C)opyright MMIV-MMVI Anselm R. Garbe\n";
|
2005-11-18 18:54:58 +03:00
|
|
|
|
2005-12-21 18:18:11 +03:00
|
|
|
static void
|
2006-10-12 18:10:57 +04:00
|
|
|
usage() {
|
2006-06-28 10:20:17 +04:00
|
|
|
fputs("usage: wmiiwm -a <address> [-r <wmiirc>] [-v]\n", stderr);
|
2006-06-27 13:44:54 +04:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2007-02-04 21:31:12 +03:00
|
|
|
static void
|
|
|
|
sigchld_handler(int sig) {
|
|
|
|
int ret;
|
|
|
|
/* We only spawn one child */
|
|
|
|
wait(&ret);
|
|
|
|
}
|
|
|
|
|
2006-06-27 13:44:54 +04:00
|
|
|
static void
|
2006-10-12 18:10:57 +04:00
|
|
|
scan_wins() {
|
2006-03-23 17:01:32 +03:00
|
|
|
int i;
|
|
|
|
unsigned int num;
|
|
|
|
Window *wins;
|
|
|
|
XWindowAttributes wa;
|
|
|
|
Window d1, d2;
|
|
|
|
|
2006-07-03 20:41:14 +04:00
|
|
|
if(XQueryTree(blz.dpy, blz.root, &d1, &d2, &wins, &num)) {
|
2006-03-23 17:01:32 +03:00
|
|
|
for(i = 0; i < num; i++) {
|
2006-07-03 20:41:14 +04:00
|
|
|
if(!XGetWindowAttributes(blz.dpy, wins[i], &wa))
|
2006-03-23 17:01:32 +03:00
|
|
|
continue;
|
2006-07-03 20:41:14 +04:00
|
|
|
if(wa.override_redirect || XGetTransientForHint(blz.dpy, wins[i], &d1))
|
2006-03-23 17:01:32 +03:00
|
|
|
continue;
|
|
|
|
if(wa.map_state == IsViewable)
|
2006-04-12 12:44:07 +04:00
|
|
|
manage_client(create_client(wins[i], &wa));
|
2006-03-23 17:01:32 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(wins)
|
|
|
|
XFree(wins);
|
2005-12-21 18:18:11 +03:00
|
|
|
}
|
|
|
|
|
2006-07-11 18:15:01 +04:00
|
|
|
static int
|
2006-10-12 18:10:57 +04:00
|
|
|
win_property(Window w, Atom a, Atom t, long l, unsigned char **prop) {
|
2006-07-11 18:15:01 +04:00
|
|
|
Atom real;
|
|
|
|
int format;
|
|
|
|
unsigned long res, extra;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
status = XGetWindowProperty(blz.dpy, w, a, 0L, l, False, t, &real, &format,
|
|
|
|
&res, &extra, prop);
|
|
|
|
if(status != Success || *prop == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if(res == 0) {
|
|
|
|
free((void *) *prop);
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2006-10-12 18:10:57 +04:00
|
|
|
win_proto(Window w) {
|
2006-07-11 18:15:01 +04:00
|
|
|
Atom *protocols;
|
|
|
|
long res;
|
|
|
|
int protos = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
res = win_property(w, wm_atom[WMProtocols], XA_ATOM, 20L,
|
|
|
|
((unsigned char **) &protocols));
|
|
|
|
if(res <= 0) {
|
|
|
|
return protos;
|
|
|
|
}
|
|
|
|
for(i = 0; i < res; i++) {
|
|
|
|
if(protocols[i] == wm_atom[WMDelete])
|
|
|
|
protos |= WM_PROTOCOL_DELWIN;
|
|
|
|
}
|
|
|
|
free((char *) protocols);
|
|
|
|
return protos;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-21 18:18:11 +03:00
|
|
|
static void
|
2006-10-12 18:10:57 +04:00
|
|
|
init_atoms() {
|
2007-01-28 15:26:01 +03:00
|
|
|
wm_atom[WMState] = XInternAtom(blz.dpy, "WM_STATE", False);
|
2006-07-11 18:15:01 +04:00
|
|
|
wm_atom[WMProtocols] = XInternAtom(blz.dpy, "WM_PROTOCOLS", False);
|
|
|
|
wm_atom[WMDelete] = XInternAtom(blz.dpy, "WM_DELETE_WINDOW", False);
|
2006-07-03 20:41:14 +04:00
|
|
|
net_atom[NetSupported] = XInternAtom(blz.dpy, "_NET_SUPPORTED", False);
|
|
|
|
net_atom[NetWMName] = XInternAtom(blz.dpy, "_NET_WM_NAME", False);
|
|
|
|
tags_atom = XInternAtom(blz.dpy, "_WIN_TAGS", False);
|
|
|
|
XChangeProperty(blz.dpy, blz.root, net_atom[NetSupported], XA_ATOM, 32,
|
2006-05-10 15:38:01 +04:00
|
|
|
PropModeReplace, (unsigned char *) net_atom, NetLast);
|
2005-12-21 18:18:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-10-12 18:10:57 +04:00
|
|
|
init_cursors() {
|
2007-02-03 22:27:32 +03:00
|
|
|
Pixmap pix;
|
|
|
|
XColor black, dummy;
|
|
|
|
|
|
|
|
XAllocNamedColor(blz.dpy, DefaultColormap(blz.dpy, blz.screen), "black", &black, &dummy);
|
|
|
|
pix = XCreateBitmapFromData(blz.dpy, blz.root, (char[]){0}, 1, 1);
|
|
|
|
|
2006-07-03 20:41:14 +04:00
|
|
|
cursor[CurNormal] = XCreateFontCursor(blz.dpy, XC_left_ptr);
|
|
|
|
cursor[CurResize] = XCreateFontCursor(blz.dpy, XC_sizing);
|
|
|
|
cursor[CurMove] = XCreateFontCursor(blz.dpy, XC_fleur);
|
2006-07-06 16:11:09 +04:00
|
|
|
cursor[CurInput] = XCreateFontCursor(blz.dpy, XC_xterm);
|
2007-02-03 22:27:32 +03:00
|
|
|
cursor[CurInvisible] = XCreatePixmapCursor(blz.dpy, pix, pix, &black, &black, 0, 0);
|
|
|
|
|
|
|
|
XFreePixmap(blz.dpy, pix);
|
2005-12-21 18:18:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-10-12 18:10:57 +04:00
|
|
|
init_screen(WMScreen *screen) {
|
2006-06-16 10:52:13 +04:00
|
|
|
Window w;
|
|
|
|
int ret;
|
|
|
|
unsigned mask;
|
2006-05-29 16:15:16 +04:00
|
|
|
XGCValues gcv;
|
|
|
|
|
|
|
|
gcv.subwindow_mode = IncludeInferiors;
|
|
|
|
gcv.function = GXxor;
|
2006-06-19 12:28:37 +04:00
|
|
|
gcv.foreground = def.selcolor.bg;
|
2006-05-29 16:15:16 +04:00
|
|
|
gcv.plane_mask = AllPlanes;
|
|
|
|
gcv.graphics_exposures = False;
|
2006-07-03 20:41:14 +04:00
|
|
|
xorgc = XCreateGC(blz.dpy, blz.root, GCForeground | GCGraphicsExposures |
|
2006-05-29 16:15:16 +04:00
|
|
|
GCFunction | GCSubwindowMode | GCPlaneMask, &gcv);
|
2006-06-30 04:02:52 +04:00
|
|
|
screen->rect.x = screen->rect.y = 0;
|
2006-07-03 20:41:14 +04:00
|
|
|
screen->rect.width = DisplayWidth(blz.dpy, blz.screen);
|
|
|
|
screen->rect.height = DisplayHeight(blz.dpy, blz.screen);
|
2006-06-30 04:02:52 +04:00
|
|
|
def.snap = screen->rect.height / 63;
|
2006-07-03 20:41:14 +04:00
|
|
|
sel_screen = XQueryPointer(blz.dpy, blz.root, &w, &w, &ret, &ret, &ret, &ret, &mask);
|
2005-11-18 18:54:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* There's no way to check accesses to destroyed windows, thus
|
|
|
|
* those cases are ignored (especially on UnmapNotify's).
|
|
|
|
* Other types of errors call Xlib's default error handler, which
|
|
|
|
* calls exit().
|
|
|
|
*/
|
2006-03-09 22:25:50 +03:00
|
|
|
int
|
2006-10-12 18:10:57 +04:00
|
|
|
wmii_error_handler(Display *dpy, XErrorEvent *error) {
|
2006-03-23 17:01:32 +03:00
|
|
|
if(error->error_code == BadWindow
|
|
|
|
|| (error->request_code == X_SetInputFocus
|
|
|
|
&& error->error_code == BadMatch)
|
|
|
|
|| (error->request_code == X_PolyText8
|
|
|
|
&& error->error_code == BadDrawable)
|
|
|
|
|| (error->request_code == X_PolyFillRectangle
|
|
|
|
&& error->error_code == BadDrawable)
|
|
|
|
|| (error->request_code == X_PolySegment
|
|
|
|
&& error->error_code == BadDrawable)
|
|
|
|
|| (error->request_code == X_ConfigureWindow
|
2006-04-26 17:19:56 +04:00
|
|
|
&& error->error_code == BadMatch)
|
|
|
|
|| (error->request_code == X_GrabKey
|
2006-06-30 06:58:06 +04:00
|
|
|
&& error->error_code == BadAccess))
|
2006-03-23 17:01:32 +03:00
|
|
|
return 0;
|
2006-05-14 19:27:00 +04:00
|
|
|
fprintf(stderr, "wmiiwm: fatal error: Xrequest code=%d, Xerror code=%d\n",
|
|
|
|
error->request_code, error->error_code);
|
2006-07-03 20:41:14 +04:00
|
|
|
return x_error_handler(blz.dpy, error); /* calls exit() */
|
2005-11-18 18:54:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Startup Error handler to check if another window manager
|
|
|
|
* is already running.
|
|
|
|
*/
|
2005-12-21 18:18:11 +03:00
|
|
|
static int
|
2006-10-12 18:10:57 +04:00
|
|
|
startup_error_handler(Display * dpy, XErrorEvent * error) {
|
2006-03-23 17:01:32 +03:00
|
|
|
other_wm_running = 1;
|
|
|
|
return -1;
|
2005-12-21 18:18:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-10-12 18:10:57 +04:00
|
|
|
cleanup() {
|
2006-06-08 12:54:19 +04:00
|
|
|
Client *c;
|
2006-10-12 18:10:57 +04:00
|
|
|
|
2006-06-08 12:54:19 +04:00
|
|
|
for(c=client; c; c=c->next)
|
2006-06-22 13:03:42 +04:00
|
|
|
reparent_client(c, blz.root, c->sel->rect.x, c->sel->rect.y);
|
2006-07-03 20:41:14 +04:00
|
|
|
XSetInputFocus(blz.dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
|
|
|
|
XSync(blz.dpy, False);
|
2005-12-21 18:18:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2006-10-12 18:10:57 +04:00
|
|
|
main(int argc, char *argv[]) {
|
2006-06-30 04:02:52 +04:00
|
|
|
int i;
|
2006-10-12 18:10:57 +04:00
|
|
|
char *address = NULL, *wmiirc = NULL, *namespace, *errstr;
|
2006-06-30 04:02:52 +04:00
|
|
|
WMScreen *s;
|
2006-06-27 14:54:21 +04:00
|
|
|
struct passwd *passwd;
|
2006-03-23 17:01:32 +03:00
|
|
|
XSetWindowAttributes wa;
|
2005-12-21 18:18:11 +03:00
|
|
|
|
2006-03-23 17:01:32 +03:00
|
|
|
/* command line args */
|
2006-06-28 06:16:14 +04:00
|
|
|
for(i = 1; (i < argc) && (argv[i][0] == '-'); i++) {
|
|
|
|
switch (argv[i][1]) {
|
|
|
|
case 'v':
|
|
|
|
fprintf(stdout, "%s", version);
|
|
|
|
exit(0);
|
|
|
|
break;
|
|
|
|
case 'a':
|
|
|
|
if(i + 1 < argc)
|
|
|
|
address = argv[++i];
|
|
|
|
else
|
2006-03-23 17:01:32 +03:00
|
|
|
usage();
|
2006-06-28 06:16:14 +04:00
|
|
|
break;
|
|
|
|
case 'r':
|
|
|
|
if(i + 1 < argc)
|
|
|
|
wmiirc = argv[++i];
|
|
|
|
else
|
|
|
|
usage();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
usage();
|
|
|
|
break;
|
2006-03-23 17:01:32 +03:00
|
|
|
}
|
|
|
|
}
|
2006-06-23 09:43:28 +04:00
|
|
|
starting = True;
|
2006-12-13 12:55:19 +03:00
|
|
|
setlocale(LC_CTYPE, "");
|
2006-07-03 20:41:14 +04:00
|
|
|
blz.dpy = XOpenDisplay(0);
|
|
|
|
if(!blz.dpy)
|
2006-10-16 16:43:31 +04:00
|
|
|
ixp_eprint("wmiiwm: cannot open dpy\n");
|
2006-07-03 20:41:14 +04:00
|
|
|
blz.screen = DefaultScreen(blz.dpy);
|
|
|
|
blz.root = RootWindow(blz.dpy, blz.screen);
|
2006-03-23 17:01:32 +03:00
|
|
|
/* check if another WM is already running */
|
|
|
|
other_wm_running = 0;
|
|
|
|
XSetErrorHandler(startup_error_handler);
|
|
|
|
/* this causes an error if some other WM is running */
|
2006-07-03 20:41:14 +04:00
|
|
|
XSelectInput(blz.dpy, blz.root, SubstructureRedirectMask | EnterWindowMask);
|
|
|
|
XSync(blz.dpy, False);
|
2006-06-27 13:44:54 +04:00
|
|
|
if(other_wm_running)
|
2006-10-16 16:43:31 +04:00
|
|
|
ixp_eprint("wmiiwm: another window manager is already running\n");
|
2006-03-23 17:01:32 +03:00
|
|
|
if(!address)
|
2006-02-08 19:59:57 +03:00
|
|
|
usage();
|
2006-06-27 13:44:54 +04:00
|
|
|
/* Check namespace permissions */
|
|
|
|
if(!strncmp(address, "unix!", 5)) {
|
|
|
|
struct stat st;
|
2006-10-12 18:10:57 +04:00
|
|
|
namespace = ixp_estrdup(&address[5]);
|
2006-06-27 13:44:54 +04:00
|
|
|
for(i = strlen(namespace) - 1; i >= 0; i--)
|
|
|
|
if(namespace[i] == '/') break;
|
|
|
|
namespace[i+1] = '\0';
|
|
|
|
if(stat(namespace, &st))
|
2006-10-16 16:43:31 +04:00
|
|
|
ixp_eprint("wmiiwm: can't stat namespace directory \"%s\": %s\n",
|
2006-06-27 13:44:54 +04:00
|
|
|
namespace, strerror(errno));
|
|
|
|
if(getuid() != st.st_uid)
|
2006-10-16 16:43:31 +04:00
|
|
|
ixp_eprint("wmiiwm: namespace directory \"%s\" exists, but is not owned by you",
|
2006-06-27 13:44:54 +04:00
|
|
|
namespace);
|
|
|
|
if(st.st_mode & 077)
|
2006-10-16 18:09:27 +04:00
|
|
|
ixp_eprint("wmiiwm: namespace directory \"%s\" exists, "
|
2006-06-27 13:44:54 +04:00
|
|
|
"but has group or world permissions",
|
|
|
|
namespace);
|
|
|
|
free(namespace);
|
|
|
|
}
|
2006-03-23 17:01:32 +03:00
|
|
|
XSetErrorHandler(0);
|
|
|
|
x_error_handler = XSetErrorHandler(wmii_error_handler);
|
2006-10-12 18:10:57 +04:00
|
|
|
errstr = NULL;
|
2006-02-02 16:50:04 +03:00
|
|
|
i = ixp_create_sock(address, &errstr);
|
2006-06-27 13:44:54 +04:00
|
|
|
if(i < 0)
|
2006-10-16 16:43:31 +04:00
|
|
|
ixp_eprint("wmiiwm: fatal: %s\n", errstr);
|
2006-06-27 13:44:54 +04:00
|
|
|
|
|
|
|
/* start wmiirc */
|
|
|
|
if(wmiirc) {
|
|
|
|
int name_len = strlen(wmiirc) + 6;
|
2006-06-28 06:16:14 +04:00
|
|
|
char execstr[name_len];
|
2007-02-04 21:31:12 +03:00
|
|
|
signal(SIGCHLD, sigchld_handler);
|
2006-06-27 13:44:54 +04:00
|
|
|
switch(fork()) {
|
|
|
|
case 0:
|
|
|
|
if(setsid() == -1)
|
2006-10-16 16:43:31 +04:00
|
|
|
ixp_eprint("wmiim: can't setsid: %s\n", strerror(errno));
|
2006-06-30 04:02:52 +04:00
|
|
|
close(i);
|
2006-07-03 20:41:14 +04:00
|
|
|
close(ConnectionNumber(blz.dpy));
|
2006-06-28 06:16:14 +04:00
|
|
|
snprintf(execstr, name_len, "exec %s", wmiirc);
|
2006-10-12 18:10:57 +04:00
|
|
|
execl("/bin/sh", "sh", "-c", execstr, NULL);
|
2006-10-16 16:43:31 +04:00
|
|
|
ixp_eprint("wmiiwm: can't exec \"%s\": %s\n", wmiirc, strerror(errno));
|
2006-06-27 13:44:54 +04:00
|
|
|
case -1:
|
|
|
|
perror("wmiiwm: cannot fork wmiirc");
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-02-02 16:50:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* IXP server */
|
2006-10-12 18:10:57 +04:00
|
|
|
ixp_server_open_conn(&srv, i, &p9srv, serve_9pcon, NULL);
|
2006-02-03 20:11:22 +03:00
|
|
|
/* X server */
|
2006-10-12 18:10:57 +04:00
|
|
|
ixp_server_open_conn(&srv, ConnectionNumber(blz.dpy), NULL, check_x_event, NULL);
|
|
|
|
view = NULL;
|
|
|
|
client = NULL;
|
|
|
|
key = NULL;
|
2006-06-27 14:54:21 +04:00
|
|
|
passwd = getpwuid(getuid());
|
2006-10-12 18:10:57 +04:00
|
|
|
user = ixp_estrdup(passwd->pw_name);
|
|
|
|
def.colrules.string = NULL;
|
2006-06-17 15:32:49 +04:00
|
|
|
def.colrules.size = 0;
|
2006-10-12 18:10:57 +04:00
|
|
|
def.tagrules.string = NULL;
|
2006-06-17 15:32:49 +04:00
|
|
|
def.tagrules.size = 0;
|
2006-10-12 18:10:57 +04:00
|
|
|
def.keys = NULL;
|
2006-03-10 18:21:20 +03:00
|
|
|
def.keyssz = 0;
|
2006-10-12 18:10:57 +04:00
|
|
|
def.font.fontstr = ixp_estrdup(BLITZ_FONT);
|
2006-03-23 18:12:06 +03:00
|
|
|
def.border = 2;
|
2006-04-14 14:03:44 +04:00
|
|
|
def.colmode = Coldefault;
|
2006-10-12 18:10:57 +04:00
|
|
|
strncpy(def.selcolor.colstr, BLITZ_SELCOLORS, sizeof(def.selcolor.colstr));
|
2006-10-12 18:12:22 +04:00
|
|
|
loadcolor(&blz, &def.selcolor);
|
2006-10-12 18:10:57 +04:00
|
|
|
strncpy(def.normcolor.colstr, BLITZ_NORMCOLORS, sizeof(def.normcolor.colstr));
|
2006-10-12 18:12:22 +04:00
|
|
|
loadcolor(&blz, &def.normcolor);
|
2006-10-12 18:10:57 +04:00
|
|
|
strncpy(def.grabmod, "Mod1", sizeof(def.grabmod));
|
2006-04-12 13:08:31 +04:00
|
|
|
def.mod = Mod1Mask;
|
2006-03-23 17:01:32 +03:00
|
|
|
init_atoms();
|
|
|
|
init_cursors();
|
2006-10-12 18:12:22 +04:00
|
|
|
loadfont(&blz, &def.font);
|
2006-04-12 12:44:07 +04:00
|
|
|
init_lock_keys();
|
2006-06-30 04:02:52 +04:00
|
|
|
num_screens = 1;
|
2006-10-12 18:10:57 +04:00
|
|
|
screens = ixp_emallocz(num_screens * sizeof(*screens));
|
2006-06-30 04:02:52 +04:00
|
|
|
for(i = 0; i < num_screens; i++) {
|
|
|
|
s = &screens[i];
|
2006-10-12 18:10:57 +04:00
|
|
|
s->lbar = NULL;
|
|
|
|
s->rbar = NULL;
|
|
|
|
s->sel = NULL;
|
2006-06-30 04:02:52 +04:00
|
|
|
init_screen(s);
|
2006-07-03 20:41:14 +04:00
|
|
|
pmap = XCreatePixmap(blz.dpy, blz.root, s->rect.width, s->rect.height,
|
|
|
|
DefaultDepth(blz.dpy, blz.screen));
|
2006-06-30 04:02:52 +04:00
|
|
|
wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask;
|
|
|
|
wa.cursor = cursor[CurNormal];
|
2006-07-03 20:41:14 +04:00
|
|
|
XChangeWindowAttributes(blz.dpy, blz.root, CWEventMask | CWCursor, &wa);
|
2006-06-30 04:02:52 +04:00
|
|
|
wa.override_redirect = 1;
|
|
|
|
wa.background_pixmap = ParentRelative;
|
|
|
|
wa.event_mask = ExposureMask | ButtonReleaseMask
|
|
|
|
| SubstructureRedirectMask | SubstructureNotifyMask;
|
|
|
|
s->brect = s->rect;
|
2006-10-12 18:12:22 +04:00
|
|
|
s->brect.height = labelh(&def.font);
|
2006-06-30 04:02:52 +04:00
|
|
|
s->brect.y = s->rect.height - s->brect.height;
|
2006-07-03 20:41:14 +04:00
|
|
|
s->barwin = XCreateWindow(blz.dpy, RootWindow(blz.dpy, blz.screen),
|
2006-06-30 04:02:52 +04:00
|
|
|
s->brect.x, s->brect.y,
|
|
|
|
s->brect.width, s->brect.height, 0,
|
2006-07-03 20:41:14 +04:00
|
|
|
DefaultDepth(blz.dpy, blz.screen),
|
|
|
|
CopyFromParent, DefaultVisual(blz.dpy, blz.screen),
|
2006-06-30 04:02:52 +04:00
|
|
|
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
2006-07-03 20:41:14 +04:00
|
|
|
XSync(blz.dpy, False);
|
2006-06-30 04:02:52 +04:00
|
|
|
s->bbrush.blitz = &blz;
|
2006-07-03 20:41:14 +04:00
|
|
|
s->bbrush.gc = XCreateGC(blz.dpy, s->barwin, 0, 0);
|
2006-06-30 04:02:52 +04:00
|
|
|
s->bbrush.drawable = pmap;
|
|
|
|
s->bbrush.rect = s->brect;
|
|
|
|
s->bbrush.rect.x = 0;
|
|
|
|
s->bbrush.rect.y = 0;
|
|
|
|
s->bbrush.color = def.normcolor;
|
|
|
|
s->bbrush.font = &def.font;
|
2006-12-21 16:18:51 +03:00
|
|
|
s->bbrush.border = False;
|
2006-06-30 04:02:52 +04:00
|
|
|
draw_bar(s);
|
2006-07-03 20:41:14 +04:00
|
|
|
XMapRaised(blz.dpy, s->barwin);
|
2006-06-30 04:02:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
screen = &screens[0];
|
2006-03-23 17:01:32 +03:00
|
|
|
scan_wins();
|
2006-06-25 17:16:03 +04:00
|
|
|
update_views();
|
2006-06-23 09:43:28 +04:00
|
|
|
starting = False;
|
|
|
|
|
2006-03-23 17:01:32 +03:00
|
|
|
/* main event loop */
|
2006-02-02 16:50:04 +03:00
|
|
|
errstr = ixp_server_loop(&srv);
|
|
|
|
if(errstr)
|
2006-03-23 17:01:32 +03:00
|
|
|
fprintf(stderr, "wmii: fatal: %s\n", errstr);
|
|
|
|
cleanup();
|
2006-07-03 20:41:14 +04:00
|
|
|
XCloseDisplay(blz.dpy);
|
2006-06-29 21:34:58 +04:00
|
|
|
ixp_server_close(&srv);
|
2006-03-23 17:01:32 +03:00
|
|
|
return errstr ? 1 : 0;
|
2005-11-18 18:54:58 +03:00
|
|
|
}
|