[Libreoffice-commits] core.git: include/vcl vcl/inc vcl/source vcl/unx

Caolán McNamara caolanm at redhat.com
Thu Mar 10 10:42:04 UTC 2016


 include/vcl/window.hxx        |    6 +++---
 vcl/inc/brdwin.hxx            |    2 --
 vcl/inc/salframe.hxx          |    5 ++++-
 vcl/inc/unx/gtk/gtkframe.hxx  |    7 +++----
 vcl/source/window/brdwin.cxx  |   12 +++++-------
 vcl/source/window/window.cxx  |    2 --
 vcl/source/window/window2.cxx |    6 ++++++
 vcl/unx/gtk3/gtk3gtkframe.cxx |   42 +++++++++++++++++++++---------------------
 8 files changed, 42 insertions(+), 40 deletions(-)

New commits:
commit 51d1fca2041ba4478c5abae59b1ed4fee37ea1ee
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Mar 10 10:33:56 2016 +0000

    Related: tdf#98419 gtk3: reimplement passing window move control to wm...
    
    for wayland
    
    Dragging toolbars around to move them (starting with an undocked toolbar, not
    the moving outline fake thing) doesn't work under wayland (as far as I can see)
    without using gtk_window_begin_move_drag i.e. gtk_window_move doesn't work.
    
    But this is supposed to be used from the initial mouse click (while it works
    under wayland from a move, it doesn't work under X from a move) so rework the
    last attempt to occur right at the initial click to drag.
    
    Change-Id: I612f188b3e8482307bc816f5aa775530e6092eda

diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index e1922d7..3e61c77 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -157,11 +157,10 @@ enum class PosSizeFlags
     PosSize          = Pos | Size,
     All              = PosSize,
     Dropdown         = 0x0010,
-    ByDrag           = 0x0020,
 };
 namespace o3tl
 {
-    template<> struct typed_flags<PosSizeFlags> : is_typed_flags<PosSizeFlags, 0x003f> {};
+    template<> struct typed_flags<PosSizeFlags> : is_typed_flags<PosSizeFlags, 0x001f> {};
 }
 
 // Flags for Show()
@@ -297,10 +296,11 @@ enum class StartTrackingFlags
     ButtonRepeat         = 0x0010,
     MouseButtonDown      = 0x0020,
     FocusCancel          = 0x0040,
+    UseToolKitDrag       = 0x0080,
 };
 namespace o3tl
 {
-    template<> struct typed_flags<StartTrackingFlags> : is_typed_flags<StartTrackingFlags, 0x007f> {};
+    template<> struct typed_flags<StartTrackingFlags> : is_typed_flags<StartTrackingFlags, 0x00ff> {};
 }
 
 // Flags for StartAutoScroll()
diff --git a/vcl/inc/brdwin.hxx b/vcl/inc/brdwin.hxx
index 5180b00..d6fa9c2 100644
--- a/vcl/inc/brdwin.hxx
+++ b/vcl/inc/brdwin.hxx
@@ -175,8 +175,6 @@ public:
 
     Rectangle               GetMenuRect() const;
 
-    void                    MoveToByDrag(const Point& rNewPos);
-
     virtual Size            GetOptimalSize() const override;
 };
 
diff --git a/vcl/inc/salframe.hxx b/vcl/inc/salframe.hxx
index e51864f..11d95e8 100644
--- a/vcl/inc/salframe.hxx
+++ b/vcl/inc/salframe.hxx
@@ -87,7 +87,6 @@ typedef sal_uInt64 SalExtStyle;
 #define SAL_FRAME_POSSIZE_Y                 ((sal_uInt16)0x0002)
 #define SAL_FRAME_POSSIZE_WIDTH             ((sal_uInt16)0x0004)
 #define SAL_FRAME_POSSIZE_HEIGHT            ((sal_uInt16)0x0008)
-#define SAL_FRAME_POSSIZE_BYDRAG            ((sal_uInt16)0x0010)
 
 struct SystemParentData;
 struct ImplSVEvent;
@@ -255,6 +254,10 @@ public:
         return false;
     }
 
+    virtual void            StartToolKitMoveBy()
+    {
+    }
+
     // 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 cf97011..072f9da 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -332,10 +332,7 @@ class GtkSalFrame : public SalFrame
     void widget_set_size_request(long nWidth, long nHeight);
 
     void resizeWindow( long nWidth, long nHeight );
-    void moveWindow(long nX, long nY);
-#if GTK_CHECK_VERSION(3,0,0)
-    void dragWindowTo(long nX, long nY);
-#endif
+    void moveWindow( long nX, long nY );
 
     Size calcDefaultSize();
 
@@ -529,6 +526,8 @@ public:
     virtual sal_uIntPtr         ShowPopover(const OUString& rHelpText, const Rectangle& rHelpArea, QuickHelpFlags nFlags) override;
     virtual bool                UpdatePopover(sal_uIntPtr nId, const OUString& rHelpText, const Rectangle& rHelpArea) override;
     virtual bool                HidePopover(sal_uIntPtr nId) override;
+
+    virtual void                StartToolKitMoveBy() override;
 #endif
 
     static GtkSalFrame         *getFromWindow( GtkWindow *pWindow );
diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx
index dc92598..da14e99 100644
--- a/vcl/source/window/brdwin.cxx
+++ b/vcl/source/window/brdwin.cxx
@@ -925,7 +925,10 @@ bool ImplStdBorderWindowView::MouseButtonDown( const MouseEvent& rMEvt )
                 maFrameData.mbDragFull = false;
                 if ( nDragFullTest != DragFullOptions::NONE )
                     maFrameData.mbDragFull = true;   // always fulldrag for proper docking, ignore system settings
-                pBorderWindow->StartTracking();
+                StartTrackingFlags eFlags = maFrameData.mbDragFull ?
+                    StartTrackingFlags::UseToolKitDrag :
+                    StartTrackingFlags::NONE;
+                pBorderWindow->StartTracking(eFlags);
             }
             else if ( bHitTest )
                 maFrameData.mnHitTest = 0;
@@ -1242,7 +1245,7 @@ bool ImplStdBorderWindowView::Tracking( const TrackingEvent& rTEvt )
                 aPos.Y() += aMousePos.Y();
                 if ( maFrameData.mbDragFull )
                 {
-                    pBorderWindow->MoveToByDrag(aPos);
+                    pBorderWindow->SetPosPixel( aPos );
                     pBorderWindow->ImplUpdateAll();
                     pBorderWindow->ImplGetFrameWindow()->ImplUpdateAll();
                 }
@@ -2203,11 +2206,6 @@ Rectangle ImplBorderWindow::GetMenuRect() const
     return mpBorderView->GetMenuRect();
 }
 
-void ImplBorderWindow::MoveToByDrag(const Point& rNewPos)
-{
-    setPosSizePixel(rNewPos.X(), rNewPos.Y(), 0, 0, PosSizeFlags::Pos | PosSizeFlags::ByDrag);
-}
-
 Size ImplBorderWindow::GetOptimalSize() const
 {
     const vcl::Window* pClientWindow = ImplGetClientWindow();
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 9f1e38c..2e54194 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -2767,8 +2767,6 @@ void Window::setPosSizePixel( long nX, long nY,
             nSysFlags |= SAL_FRAME_POSSIZE_WIDTH;
         if( nFlags & PosSizeFlags::Height )
             nSysFlags |= SAL_FRAME_POSSIZE_HEIGHT;
-        if( nFlags & PosSizeFlags::ByDrag )
-            nSysFlags |= SAL_FRAME_POSSIZE_BYDRAG;
         if( nFlags & PosSizeFlags::X )
         {
             nSysFlags |= SAL_FRAME_POSSIZE_X;
diff --git a/vcl/source/window/window2.cxx b/vcl/source/window/window2.cxx
index 9f988fd..4c42447 100644
--- a/vcl/source/window/window2.cxx
+++ b/vcl/source/window/window2.cxx
@@ -326,6 +326,12 @@ void Window::StartTracking( StartTrackingFlags nFlags )
     pSVData->maWinData.mpTrackWin   = this;
     pSVData->maWinData.mnTrackFlags = nFlags;
     CaptureMouse();
+
+    if (nFlags & StartTrackingFlags::UseToolKitDrag)
+    {
+        SalFrame* pFrame = mpWindowImpl->mpFrame;
+        pFrame->StartToolKitMoveBy();
+    }
 }
 
 void Window::EndTracking( TrackingEventFlags nFlags )
diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx
index 1e69fe3..bdd5499 100644
--- a/vcl/unx/gtk3/gtk3gtkframe.cxx
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
@@ -888,23 +888,6 @@ void GtkSalFrame::moveWindow( long nX, long nY )
         gtk_window_move( GTK_WINDOW(m_pWindow), nX, nY );
 }
 
-void GtkSalFrame::dragWindowTo(long nX, long nY)
-{
-    if (isChild(false))
-        moveWindow(nX, nY);
-    else
-    {
-#if defined(GDK_WINDOWING_WAYLAND)
-        if (GDK_IS_WAYLAND_DISPLAY(getGdkDisplay()))
-        {
-            gtk_window_begin_move_drag(GTK_WINDOW(m_pWindow), 1, nX, nY, GDK_CURRENT_TIME);
-            return;
-        }
-#endif
-        gtk_window_move(GTK_WINDOW(m_pWindow), nX, nY);
-    }
-}
-
 void GtkSalFrame::widget_set_size_request(long nWidth, long nHeight)
 {
     gtk_widget_set_size_request(GTK_WIDGET(m_pFixedContainer), nWidth, nHeight );
@@ -1649,10 +1632,7 @@ void GtkSalFrame::SetPosSize( long nX, long nY, long nWidth, long nHeight, sal_u
 
         m_bDefaultPos = false;
 
-        if (nFlags & SAL_FRAME_POSSIZE_BYDRAG)
-            dragWindowTo(nX, nY);
-        else
-            moveWindow(nX, nY);
+        moveWindow(nX, nY);
 
         updateScreenNumber();
     }
@@ -2564,6 +2544,26 @@ bool GtkSalFrame::HidePopover(sal_uIntPtr nId)
 #endif
 }
 
+void GtkSalFrame::StartToolKitMoveBy()
+{
+    GdkEvent *pEvent = gtk_get_current_event();
+    if (!pEvent)
+    {
+        SAL_WARN("vcl.gtk", "no current event for starting window move by wm");
+        return;
+    }
+    if (pEvent->type != GDK_BUTTON_PRESS)
+    {
+        SAL_WARN("vcl.gtk", "current event for starting window move by wm is not a button");
+        return;
+    }
+    gtk_window_begin_move_drag(GTK_WINDOW(m_pWindow),
+                               pEvent->button.button,
+                               pEvent->button.x_root,
+                               pEvent->button.y_root,
+                               pEvent->button.time);
+}
+
 gboolean GtkSalFrame::signalButton( GtkWidget*, GdkEventButton* pEvent, gpointer frame )
 {
     GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);


More information about the Libreoffice-commits mailing list