[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - include/vcl sfx2/source vcl/inc vcl/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 14 11:48:11 UTC 2019


 include/vcl/event.hxx        |    4 +---
 include/vcl/window.hxx       |    1 +
 sfx2/source/view/frame2.cxx  |   34 ++++++++++++++++++++--------------
 vcl/inc/salframe.hxx         |    4 ++++
 vcl/source/window/dialog.cxx |    8 ++++----
 vcl/source/window/window.cxx |    5 +++++
 6 files changed, 35 insertions(+), 21 deletions(-)

New commits:
commit ca525d1375ab06889ba1cf9d904652f2eb61d1bf
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Jun 14 09:18:44 2019 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Jun 14 13:47:24 2019 +0200

    disable 'quit' menu entry when modal dialog waiting response
    
    Traditionally when a modal dialog is active, the quit menu entry of all
    LibreOffice toplevel frames, not just those which are themselves modal, is get
    disabled.
    
    This has come unstuck because its implemented by dialogs emitting
    MouseNotifyEvent::[END]EXECUTEDIALOG on its parent, and SfxFrameWindow_Impl
    listening for that event. But if the dialog parent is the toplevel parent of
    SfxFrameWindow_Impl then it doesn't get seen by the SfxFrameWindow_Impl child.
    
    Change-Id: I0c4a5472d16d9169e68f6b0c230d039f1119489a
    Reviewed-on: https://gerrit.libreoffice.org/74030
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/vcl/event.hxx b/include/vcl/event.hxx
index d1e4b61b876d..bd0b5589f375 100644
--- a/include/vcl/event.hxx
+++ b/include/vcl/event.hxx
@@ -276,9 +276,7 @@ enum class MouseNotifyEvent
     GETFOCUS         = 6,
     LOSEFOCUS        = 7,
     COMMAND          = 8,
-    INPUTENABLE      = 10,
-    EXECUTEDIALOG    = 100,
-    ENDEXECUTEDIALOG = 101
+    INPUTENABLE      = 10
 };
 
 class VCL_DLLPUBLIC NotifyEvent
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index e2223af65950..3b28f9a503a0 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1578,6 +1578,7 @@ public:
 
     void SetHelpHdl(const Link<vcl::Window&, bool>& rLink);
     void SetMnemonicActivateHdl(const Link<vcl::Window&, bool>& rLink);
+    void SetModalHierarchyHdl(const Link<bool, void>& rLink);
 };
 
 }
diff --git a/sfx2/source/view/frame2.cxx b/sfx2/source/view/frame2.cxx
index 804440a4f24f..dd894c87dc37 100644
--- a/sfx2/source/view/frame2.cxx
+++ b/sfx2/source/view/frame2.cxx
@@ -61,9 +61,9 @@ using namespace ::com::sun::star::container;
 using namespace ::com::sun::star::beans;
 using ::com::sun::star::frame::XComponentLoader;
 
-
 class SfxFrameWindow_Impl : public vcl::Window
 {
+    DECL_LINK(ModalHierarchyHdl, bool, void);
 public:
     SfxFrame*           pFrame;
 
@@ -75,13 +75,21 @@ public:
     virtual bool        EventNotify( NotifyEvent& rEvt ) override;
     virtual void        Resize() override;
     virtual void        GetFocus() override;
+    virtual void        dispose() override;
     void                DoResize();
 };
 
-SfxFrameWindow_Impl::SfxFrameWindow_Impl( SfxFrame* pF, vcl::Window& i_rContainerWindow )
-        : Window( &i_rContainerWindow, WB_BORDER | WB_CLIPCHILDREN | WB_NODIALOGCONTROL | WB_3DLOOK )
-        , pFrame( pF )
+SfxFrameWindow_Impl::SfxFrameWindow_Impl(SfxFrame* pF, vcl::Window& i_rContainerWindow)
+    : Window(&i_rContainerWindow, WB_BORDER | WB_CLIPCHILDREN | WB_NODIALOGCONTROL | WB_3DLOOK)
+    , pFrame(pF)
+{
+    i_rContainerWindow.SetModalHierarchyHdl(LINK(this, SfxFrameWindow_Impl, ModalHierarchyHdl));
+}
+
+void SfxFrameWindow_Impl::dispose()
 {
+    GetParent()->SetModalHierarchyHdl(Link<bool, void>());
+    vcl::Window::dispose();
 }
 
 void SfxFrameWindow_Impl::DataChanged( const DataChangedEvent& rDCEvt )
@@ -119,20 +127,18 @@ bool SfxFrameWindow_Impl::EventNotify( NotifyEvent& rNEvt )
         if ( pView->GetViewShell()->KeyInput( *rNEvt.GetKeyEvent() ) )
             return true;
     }
-    else if ( rNEvt.GetType() == MouseNotifyEvent::EXECUTEDIALOG )
-    {
-        pView->SetModalMode( true );
-        return true;
-    }
-    else if ( rNEvt.GetType() == MouseNotifyEvent::ENDEXECUTEDIALOG /*|| rNEvt.GetType() == MouseNotifyEvent::INPUTENABLE*/ )
-    {
-        pView->SetModalMode( false );
-        return true;
-    }
 
     return Window::EventNotify( rNEvt );
 }
 
+IMPL_LINK(SfxFrameWindow_Impl, ModalHierarchyHdl, bool, bSetModal, void)
+{
+    SfxViewFrame* pView = pFrame->GetCurrentViewFrame();
+    if (!pView || !pView->GetObjectShell())
+        return;
+    pView->SetModalMode(bSetModal);
+}
+
 bool SfxFrameWindow_Impl::PreNotify( NotifyEvent& rNEvt )
 {
     MouseNotifyEvent nType = rNEvt.GetType();
diff --git a/vcl/inc/salframe.hxx b/vcl/inc/salframe.hxx
index b77ceafa8079..86ad6da98b6e 100644
--- a/vcl/inc/salframe.hxx
+++ b/vcl/inc/salframe.hxx
@@ -117,6 +117,7 @@ private:
     // the VCL window corresponding to this frame
     VclPtr<vcl::Window>     m_pWindow;
     SALFRAMEPROC            m_pProc;
+    Link<bool, void>        m_aModalHierarchyHdl;
 protected:
     mutable std::unique_ptr<weld::Window> m_xFrameWeld;
 public:
@@ -287,6 +288,9 @@ public:
     // returns the instance set
     vcl::Window*            GetWindow() const { return m_pWindow; }
 
+    void SetModalHierarchyHdl(const Link<bool, void>& rLink) { m_aModalHierarchyHdl = rLink; }
+    void NotifyModalHierarchy(bool bModal) { m_aModalHierarchyHdl.Call(bModal); }
+
     // Call the callback set; this sometimes necessary for implementation classes
     // that should not know more than necessary about the SalFrame implementation
     // (e.g. input methods, printer update handlers).
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 03512eb76178..ce83520c997a 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -967,8 +967,8 @@ bool Dialog::ImplStartExecute()
 
         if ( GetParent() )
         {
-            NotifyEvent aNEvt( MouseNotifyEvent::EXECUTEDIALOG, this );
-            GetParent()->CompatNotify( aNEvt );
+            SalFrame* pFrame = GetParent()->ImplGetFrame();
+            pFrame->NotifyModalHierarchy(true);
         }
     }
 
@@ -1161,8 +1161,8 @@ void Dialog::EndDialog( long nResult )
 
     if (bModal && GetParent())
     {
-        NotifyEvent aNEvt( MouseNotifyEvent::ENDEXECUTEDIALOG, this );
-        GetParent()->CompatNotify( aNEvt );
+        SalFrame* pFrame = GetParent()->ImplGetFrame();
+        pFrame->NotifyModalHierarchy(false);
     }
 
     mpDialogImpl->mnResult = nResult;
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index c6dc06416c8f..27f027eb3224 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -1745,6 +1745,11 @@ void Window::ImplNewInputContext()
     pFocusWin->ImplGetFrame()->SetInputContext( &aNewContext );
 }
 
+void Window::SetModalHierarchyHdl(const Link<bool, void>& rLink)
+{
+    ImplGetFrame()->SetModalHierarchyHdl(rLink);
+}
+
 void Window::SetParentToDefaultWindow()
 {
     Show(false);


More information about the Libreoffice-commits mailing list