diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-03-27 15:28:28 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-03-27 15:30:58 +0000 |
commit | 27e0fee7da99f3df722668d132bc034bef421514 (patch) | |
tree | 0ef87ee51f706101396ebefd1ed23ebc7e09056d /vcl/unx | |
parent | 8c3cf9dd48e40604867d3a28bddaccd65142df17 (diff) |
gnome#745909 grab/ungrab keyboard for menus
Change-Id: Id0593e1c9af79084ae798f26a0be37c57d254227
Diffstat (limited to 'vcl/unx')
-rw-r--r-- | vcl/unx/gtk/window/gtksalframe.cxx | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx index aa94c26e924c..1b8bdc52da46 100644 --- a/vcl/unx/gtk/window/gtksalframe.cxx +++ b/vcl/unx/gtk/window/gtksalframe.cxx @@ -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 ); |