author | alwin <alwin> | 2004-08-01 10:32:56 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-08-01 10:32:56 (UTC) |
commit | 142d432ef9f8215636a81c358c828d4b6986a6ad (patch) (unidiff) | |
tree | faf33f40f3e19fdd0362256c61e6774ea949f70c /libopie2/opiecore/okeyfilter.cpp | |
parent | 24c8aff75cbb41ccb2acf3de79675c2f4fd7ecc9 (diff) | |
download | opie-142d432ef9f8215636a81c358c828d4b6986a6ad.zip opie-142d432ef9f8215636a81c358c828d4b6986a6ad.tar.gz opie-142d432ef9f8215636a81c358c828d4b6986a6ad.tar.bz2 |
added a keyfilter singleton. All OPIE apps should use that instead of
the base from qte 'cause there are some stupids in handling pointers.
key handlers from odevice-classes will handled at top of all others
iPAQ and SIMPad are switched to that filter queue.
Diffstat (limited to 'libopie2/opiecore/okeyfilter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/okeyfilter.cpp | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/libopie2/opiecore/okeyfilter.cpp b/libopie2/opiecore/okeyfilter.cpp new file mode 100644 index 0000000..d806dbd --- a/dev/null +++ b/libopie2/opiecore/okeyfilter.cpp | |||
@@ -0,0 +1,119 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | =. Copyright (C) 2004 Rajko 'Alwin' Albrecht <alwin@handhelds.org> | ||
4 | .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This program is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This program is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
18 | ..}^=.= = ; Library General Public License for more | ||
19 | ++= -. .` .: details. | ||
20 | : = ...= . :.=- | ||
21 | -. .:....=;==+<; You should have received a copy of the GNU | ||
22 | -_. . . )=. = Library General Public License along with | ||
23 | -- :-=` this library; see the file COPYING.LIB. | ||
24 | If not, write to the Free Software Foundation, | ||
25 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | ||
27 | */ | ||
28 | |||
29 | #include "okeyfilter.h" | ||
30 | #include "device/odevice.h" | ||
31 | #include "odebug.h" | ||
32 | |||
33 | namespace Opie { | ||
34 | namespace Core { | ||
35 | |||
36 | QValueList<QWSServer::KeyboardFilter*> OKeyFilter::filterList; | ||
37 | QValueList<QWSServer::KeyboardFilter*> OKeyFilter::preFilterList; | ||
38 | |||
39 | OKeyFilter::OKeyFilter() | ||
40 | :QWSServer::KeyboardFilter() | ||
41 | { | ||
42 | filterList.clear(); | ||
43 | preFilterList.clear(); | ||
44 | if ( isQWS( ) ) { | ||
45 | QWSServer::setKeyboardFilter ( this ); | ||
46 | } | ||
47 | } | ||
48 | |||
49 | OKeyFilter::~OKeyFilter() | ||
50 | { | ||
51 | } | ||
52 | |||
53 | OKeyFilter* OKeyFilter::inst() | ||
54 | { | ||
55 | static OKeyFilter*ofilter = 0; | ||
56 | if (!ofilter) { | ||
57 | ofilter = new OKeyFilter; | ||
58 | } | ||
59 | return ofilter; | ||
60 | } | ||
61 | |||
62 | bool OKeyFilter::filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ) | ||
63 | { | ||
64 | QValueList<QWSServer::KeyboardFilter*>::Iterator iter; | ||
65 | for (iter=preFilterList.begin();iter!=preFilterList.end();++iter) { | ||
66 | if ((*iter)->filter(unicode,keycode,modifiers,isPress,autoRepeat)) { | ||
67 | return true; | ||
68 | } | ||
69 | } | ||
70 | for (iter=filterList.begin();iter!=filterList.end();++iter) { | ||
71 | if ((*iter)->filter(unicode,keycode,modifiers,isPress,autoRepeat)) { | ||
72 | return true; | ||
73 | } | ||
74 | } | ||
75 | return false; | ||
76 | } | ||
77 | |||
78 | void OKeyFilter::addHandler(QWSServer::KeyboardFilter*aF) | ||
79 | { | ||
80 | if (filterList.find(aF)!=filterList.end()) { | ||
81 | return; | ||
82 | } | ||
83 | odebug << "adding a keyboard filter handler"<<oendl; | ||
84 | filterList.append(aF); | ||
85 | } | ||
86 | |||
87 | void OKeyFilter::remHandler(QWSServer::KeyboardFilter*aF) | ||
88 | { | ||
89 | QValueList<QWSServer::KeyboardFilter*>::Iterator iter; | ||
90 | if ( (iter=filterList.find(aF))==filterList.end() ) { | ||
91 | return; | ||
92 | } | ||
93 | odebug << "removing a keyboard filter handler"<<oendl; | ||
94 | filterList.remove(iter); | ||
95 | } | ||
96 | |||
97 | void OKeyFilter::addPreHandler(QWSServer::KeyboardFilter*aF) | ||
98 | { | ||
99 | if (preFilterList.find(aF)!=preFilterList.end()) { | ||
100 | return; | ||
101 | } | ||
102 | odebug << "adding a preferred keyboard filter handler"<<oendl; | ||
103 | preFilterList.append(aF); | ||
104 | } | ||
105 | |||
106 | void OKeyFilter::remPreHandler(QWSServer::KeyboardFilter*aF) | ||
107 | { | ||
108 | QValueList<QWSServer::KeyboardFilter*>::Iterator iter; | ||
109 | if ( (iter=preFilterList.find(aF))==preFilterList.end() ) { | ||
110 | return; | ||
111 | } | ||
112 | odebug << "removing a preferred keyboard filter handler"<<oendl; | ||
113 | preFilterList.remove(iter); | ||
114 | } | ||
115 | |||
116 | /* namespace Core */ | ||
117 | } | ||
118 | /* namespace Opie */ | ||
119 | } | ||