summaryrefslogtreecommitdiff
path: root/keys.h
blob: 5d09801538a76b95f44a34ca6a12e6738fa1bd16 (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
88
89
90
91
92
93
94
/***************************************************************************
        xbindkeys : a program to bind keys to commands under X11.
                           -------------------
    begin                : Sat Oct 13 14:11:34 CEST 2001
    copyright            : (C) 2001 by Philippe Brochard
    email                : hocwp@free.fr
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef __KEYS_H
#define __KEYS_H

#include <X11/Xlib.h>
#ifdef GUILE_FLAG
#include <libguile.h>
#endif

typedef enum
  { SYM, CODE, BUTTON }
KeyType_t;

typedef enum
  { PRESS, RELEASE}
EventType_t;

#ifndef GUILE_FLAG
typedef int SCM;
#endif

typedef struct
{
  KeyType_t type;

  EventType_t event_type;

  union
  {
    KeySym sym;
    KeyCode code;
    unsigned int button;
  }
  key;

  unsigned int modifier;
  char *command;
  SCM function;    // This is to call a scheme function instead of a shell command
                   // when command == NULL (not used when guile is not used).
}
Keys_t;


extern int init_keys (void);
extern void close_keys (void);

extern int add_key (KeyType_t type, EventType_t event_type, KeySym keysym, KeyCode keycode,
		    unsigned int button, unsigned int modifier,
		    char *command, SCM function);

extern int remove_key (KeyType_t type, EventType_t event_type, KeySym keysym, KeyCode keycode,
		       unsigned int button, unsigned int modifier);


extern void show_key_binding (Display * d);

extern void print_key (Display * d, Keys_t * key);

extern void set_keysym (Keys_t * key, EventType_t event_type, KeySym keysym,
			unsigned int modifier, char *command, SCM function);
extern void set_keycode (Keys_t * key, EventType_t event_type, KeyCode keycode,
			 unsigned int modifier, char *command, SCM function);
extern void set_button (Keys_t * key, EventType_t event_type, unsigned int button,
			unsigned int modifier, char *command, SCM function);

extern void free_key (Keys_t * key);

extern void start_command_key (Keys_t * key);

extern void modifier_to_string (unsigned int modifier, char *str);

extern void run_command (char * command);


extern int nb_keys;
extern Keys_t *keys;

#endif /* __KEYS_H */