gnome#745909 grab/ungrab keyboard for menus

Change-Id: Id0593e1c9af79084ae798f26a0be37c57d254227
This commit is contained in:
Caolán McNamara
2015-03-27 15:28:28 +00:00
parent 8c3cf9dd48
commit 27e0fee7da
2 changed files with 39 additions and 3 deletions

View File

@@ -328,7 +328,8 @@ public:
// and false else; if true was returned the event should
// be swallowed
bool Dispatch( const XEvent* pEvent );
void grabPointer( bool bGrab, bool bOwnerEvents = false );
void grabPointer(bool bGrab, bool bOwnerEvents = false);
void grabKeyboard(bool bGrab);
GtkSalDisplay* getDisplay();
GdkDisplay* getGdkDisplay();

View File

@@ -1864,7 +1864,13 @@ void GtkSalFrame::Show( bool bVisible, bool bNoActivate )
{
m_nFloats++;
if( ! getDisplay()->GetCaptureFrame() && m_nFloats == 1 )
grabPointer( true, true );
{
grabPointer(true, true);
GtkSalFrame *pKeyboardFrame = this;
while (pKeyboardFrame->m_pParent)
pKeyboardFrame = pKeyboardFrame->m_pParent;
pKeyboardFrame->grabKeyboard(true);
}
// #i44068# reset parent's IM context
if( m_pParent )
m_pParent->EndExtTextInput(0);
@@ -1878,7 +1884,13 @@ void GtkSalFrame::Show( bool bVisible, bool bNoActivate )
{
m_nFloats--;
if( ! getDisplay()->GetCaptureFrame() && m_nFloats == 0)
grabPointer( false );
{
GtkSalFrame *pKeyboardFrame = this;
while (pKeyboardFrame->m_pParent)
pKeyboardFrame = pKeyboardFrame->m_pParent;
pKeyboardFrame->grabKeyboard(false);
grabPointer(false);
}
}
gtk_widget_hide( m_pWindow );
if( m_pIMHandler )
@@ -2762,7 +2774,9 @@ void GtkSalFrame::grabPointer( bool bGrab, bool bOwnerEvents )
{
// Two GdkDisplays may be open
if( !pEnv || !*pEnv )
{
gdk_display_pointer_ungrab( getGdkDisplay(), GDK_CURRENT_TIME);
}
}
}
#else
@@ -2771,6 +2785,27 @@ void GtkSalFrame::grabPointer( bool bGrab, bool bOwnerEvents )
#endif
}
void GtkSalFrame::grabKeyboard( bool bGrab )
{
#if !GTK_CHECK_VERSION(3,0,0)
if( m_pWindow )
{
if( bGrab )
{
gdk_keyboard_grab(widget_get_window(m_pWindow), true,
GDK_CURRENT_TIME);
}
else
{
gdk_keyboard_ungrab(GDK_CURRENT_TIME);
}
}
#else
(void)bGrab;
//FIXME: No GrabKeyboard implementation for gtk3 ...
#endif
}
void GtkSalFrame::CaptureMouse( bool bCapture )
{
getDisplay()->CaptureMouse( bCapture ? this : NULL );