parent
e5178630aa
commit
37d05d248e
@ -0,0 +1,100 @@
|
||||
From 27e0fee7da99f3df722668d132bc034bef421514 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
|
||||
Date: Fri, 27 Mar 2015 15:28:28 +0000
|
||||
Subject: [PATCH] gnome#745909 grab/ungrab keyboard for menus
|
||||
|
||||
Change-Id: Id0593e1c9af79084ae798f26a0be37c57d254227
|
||||
---
|
||||
vcl/inc/unx/gtk/gtkframe.hxx | 3 ++-
|
||||
vcl/unx/gtk/window/gtksalframe.cxx | 39 ++++++++++++++++++++++++++++++++++++--
|
||||
2 files changed, 39 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
|
||||
index d514411..2eb0634 100644
|
||||
--- a/vcl/inc/unx/gtk/gtkframe.hxx
|
||||
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
|
||||
@@ -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();
|
||||
diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx
|
||||
index aa94c26..1b8bdc5 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 );
|
||||
--
|
||||
1.9.3
|
||||
|
Loading…
Reference in new issue