From 3266c3bf545cc3045f843f764b4c420241d9e4da Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 4 Sep 2017 12:05:04 +0100 Subject: Resolves: tdf#110452 stop menubar processing Alt+foo if handled by core widget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I69f975d0f7a753e55f72fcd63f6580e958a80f38 Reviewed-on: https://gerrit.libreoffice.org/41884 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- vcl/inc/unx/gtk/gtkframe.hxx | 2 +- vcl/unx/gtk/gtksalframe.cxx | 4 +++- vcl/unx/gtk3/gtk3gtkframe.cxx | 38 +++++++++++++++++++++----------------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx index 772033b49b76..0d40659e49f9 100644 --- a/vcl/inc/unx/gtk/gtkframe.hxx +++ b/vcl/inc/unx/gtk/gtkframe.hxx @@ -288,7 +288,7 @@ class GtkSalFrame : public SalFrame void Center(); void SetDefaultSize(); - void doKeyCallback( guint state, + bool doKeyCallback( guint state, guint keyval, guint16 hardware_keycode, guint8 group, diff --git a/vcl/unx/gtk/gtksalframe.cxx b/vcl/unx/gtk/gtksalframe.cxx index b8cac669deb4..8bd532eea78c 100644 --- a/vcl/unx/gtk/gtksalframe.cxx +++ b/vcl/unx/gtk/gtksalframe.cxx @@ -363,7 +363,7 @@ GetAlternateKeyCode( const sal_uInt16 nKeyCode ) return aAlternate; } -void GtkSalFrame::doKeyCallback( guint state, +bool GtkSalFrame::doKeyCallback( guint state, guint keyval, guint16 hardware_keycode, guint8 group, @@ -445,6 +445,8 @@ void GtkSalFrame::doKeyCallback( guint state, } else CallCallback( SalEvent::KeyUp, &aEvent ); + + return false; } GtkSalFrame::GtkSalFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx index 1d43d1999811..c9c0eb50c7c9 100644 --- a/vcl/unx/gtk3/gtk3gtkframe.cxx +++ b/vcl/unx/gtk3/gtk3gtkframe.cxx @@ -363,7 +363,7 @@ GetAlternateKeyCode( const sal_uInt16 nKeyCode ) static bool dumpframes = false; -void GtkSalFrame::doKeyCallback( guint state, +bool GtkSalFrame::doKeyCallback( guint state, guint keyval, guint16 hardware_keycode, guint8 group, @@ -387,19 +387,19 @@ void GtkSalFrame::doKeyCallback( guint state, { fprintf( stderr, "force widget_queue_draw\n"); gtk_widget_queue_draw(GTK_WIDGET(m_pFixedContainer)); - return; + return false; } else if (keyval == GDK_KEY_1) { fprintf( stderr, "force repaint all\n"); TriggerPaintEvent(); - return; + return false; } else if (keyval == GDK_KEY_2) { dumpframes = !dumpframes; fprintf(stderr, "toggle dump frames to %d\n", dumpframes); - return; + return false; } } #endif @@ -448,11 +448,12 @@ void GtkSalFrame::doKeyCallback( guint state, aEvent.mnCode |= GetKeyModCode( state ); + bool bStopProcessingKey; if (bDown) { - bool bHandled = CallCallbackExc( SalEvent::KeyInput, &aEvent ); + bStopProcessingKey = CallCallbackExc(SalEvent::KeyInput, &aEvent); // #i46889# copy AlternateKeyCode handling from generic plugin - if( ! bHandled ) + if (!bStopProcessingKey) { KeyAlternate aAlternate = GetAlternateKeyCode( aEvent.mnCode ); if( aAlternate.nKeyCode ) @@ -460,16 +461,17 @@ void GtkSalFrame::doKeyCallback( guint state, aEvent.mnCode = aAlternate.nKeyCode; if( aAlternate.nCharCode ) aEvent.mnCharCode = aAlternate.nCharCode; - CallCallbackExc( SalEvent::KeyInput, &aEvent ); + bStopProcessingKey = CallCallbackExc(SalEvent::KeyInput, &aEvent); } } if( bSendRelease && ! aDel.isDeleted() ) { - CallCallbackExc( SalEvent::KeyUp, &aEvent ); + CallCallbackExc(SalEvent::KeyUp, &aEvent); } } else - CallCallbackExc( SalEvent::KeyUp, &aEvent ); + bStopProcessingKey = CallCallbackExc(SalEvent::KeyUp, &aEvent); + return bStopProcessingKey; } GtkSalFrame::GtkSalFrame( SalFrame* pParent, SalFrameStyleFlags nStyle ) @@ -3073,6 +3075,8 @@ gboolean GtkSalFrame::signalKey(GtkWidget* pWidget, GdkEventKey* pEvent, gpointe return true; } + bool bStopProcessingKey = false; + // handle modifiers if( pEvent->keyval == GDK_KEY_Shift_L || pEvent->keyval == GDK_KEY_Shift_R || pEvent->keyval == GDK_KEY_Control_L || pEvent->keyval == GDK_KEY_Control_R || @@ -3148,13 +3152,13 @@ gboolean GtkSalFrame::signalKey(GtkWidget* pWidget, GdkEventKey* pEvent, gpointe } else { - pThis->doKeyCallback( pEvent->state, - pEvent->keyval, - pEvent->hardware_keycode, - pEvent->group, - sal_Unicode(gdk_keyval_to_unicode( pEvent->keyval )), - (pEvent->type == GDK_KEY_PRESS), - false ); + bStopProcessingKey = pThis->doKeyCallback(pEvent->state, + pEvent->keyval, + pEvent->hardware_keycode, + pEvent->group, + sal_Unicode(gdk_keyval_to_unicode( pEvent->keyval )), + (pEvent->type == GDK_KEY_PRESS), + false); if( ! aDel.isDeleted() ) pThis->m_nKeyModifiers = ModKeyFlags::NONE; } @@ -3162,7 +3166,7 @@ gboolean GtkSalFrame::signalKey(GtkWidget* pWidget, GdkEventKey* pEvent, gpointe if( !aDel.isDeleted() && pThis->m_pIMHandler ) pThis->m_pIMHandler->updateIMSpotLocation(); - return false; + return bStopProcessingKey; } gboolean GtkSalFrame::signalDelete( GtkWidget*, GdkEvent*, gpointer frame ) -- cgit v1.2.3