summaryrefslogtreecommitdiffstats
path: root/examples/rotate.c
blob: 028de8c6b1bc638f41141a7559857af8fc2d8efe (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
#include <stdio.h>
#include <rfb/rfb.h>
#include <rfb/keysym.h>

#define CONCAT2(a,b) a##b
#define CONCAT2E(a,b) CONCAT2(a,b)
#define CONCAT3(a,b,c) a##b##c
#define CONCAT3E(a,b,c) CONCAT3(a,b,c)

#define FUNCNAME rfbRotate
#define FUNC(i, j) (h - 1 - j + i * h)
#define SWAPDIMENSIONS
#define OUTBITS 8
#include "rotatetemplate.c"
#define OUTBITS 16
#include "rotatetemplate.c"
#define OUTBITS 32
#include "rotatetemplate.c"
#undef FUNCNAME
#undef FUNC

#define FUNCNAME rfbRotateCounterClockwise
#define FUNC(i, j) (j + (w - 1 - i) * h)
#define OUTBITS 8
#include "rotatetemplate.c"
#define OUTBITS 16
#include "rotatetemplate.c"
#define OUTBITS 32
#include "rotatetemplate.c"
#undef FUNCNAME
#undef FUNC
#undef SWAPDIMENSIONS

#define FUNCNAME rfbFlipHorizontally
#define FUNC(i, j) ((w - 1 - i) + j * w)
#define OUTBITS 8
#include "rotatetemplate.c"
#define OUTBITS 16
#include "rotatetemplate.c"
#define OUTBITS 32
#include "rotatetemplate.c"
#undef FUNCNAME
#undef FUNC

#define FUNCNAME rfbFlipVertically
#define FUNC(i, j) (i + (h - 1 - j) * w)
#define OUTBITS 8
#include "rotatetemplate.c"
#define OUTBITS 16
#include "rotatetemplate.c"
#define OUTBITS 32
#include "rotatetemplate.c"
#undef FUNCNAME
#undef FUNC

#define FUNCNAME rfbRotateHundredAndEighty
#define FUNC(i, j) ((w - 1 - i) + (h - 1 - j) * w)
#define OUTBITS 8
#include "rotatetemplate.c"
#define OUTBITS 16
#include "rotatetemplate.c"
#define OUTBITS 32
#include "rotatetemplate.c"
#undef FUNCNAME
#undef FUNC

static void HandleKey(rfbBool down,rfbKeySym key,rfbClientPtr cl)
{
	if(down) {
		if (key==XK_Escape || key=='q' || key=='Q')
			rfbCloseClient(cl);
		else if (key == 'r')
			rfbRotate(cl->screen);
		else if (key == 'R')
			rfbRotateCounterClockwise(cl->screen);
		else if (key == 'f')
			rfbFlipHorizontally(cl->screen);
		else if (key == 'F')
			rfbFlipVertically(cl->screen);
	}
}

#define HAVE_HANDLEKEY
#include "pnmshow.c"