[ooo-build-commit] .: vcl/aqua vcl/inc vcl/os2 vcl/source vcl/unx vcl/win
Kohei Yoshida
kohei at kemper.freedesktop.org
Wed Sep 29 13:22:47 PDT 2010
vcl/aqua/inc/salframe.h | 2
vcl/aqua/source/window/salframe.cxx | 11 +++++
vcl/inc/vcl/keycodes.hxx | 12 +++++
vcl/inc/vcl/salframe.hxx | 9 ++++
vcl/inc/vcl/window.hxx | 16 +++++++
vcl/os2/inc/salframe.h | 2
vcl/os2/source/window/salframe.cxx | 13 ++++++
vcl/source/window/window.cxx | 10 ++++
vcl/unx/gtk/window/gtkframe.cxx | 12 +++++
vcl/unx/headless/svpframe.cxx | 11 +++++
vcl/unx/headless/svpframe.hxx | 2
vcl/unx/inc/plugins/gtk/gtkframe.hxx | 4 +
vcl/unx/inc/saldisp.hxx | 2
vcl/unx/inc/salframe.h | 2
vcl/unx/source/app/saldisp.cxx | 73 ++++++++++++++++++++++++++++++++++-
vcl/unx/source/window/salframe.cxx | 12 +++++
vcl/win/inc/salframe.h | 2
vcl/win/source/window/salframe.cxx | 35 ++++++++++++++++
18 files changed, 229 insertions(+), 1 deletion(-)
New commits:
commit 0adac7d98c6e3d1b01bc943f0d99d7f4141fe59f
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Wed Sep 29 16:21:04 2010 -0400
Ported autocorrect-accidental-caps-lock-vcl.diff from ooo-build.
diff --git a/vcl/aqua/inc/salframe.h b/vcl/aqua/inc/salframe.h
index af8811a..731b04e 100644
--- a/vcl/aqua/inc/salframe.h
+++ b/vcl/aqua/inc/salframe.h
@@ -152,6 +152,8 @@ public:
virtual void Beep( SoundType eSoundType );
virtual const SystemEnvData* GetSystemData() const;
virtual SalPointerState GetPointerState();
+ virtual SalIndicatorState GetIndicatorState();
+ virtual void SimulateKeyPress( USHORT nKeyCode );
virtual void SetParent( SalFrame* pNewParent );
virtual bool SetPluginParent( SystemParentData* pNewParent );
virtual void SetExtendedFrameStyle( SalExtStyle );
diff --git a/vcl/aqua/source/window/salframe.cxx b/vcl/aqua/source/window/salframe.cxx
index 9406e78..6fb4d2e 100644
--- a/vcl/aqua/source/window/salframe.cxx
+++ b/vcl/aqua/source/window/salframe.cxx
@@ -1436,6 +1436,17 @@ SalPointerState AquaSalFrame::GetPointerState()
return state;
}
+SalFrame::SalIndicatorState AquaSalFrame::GetIndicatorState()
+{
+ SalIndicatorState aState;
+ aState.mnState = 0;
+ return aState;
+}
+
+void AquaSalFrame::SimulateKeyPress( USHORT /*nKeyCode*/ )
+{
+}
+
bool AquaSalFrame::SetPluginParent( SystemParentData* pNewParent )
{
// plugin parent may be killed unexpectedly by
diff --git a/vcl/inc/vcl/keycodes.hxx b/vcl/inc/vcl/keycodes.hxx
index 8316ec7..7275947 100644
--- a/vcl/inc/vcl/keycodes.hxx
+++ b/vcl/inc/vcl/keycodes.hxx
@@ -158,6 +158,10 @@
#define KEY_BRACKETLEFT ((USHORT)::com::sun::star::awt::Key::BRACKETLEFT)
#define KEY_BRACKETRIGHT ((USHORT)::com::sun::star::awt::Key::BRACKETRIGHT)
+#define KEY_CAPSLOCK ((USHORT)::com::sun::star::awt::Key::CAPSLOCK)
+#define KEY_NUMLOCK ((USHORT)::com::sun::star::awt::Key::NUMLOCK)
+#define KEY_SCROLLLOCK ((USHORT)::com::sun::star::awt::Key::SCROLLLOCK)
+
#define KEY_CODE ((USHORT)0x0FFF)
// Modifier-Tasten
@@ -190,4 +194,12 @@
#define MOUSE_MIDDLE ((USHORT)0x0002)
#define MOUSE_RIGHT ((USHORT)0x0004)
+// -------------------
+// - Indicator-Types -
+// -------------------
+
+#define INDICATOR_CAPSLOCK 0x0001
+#define INDICATOR_NUMLOCK 0x0002
+#define INDICATOR_SCROLLLOCK 0x0004
+
#endif // _SV_KEYCODES_HXX
diff --git a/vcl/inc/vcl/salframe.hxx b/vcl/inc/vcl/salframe.hxx
index 37b0f5f..4e40b3e 100644
--- a/vcl/inc/vcl/salframe.hxx
+++ b/vcl/inc/vcl/salframe.hxx
@@ -250,6 +250,15 @@ public:
virtual SalPointerState GetPointerState() = 0;
+ struct SalIndicatorState
+ {
+ USHORT mnState;
+ };
+
+ virtual SalIndicatorState GetIndicatorState() = 0;
+
+ virtual void SimulateKeyPress( USHORT nKeyCode ) = 0;
+
// set new parent window
virtual void SetParent( SalFrame* pNewParent ) = 0;
// reparent window to act as a plugin; implementation
diff --git a/vcl/inc/vcl/window.hxx b/vcl/inc/vcl/window.hxx
index 96588a8..b7b5ad4 100644
--- a/vcl/inc/vcl/window.hxx
+++ b/vcl/inc/vcl/window.hxx
@@ -1101,6 +1101,22 @@ public:
*/
void doLazyDelete();
+ //-------------------------------------
+ // Keyboard access functions
+ //-------------------------------------
+
+ /** Query the states of keyboard indicators - Caps Lock, Num Lock and
+ Scroll Lock. Use the following mask to retrieve the state of each
+ indicator:
+
+ INDICATOR_CAPS_LOCK
+ INDICATOR_NUM_LOCK
+ INDICATOR_SCROLL_LOCK
+ */
+ USHORT GetIndicatorState() const;
+
+ void SimulateKeyPress( USHORT nKeyCode ) const;
+
virtual XubString GetSurroundingText() const;
virtual Selection GetSurroundingTextSelection() const;
};
diff --git a/vcl/os2/inc/salframe.h b/vcl/os2/inc/salframe.h
index 9c51ae4..5461c3c 100644
--- a/vcl/os2/inc/salframe.h
+++ b/vcl/os2/inc/salframe.h
@@ -152,6 +152,8 @@ public:
virtual void Beep( SoundType eSoundType );
virtual const SystemEnvData* GetSystemData() const;
virtual SalPointerState GetPointerState();
+ virtual SalIndicatorState GetIndicatorState();
+ virtual void SimulateKeyPress( USHORT nKeyCode );
virtual void SetParent( SalFrame* pNewParent );
virtual bool SetPluginParent( SystemParentData* pNewParent );
virtual void SetBackgroundBitmap( SalBitmap* );
diff --git a/vcl/os2/source/window/salframe.cxx b/vcl/os2/source/window/salframe.cxx
index 6217043..9cee199 100644
--- a/vcl/os2/source/window/salframe.cxx
+++ b/vcl/os2/source/window/salframe.cxx
@@ -2354,6 +2354,19 @@ SalFrame::SalPointerState Os2SalFrame::GetPointerState()
// -----------------------------------------------------------------------
+SalFrame::SalIndicatorState Os2SalFrame::GetIndicatorState()
+{
+ SalIndicatorState aState;
+ aState.mnState = 0;
+ return aState;
+}
+
+void Os2SalFrame::SimulateKeyPress( USHORT /*nKeyCode*/ )
+{
+}
+
+// -----------------------------------------------------------------------
+
void Os2SalFrame::SetBackgroundBitmap( SalBitmap* )
{
}
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 72e0e20..b1049d3 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -4791,6 +4791,16 @@ void Window::doLazyDelete()
vcl::LazyDeletor<Window>::Delete( this );
}
+USHORT Window::GetIndicatorState() const
+{
+ return mpWindowImpl->mpFrame->GetIndicatorState().mnState;
+}
+
+void Window::SimulateKeyPress( USHORT nKeyCode ) const
+{
+ mpWindowImpl->mpFrame->SimulateKeyPress(nKeyCode);
+}
+
// -----------------------------------------------------------------------
void Window::MouseMove( const MouseEvent& rMEvt )
diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx
index e3d6b6e..f45b5ef 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -2257,6 +2257,18 @@ SalFrame::SalPointerState GtkSalFrame::GetPointerState()
return aState;
}
+SalFrame::SalIndicatorState GtkSalFrame::GetIndicatorState()
+{
+ SalIndicatorState aState;
+ aState.mnState = GetX11SalData()->GetDisplay()->GetIndicatorState();
+ return aState;
+}
+
+void GtkSalFrame::SimulateKeyPress( USHORT nKeyCode )
+{
+ GetX11SalData()->GetDisplay()->SimulateKeyPress(nKeyCode);
+}
+
void GtkSalFrame::SetInputContext( SalInputContext* pContext )
{
if( ! pContext )
diff --git a/vcl/unx/headless/svpframe.cxx b/vcl/unx/headless/svpframe.cxx
index 7f30417..8e95917 100644
--- a/vcl/unx/headless/svpframe.cxx
+++ b/vcl/unx/headless/svpframe.cxx
@@ -415,6 +415,17 @@ SalFrame::SalPointerState SvpSalFrame::GetPointerState()
return aState;
}
+SalFrame::SalIndicatorState SvpSalFrame::GetIndicatorState()
+{
+ SalIndicatorState aState;
+ aState.mnState = 0;
+ return aState;
+}
+
+void SvpSalFrame::SimulateKeyPress( USHORT /*nKeyCode*/ )
+{
+}
+
void SvpSalFrame::SetParent( SalFrame* pNewParent )
{
if( m_pParent )
diff --git a/vcl/unx/headless/svpframe.hxx b/vcl/unx/headless/svpframe.hxx
index 9e5fb60..957224d 100644
--- a/vcl/unx/headless/svpframe.hxx
+++ b/vcl/unx/headless/svpframe.hxx
@@ -112,6 +112,8 @@ public:
virtual void Beep( SoundType eSoundType );
virtual const SystemEnvData* GetSystemData() const;
virtual SalPointerState GetPointerState();
+ virtual SalIndicatorState GetIndicatorState();
+ virtual void SimulateKeyPress( USHORT nKeyCode );
virtual void SetParent( SalFrame* pNewParent );
virtual bool SetPluginParent( SystemParentData* pNewParent );
virtual void SetBackgroundBitmap( SalBitmap* pBitmap );
diff --git a/vcl/unx/inc/plugins/gtk/gtkframe.hxx b/vcl/unx/inc/plugins/gtk/gtkframe.hxx
index 508eb86..1ee03c9 100644
--- a/vcl/unx/inc/plugins/gtk/gtkframe.hxx
+++ b/vcl/unx/inc/plugins/gtk/gtkframe.hxx
@@ -371,6 +371,10 @@ public:
// get current modifier and button mask
virtual SalPointerState GetPointerState();
+ virtual SalIndicatorState GetIndicatorState();
+
+ virtual void SimulateKeyPress( USHORT nKeyCode );
+
// set new parent window
virtual void SetParent( SalFrame* pNewParent );
// reparent window to act as a plugin; implementation
diff --git a/vcl/unx/inc/saldisp.hxx b/vcl/unx/inc/saldisp.hxx
index 58f3302..4f4185a 100644
--- a/vcl/unx/inc/saldisp.hxx
+++ b/vcl/unx/inc/saldisp.hxx
@@ -445,6 +445,8 @@ public:
void Beep() const;
void ModifierMapping();
+ void SimulateKeyPress( USHORT nKeyCode );
+ USHORT GetIndicatorState() const;
String GetKeyNameFromKeySym( KeySym keysym ) const;
XubString GetKeyName( USHORT nKeyCode ) const;
USHORT GetKeyCode( KeySym keysym, char*pcPrintable ) const;
diff --git a/vcl/unx/inc/salframe.h b/vcl/unx/inc/salframe.h
index 5902dea..7888d0b 100644
--- a/vcl/unx/inc/salframe.h
+++ b/vcl/unx/inc/salframe.h
@@ -254,6 +254,8 @@ public:
virtual void Beep( SoundType eSoundType );
virtual const SystemEnvData* GetSystemData() const;
virtual SalPointerState GetPointerState();
+ virtual SalIndicatorState GetIndicatorState();
+ virtual void SimulateKeyPress( USHORT nKeyCode );
virtual void SetParent( SalFrame* pNewParent );
virtual bool SetPluginParent( SystemParentData* pNewParent );
virtual void SetBackgroundBitmap( SalBitmap* pBitmap );
diff --git a/vcl/unx/source/app/saldisp.cxx b/vcl/unx/source/app/saldisp.cxx
index 4cf8081..4d7fabb 100644
--- a/vcl/unx/source/app/saldisp.cxx
+++ b/vcl/unx/source/app/saldisp.cxx
@@ -54,7 +54,7 @@
#define XK_KOREAN
#endif
#include <X11/keysym.h>
-
+#include <X11/XKBlib.h>
#include <X11/Xatom.h>
#ifdef USE_XINERAMA
@@ -1037,6 +1037,77 @@ void SalDisplay::Beep() const
// Keyboard
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+namespace {
+
+bool InitXkb(Display* dpy)
+{
+ int nOpcode, nEvent, nError;
+ int nXkbMajor = XkbMajorVersion;
+ int nXkbMinor = XkbMinorVersion;
+
+ if (!XkbLibraryVersion(&nXkbMajor, &nXkbMinor))
+ return false;
+
+ return XkbQueryExtension(
+ dpy, &nOpcode, &nEvent, &nError, &nXkbMajor, &nXkbMinor);
+}
+
+unsigned int GetKeySymMask(Display* dpy, KeySym nKeySym)
+{
+ int nMask = 0;
+ XModifierKeymap* pXmkMap = XGetModifierMapping(dpy);
+ KeyCode nKeyCode = XKeysymToKeycode(dpy, nKeySym);
+ if (nKeyCode == NoSymbol)
+ return 0;
+
+ for (int i = 0; i < 8; ++i)
+ {
+ KeyCode nThisKeyCode = pXmkMap->modifiermap[pXmkMap->max_keypermod*i];
+ if (nThisKeyCode == nKeyCode)
+ nMask = 1 << i;
+ }
+ XFreeModifiermap(pXmkMap);
+ return nMask;
+}
+
+}
+
+void SalDisplay::SimulateKeyPress( USHORT nKeyCode )
+{
+ if (nKeyCode == KEY_CAPSLOCK)
+ {
+ Display* dpy = GetDisplay();
+ if (!InitXkb(dpy))
+ return;
+
+ unsigned int nMask = GetKeySymMask(dpy, XK_Caps_Lock);
+ XkbStateRec xkbState;
+ XkbGetState(dpy, XkbUseCoreKbd, &xkbState);
+ unsigned int nCapsLockState = xkbState.locked_mods & nMask;
+ if (nCapsLockState)
+ XkbLockModifiers (dpy, XkbUseCoreKbd, nMask, 0);
+ else
+ XkbLockModifiers (dpy, XkbUseCoreKbd, nMask, nMask);
+ }
+}
+
+USHORT SalDisplay::GetIndicatorState() const
+{
+ unsigned int _state = 0;
+ USHORT nState = 0;
+ XkbGetIndicatorState(pDisp_, XkbUseCoreKbd, &_state);
+
+ if ((_state & 0x00000001))
+ nState |= INDICATOR_CAPSLOCK;
+ if ((_state & 0x00000002))
+ nState |= INDICATOR_NUMLOCK;
+ if ((_state & 0x00000004))
+ nState |= INDICATOR_SCROLLLOCK;
+
+ return nState;
+}
+
String SalDisplay::GetKeyNameFromKeySym( KeySym nKeySym ) const
{
String aRet;
diff --git a/vcl/unx/source/window/salframe.cxx b/vcl/unx/source/window/salframe.cxx
index cbfb989..ddadc77 100644
--- a/vcl/unx/source/window/salframe.cxx
+++ b/vcl/unx/source/window/salframe.cxx
@@ -2849,6 +2849,18 @@ SalFrame::SalPointerState X11SalFrame::GetPointerState()
return aState;
}
+SalFrame::SalIndicatorState X11SalFrame::GetIndicatorState()
+{
+ SalIndicatorState aState;
+ aState.mnState = GetX11SalData()->GetDisplay()->GetIndicatorState();
+ return aState;
+}
+
+void X11SalFrame::SimulateKeyPress( USHORT nKeyCode )
+{
+ GetX11SalData()->GetDisplay()->SimulateKeyPress(nKeyCode);
+}
+
long X11SalFrame::HandleMouseEvent( XEvent *pEvent )
{
SalMouseEvent aMouseEvt;
diff --git a/vcl/win/inc/salframe.h b/vcl/win/inc/salframe.h
index e846238..676a054 100644
--- a/vcl/win/inc/salframe.h
+++ b/vcl/win/inc/salframe.h
@@ -135,6 +135,8 @@ public:
virtual void Beep( SoundType eSoundType );
virtual const SystemEnvData* GetSystemData() const;
virtual SalPointerState GetPointerState();
+ virtual SalIndicatorState GetIndicatorState();
+ virtual void SimulateKeyPress( USHORT nKeyCode );
virtual void SetParent( SalFrame* pNewParent );
virtual bool SetPluginParent( SystemParentData* pNewParent );
virtual void SetBackgroundBitmap( SalBitmap* );
diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx
index b73bf77..d6c906a 100644
--- a/vcl/win/source/window/salframe.cxx
+++ b/vcl/win/source/window/salframe.cxx
@@ -3227,6 +3227,41 @@ SalFrame::SalPointerState WinSalFrame::GetPointerState()
// -----------------------------------------------------------------------
+SalFrame::SalIndicatorState WinSalFrame::GetIndicatorState()
+{
+ SalIndicatorState aState;
+ aState.mnState = 0;
+ if (::GetKeyState(VK_CAPITAL))
+ aState.mnState |= INDICATOR_CAPSLOCK;
+
+ if (::GetKeyState(VK_NUMLOCK))
+ aState.mnState |= INDICATOR_NUMLOCK;
+
+ if (::GetKeyState(VK_SCROLL))
+ aState.mnState |= INDICATOR_SCROLLLOCK;
+
+ return aState;
+}
+
+void WinSalFrame::SimulateKeyPress( USHORT nKeyCode )
+{
+ BYTE nVKey = 0;
+ switch (nKeyCode)
+ {
+ case KEY_CAPSLOCK:
+ nVKey = VK_CAPITAL;
+ break;
+ }
+
+ if (nVKey > 0 && nVKey < 255)
+ {
+ ::keybd_event(nVKey, 0x45, KEYEVENTF_EXTENDEDKEY, 0);
+ ::keybd_event(nVKey, 0x45, KEYEVENTF_EXTENDEDKEY|KEYEVENTF_KEYUP, 0);
+ }
+}
+
+// -----------------------------------------------------------------------
+
void WinSalFrame::SetBackgroundBitmap( SalBitmap* )
{
}
More information about the ooo-build-commit
mailing list