summaryrefslogtreecommitdiff
path: root/vcl/unx/gtk
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2017-09-04 17:40:13 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2017-09-28 17:48:37 +0200
commite310c00709ed4fe0788aeff5142e3581d8b4d319 (patch)
treeb85827742e4a93a57150b5d8d254ea85a6265379 /vcl/unx/gtk
parentdea1b649765262b2e8beac88b0977d5dead98953 (diff)
Unify SalUserEvent handling
Merges the various SalUserEvent structs and their handling into a single class. This includes a common SalFrame* hash map, as all backends use such a map to verify alive SalFrames. It also reverts the "FIXME: lousy workaround" for i#90083, which was part of commit d6f7c94e5c27ba02ff5c3229760c9808cc9b5bea. At least on my current OSX box application based window switching "just works" "out of the box", even without the code. Change-Id: I188b567e44fd79c162b2d9cabbd771d1f66c7dc4 Reviewed-on: https://gerrit.libreoffice.org/42845 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/unx/gtk')
-rw-r--r--vcl/unx/gtk/gtkdata.cxx85
-rw-r--r--vcl/unx/gtk/gtksalframe.cxx5
2 files changed, 37 insertions, 53 deletions
diff --git a/vcl/unx/gtk/gtkdata.cxx b/vcl/unx/gtk/gtkdata.cxx
index eaa34d9461e5..da70c0fbd62c 100644
--- a/vcl/unx/gtk/gtkdata.cxx
+++ b/vcl/unx/gtk/gtkdata.cxx
@@ -133,19 +133,17 @@ GdkFilterReturn GtkSalDisplay::filterGdkEvent( GdkXEvent* sys_event )
// so we need to listen for corresponding property notifications here
// these should be rare enough so that we can assume that the settings
// actually change when a corresponding PropertyNotify occurs
- if( pEvent->type == PropertyNotify &&
- pEvent->xproperty.atom == getWMAdaptor()->getAtom( WMAdaptor::XSETTINGS ) &&
- ! m_aFrames.empty()
- )
+ SalFrame *pAnyFrame = anyFrame();
+ if( pAnyFrame && pEvent->type == PropertyNotify &&
+ pEvent->xproperty.atom == getWMAdaptor()->getAtom( WMAdaptor::XSETTINGS ) )
{
- SendInternalEvent( m_aFrames.front(), nullptr, SalEvent::SettingsChanged );
+ PostEvent( pAnyFrame, nullptr, SalEvent::SettingsChanged );
}
// let's see if one of our frames wants to swallow these events
// get the frame
- for( std::list< SalFrame* >::const_iterator it = m_aFrames.begin();
- it != m_aFrames.end(); ++it )
+ for (auto pSalFrame : m_aFrames )
{
- GtkSalFrame* pFrame = static_cast<GtkSalFrame*>(*it);
+ GtkSalFrame* pFrame = static_cast<GtkSalFrame*>( pSalFrame );
if( pFrame->GetSystemData()->aWindow == pEvent->xany.window ||
( pFrame->getForeignParent() && pFrame->getForeignParentWindow() == pEvent->xany.window ) ||
( pFrame->getForeignTopLevel() && pFrame->getForeignTopLevelWindow() == pEvent->xany.window )
@@ -213,11 +211,10 @@ bool GtkSalDisplay::Dispatch( XEvent* pEvent )
{
// let's see if one of our frames wants to swallow these events
// get the child frame
- for( std::list< SalFrame* >::const_iterator it = m_aFrames.begin();
- it != m_aFrames.end(); ++it )
+ for (auto pSalFrame : m_aFrames )
{
- if ((*it)->GetSystemData()->aWindow == pEvent->xany.window)
- return static_cast<GtkSalFrame*>(*it)->Dispatch( pEvent );
+ if (pSalFrame->GetSystemData()->aWindow == pEvent->xany.window)
+ return static_cast<GtkSalFrame*>( pSalFrame )->Dispatch( pEvent );
}
}
@@ -816,47 +813,23 @@ void GtkSalTimer::Stop()
}
}
-gboolean GtkSalData::userEventFn( gpointer data )
-{
- gboolean bContinue = FALSE;
- GtkSalData *pThis = static_cast<GtkSalData *>(data);
- GenericUnixSalData *pData = GetGenericUnixSalData();
- SolarMutexGuard aGuard;
- const SalGenericDisplay *pDisplay = pData->GetDisplay();
- if (pDisplay)
- {
- OSL_ASSERT(static_cast<const SalGenericDisplay *>(pThis->GetGtkDisplay()) == pDisplay);
- {
- osl::MutexGuard g (pThis->GetGtkDisplay()->getEventGuardMutex());
-
- if( !pThis->GetGtkDisplay()->HasUserEvents() )
- {
- if( pThis->m_pUserEvent )
- {
- g_source_unref (pThis->m_pUserEvent);
- pThis->m_pUserEvent = nullptr;
- }
- bContinue = FALSE;
- }
- else
- bContinue = TRUE;
- }
- pThis->GetGtkDisplay()->DispatchInternalEvent();
- }
-
- return bContinue;
-}
-
extern "C" {
static gboolean call_userEventFn( void *data )
{
+ GtkSalData *pThis = static_cast<GtkSalData *>(data);
SolarMutexGuard aGuard;
- return GtkSalData::userEventFn( data );
+ const SalGenericDisplay *pDisplay = GetGenericUnixSalData()->GetDisplay();
+ if ( pDisplay )
+ {
+ GtkSalDisplay *pThisDisplay = pThis->GetGtkDisplay();
+ assert(static_cast<const SalGenericDisplay *>(pThisDisplay) == pDisplay);
+ pThisDisplay->DispatchInternalEvent();
+ }
+ return TRUE;
}
}
-// hEventGuard_ held during this invocation
-void GtkSalData::PostUserEvent()
+void GtkSalData::TriggerUserEventProcessing()
{
if (m_pUserEvent)
g_main_context_wakeup (nullptr); // really needed ?
@@ -871,16 +844,28 @@ void GtkSalData::PostUserEvent()
}
}
-void GtkSalDisplay::PostUserEvent()
+void GtkSalData::TriggerAllUserEventsProcessed()
+{
+ assert( m_pUserEvent );
+ g_source_destroy( m_pUserEvent );
+ g_source_unref( m_pUserEvent );
+ m_pUserEvent = nullptr;
+}
+
+void GtkSalDisplay::TriggerUserEventProcessing()
+{
+ GetGtkSalData()->TriggerUserEventProcessing();
+}
+
+void GtkSalDisplay::TriggerAllUserEventsProcessed()
{
- GetGtkSalData()->PostUserEvent();
+ GetGtkSalData()->TriggerAllUserEventsProcessed();
}
GtkWidget* GtkSalDisplay::findGtkWidgetForNativeHandle(sal_uIntPtr hWindow) const
{
- for (auto it = m_aFrames.begin(); it != m_aFrames.end(); ++it)
+ for (auto pFrame : m_aFrames)
{
- SalFrame* pFrame = *it;
const SystemEnvData* pEnvData = pFrame->GetSystemData();
if (pEnvData->aWindow == hWindow)
return GTK_WIDGET(pEnvData->pWidget);
diff --git a/vcl/unx/gtk/gtksalframe.cxx b/vcl/unx/gtk/gtksalframe.cxx
index 3ca2b4816ad8..0077a056bb53 100644
--- a/vcl/unx/gtk/gtksalframe.cxx
+++ b/vcl/unx/gtk/gtksalframe.cxx
@@ -2180,10 +2180,9 @@ void GtkSalFrame::grabPointer( bool bGrab, bool bOwnerEvents )
if( bGrab )
{
bool bUseGdkGrab = true;
- const std::list< SalFrame* >& rFrames = getDisplay()->getFrames();
- for( std::list< SalFrame* >::const_iterator it = rFrames.begin(); it != rFrames.end(); ++it )
+ for (auto pSalFrame : getDisplay()->getFrames() )
{
- const GtkSalFrame* pFrame = static_cast< const GtkSalFrame* >(*it);
+ const GtkSalFrame* pFrame = static_cast< const GtkSalFrame* >( pSalFrame );
if( pFrame->m_bWindowIsGtkPlug )
{
bUseGdkGrab = false;