File: translation_shift.c

package info (click to toggle)
garlic 1.6-1.1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch, wheezy
  • size: 4,440 kB
  • ctags: 1,403
  • sloc: ansic: 52,465; makefile: 1,134
file content (116 lines) | stat: -rw-r--r-- 3,308 bytes parent folder | download | duplicates (5)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/* Copyright (C) 2000 Damir Zucic */

/*=============================================================================

				translation_shift.c

Purpose:
	Prepare the translation shift. By default, the normal translation
	shift is copied  (translation_shiftA[2] from  ConfigS structure).
	See note 1 for combination of modifier keys. Modifier keys may be
	used to select the translation shift.

Input:
	(1) Pointer to ConfigS structure, with configuration data.
	(2) Pointer to GUIS structure, with GUI data.
	(3) The sign used to distinguish  positive and negative translat.
	    Value +1.0 is used with positive translation, while -1.0
	    defines negative translation.

Output:
	(1) Return value.

Return value:
	(1) Translation shift.

Notes:
	(1) The following  combinations  of modifier keys  may be used to
	    select the translation shift:
	    -------------------------------------------------------------
	    |  modifiers         translation shift    ConfigS member    |
	    |-----------------------------------------------------------|
	    | none               normal (default)  translation_stepA[2] |
	    | shift              large             translation_stepA[3] |
	    | alt+shift          very large        translation_stepA[4] |
	    | control            small             translation_stepA[1] |
	    | alt+control        very small        translation_stepA[0] |
	    | shift+control      very small        translation_stepA[2] |
	    | alt                normal            translation_stepA[2] |
	    | alt+shift+control  normal            translation_stepA[2] |
	    -------------------------------------------------------------
	    Note that some  modifier combinations are ignored  (alt alone
	    and alt+control+shift).

	(2) On some laptops the status of shift key may be changed before
	    the KeyPress event is send for the keys on  "numeric keypad".
 
========includes:============================================================*/

#include <stdio.h>

#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <X11/Xatom.h>

#include "defines.h"
#include "typedefs.h"

/*======prepare translation shift:===========================================*/

double TranslationShift_ (ConfigS *configSP, GUIS *guiSP, double sign)
{
double		translation_shift;
int		largeF, smallF, altF;

/* Copy the flags: */
largeF = guiSP->shift_pressedF;
smallF = guiSP->control_pressedF;
altF   = guiSP->alt_pressedF;

/* Select the requested translation shift: */
if (altF)
	{
	if (largeF && !smallF)
		{
		translation_shift = configSP->translation_stepA[4];
		}
	else if (smallF && !largeF)
		{
		translation_shift = configSP->translation_stepA[0];
		}
	else
		{
		translation_shift = configSP->translation_stepA[2];
		}
	}
else
	{
	if (largeF && !smallF)
		{
		translation_shift = configSP->translation_stepA[3];
		}
	else if (smallF && !largeF)
		{
		translation_shift = configSP->translation_stepA[1];
		}
	else if (smallF && largeF)
		{
		translation_shift = configSP->translation_stepA[0];
		}
	else
		{
		translation_shift = configSP->translation_stepA[2];
		}
	}

/* Take care for the sign: */
translation_shift *= sign;

/* Return the translation shift: */
return translation_shift;
}

/*===========================================================================*/