Blob Blame History Raw
From 8a30dab4e78b42cf3ce587965414b98a50830a78 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
Date: Mon, 14 Dec 2015 11:36:50 +0000
Subject: [PATCH 1/2] Related: rhbz#1290014 gtk3: use gtk_window_set_modal on
 modal dialogs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

which makes modal dialogs (which are most of them) place correctly
under wayland. Modeless ones are still uselessly shoved far to the
left, but this makes things near usable and gives the same "graying
into the bg" effect for the main window as other gtk apps

Change-Id: If1486feb7631c5a0c2aa6efac3a6b9dd1b215daf
Reviewed-on: https://gerrit.libreoffice.org/20699
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit 8d5822983e9b6a1e04874ce4d2c807fd0cf1ee04)
Reviewed-on: https://gerrit.libreoffice.org/20700
---
 vcl/inc/salframe.hxx          | 4 ++++
 vcl/inc/unx/gtk/gtkframe.hxx  | 4 ++++
 vcl/source/window/dialog.cxx  | 3 ++-
 vcl/unx/gtk3/gtk3gtkframe.cxx | 7 +++++++
 4 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/vcl/inc/salframe.hxx b/vcl/inc/salframe.hxx
index 4e52fe4..484504c 100644
--- a/vcl/inc/salframe.hxx
+++ b/vcl/inc/salframe.hxx
@@ -233,6 +233,10 @@ public:
     // done setting up the clipregion
     virtual void            EndSetClipRegion() = 0;
 
+    virtual void            SetModal(bool /*bModal*/)
+    {
+    }
+
     // Callbacks (indepent part in vcl/source/window/winproc.cxx)
     // for default message handling return 0
     void                    SetCallback( vcl::Window* pWindow, SALFRAMEPROC pProc );
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index 3bd5353..ee19e6c 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -465,6 +465,10 @@ public:
     // done setting up the clipregion
     virtual void                EndSetClipRegion() SAL_OVERRIDE;
 
+#if GTK_CHECK_VERSION(3,0,0)
+    virtual void                SetModal(bool bModal) override;
+#endif
+
     static GtkSalFrame         *getFromWindow( GtkWindow *pWindow );
 
     virtual Window              GetX11Window() SAL_OVERRIDE;
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 4ce15de..cd1f0da 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -46,6 +46,7 @@
 #include <vcl/msgbox.hxx>
 #include <vcl/unowrap.hxx>
 #include <vcl/settings.hxx>
+#include <salframe.hxx>
 
 #include <iostream>
 
@@ -1001,7 +1002,6 @@ void Dialog::SetModalInputMode( bool bModal )
             mpDialogParent = pParent->mpWindowImpl->mpFrameWindow;
             mpDialogParent->ImplIncModalCount();
         }
-
     }
     else
     {
@@ -1037,6 +1037,7 @@ void Dialog::SetModalInputMode( bool bModal )
             }
         }
     }
+    ImplGetFrame()->SetModal(bModal);
 }
 
 void Dialog::SetModalInputMode( bool bModal, bool bSubModalDialogs )
diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx
index 1443054..ca9d371 100644
--- a/vcl/unx/gtk3/gtk3gtkframe.cxx
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
@@ -2616,6 +2616,13 @@ void GtkSalFrame::EndSetClipRegion()
         gdk_window_shape_combine_region( widget_get_window(m_pWindow), m_pRegion, 0, 0 );
 }
 
+void GtkSalFrame::SetModal(bool bModal)
+{
+    if (!m_pWindow)
+        return;
+    gtk_window_set_modal(GTK_WINDOW(m_pWindow), bModal);
+}
+
 gboolean GtkSalFrame::signalButton( GtkWidget*, GdkEventButton* pEvent, gpointer frame )
 {
     GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
-- 
2.5.0