File: xautolock.h

package info (click to toggle)
kdeutils 4%3A3.5.5-3etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 21,152 kB
  • ctags: 16,106
  • sloc: cpp: 114,950; sh: 10,061; ansic: 3,182; perl: 2,835; python: 1,308; makefile: 931; xml: 303; lex: 302; yacc: 167
file content (92 lines) | stat: -rw-r--r-- 1,991 bytes parent folder | download | duplicates (3)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//===========================================================================
//
// This file is part of the KDE project
//
// Copyright (c) 1999 Martin R. Jones <mjones@kde.org>
//

#ifndef __XAUTOLOCK_H__
#define __XAUTOLOCK_H__

#include <time.h>
#include <qobject.h>
#include <qptrqueue.h>
#include <X11/Xlib.h>

//===========================================================================
//
// A window and its creation time.
//
class WatchedWindow
{
public:
    WatchedWindow(Window w)
        { mWindow = w; mTime = time(0); }

    time_t created() { return mTime; }
    Window window() { return mWindow; }

protected:
    Window mWindow;
    time_t mTime;
};

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

    //-----------------------------------------------------------------------
    //
    // The time in seconds of continuous inactivity.
    //
    void setTimeout(int t);

    //-----------------------------------------------------------------------
    //
    // Start watching Activity
    //
    void start();

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

    void setLoadAverage(bool enable, float value) {mLavEnabled=enable&(value>=0.0); mLav=value;}

public slots:
    void windowCreated(Window w);
    void keyPressed();

signals:
    void timeout();

protected:
    void resetTrigger();
    void processWatched(time_t delay);
    void selectEvents(Window window);
    void queryPointer();
    virtual void timerEvent(QTimerEvent *ev);

protected:
    float   mLav;
    bool    mLavEnabled;
    int     mTimerId;
    int     mTimeout;
    int     mTrigger;
    bool    mActive;
    time_t  mLastTimeout;
    QPtrQueue<WatchedWindow>  mWindows;
};

#endif