#include <stdlib.h>
#include <string.h>
#include <signal.h>
+#include <stdint.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/stat.h>
typedef struct {
char c[UTF_SIZ]; /* character code */
ushort mode; /* attribute flags */
- ulong fg; /* foreground */
- ulong bg; /* background */
+ uint32_t fg; /* foreground */
+ uint32_t bg; /* background */
} Glyph;
typedef Glyph *Line;
Colourmap cmap;
Window win;
Drawable buf;
- Atom xembed, wmdeletewin;
+ Atom xembed, wmdeletewin, netwmname, netwmpid;
XIM xim;
XIC xic;
Draw draw;
static void tsetmode(bool, bool, int *, int);
static void tfulldirt(void);
static void techo(char *, int);
-static long tdefcolor(int *, int *, int);
+static int32_t tdefcolor(int *, int *, int);
static void tselcs(void);
static void tdeftran(char);
static inline bool match(uint, uint);
tscrollup(term.c.y, n);
}
-long
+int32_t
tdefcolor(int *attr, int *npar, int l) {
- long idx = -1;
+ int32_t idx = -1;
uint r, g, b;
switch (attr[*npar + 1]) {
void
tsetattr(int *attr, int l) {
int i;
- long idx;
+ int32_t idx;
for(i = 0; i < l; i++) {
switch(attr[i]) {
Cursor cursor;
Window parent;
int sw, sh;
+ pid_t thispid = getpid();
if(!(xw.dpy = XOpenDisplay(NULL)))
die("Can't open display\n");
xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False);
+ xw.netwmname = XInternAtom(xw.dpy, "_NET_WM_NAME", False);
XSetWMProtocols(xw.dpy, xw.win, &xw.wmdeletewin, 1);
+ xw.netwmpid = XInternAtom(xw.dpy, "_NET_WM_PID", False);
+ XChangeProperty(xw.dpy, xw.win, xw.netwmpid, XA_CARDINAL, 32,
+ PropModeReplace, (unsigned char *)&thispid, 1);
+
xresettitle();
XMapWindow(xw.dpy, xw.win);
xhints();
Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
&prop);
XSetWMName(xw.dpy, xw.win, &prop);
+ XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmname);
XFree(prop.value);
}
static inline bool
match(uint mask, uint state) {
- state &= ~ignoremod;
-
- if(mask == XK_NO_MOD && state)
- return false;
- if(mask != XK_ANY_MOD && mask != XK_NO_MOD && !state)
- return false;
- if(mask == XK_ANY_MOD)
- return true;
- return state == mask;
+ return mask == XK_ANY_MOD || mask == (state & ~ignoremod);
}
void
if(!match(kp->mask, state))
continue;
- if(kp->appkey > 0) {
- if(!IS_SET(MODE_APPKEYPAD))
- continue;
- if(term.numlock && kp->appkey == 2)
- continue;
- } else if(kp->appkey < 0 && IS_SET(MODE_APPKEYPAD)) {
+ if(IS_SET(MODE_APPKEYPAD) ? kp->appkey < 0 : kp->appkey > 0)
+ continue;
+ if(term.numlock && kp->appkey == 2)
continue;
- }
- if((kp->appcursor < 0 && IS_SET(MODE_APPCURSOR)) ||
- (kp->appcursor > 0
- && !IS_SET(MODE_APPCURSOR))) {
+ if(IS_SET(MODE_APPCURSOR) ? kp->appcursor < 0 : kp->appcursor > 0)
continue;
- }
- if((kp->crlf < 0 && IS_SET(MODE_CRLF)) ||
- (kp->crlf > 0 && !IS_SET(MODE_CRLF))) {
+ if(IS_SET(MODE_CRLF) ? kp->crlf < 0 : kp->crlf > 0)
continue;
- }
return kp->s;
}
return;
len = XmbLookupString(xw.xic, e, buf, sizeof buf, &ksym, &status);
- e->state &= ~Mod2Mask;
/* 1. shortcuts */
for(bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) {
if(ksym == bp->keysym && match(bp->mod, e->state)) {
}
}
+ ttynew();
if(!xw.isfixed)
cresize(w, h);
else
cresize(xw.fw, xw.fh);
- ttynew();
gettimeofday(&lastblink, NULL);
gettimeofday(&last, NULL);