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
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/***************************************************************************
* Copyright (C) 2003 by S�bastien Lao�t *
* slaout@linux62.org *
* *
* 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. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
#include <tdeapplication.h> // it define TQ_WS_X11
#include "keyboard.h"
/* This file contain modified code from tdelistbox.cpp
*/
// ShiftMask, ControlMask and Mod1Mask are defined in <X11/X.h>
#if defined TQ_WS_X11 && ! defined K_WS_TQTONLY
#include <X11/Xlib.h> // schroder
#endif
void Keyboard::pressedKeys(bool &shiftPressed, bool &controlPressed)
{
#if defined TQ_WS_X11 && ! defined K_WS_TQTONLY
Window root;
Window child;
int root_x, root_y, win_x, win_y;
uint keybstate;
XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
&root_x, &root_y, &win_x, &win_y, &keybstate );
shiftPressed = keybstate & ShiftMask;
controlPressed = keybstate & ControlMask;
#endif
}
/** Same code as pressedKeys(...) but for shift key only
*/
bool Keyboard::shiftPressed()
{
#if defined TQ_WS_X11 && ! defined K_WS_TQTONLY
Window root;
Window child;
int root_x, root_y, win_x, win_y;
uint keybstate;
XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
&root_x, &root_y, &win_x, &win_y, &keybstate );
return (keybstate & ShiftMask) != 0;
#else
return false;
#endif
}
/** Same code as pressedKeys(...) but for control key only
*/
bool Keyboard::controlPressed()
{
#if defined TQ_WS_X11 && ! defined K_WS_TQTONLY
Window root;
Window child;
int root_x, root_y, win_x, win_y;
uint keybstate;
XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
&root_x, &root_y, &win_x, &win_y, &keybstate );
return (keybstate & ControlMask) != 0;
#else
return false;
#endif
}
/** Return if Alt key is pressed
*/
bool Keyboard::altPressed()
{
#if defined TQ_WS_X11 && ! defined K_WS_TQTONLY
Window root;
Window child;
int root_x, root_y, win_x, win_y;
uint keybstate;
XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
&root_x, &root_y, &win_x, &win_y, &keybstate );
return (keybstate & Mod1Mask) != 0;
#else
return false;
#endif
}
/*******************
* What does KDE 3.1 and later:
* FIXME: Use this function in KDE 4
* (I wasn't knowing it by creating this class)
/ *
* Returns the currently pressed keyboard modifiers (e.g. shift, control, etc.)
* Usually you simply want to test for those in key events, in which case
* TQKeyEvent::state() does the job (or TQKeyEvent::key() to
* notice when a modifier is pressed alone).
* But it can be useful to query for the status of the modifiers at another moment
* (e.g. some KDE apps do that upon a drop event).
* @return the keyboard modifiers
* @since 3.1
/
uint TDEApplication::keyboardModifiers()
{
Window root;
Window child;
int root_x, root_y, win_x, win_y;
uint keybstate;
XQueryPointer( tqt_xdisplay(), tqt_xrootwin(), &root, &child,
&root_x, &root_y, &win_x, &win_y, &keybstate );
return keybstate & 0x00ff;
}
*
*******************/
|