summaryrefslogtreecommitdiffstats
path: root/khotkeys/shared/input.h
blob: a9f19240d091465e6be0a7b16734f6b712061084 (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
78
79
80
81
82
83
84
85
86
87
/****************************************************************************

 KHotKeys
 
 Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>

 Distributed under the terms of the GNU General Public License version 2.
 
****************************************************************************/

#ifndef _INPUT_H_
#define _INPUT_H_

#include <tqobject.h>
#include <tqwindowdefs.h>
#include <tqmap.h>
#include <tqwidget.h>
#include <tqvaluelist.h>
#include <kshortcut.h>

#include <X11/X.h>
#include <fixx11h.h>

class KGlobalAccel;

namespace KHotKeys
{

class Kbd_receiver
    {
    public:
        virtual bool handle_key( const KShortcut& shortcut_P ) = 0;
    };

class Kbd
    : public TQObject
    {
    Q_OBJECT
    public:
	Kbd( bool grabbing_enabled_P, TQObject* parent_P );
        virtual ~Kbd();
	void insert_item( const KShortcut& shortcut_P, Kbd_receiver* receiver_P );
        void remove_item( const KShortcut& shortcut_P, Kbd_receiver* receiver_P );
        void activate_receiver( Kbd_receiver* receiver_P );
        void deactivate_receiver( Kbd_receiver* receiver_P );
        static bool send_macro_key( const KKey& key, Window window_P = InputFocus );
    protected:
        bool x11EventFilter( const XEvent* );                                                              
        void grab_shortcut( const KShortcut& shortcut_P );
        void ungrab_shortcut( const KShortcut& shortcut_P );
    private slots:
        void key_slot( TQString key_P );
        void update_connections();
    private:
        struct Receiver_data
            {
            Receiver_data();
            TQValueList< KShortcut > shortcuts;
            bool active;
            };
        TQMap< Kbd_receiver*, Receiver_data > tqreceivers;
        TQMap< KShortcut, int > grabs;
        KGlobalAccel* kga;
    };

class Mouse
    {
    public:
        static bool send_mouse_button( int button_P, bool release_P );
    };


//***************************************************************************
// Inline
//***************************************************************************

// Kbd::Receiver_data

inline
Kbd::Receiver_data::Receiver_data()
    : active( false )
    {
    }

} // namespace KHotKeys

#endif