Update ooo320-m1
[ooovba.git] / applied_patches / 0414-autocorrect-accidental-caps-lock-vcl.diff
blob603af41bc51de7f0e4cd22d640438c00a4e0f85a
1 diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=vcl.vpj vcl.clean/aqua/inc/salframe.h vcl/aqua/inc/salframe.h
2 --- vcl.clean/aqua/inc/salframe.h 2008-01-14 11:13:04.000000000 -0500
3 +++ vcl/aqua/inc/salframe.h 2008-02-28 12:57:14.000000000 -0500
4 @@ -146,6 +146,8 @@ public:
5 virtual void Beep( SoundType eSoundType );
6 virtual const SystemEnvData* GetSystemData() const;
7 virtual SalPointerState GetPointerState();
8 + virtual SalIndicatorState GetIndicatorState();
9 + virtual void SimulateKeyPress( USHORT nKeyCode );
10 virtual void SetParent( SalFrame* pNewParent );
11 virtual bool SetPluginParent( SystemParentData* pNewParent );
12 virtual void SetExtendedFrameStyle( SalExtStyle );
13 diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=vcl.vpj vcl.clean/aqua/source/window/salframe.cxx vcl/aqua/source/window/salframe.cxx
14 --- vcl.clean/aqua/source/window/salframe.cxx 2008-01-14 11:18:51.000000000 -0500
15 +++ vcl/aqua/source/window/salframe.cxx 2008-02-28 12:57:39.000000000 -0500
16 @@ -1197,6 +1197,17 @@ SalPointerState AquaSalFrame::GetPointer
17 return state;
20 +SalFrame::SalIndicatorState AquaSalFrame::GetIndicatorState()
22 + SalIndicatorState aState;
23 + aState.mnState = 0;
24 + return aState;
27 +void AquaSalFrame::SimulateKeyPress( USHORT /*nKeyCode*/ )
31 bool AquaSalFrame::SetPluginParent( SystemParentData* pNewParent )
33 // plugin parent may be killed unexpectedly by
34 --- vcl/inc/vcl/keycodes.hxx
35 +++ vcl/inc/vcl/keycodes.hxx
36 @@ -171,6 +171,10 @@
37 #define KEY_BRACKETLEFT ((USHORT)::com::sun::star::awt::Key::BRACKETLEFT)
38 #define KEY_BRACKETRIGHT ((USHORT)::com::sun::star::awt::Key::BRACKETRIGHT)
40 +#define KEY_CAPSLOCK ((USHORT)::com::sun::star::awt::Key::CAPSLOCK)
41 +#define KEY_NUMLOCK ((USHORT)::com::sun::star::awt::Key::NUMLOCK)
42 +#define KEY_SCROLLLOCK ((USHORT)::com::sun::star::awt::Key::SCROLLLOCK)
44 #define KEY_CODE ((USHORT)0x0FFF)
46 // Modifier-Tasten
47 @@ -200,4 +204,12 @@
48 #define MOUSE_MIDDLE ((USHORT)0x0002)
49 #define MOUSE_RIGHT ((USHORT)0x0004)
51 +// -------------------
52 +// - Indicator-Types -
53 +// -------------------
55 +#define INDICATOR_CAPSLOCK 0x0001
56 +#define INDICATOR_NUMLOCK 0x0002
57 +#define INDICATOR_SCROLLLOCK 0x0004
59 #endif // _SV_KEYCODES_HXX
60 diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=vcl.vpj vcl.clean/inc/vcl/salframe.hxx vcl/inc/vcl/salframe.hxx
61 --- vcl.clean/inc/vcl/salframe.hxx 2007-10-09 11:17:45.000000000 -0400
62 +++ vcl/inc/vcl/salframe.hxx 2008-02-28 11:21:03.000000000 -0500
63 @@ -272,6 +272,15 @@ public:
65 virtual SalPointerState GetPointerState() = 0;
67 + struct SalIndicatorState
68 + {
69 + USHORT mnState;
70 + };
72 + virtual SalIndicatorState GetIndicatorState() = 0;
74 + virtual void SimulateKeyPress( USHORT nKeyCode ) = 0;
76 // set new parent window
77 virtual void SetParent( SalFrame* pNewParent ) = 0;
78 // reparent window to act as a plugin; implementation
79 diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=vcl.vpj vcl.clean/inc/vcl/window.hxx vcl/inc/vcl/window.hxx
80 --- vcl.clean/inc/vcl/window.hxx 2008-01-14 08:04:14.000000000 -0500
81 +++ vcl/inc/vcl/window.hxx 2008-02-28 02:11:44.000000000 -0500
82 @@ -1121,6 +1121,22 @@ public:
83 /* mark Window for deletion in top of event queue
85 void doLazyDelete();
87 + //-------------------------------------
88 + // Keyboard access functions
89 + //-------------------------------------
91 + /** Query the states of keyboard indicators - Caps Lock, Num Lock and
92 + Scroll Lock. Use the following mask to retrieve the state of each
93 + indicator:
95 + INDICATOR_CAPS_LOCK
96 + INDICATOR_NUM_LOCK
97 + INDICATOR_SCROLL_LOCK
98 + */
99 + USHORT GetIndicatorState() const;
101 + void SimulateKeyPress( USHORT nKeyCode ) const;
103 virtual XubString GetSurroundingText() const;
104 virtual Selection GetSurroundingTextSelection() const;
105 diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=vcl.vpj vcl.clean/os2/inc/salframe.h vcl/os2/inc/salframe.h
106 --- vcl.clean/os2/inc/salframe.h 2007-11-02 08:44:25.000000000 -0400
107 +++ vcl/os2/inc/salframe.h 2008-02-28 13:00:17.000000000 -0500
108 @@ -168,6 +168,8 @@ public:
109 virtual void Beep( SoundType eSoundType );
110 virtual const SystemEnvData* GetSystemData() const;
111 virtual SalPointerState GetPointerState();
112 + virtual SalIndicatorState GetIndicatorState();
113 + virtual void SimulateKeyPress( USHORT nKeyCode );
114 virtual void SetParent( SalFrame* pNewParent );
115 virtual bool SetPluginParent( SystemParentData* pNewParent );
116 virtual void SetBackgroundBitmap( SalBitmap* );
117 diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=vcl.vpj vcl.clean/os2/source/window/salframe.cxx vcl/os2/source/window/salframe.cxx
118 --- vcl.clean/os2/source/window/salframe.cxx 2007-11-02 08:51:30.000000000 -0400
119 +++ vcl/os2/source/window/salframe.cxx 2008-02-28 13:01:25.000000000 -0500
120 @@ -2335,6 +2335,19 @@ SalFrame::SalPointerState Os2SalFrame::G
122 // -----------------------------------------------------------------------
124 +SalFrame::SalIndicatorState Os2SalFrame::GetIndicatorState()
126 + SalIndicatorState aState;
127 + aState.mnState = 0;
128 + return aState;
131 +void Os2SalFrame::SimulateKeyPress( USHORT /*nKeyCode*/ )
135 +// -----------------------------------------------------------------------
137 void Os2SalFrame::SetBackgroundBitmap( SalBitmap* )
140 diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=vcl.vpj vcl.clean/source/window/window.cxx vcl/source/window/window.cxx
141 --- vcl.clean/source/window/window.cxx 2008-01-29 11:18:41.000000000 -0500
142 +++ vcl/source/window/window.cxx 2008-02-28 14:00:43.000000000 -0500
143 @@ -4797,6 +4797,16 @@ void Window::doLazyDelete()
144 vcl::LazyDeletor<Window>::Delete( this );
147 +USHORT Window::GetIndicatorState() const
149 + return mpWindowImpl->mpFrame->GetIndicatorState().mnState;
152 +void Window::SimulateKeyPress( USHORT nKeyCode ) const
154 + mpWindowImpl->mpFrame->SimulateKeyPress(nKeyCode);
157 // -----------------------------------------------------------------------
159 void Window::MouseMove( const MouseEvent& rMEvt )
160 diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=vcl.vpj vcl.clean/unx/gtk/window/gtkframe.cxx vcl/unx/gtk/window/gtkframe.cxx
161 --- vcl.clean/unx/gtk/window/gtkframe.cxx 2008-01-29 11:21:11.000000000 -0500
162 +++ vcl/unx/gtk/window/gtkframe.cxx 2008-02-28 14:02:01.000000000 -0500
163 @@ -2068,6 +2068,18 @@ SalFrame::SalPointerState GtkSalFrame::G
164 return aState;
167 +SalFrame::SalIndicatorState GtkSalFrame::GetIndicatorState()
169 + SalIndicatorState aState;
170 + aState.mnState = GetX11SalData()->GetDisplay()->GetIndicatorState();
171 + return aState;
174 +void GtkSalFrame::SimulateKeyPress( USHORT nKeyCode )
176 + GetX11SalData()->GetDisplay()->SimulateKeyPress(nKeyCode);
179 void GtkSalFrame::SetInputContext( SalInputContext* pContext )
181 if( ! pContext )
182 diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=vcl.vpj vcl.clean/unx/headless/svpframe.cxx vcl/unx/headless/svpframe.cxx
183 --- vcl.clean/unx/headless/svpframe.cxx 2007-08-03 10:09:51.000000000 -0400
184 +++ vcl/unx/headless/svpframe.cxx 2008-02-28 11:27:06.000000000 -0500
185 @@ -396,6 +396,17 @@ SalFrame::SalPointerState SvpSalFrame::G
186 return aState;
189 +SalFrame::SalIndicatorState SvpSalFrame::GetIndicatorState()
191 + SalIndicatorState aState;
192 + aState.mnState = 0;
193 + return aState;
196 +void SvpSalFrame::SimulateKeyPress( USHORT /*nKeyCode*/ )
200 void SvpSalFrame::SetParent( SalFrame* pNewParent )
202 if( m_pParent )
203 diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=vcl.vpj vcl.clean/unx/headless/svpframe.hxx vcl/unx/headless/svpframe.hxx
204 --- vcl.clean/unx/headless/svpframe.hxx 2007-07-24 06:27:17.000000000 -0400
205 +++ vcl/unx/headless/svpframe.hxx 2008-02-28 11:26:40.000000000 -0500
206 @@ -119,6 +119,8 @@ public:
207 virtual void Beep( SoundType eSoundType );
208 virtual const SystemEnvData* GetSystemData() const;
209 virtual SalPointerState GetPointerState();
210 + virtual SalIndicatorState GetIndicatorState();
211 + virtual void SimulateKeyPress( USHORT nKeyCode );
212 virtual void SetParent( SalFrame* pNewParent );
213 virtual bool SetPluginParent( SystemParentData* pNewParent );
214 virtual void SetBackgroundBitmap( SalBitmap* pBitmap );
215 diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=vcl.vpj vcl.clean/unx/inc/plugins/gtk/gtkframe.hxx vcl/unx/inc/plugins/gtk/gtkframe.hxx
216 --- vcl.clean/unx/inc/plugins/gtk/gtkframe.hxx 2008-01-29 11:21:43.000000000 -0500
217 +++ vcl/unx/inc/plugins/gtk/gtkframe.hxx 2008-02-28 11:22:22.000000000 -0500
218 @@ -364,6 +364,10 @@ public:
219 // get current modifier and button mask
220 virtual SalPointerState GetPointerState();
222 + virtual SalIndicatorState GetIndicatorState();
224 + virtual void SimulateKeyPress( USHORT nKeyCode );
226 // set new parent window
227 virtual void SetParent( SalFrame* pNewParent );
228 // reparent window to act as a plugin; implementation
229 --- tools/inc/tools/prex.h
230 +++ tools/inc/tools/prex.h
231 @@ -64,6 +64,12 @@ extern "C" {
232 #define __XKeyboardExtension__ 0
233 #endif
235 +#if defined(LINUX) || defined(SOLARIS) || defined(FREEBSD)
236 +#define __XTestExtension__ 1
237 +#else
238 +#define __XTestExtension__ 0
239 +#endif
241 #include <X11/X.h>
242 #include <X11/Xlib.h>
243 #include <X11/Xutil.h>
244 diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=vcl.vpj vcl.clean/unx/inc/saldisp.hxx vcl/unx/inc/saldisp.hxx
245 --- vcl.clean/unx/inc/saldisp.hxx 2008-01-29 11:21:27.000000000 -0500
246 +++ vcl/unx/inc/saldisp.hxx 2008-02-28 10:16:38.000000000 -0500
247 @@ -457,6 +457,8 @@ public:
248 void Beep() const;
250 void ModifierMapping();
251 + void SimulateKeyPress( USHORT nKeyCode );
252 + USHORT GetIndicatorState() const;
253 String GetKeyNameFromKeySym( KeySym keysym ) const;
254 XubString GetKeyName( USHORT nKeyCode ) const;
255 USHORT GetKeyCode( KeySym keysym, char*pcPrintable ) const;
256 diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=vcl.vpj vcl.clean/unx/inc/salframe.h vcl/unx/inc/salframe.h
257 --- vcl.clean/unx/inc/salframe.h 2007-08-30 09:56:30.000000000 -0400
258 +++ vcl/unx/inc/salframe.h 2008-02-28 11:25:36.000000000 -0500
259 @@ -272,6 +272,8 @@ public:
260 virtual void Beep( SoundType eSoundType );
261 virtual const SystemEnvData* GetSystemData() const;
262 virtual SalPointerState GetPointerState();
263 + virtual SalIndicatorState GetIndicatorState();
264 + virtual void SimulateKeyPress( USHORT nKeyCode );
265 virtual void SetParent( SalFrame* pNewParent );
266 virtual bool SetPluginParent( SystemParentData* pNewParent );
267 virtual void SetBackgroundBitmap( SalBitmap* pBitmap );
268 --- vcl/unx/source/app/saldisp.cxx
269 +++ vcl/unx/source/app/saldisp.cxx
270 @@ -86,6 +86,12 @@ Status XineramaGetInfo(Display*, int, XR
271 #endif
272 #endif
274 +#if __XTestExtension__
275 +#include <X11/extensions/XTest.h>
276 +#include <X11/extensions/XKB.h>
277 +#include <X11/XKBlib.h>
278 +#endif
280 #include <tools/postx.h>
282 #include <salunx.h>
283 @@ -1074,6 +1078,35 @@ void SalDisplay::Beep() const
285 // Keyboard
286 // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
288 +void SalDisplay::SimulateKeyPress( USHORT nKeyCode )
290 +#if __XTestExtension__
291 + if (nKeyCode == KEY_CAPSLOCK)
293 + XLIB_KeyCode keyCaps = XKeysymToKeycode(GetDisplay(), XK_Caps_Lock);
294 + if (XTestFakeKeyEvent(GetDisplay(), keyCaps, true, CurrentTime))
295 + XTestFakeKeyEvent(GetDisplay(), keyCaps, false, CurrentTime);
297 +#endif
300 +USHORT SalDisplay::GetIndicatorState() const
302 + unsigned int _state = 0;
303 + USHORT nState = 0;
304 + XkbGetIndicatorState(pDisp_, XkbUseCoreKbd, &_state);
306 + if ((_state & 0x00000001))
307 + nState |= INDICATOR_CAPSLOCK;
308 + if ((_state & 0x00000002))
309 + nState |= INDICATOR_NUMLOCK;
310 + if ((_state & 0x00000004))
311 + nState |= INDICATOR_SCROLLLOCK;
313 + return nState;
316 String SalDisplay::GetKeyNameFromKeySym( KeySym nKeySym ) const
318 String aRet;
319 diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=vcl.vpj vcl.clean/unx/source/window/salframe.cxx vcl/unx/source/window/salframe.cxx
320 --- vcl.clean/unx/source/window/salframe.cxx 2008-01-30 04:12:30.000000000 -0500
321 +++ vcl/unx/source/window/salframe.cxx 2008-02-28 11:26:21.000000000 -0500
322 @@ -2757,6 +2757,18 @@ SalFrame::SalPointerState X11SalFrame::G
323 return aState;
326 +SalFrame::SalIndicatorState X11SalFrame::GetIndicatorState()
328 + SalIndicatorState aState;
329 + aState.mnState = GetX11SalData()->GetDisplay()->GetIndicatorState();
330 + return aState;
333 +void X11SalFrame::SimulateKeyPress( USHORT nKeyCode )
335 + GetX11SalData()->GetDisplay()->SimulateKeyPress(nKeyCode);
338 long X11SalFrame::HandleMouseEvent( XEvent *pEvent )
340 SalMouseEvent aMouseEvt;
341 diff -urp --exclude=CVS --exclude=unxlngi6.pro --exclude=vcl.vpj vcl.clean/win/inc/salframe.h vcl/win/inc/salframe.h
342 --- vcl.clean/win/inc/salframe.h 2007-07-24 06:33:22.000000000 -0400
343 +++ vcl/win/inc/salframe.h 2008-02-28 12:58:19.000000000 -0500
344 @@ -149,6 +149,8 @@ public:
345 virtual void Beep( SoundType eSoundType );
346 virtual const SystemEnvData* GetSystemData() const;
347 virtual SalPointerState GetPointerState();
348 + virtual SalIndicatorState GetIndicatorState();
349 + virtual void SimulateKeyPress( USHORT nKeyCode );
350 virtual void SetParent( SalFrame* pNewParent );
351 virtual bool SetPluginParent( SystemParentData* pNewParent );
352 virtual void SetBackgroundBitmap( SalBitmap* );
353 --- vcl.clean/win/source/window/salframe.cxx 2008-01-15 08:25:15.000000000 -0500
354 +++ vcl/win/source/window/salframe.cxx 2008-03-01 21:12:23.000000000 -0500
355 @@ -3177,6 +3177,41 @@ SalFrame::SalPointerState WinSalFrame::G
357 // -----------------------------------------------------------------------
359 +SalFrame::SalIndicatorState WinSalFrame::GetIndicatorState()
361 + SalIndicatorState aState;
362 + aState.mnState = 0;
363 + if (::GetKeyState(VK_CAPITAL))
364 + aState.mnState |= INDICATOR_CAPSLOCK;
366 + if (::GetKeyState(VK_NUMLOCK))
367 + aState.mnState |= INDICATOR_NUMLOCK;
369 + if (::GetKeyState(VK_SCROLL))
370 + aState.mnState |= INDICATOR_SCROLLLOCK;
372 + return aState;
375 +void WinSalFrame::SimulateKeyPress( USHORT nKeyCode )
377 + BYTE nVKey = 0;
378 + switch (nKeyCode)
380 + case KEY_CAPSLOCK:
381 + nVKey = VK_CAPITAL;
382 + break;
385 + if (nVKey > 0 && nVKey < 255)
387 + ::keybd_event(nVKey, 0x45, KEYEVENTF_EXTENDEDKEY, 0);
388 + ::keybd_event(nVKey, 0x45, KEYEVENTF_EXTENDEDKEY|KEYEVENTF_KEYUP, 0);
392 +// -----------------------------------------------------------------------
394 void WinSalFrame::SetBackgroundBitmap( SalBitmap* )
397 --- vcl/util/makefile.mk
398 +++ vcl/util/makefile.mk
399 @@ -323,7 +323,7 @@
401 .IF "$(GUIBASE)"=="unx"
403 -SHL2STDLIBS += -lXext -lSM -lICE -lX11
404 +SHL2STDLIBS += -lXext -lXtst -lSM -lICE -lX11
405 .IF "$(OS)"!="MACOSX" && "$(OS)"!="FREEBSD" && "$(OS)"!="NETBSD"
406 # needed by salprnpsp.cxx
407 SHL2STDLIBS+= -ldl