[Libreoffice-commits] core.git: vcl/inc vcl/unx
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jan 9 09:17:49 UTC 2020
vcl/inc/unx/gtk/gtkframe.hxx | 2 +-
vcl/unx/gtk3/gtk3gtkdata.cxx | 8 ++++----
vcl/unx/gtk3/gtk3gtkframe.cxx | 32 +++++++++++++++++++-------------
3 files changed, 24 insertions(+), 18 deletions(-)
New commits:
commit ace72553247e2862e2f2d9815334fc2db91a79e5
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Jan 8 20:21:05 2020 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Jan 9 10:17:15 2020 +0100
also grab the keyboard under gtk when showing a temp floating window
so keyboard focus in inside native gtk popovers for nonnative toolbar
items
Change-Id: I82073b3912698c32022eb4619c31d1b2f9d8a801
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86456
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index 033ee93efe42..3259991329c0 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -334,7 +334,7 @@ public:
guint m_nHudAwarenessId;
std::vector<gulong> m_aMouseSignalIds;
- void grabPointer(bool bGrab, bool bOwnerEvents = false);
+ void grabPointer(bool bGrab, bool bKeyboardAlso, bool bOwnerEvents);
static GtkSalDisplay* getDisplay();
static GdkDisplay* getGdkDisplay();
diff --git a/vcl/unx/gtk3/gtk3gtkdata.cxx b/vcl/unx/gtk3/gtk3gtkdata.cxx
index 29d038141d50..36d4e6d76fa1 100644
--- a/vcl/unx/gtk3/gtk3gtkdata.cxx
+++ b/vcl/unx/gtk3/gtk3gtkdata.cxx
@@ -279,7 +279,7 @@ int GtkSalDisplay::CaptureMouse( SalFrame* pSFrame )
if( !pFrame )
{
if( m_pCapture )
- static_cast<GtkSalFrame*>(m_pCapture)->grabPointer( false );
+ static_cast<GtkSalFrame*>(m_pCapture)->grabPointer( false, false, false );
m_pCapture = nullptr;
return 0;
}
@@ -288,11 +288,11 @@ int GtkSalDisplay::CaptureMouse( SalFrame* pSFrame )
{
if( pFrame == m_pCapture )
return 1;
- static_cast<GtkSalFrame*>(m_pCapture)->grabPointer( false );
+ static_cast<GtkSalFrame*>(m_pCapture)->grabPointer( false, false, false );
}
m_pCapture = pFrame;
- pFrame->grabPointer( true );
+ pFrame->grabPointer( true, false, false );
return 1;
}
@@ -760,7 +760,7 @@ void GtkSalDisplay::deregisterFrame( SalFrame* pFrame )
{
if( m_pCapture == pFrame )
{
- static_cast<GtkSalFrame*>(m_pCapture)->grabPointer( false );
+ static_cast<GtkSalFrame*>(m_pCapture)->grabPointer( false, false, false );
m_pCapture = nullptr;
}
SalGenericDisplay::deregisterFrame( pFrame );
diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx
index 8dddd5fb2b9e..8b1d165520dc 100644
--- a/vcl/unx/gtk3/gtk3gtkframe.cxx
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
@@ -1302,7 +1302,7 @@ void GtkSalFrame::Show( bool bVisible, bool /*bNoActivate*/ )
if (isFloatGrabWindow() && !getDisplay()->GetCaptureFrame())
{
- m_pParent->grabPointer(true, true);
+ m_pParent->grabPointer(true, true, true);
m_pParent->addGrabLevel();
}
@@ -1333,7 +1333,7 @@ void GtkSalFrame::Show( bool bVisible, bool /*bNoActivate*/ )
m_nFloats++;
if (!getDisplay()->GetCaptureFrame())
{
- grabPointer(true, true);
+ grabPointer(true, true, true);
addGrabLevel();
}
// #i44068# reset parent's IM context
@@ -1349,9 +1349,9 @@ void GtkSalFrame::Show( bool bVisible, bool /*bNoActivate*/ )
if (!getDisplay()->GetCaptureFrame())
{
removeGrabLevel();
- grabPointer(false);
+ grabPointer(false, true, false);
m_pParent->removeGrabLevel();
- m_pParent->grabPointer(false);
+ m_pParent->grabPointer(false, true, false);
}
}
gtk_widget_hide( m_pWindow );
@@ -1955,13 +1955,13 @@ void GtkSalFrame::SetPointer( PointerStyle ePointerStyle )
// #i80791# use grabPointer the same way as CaptureMouse, respective float grab
if( getDisplay()->MouseCaptured( this ) )
- grabPointer( true );
+ grabPointer( true, false, false );
else if( m_nFloats > 0 )
- grabPointer( true, true );
+ grabPointer( true, false, true );
}
}
-void GtkSalFrame::grabPointer( bool bGrab, bool bOwnerEvents )
+void GtkSalFrame::grabPointer( bool bGrab, bool bKeyboardAlso, bool bOwnerEvents )
{
static const char* pEnv = getenv( "SAL_NO_MOUSEGRABS" );
if (pEnv && *pEnv)
@@ -1976,7 +1976,8 @@ void GtkSalFrame::grabPointer( bool bGrab, bool bOwnerEvents )
GdkSeat* pSeat = gdk_display_get_default_seat(getGdkDisplay());
if (bGrab)
{
- gdk_seat_grab(pSeat, gtk_widget_get_window(getMouseEventWidget()), GDK_SEAT_CAPABILITY_ALL_POINTING,
+ GdkSeatCapabilities eCapability = bKeyboardAlso ? GDK_SEAT_CAPABILITY_ALL : GDK_SEAT_CAPABILITY_ALL_POINTING;
+ gdk_seat_grab(pSeat, gtk_widget_get_window(getMouseEventWidget()), eCapability,
bOwnerEvents, nullptr, nullptr, nullptr, nullptr);
}
else
@@ -1988,18 +1989,23 @@ void GtkSalFrame::grabPointer( bool bGrab, bool bOwnerEvents )
#endif
//else older gtk3
- const int nMask = (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK);
-
GdkDeviceManager* pDeviceManager = gdk_display_get_device_manager(getGdkDisplay());
GdkDevice* pPointer = gdk_device_manager_get_client_pointer(pDeviceManager);
+ GdkDevice* pKeyboard = bKeyboardAlso ? gdk_device_get_associated_device(pPointer) : nullptr;
+ GdkWindow* pWindow = gtk_widget_get_window(getMouseEventWidget());
+ guint32 nCurrentTime = gtk_get_current_event_time();
if (bGrab)
{
- gdk_device_grab(pPointer, gtk_widget_get_window(getMouseEventWidget()), GDK_OWNERSHIP_NONE,
- bOwnerEvents, GdkEventMask(nMask), m_pCurrentCursor, gtk_get_current_event_time());
+ gdk_device_grab(pPointer, pWindow, GDK_OWNERSHIP_NONE,
+ bOwnerEvents, GDK_ALL_EVENTS_MASK, m_pCurrentCursor, nCurrentTime);
+ if (pKeyboard)
+ gdk_device_grab(pKeyboard, pWindow, GDK_OWNERSHIP_NONE, true, GDK_ALL_EVENTS_MASK, nullptr, nCurrentTime);
}
else
{
- gdk_device_ungrab(pPointer, gtk_get_current_event_time());
+ gdk_device_ungrab(pPointer, nCurrentTime);
+ if (pKeyboard)
+ gdk_device_ungrab(pKeyboard, nCurrentTime);
}
}
More information about the Libreoffice-commits
mailing list