3a3da35
From 19e1876935e6e14e73c8605a381eca6314357181 Mon Sep 17 00:00:00 2001
a7dfdb0
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
a7dfdb0
Date: Thu, 10 Nov 2016 13:20:34 +0000
a7dfdb0
Subject: [PATCH] Resolves: rhbz#1391418 wayland toolbars can't be docked after
a7dfdb0
 undocking
a7dfdb0
a7dfdb0
see gnome#768128 for extra details
a7dfdb0
a7dfdb0
under wayland, given the misery here I'm going to just disable toggling between
a7dfdb0
docked and undocked under wayland, and throw away user config on toggling
a7dfdb0
docked/undocked away from the defaults. You can still drag docked things around
a7dfdb0
to new docking position, but you can't pull them out of the dock to float.
a7dfdb0
a7dfdb0
non-wayland is unaffected
a7dfdb0
a7dfdb0
Change-Id: Iaa859f3420e6d1b103a8b93d1ad8f82dbffe75d4
a7dfdb0
---
a7dfdb0
 framework/source/layoutmanager/layoutmanager.cxx |  4 ++++
a7dfdb0
 include/vcl/settings.hxx                         |  2 ++
a7dfdb0
 sfx2/source/dialog/dockwin.cxx                   |  4 +++-
a7dfdb0
 vcl/inc/svdata.hxx                               |  4 ++++
a7dfdb0
 vcl/source/app/settings.cxx                      |  7 +++++++
3a3da35
 vcl/source/app/svdata.cxx                        |  1 +
a7dfdb0
 vcl/source/window/dockmgr.cxx                    |  3 +++
a7dfdb0
 vcl/source/window/dockwin.cxx                    |  9 +++++++--
a7dfdb0
 vcl/source/window/event.cxx                      | 10 ++++++----
a7dfdb0
 vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx        | 12 +++++++++++-
3a3da35
 10 files changed, 48 insertions(+), 8 deletions(-)
a7dfdb0
a7dfdb0
diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx
e853b4c
index 2ade77e..46079eb 100644
a7dfdb0
--- a/framework/source/layoutmanager/layoutmanager.cxx
a7dfdb0
+++ b/framework/source/layoutmanager/layoutmanager.cxx
e853b4c
@@ -615,6 +615,10 @@ bool LayoutManager::readWindowStateData( const OUString& aName, UIElement& rElem
a7dfdb0
                 }
a7dfdb0
             }
a7dfdb0
 
a7dfdb0
+            const bool bDockingSupportCrippled = !StyleSettings::GetDockingFloatsSupported();
a7dfdb0
+            if (bDockingSupportCrippled)
a7dfdb0
+                rElementData.m_bFloating = false;
a7dfdb0
+
a7dfdb0
             return true;
a7dfdb0
         }
a7dfdb0
         catch (const NoSuchElementException&)
a7dfdb0
diff --git a/include/vcl/settings.hxx b/include/vcl/settings.hxx
e853b4c
index acbacf3..815e9f7 100644
a7dfdb0
--- a/include/vcl/settings.hxx
a7dfdb0
+++ b/include/vcl/settings.hxx
e853b4c
@@ -525,6 +525,8 @@ public:
a7dfdb0
     void                            SetAutoMnemonic( bool bAutoMnemonic );
a7dfdb0
     bool                            GetAutoMnemonic() const;
a7dfdb0
 
a7dfdb0
+    static bool                     GetDockingFloatsSupported();
a7dfdb0
+
a7dfdb0
     void                            SetFontColor( const Color& rColor );
a7dfdb0
     const Color&                    GetFontColor() const;
a7dfdb0
 
a7dfdb0
diff --git a/sfx2/source/dialog/dockwin.cxx b/sfx2/source/dialog/dockwin.cxx
e853b4c
index 25c72d8..0b45e7e 100644
a7dfdb0
--- a/sfx2/source/dialog/dockwin.cxx
a7dfdb0
+++ b/sfx2/source/dialog/dockwin.cxx
e853b4c
@@ -929,7 +929,9 @@ void SfxDockingWindow::Initialize(SfxChildWinInfo *pInfo)
a7dfdb0
 
a7dfdb0
             // check for valid alignment
a7dfdb0
             SfxChildAlignment eLocalAlignment = (SfxChildAlignment) (sal_uInt16) aStr.toInt32();
a7dfdb0
-            if ( pImpl->bDockingPrevented )
a7dfdb0
+            bool bIgnoreFloatConfig = (eLocalAlignment == SfxChildAlignment::NOALIGNMENT &&
a7dfdb0
+                                       !StyleSettings::GetDockingFloatsSupported());
a7dfdb0
+            if (pImpl->bDockingPrevented || bIgnoreFloatConfig)
a7dfdb0
                 // docking prevented, ignore old configuration and take alignment from default
a7dfdb0
                 aStr.clear();
a7dfdb0
             else
a7dfdb0
diff --git a/vcl/inc/svdata.hxx b/vcl/inc/svdata.hxx
3a3da35
index 39b5610..f348f84 100644
a7dfdb0
--- a/vcl/inc/svdata.hxx
a7dfdb0
+++ b/vcl/inc/svdata.hxx
e853b4c
@@ -280,6 +280,10 @@ struct ImplSVNWFData
e853b4c
     bool                    mbDDListBoxNoTextArea:1;
e853b4c
     bool                    mbEnableAccel:1;                // whether or not accelerators are shown
e853b4c
     bool                    mbAutoAccel:1;                  // whether accelerators are only shown when Alt is held down
a7dfdb0
+    // gnome#768128 I cannot see a route under wayland at present to support
a7dfdb0
+    // floating toolbars that can be redocked because there's no way to track
a7dfdb0
+    // that the toolbar is over a dockable area.
3a3da35
+    bool                    mbCanDetermineWindowPosition:1;
a7dfdb0
 };
a7dfdb0
 
a7dfdb0
 struct BlendFrameCache
a7dfdb0
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
e853b4c
index cb84dbe..9ef9fd2 100644
a7dfdb0
--- a/vcl/source/app/settings.cxx
a7dfdb0
+++ b/vcl/source/app/settings.cxx
e853b4c
@@ -1931,6 +1931,13 @@ StyleSettings::GetAutoMnemonic() const
a7dfdb0
     return mxData->mbAutoMnemonic;
a7dfdb0
 }
a7dfdb0
 
a7dfdb0
+bool
a7dfdb0
+StyleSettings::GetDockingFloatsSupported()
a7dfdb0
+{
a7dfdb0
+    ImplSVData* pSVData = ImplGetSVData();
a7dfdb0
+    return pSVData->maNWFData.mbDockingFloatsSupported;
a7dfdb0
+}
a7dfdb0
+
a7dfdb0
 void
a7dfdb0
 StyleSettings::SetFontColor( const Color& rColor )
a7dfdb0
 {
3a3da35
diff --git a/vcl/source/app/svdata.cxx b/vcl/source/app/svdata.cxx
3a3da35
index ddad3e3..d050e0b 100644
3a3da35
--- a/vcl/source/app/svdata.cxx
3a3da35
+++ b/vcl/source/app/svdata.cxx
3a3da35
@@ -87,6 +87,7 @@ ImplSVData::ImplSVData()
3a3da35
     maNWFData.maMenuBarHighlightTextColor = Color( COL_TRANSPARENT );
3a3da35
     maNWFData.mbEnableAccel = true;
3a3da35
     maNWFData.mbAutoAccel = false;
3a3da35
+    maNWFData.mbCanDetermineWindowPosition = true;
3a3da35
 }
3a3da35
 
3a3da35
 ImplSVGDIData::~ImplSVGDIData()
a7dfdb0
diff --git a/vcl/source/window/dockmgr.cxx b/vcl/source/window/dockmgr.cxx
e853b4c
index 1b8ef13..d292553 100644
a7dfdb0
--- a/vcl/source/window/dockmgr.cxx
a7dfdb0
+++ b/vcl/source/window/dockmgr.cxx
e853b4c
@@ -992,6 +992,9 @@ void ImplDockingWindowWrapper::EndDocking( const Rectangle& rRect, bool bFloatMo
a7dfdb0
 {
a7dfdb0
     Rectangle aRect( rRect );
a7dfdb0
 
a7dfdb0
+    if (bFloatMode && !StyleSettings::GetDockingFloatsSupported())
a7dfdb0
+        mbDockCanceled = true;
a7dfdb0
+
a7dfdb0
     if ( !IsDockingCanceled() )
a7dfdb0
     {
a7dfdb0
         bool bShow = false;
a7dfdb0
diff --git a/vcl/source/window/dockwin.cxx b/vcl/source/window/dockwin.cxx
e853b4c
index 984d713..c3b2952 100644
a7dfdb0
--- a/vcl/source/window/dockwin.cxx
a7dfdb0
+++ b/vcl/source/window/dockwin.cxx
e853b4c
@@ -612,12 +612,14 @@ bool DockingWindow::Notify( NotifyEvent& rNEvt )
a7dfdb0
 
a7dfdb0
     if ( mbDockable )
a7dfdb0
     {
a7dfdb0
+        const bool bDockingSupportCrippled = !StyleSettings::GetDockingFloatsSupported();
a7dfdb0
+
a7dfdb0
         if ( rNEvt.GetType() == MouseNotifyEvent::MOUSEBUTTONDOWN )
a7dfdb0
         {
a7dfdb0
             const MouseEvent* pMEvt = rNEvt.GetMouseEvent();
a7dfdb0
             if ( pMEvt->IsLeft() )
a7dfdb0
             {
a7dfdb0
-                if ( pMEvt->IsMod1() && (pMEvt->GetClicks() == 2) )
a7dfdb0
+                if (!bDockingSupportCrippled && pMEvt->IsMod1() && (pMEvt->GetClicks() == 2) )
a7dfdb0
                 {
a7dfdb0
                     SetFloatingMode( !IsFloatingMode() );
a7dfdb0
                     return true;
e853b4c
@@ -646,7 +648,7 @@ bool DockingWindow::Notify( NotifyEvent& rNEvt )
a7dfdb0
         {
a7dfdb0
             const vcl::KeyCode& rKey = rNEvt.GetKeyEvent()->GetKeyCode();
a7dfdb0
             if( rKey.GetCode() == KEY_F10 && rKey.GetModifier() &&
a7dfdb0
-                rKey.IsShift() && rKey.IsMod1() )
a7dfdb0
+                rKey.IsShift() && rKey.IsMod1() && !bDockingSupportCrippled )
a7dfdb0
             {
a7dfdb0
                 SetFloatingMode( !IsFloatingMode() );
a7dfdb0
                 return true;
e853b4c
@@ -669,6 +671,9 @@ bool DockingWindow::Docking( const Point&, Rectangle& )
a7dfdb0
 
a7dfdb0
 void DockingWindow::EndDocking( const Rectangle& rRect, bool bFloatMode )
a7dfdb0
 {
a7dfdb0
+    if (bFloatMode && !StyleSettings::GetDockingFloatsSupported())
a7dfdb0
+        mbDockCanceled = true;
a7dfdb0
+
a7dfdb0
     if ( !IsDockingCanceled() )
a7dfdb0
     {
a7dfdb0
         bool bShow = false;
a7dfdb0
diff --git a/vcl/source/window/event.cxx b/vcl/source/window/event.cxx
e853b4c
index aa09c10..74abb18 100644
a7dfdb0
--- a/vcl/source/window/event.cxx
a7dfdb0
+++ b/vcl/source/window/event.cxx
a7dfdb0
@@ -101,15 +101,17 @@ bool Window::Notify( NotifyEvent& rNEvt )
a7dfdb0
     // check for docking window
a7dfdb0
     // but do nothing if window is docked and locked
a7dfdb0
     ImplDockingWindowWrapper *pWrapper = ImplGetDockingManager()->GetDockingWindowWrapper( this );
a7dfdb0
-    if( pWrapper && !( !pWrapper->IsFloatingMode() && pWrapper->IsLocked() ) )
a7dfdb0
+    if (pWrapper && !( !pWrapper->IsFloatingMode() && pWrapper->IsLocked() ))
a7dfdb0
     {
a7dfdb0
+        const bool bDockingSupportCrippled = !StyleSettings::GetDockingFloatsSupported();
a7dfdb0
+
a7dfdb0
         if ( rNEvt.GetType() == MouseNotifyEvent::MOUSEBUTTONDOWN )
a7dfdb0
         {
a7dfdb0
             const MouseEvent* pMEvt = rNEvt.GetMouseEvent();
a7dfdb0
             bool bHit = pWrapper->GetDragArea().IsInside( pMEvt->GetPosPixel() );
a7dfdb0
             if ( pMEvt->IsLeft() )
a7dfdb0
             {
a7dfdb0
-                if ( pMEvt->IsMod1() && (pMEvt->GetClicks() == 2) )
a7dfdb0
+                if (!bDockingSupportCrippled && pMEvt->IsMod1() && (pMEvt->GetClicks() == 2))
a7dfdb0
                 {
a7dfdb0
                     // ctrl double click toggles floating mode
a7dfdb0
                     pWrapper->SetFloatingMode( !pWrapper->IsFloatingMode() );
a7dfdb0
@@ -149,8 +151,8 @@ bool Window::Notify( NotifyEvent& rNEvt )
a7dfdb0
         else if( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
a7dfdb0
         {
a7dfdb0
             const vcl::KeyCode& rKey = rNEvt.GetKeyEvent()->GetKeyCode();
a7dfdb0
-            if( rKey.GetCode() == KEY_F10 && rKey.GetModifier() &&
a7dfdb0
-                rKey.IsShift() && rKey.IsMod1() )
a7dfdb0
+            if (rKey.GetCode() == KEY_F10 && rKey.GetModifier() &&
a7dfdb0
+                rKey.IsShift() && rKey.IsMod1() && !bDockingSupportCrippled)
a7dfdb0
             {
a7dfdb0
                 pWrapper->SetFloatingMode( !pWrapper->IsFloatingMode() );
a7dfdb0
                 /* At this point the floating toolbar frame does not have the
a7dfdb0
diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
e853b4c
index 0365c52..091a615 100644
a7dfdb0
--- a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
a7dfdb0
+++ b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
a7dfdb0
@@ -18,7 +18,9 @@
a7dfdb0
 #include <vcl/settings.hxx>
a7dfdb0
 #include "unx/fontmanager.hxx"
a7dfdb0
 #include "cairo_gtk3_cairo.hxx"
a7dfdb0
-
a7dfdb0
+#if defined(GDK_WINDOWING_WAYLAND)
a7dfdb0
+#   include <gdk/gdkwayland.h>
a7dfdb0
+#endif
a7dfdb0
 #include <boost/optional.hpp>
a7dfdb0
 
e853b4c
 GtkStyleContext* GtkSalGraphics::mpButtonStyle = nullptr;
e853b4c
@@ -2322,6 +2324,14 @@ void GtkData::initNWF()
a7dfdb0
     pSVData->maNWFData.mbNoFocusRectsForFlatButtons = true;
a7dfdb0
     pSVData->maNWFData.mbAutoAccel = true;
a7dfdb0
     pSVData->maNWFData.mbEnableAccel = true;
a7dfdb0
+
a7dfdb0
+#if defined(GDK_WINDOWING_WAYLAND)
a7dfdb0
+    //gnome#768128 for the car crash that is wayland
a7dfdb0
+    //and floating dockable toolbars
a7dfdb0
+    GdkDisplay *pDisplay = gdk_display_get_default();
a7dfdb0
+    if (GDK_IS_WAYLAND_DISPLAY(pDisplay))
a7dfdb0
+        pSVData->maNWFData.mbDockingFloatsSupported = false;
a7dfdb0
+#endif
a7dfdb0
 }
a7dfdb0
 
a7dfdb0
 void GtkData::deInitNWF()
a7dfdb0
-- 
a7dfdb0
2.9.3
a7dfdb0