#include <termios.h>
#include <fcntl.h>
#include <sys/time.h>
+#include <signal.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
error("%s: XAllocColor(%02x%02x%02x) failed!", Name, c.R, c.G, c.B);
}
XSetForeground(dp, gc, xc.pixel);
- XSetBackground(dp, gc, xc.pixel);
}
XSetWindowBackground(dp, w, xc.pixel);
/* redraw every LCD pixel */
- drv_X11_blit(0, 0, LROWS, LCOLS);
+ drv_X11_blit(0, 0, DROWS, DCOLS);
/* remember new brightness */
Brightness = brightness;
RGBA col;
RGBA lastCol = { 0, 0, 0, 0 };
int hasLastCol = 0;
+ int brightness = drv_X11_brightness(-1);
x0 = x - pixel;
x1 = x + pixel + width;
if (hasLastCol) {
/* if the color of this pixel is different to the last pixels draw the old ones */
if (col.R != lastCol.R || col.G != lastCol.G || col.B != lastCol.B) {
- drv_X11_color(lastCol, 255);
+ drv_X11_color(lastCol, brightness);
XFillRectangles(dp, w, gc, rect, nrect);
nrect = 0;
lastCol = col;
nrect++;
} else {
/* 1st shot: no old color */
- drv_X11_color(col, 255);
+ drv_X11_color(col, brightness);
XFillRectangle(dp, w, gc, xc, yc, pixel, pixel);
lastCol = col;
hasLastCol = 1;
}
}
/* draw the last block of rectangles */
- drv_X11_color(lastCol, 255);
+ drv_X11_color(lastCol, brightness);
XFillRectangles(dp, w, gc, rect, nrect);
/* Keypad on the right side */
int yoffset = border + (DROWS / YRES) * rgap;
static int btn = 0;
- if (XCheckWindowEvent(dp, w, ExposureMask | ButtonPressMask | ButtonReleaseMask, &ev) == 0)
+ if (XCheckWindowEvent(dp, w, ExposureMask | ButtonPressMask | ButtonReleaseMask, &ev) == 0
+ /* there is no ClientMessageMask, so this will be checked separately */
+ && XCheckTypedWindowEvent(dp, w, ClientMessage, &ev) == 0)
return;
switch (ev.type) {
case ClientMessage:
if ((Atom) (ev.xclient.data.l[0]) == wmDeleteMessage) {
info("%s: Window closed by WindowManager, quit.", Name);
- exit(0);
+ if (raise(SIGTERM) != 0) {
+ error("%s: Error raising SIGTERM: exit!", Name);
+ exit(1);
+ }
} else {
- debug("%s: Got client message 0x%lx %lx %lx %lx %lx", Name, ev.xclient.data.l[0],
+ debug("%s: Got XClient message 0x%lx %lx %lx %lx %lx", Name, ev.xclient.data.l[0],
ev.xclient.data.l[1], ev.xclient.data.l[2], ev.xclient.data.l[3], ev.xclient.data.l[4]);
}
XSetWMProperties(dp, w, NULL, NULL, NULL, 0, &sh, NULL, NULL);
wmDeleteMessage = XInternAtom(dp, "WM_DELETE_WINDOW", False);
- /* XSetWMProtocols(dp, w, &wmDeleteMessage, 1); *to be tested* */
+ XSetWMProtocols(dp, w, &wmDeleteMessage, 1);
drv_X11_color(BR_COL, 255);
XSetWindowBackground(dp, w, xc.pixel);