summaryrefslogtreecommitdiffstats
path: root/kdesktop/xautolock.h
blob: aa618f2523962d0db7c32394de4510fbcf557eed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//===========================================================================
//
// This file is part of the KDE project
//
// Copyright (c) 1999 Martin R. Jones <mjones@kde.org>
//

#ifndef __XAUTOLOCK_H__
#define __XAUTOLOCK_H__

#include <qwidget.h>

#include <X11/Xlib.h>

//===========================================================================
//
// Detect user inactivity.
// Named XAutoLock after the program that it is based on.
//
class XAutoLock : public QWidget
{
    Q_OBJECT
public:
    XAutoLock();
    ~XAutoLock();

    //-----------------------------------------------------------------------
    //
    // The time in seconds of continuous inactivity.
    //
    void setTimeout(int t);
    
    void setDPMS(bool s);
    
    //-----------------------------------------------------------------------
    //
    // Start watching Activity
    //
    void start();

    //-----------------------------------------------------------------------
    //
    // Stop watching Activity
    //
    void stop();

    //-----------------------------------------------------------------------
    //
    // Should be called only from a slot connected to the timeout() signal. Will
    // result in the timeout() signal being emitted again with a delay (i.e. postponed).
    //
    void postpone();

    // internal
    void resetTrigger();
    // internal
    void setTrigger( time_t );
    // internal
    bool ignoreWindow( WId );
    
signals:
    void timeout();

protected:
    virtual void timerEvent(QTimerEvent *ev);
    virtual bool x11Event( XEvent* );

protected:
    int     mTimerId;
    int     mTimeout;
    time_t  mTrigger;
    bool    mActive;
    time_t  mLastTimeout;
    bool    mDPMS;
};

#endif