diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-02-04 13:15:07 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-02-04 20:52:02 +0100 |
commit | cbe85ddc59b4f49f9fcf1c968519061c8c86cce9 (patch) | |
tree | 898495e96cf141aae1085cbeeb6abdc502b6e738 /vcl | |
parent | 80a1c69a30a55ed648a43976f6ab401ac2b5ceaa (diff) |
add a way to return focus to the main widget
Change-Id: Ia06eaf6021b22a63a74f8a0b7edc96339dfb2e17
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87970
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/salframe.hxx | 3 | ||||
-rw-r--r-- | vcl/inc/unx/gtk/gtkframe.hxx | 1 | ||||
-rw-r--r-- | vcl/source/window/mouse.cxx | 1 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkframe.cxx | 17 |
4 files changed, 14 insertions, 8 deletions
diff --git a/vcl/inc/salframe.hxx b/vcl/inc/salframe.hxx index 4b540d61ca0e..b83138e29d40 100644 --- a/vcl/inc/salframe.hxx +++ b/vcl/inc/salframe.hxx @@ -180,6 +180,9 @@ public: // Window to top and grab focus virtual void ToTop( SalFrameToTop nFlags ) = 0; + // grab focus to the main widget, can be no-op if the vclplug only uses one widget + virtual void GrabFocus() {} + // this function can call with the same // pointer style virtual void SetPointer( PointerStyle ePointerStyle ) = 0; diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx index 3259991329c0..7b6d01d872c3 100644 --- a/vcl/inc/unx/gtk/gtkframe.hxx +++ b/vcl/inc/unx/gtk/gtkframe.hxx @@ -433,6 +433,7 @@ public: // pointer style virtual void SetPointer( PointerStyle ePointerStyle ) override; virtual void CaptureMouse( bool bMouse ) override; + virtual void GrabFocus() override; virtual void SetPointerPos( long nX, long nY ) override; // flush output buffer diff --git a/vcl/source/window/mouse.cxx b/vcl/source/window/mouse.cxx index 16993d199987..5894d88bd94b 100644 --- a/vcl/source/window/mouse.cxx +++ b/vcl/source/window/mouse.cxx @@ -397,6 +397,7 @@ void Window::ImplGrabFocusToDocument( GetFocusFlags nFlags ) { if( !pWin->GetParent() ) { + pWin->mpWindowImpl->mpFrame->GrabFocus(); pWin->ImplGetFrameWindow()->GetWindow( GetWindowType::Client )->ImplGrabFocus(nFlags); return; } diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx index ce2ed4f3ab47..85106bb86035 100644 --- a/vcl/unx/gtk3/gtk3gtkframe.cxx +++ b/vcl/unx/gtk3/gtk3gtkframe.cxx @@ -1925,16 +1925,14 @@ void GtkSalFrame::ToTop( SalFrameToTop nFlags ) if( m_pWindow ) { if( isChild( false ) ) - { - gtk_widget_set_can_focus(GTK_WIDGET(m_pFixedContainer), true); - gtk_widget_grab_focus(GTK_WIDGET(m_pFixedContainer)); - } + GrabFocus(); else if( gtk_widget_get_mapped( m_pWindow ) ) { if (!(nFlags & SalFrameToTop::GrabFocusOnly)) gtk_window_present_with_time(GTK_WINDOW(m_pWindow), GetLastInputEventTime()); else gdk_window_focus(gtk_widget_get_window(m_pWindow), GetLastInputEventTime()); + GrabFocus(); } else { @@ -2478,6 +2476,12 @@ namespace } } +void GtkSalFrame::GrabFocus() +{ + gtk_widget_set_can_focus(GTK_WIDGET(m_pFixedContainer), true); + gtk_widget_grab_focus(GTK_WIDGET(m_pFixedContainer)); +} + gboolean GtkSalFrame::signalButton(GtkWidget*, GdkEventButton* pEvent, gpointer frame) { UpdateLastInputEventTime(pEvent->time); @@ -2498,10 +2502,7 @@ gboolean GtkSalFrame::signalButton(GtkWidget*, GdkEventButton* pEvent, gpointer // focus on click if (!bDifferentEventWindow) - { - gtk_widget_set_can_focus(GTK_WIDGET(pThis->m_pFixedContainer), true); - gtk_widget_grab_focus(GTK_WIDGET(pThis->m_pFixedContainer)); - } + pThis->GrabFocus(); } SalMouseEvent aEvent; |