From 869bdc2b3c8af5105c4a521c900c2e4e7e5fc25a Mon Sep 17 00:00:00 2001
From: jean-pierre charras <jp.charras@wanadoo.fr>
Date: Tue, 12 Feb 2019 13:10:30 +0100
Subject: [PATCH] Eeschema: regression fix: re-enable hold down control+shift
 to disable grid snapping when moving the mouse.

Fixes: lp:1815487
https://bugs.launchpad.net/kicad/+bug/1815487
---
 eeschema/controle.cpp           |  6 +++---
 eeschema/libedit/controller.cpp |  6 ++++--
 eeschema/sch_draw_panel.cpp     |  1 -
 include/view/view_controls.h    | 10 +++++++++-
 4 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp
index caf7c7bac1..eab621a48e 100644
--- a/eeschema/controle.cpp
+++ b/eeschema/controle.cpp
@@ -1,9 +1,9 @@
 /*
  * This program source code file is part of KiCad, a free EDA CAD application.
  *
- * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
+ * Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
  * Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
- * Copyright (C) 2004-2016 KiCad Developers, see AUTHORS.txt for contributors.
+ * Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -253,7 +253,6 @@ bool SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KE
         return false;
     }
 
-
     // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed
     // for next cursor position
     // ( shift or ctrl key down are PAN command with mouse wheel)
@@ -274,6 +273,7 @@ bool SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KE
     else
         m_canvas->CrossHairOn( aDC );
 
+    GetGalCanvas()->GetViewControls()->SetSnapping( snapToGrid );
     SetCrossHairPosition( pos, snapToGrid );
 
     if( m_canvas->IsMouseCaptured() )
diff --git a/eeschema/libedit/controller.cpp b/eeschema/libedit/controller.cpp
index 4501ae40a9..506678f1b6 100644
--- a/eeschema/libedit/controller.cpp
+++ b/eeschema/libedit/controller.cpp
@@ -1,9 +1,9 @@
 /*
  * This program source code file is part of KiCad, a free EDA CAD application.
  *
- * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
+ * Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
  * Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
- * Copyright (C) 2004-2016 KiCad Developers, see AUTHORS.txt for contributors.
+ * Copyright (C) 2004-2019 KiCad Developers, see AUTHORS.txt for contributors.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -43,6 +43,7 @@
 #include <sch_sheet_path.h>
 #include <sch_marker.h>
 #include <sch_component.h>
+#include <sch_view.h>
 
 bool LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KEY aHotKey )
 {
@@ -73,6 +74,7 @@ bool LIB_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, EDA_KE
     else
         m_canvas->CrossHairOn( aDC );
 
+    GetGalCanvas()->GetViewControls()->SetSnapping( snapToGrid );
     SetCrossHairPosition( pos, snapToGrid );
 
     if( m_canvas->IsMouseCaptured() )
diff --git a/eeschema/sch_draw_panel.cpp b/eeschema/sch_draw_panel.cpp
index e4fbfbe30f..29f35cd885 100644
--- a/eeschema/sch_draw_panel.cpp
+++ b/eeschema/sch_draw_panel.cpp
@@ -535,7 +535,6 @@ void SCH_DRAW_PANEL::OnMouseEvent( wxMouseEvent& event )
     }
 
     lastPanel = this;
-
 }
 
 
diff --git a/include/view/view_controls.h b/include/view/view_controls.h
index 6fe840a713..fa374ed9ee 100644
--- a/include/view/view_controls.h
+++ b/include/view/view_controls.h
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 2012 Torsten Hueter, torstenhtr <at> gmx.de
  * Copyright (C) 2013 CERN
- * Copyright (C) 2013-2016 KiCad Developers, see AUTHORS.txt for contributors.
+ * Copyright (C) 2013-2019 KiCad Developers, see AUTHORS.txt for contributors.
  *
  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
  *
@@ -128,6 +128,14 @@ public:
         m_settings.m_snappingEnabled = aEnabled;
     }
 
+    /**
+     * @return the current state of the snapping cursor to grid.
+     */
+    virtual bool GetSnappingState()
+    {
+        return m_settings.m_snappingEnabled;
+    }
+
     /**
      * Function SetGrabMouse
      * Turns on/off mouse grabbing. When the mouse is grabbed, it cannot go outside the VIEW.