aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/rio/key.c
blob: 95333ec540e6f5594849e938ef1afbea36ad9a0d (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
/* Copyright (c) 2005 Russ Cox, see README for licence details */
#include <stdio.h>
#include <stdlib.h>
#include <X11/X.h>
#include <X11/Xos.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/extensions/shape.h>
#include "dat.h"
#include "fns.h"
#include "patchlevel.h"

enum
{
	GrabAltTab,
	GrabAltAny
};

static int tabcode = 0x17;
/*static int altcode = 0x40; */
/*static int pgupcode = 0x63; */
/*static int pgdowncode = 0x69; */

static void alttab(int shift);

void
keysetup(void)
{
	int i;

	for(i=0; i<num_screens; i++){
		XGrabKey(dpy, tabcode, Mod1Mask, screens[i].root, 0, GrabModeSync, GrabModeAsync);
		XGrabKey(dpy, tabcode, Mod1Mask|ShiftMask, screens[i].root, 0, GrabModeSync, GrabModeAsync);
	/*	XGrabKey(dpy, pgupcode, Mod1Mask, screens[i].root, 0, GrabModeSync, GrabModeAsync); */
	/*	XGrabKey(dpy, pgdowncode, Mod1Mask, screens[i].root, 0, GrabModeSync, GrabModeAsync); */
	/*	XGrabKey(dpy, altcode, 0, screens[i].root, 0, GrabModeSync, GrabModeAsync); */
	}
}

void
keypress(XKeyEvent *e)
{
	/*
	 * process key press here
	 */
	if(0)
	if(e->keycode == tabcode)
		alttab(e->state&ShiftMask);
	XAllowEvents(dpy, SyncKeyboard, e->time);
}

void
keyrelease(XKeyEvent *e)
{
	XAllowEvents(dpy, SyncKeyboard, e->time);
}

static void
alttab(int shift)
{
	shuffle(shift);
/*	fprintf(stderr, "%sTab\n", shift ? "Back" : ""); */
}