1
0
mirror of git://git.suckless.org/slock synced 2024-12-25 08:22:15 +00:00

fixed DPMS crashing issue

This commit is contained in:
Anselm R Garbe 2008-04-08 09:55:46 +01:00
parent 4ed35d22dc
commit 049ccf9a90
2 changed files with 8 additions and 4 deletions

View File

@ -1,5 +1,5 @@
# slock version # slock version
VERSION = 0.8 VERSION = 0.9
# Customize below to fit your system # Customize below to fit your system

10
slock.c
View File

@ -1,5 +1,4 @@
/* © 2006-2008 Anselm R Garbe <garbeam at gmail dot com> /* See LICENSE file for license details. */
* See LICENSE file for license details. */
#define _XOPEN_SOURCE 500 #define _XOPEN_SOURCE 500
#if HAVE_SHADOW_H #if HAVE_SHADOW_H
#include <shadow.h> #include <shadow.h>
@ -126,11 +125,16 @@ main(int argc, char **argv) {
/* main event loop */ /* main event loop */
while(running && !XNextEvent(dpy, &ev)) { while(running && !XNextEvent(dpy, &ev)) {
if(len == 0) if(len == 0 && DPMSCapable(dpy))
DPMSForceLevel(dpy, DPMSModeOff); DPMSForceLevel(dpy, DPMSModeOff);
if(ev.type == KeyPress) { if(ev.type == KeyPress) {
buf[0] = 0; buf[0] = 0;
num = XLookupString(&ev.xkey, buf, sizeof buf, &ksym, 0); num = XLookupString(&ev.xkey, buf, sizeof buf, &ksym, 0);
if(IsKeypadKey(ksym))
if(ksym == XK_KP_Enter)
ksym = XK_Return;
else if(ksym >= XK_KP_0 && ksym <= XK_KP_9)
ksym = (ksym - XK_KP_0) + XK_0;
if(IsFunctionKey(ksym) || IsKeypadKey(ksym) if(IsFunctionKey(ksym) || IsKeypadKey(ksym)
|| IsMiscFunctionKey(ksym) || IsPFKey(ksym) || IsMiscFunctionKey(ksym) || IsPFKey(ksym)
|| IsPrivateKeypadKey(ksym)) || IsPrivateKeypadKey(ksym))