summaryrefslogtreecommitdiff
path: root/src/keys.c
blob: 902f8dc77f7cc082764c04cdc8514ec2c9f77797 (plain) (blame)
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
#include "e.h"

static void e_key_down(Eevent * ev);
static void e_key_up(Eevent * ev);

static void 
e_key_down(Eevent * ev)
{
   Ev_Key_Down          *e;
   
   e = ev->event;
   if (e->win == e_get_key_grab_win())
     {
	e_action_stop("Key_Binding", ACT_KEY_DOWN, 0, e->key, e->mods, 
		      NULL, NULL, 0, 0, 0, 0);
	e_action_start("Key_Binding", ACT_KEY_DOWN, 0, e->key, e->mods, 
		      NULL, NULL, 0, 0, 0, 0);
     }
}

static void 
e_key_up(Eevent * ev)
{
   Ev_Key_Up          *e;
   
   e = ev->event;
   if (e->win == e_get_key_grab_win())
     {
	e_action_stop("Key_Binding", ACT_KEY_UP, 0, e->key, e->mods, 
		      NULL, NULL, 0, 0, 0, 0);
	e_action_start("Key_Binding", ACT_KEY_UP, 0, e->key, e->mods, 
		      NULL, NULL, 0, 0, 0, 0);
     }
}

void
e_keys_init(void)
{
   /* load up our actions .... once to get some grabbed keys */
   e_action_start("", ACT_KEY_DOWN, 0, NULL, EV_KEY_MODIFIER_NONE,
		  NULL, NULL, 0, 0, 0, 0);   
   e_event_filter_handler_add(EV_KEY_DOWN,                 e_key_down);
   e_event_filter_handler_add(EV_KEY_UP,                   e_key_up);
}

void
e_keys_grab(char *key, Ev_Key_Modifiers mods, int anymod)
{
   e_key_grab(key, mods, anymod, 0);
}

void
e_keys_ungrab(char *key, Ev_Key_Modifiers mods, int anymod)
{
   e_key_ungrab(key, mods, anymod);
}