vcl/unx/gtk/window/gtksalframe.cxx | 142 +++++++++++++++++++------------------ 1 file changed, 75 insertions(+), 67 deletions(-)
New commits: commit cd1c1acd2bc58f83183776f210a5d75c2c46037a Author: Caolán McNamara <caol...@redhat.com> Date: Fri May 22 16:30:50 2015 +0100 gtk3: call gtk_window_set_accept_focus Change-Id: I4f30f05e81e1d5539e832fda144a9fafecdce8e2 (cherry picked from commit 17ee476e21fd07a82744d667ae2d5aa86fb390df) diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx index 5e519f4..4093737 100644 --- a/vcl/unx/gtk/window/gtksalframe.cxx +++ b/vcl/unx/gtk/window/gtksalframe.cxx @@ -1218,8 +1218,8 @@ static void lcl_set_accept_focus( GtkWindow* pWindow, gboolean bAccept, bool bBe } } #else - (void)pWindow; (void)bAccept; (void)bBeforeRealize; - //FIXME: No set_accept_focus impl + gtk_window_set_accept_focus(pWindow, bAccept); + (void)bBeforeRealize; #endif } commit 8908f14cecf3dac2eb7081f1499d07305d701402 Author: Caolán McNamara <caol...@redhat.com> Date: Thu May 21 15:44:20 2015 +0100 gtk3: implement keyboard and mouse grab Change-Id: Iff17dccc58e0fcd6bdc479e6135e067ae375dce9 (cherry picked from commit 06cb0e6d2675cff7b526f9fe2578d9727fda4404) diff --git a/vcl/unx/gtk/window/gtksalframe.cxx b/vcl/unx/gtk/window/gtksalframe.cxx index 8ca6a53..5e519f4 100644 --- a/vcl/unx/gtk/window/gtksalframe.cxx +++ b/vcl/unx/gtk/window/gtksalframe.cxx @@ -2726,90 +2726,98 @@ void GtkSalFrame::SetPointer( PointerStyle ePointerStyle ) void GtkSalFrame::grabPointer( bool bGrab, bool bOwnerEvents ) { -#if !GTK_CHECK_VERSION(3,0,0) static const char* pEnv = getenv( "SAL_NO_MOUSEGRABS" ); + if (pEnv && *pEnv) + return; - if( m_pWindow ) + if (!m_pWindow) + return; + + const int nMask = (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); + +#if GTK_CHECK_VERSION(3,0,0) + GdkDeviceManager* pDeviceManager = gdk_display_get_device_manager(getGdkDisplay()); + GdkDevice* pPointer = gdk_device_manager_get_client_pointer(pDeviceManager); + if (bGrab) + gdk_device_grab(pPointer, widget_get_window(m_pWindow), GDK_OWNERSHIP_NONE, bOwnerEvents, (GdkEventMask) nMask, m_pCurrentCursor, GDK_CURRENT_TIME); + else + gdk_device_ungrab(pPointer, GDK_CURRENT_TIME); +#else + if( bGrab ) { - 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 ) { - bool bUseGdkGrab = true; - const std::list< SalFrame* >& rFrames = getDisplay()->getFrames(); - for( std::list< SalFrame* >::const_iterator it = rFrames.begin(); it != rFrames.end(); ++it ) - { - const GtkSalFrame* pFrame = static_cast< const GtkSalFrame* >(*it); - if( pFrame->m_bWindowIsGtkPlug ) - { - bUseGdkGrab = false; - break; - } - } - if( bUseGdkGrab ) - { - const int nMask = ( GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK ); - - if( !pEnv || !*pEnv ) - gdk_pointer_grab( widget_get_window( m_pWindow ), bOwnerEvents, - (GdkEventMask) nMask, NULL, m_pCurrentCursor, - GDK_CURRENT_TIME ); - } - else + const GtkSalFrame* pFrame = static_cast< const GtkSalFrame* >(*it); + if( pFrame->m_bWindowIsGtkPlug ) { - // FIXME: for some unknown reason gdk_pointer_grab does not - // really produce owner events for GtkPlug windows - // the cause is yet unknown - - // this is of course a bad hack, especially as we cannot - // set the right cursor this way - if( !pEnv || !*pEnv ) - XGrabPointer( getDisplay()->GetDisplay(), - widget_get_xid( m_pWindow ), - bOwnerEvents, - PointerMotionMask | ButtonPressMask | ButtonReleaseMask, - GrabModeAsync, - GrabModeAsync, - None, - None, - CurrentTime - ); - + bUseGdkGrab = false; + break; } } + if( bUseGdkGrab ) + { + gdk_pointer_grab( widget_get_window( m_pWindow ), bOwnerEvents, + (GdkEventMask) nMask, NULL, m_pCurrentCursor, + GDK_CURRENT_TIME ); + } else { - // Two GdkDisplays may be open - if( !pEnv || !*pEnv ) - { - gdk_display_pointer_ungrab( getGdkDisplay(), GDK_CURRENT_TIME); - } + // FIXME: for some unknown reason gdk_pointer_grab does not + // really produce owner events for GtkPlug windows + // the cause is yet unknown + + // this is of course a bad hack, especially as we cannot + // set the right cursor this way + XGrabPointer( getDisplay()->GetDisplay(), + widget_get_xid( m_pWindow ), + bOwnerEvents, + PointerMotionMask | ButtonPressMask | ButtonReleaseMask, + GrabModeAsync, + GrabModeAsync, + None, + None, + CurrentTime + ); } } -#else - (void) this; // loplugin:staticmethods - (void)bGrab; (void) bOwnerEvents; - //FIXME: No GrabPointer implementation for gtk3 ... + else + { + // Two GdkDisplays may be open + gdk_display_pointer_ungrab( getGdkDisplay(), GDK_CURRENT_TIME); + } #endif } void GtkSalFrame::grabKeyboard( bool bGrab ) { -#if !GTK_CHECK_VERSION(3,0,0) - if( m_pWindow ) + if (!m_pWindow) + return; + +#if GTK_CHECK_VERSION(3,0,0) + GdkDeviceManager* pDeviceManager = gdk_display_get_device_manager(getGdkDisplay()); + GdkDevice* pPointer = gdk_device_manager_get_client_pointer(pDeviceManager); + GdkDevice* pKeyboard = gdk_device_get_associated_device(pPointer); + if (bGrab) { - if( bGrab ) - { - gdk_keyboard_grab(widget_get_window(m_pWindow), true, - GDK_CURRENT_TIME); - } - else - { - gdk_keyboard_ungrab(GDK_CURRENT_TIME); - } + gdk_device_grab(pKeyboard, widget_get_window(m_pWindow), GDK_OWNERSHIP_NONE, + FALSE, (GdkEventMask)(GDK_KEY_PRESS | GDK_KEY_RELEASE), NULL, GDK_CURRENT_TIME); + } + else + { + gdk_device_ungrab(pKeyboard, GDK_CURRENT_TIME); } #else - (void) this; // loplugin:staticmethods - (void)bGrab; - //FIXME: No GrabKeyboard implementation for gtk3 ... + if( bGrab ) + { + gdk_keyboard_grab(widget_get_window(m_pWindow), true, + GDK_CURRENT_TIME); + } + else + { + gdk_keyboard_ungrab(GDK_CURRENT_TIME); + } #endif }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits