← Back to team overview

kicad-developers team mailing list archive

Group selection not working with fluxbox, windowmaker (patch included)

 

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello everyone,

I have come across the same problem as Jacques mentioned in
http://tech.dir.groups.yahoo.com/group/kicad-users/message/7780 - group
selection does not work, dragging the mouse with left button pressed
shows no reaction. This was on gentoo linux, fluxbox 1.0.0,
wxGTK-2.8.10.1-r5 and I also tried it with windowmaker. Strangely,
dragging the middle mouse button for zooming works...

After reading his "solution" in
http://tech.dir.groups.yahoo.com/group/kicad-users/message/7781 I also
tried xfce and with xfce this works.

But that's no solution for me, I don't want to switch window managers
just for pcb layout.

So I started digging into the code. Pretty soon found the culprit to be
somewhere in common/drawpanel.cpp. Added some debugging here and there,
I compared the output on xfce and fluxbox, and found: Using fluxbox, a
left mouse click generates two wxMouseEvents - one with Entering() set
and one with LeftDown() set, both have LeftIsDown() set. Now the first
one sets m_CanStartBlock to -1 and this does not get reset until the
mouse button is released. Voila, and although this probably is a bug in
either (fluxbox, windowmaker, fvwm) or wxWidgets, I wrote a small patch
against SVN2518 for kicad anyway, because I know where to work around
this problem in kicad :)

This is my first patch and actually my first contribution to someone
else's code, so please be kind in telling me what I'm doing wrong...

The first hunk only has some #defines for activating debugging and for
activating/deactivating my workaround. The second hunk contains both the
debugging output and the workaround.

This does not cripple anything for me as neither with fluxbox nor with
xfce I get a MouseEvent with Entering() set when the mouse enters the
panel while the left mouse button is held. I have not tested this on
Windows, though - but still, it can easily be deactivated...

I also attached the patchfile (fluxbox_events.patch), so you don't need
to rebuild newlines from this email message...

- --- kicad/common/drawpanel.cpp  2010-08-13 15:15:02.000000000 +0200
+++ kicad_new/common/drawpanel.cpp      2010-08-13 15:04:14.000000000 +0200
@@ -27,7 +27,11 @@
 #define DEBUG_SHOW_CLIP_RECT       0  // Set to 1 to draw clipping
rectangle.
 #define DEBUG_DUMP_CLIP_COORDS     0  // Set to 1 to dump clipping
rectangle coordinates.
 #define DEBUG_DUMP_SCROLL_SETTINGS 0  // Set to 1 to dump scroll settings.
+#define DEBUG_BLOCKS               0  // Set to 1 to dump block information

+/* Definitions for workarounds in drawpanel.cpp */
+#define FLUXBOX_WORKAROUND         1  // Set to 1 to enable group/block
actions on fluxbox, windowmaker, fvwm and probably others
+                                      // with this, we ignore mouse
entering events if the left button is pressed

 /* Used to inhibit a response to a mouse left button release, after a
  * double click (when releasing the left button at the end of the second
@@ -1042,8 +1046,21 @@ void WinEDA_DrawPanel::OnMouseEvent( wxM
      * MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND in order to avoid
spurious block
      * commands. */
     static int MinDragEventCount;
+#if DEBUG_BLOCKS
+        std::cout << "Left button pressed: " << event.LeftDown() << "
Middle button pressed: " << event.MiddleDown() << std::endl
+                << "Left button down: " << event.LeftIsDown() <<
"Middle Button down: " << event.MiddleIsDown() << std::endl
+                << "event.Leaving: " << event.Leaving() << "
event.Entering:" << event.Entering() << " Can start block: " <<
m_CanStartBlock << std::endl << std::endl;
+#endif
     if( event.Leaving() || event.Entering() )
     {
+#if FLUXBOX_WORKAROUND
+        // when using fluxbox (and probably windowmaker, fwvm) we get
two events on a mouse left click. Ignore the entering event in this case.
+        // (there won't be an event on entering until we release the
left mouse button anyway)
+        if(event.LeftIsDown())
+        {
+            return;
+        }
+#endif
         m_CanStartBlock = -1;
     }

While I was trying to unterstand the code, I also replaced some magic
numbers with the "correct" symbolic names. While this is no really big
deal, it improves the code readability, so please consider including the
following little patch, also attached as magic_numbers_cleanup.patch:

- --- kicad/common/drawpanel.cpp  2010-08-13 15:15:02.000000000 +0200
+++ kicad_new/common/drawpanel.cpp      2010-08-13 15:04:14.000000000 +0200
@@ -1147,7 +1164,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxM
         s_IgnoreNextLeftButtonRelease = false;
     }

- -    if( event.ButtonUp( 2 )
+    if( event.ButtonUp( wxMOUSE_BTN_MIDDLE )
        && (screen->m_BlockLocate.m_State == STATE_NO_BLOCK) )
     {
         // The middle button has been released, with no block command:
@@ -1250,7 +1267,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxM
             }
         }

- -        if( event.ButtonUp( 1 ) || event.ButtonUp( 2 ) )
+        if( event.ButtonUp( wxMOUSE_BTN_LEFT ) || event.ButtonUp(
wxMOUSE_BTN_MIDDLE ) )
         {
             /* Release the mouse button: end of block.
              * The command can finish (DELETE) or have a next command
(MOVE,

Regards,
Heiko

- -- 
eMails verschlüsseln mit PGP - privacy is your right!
Mein PGP-Key zur Verifizierung: http://pgp.mit.edu

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxlThcACgkQ/Vb5NagElAV3AACdFxQhZ+d9zcUwO/vhL3zm2T/p
n1sAn3Lb9H+tVLY0kJD7f45G2zzPCTJj
=V/JW
-----END PGP SIGNATURE-----
--- kicad/common/drawpanel.cpp	2010-08-13 15:15:02.000000000 +0200
+++ kicad_new/common/drawpanel.cpp	2010-08-13 15:04:14.000000000 +0200
@@ -27,7 +27,11 @@
 #define DEBUG_SHOW_CLIP_RECT       0  // Set to 1 to draw clipping rectangle.
 #define DEBUG_DUMP_CLIP_COORDS     0  // Set to 1 to dump clipping rectangle coordinates.
 #define DEBUG_DUMP_SCROLL_SETTINGS 0  // Set to 1 to dump scroll settings.
+#define DEBUG_BLOCKS               0  // Set to 1 to dump block information
 
+/* Definitions for workarounds in drawpanel.cpp */
+#define FLUXBOX_WORKAROUND         1  // Set to 1 to enable group/block actions on fluxbox, windowmaker, fvwm and probably others
+                                      // with this, we ignore mouse entering events if the left button is pressed
 
 /* Used to inhibit a response to a mouse left button release, after a
  * double click (when releasing the left button at the end of the second
@@ -1042,8 +1046,21 @@ void WinEDA_DrawPanel::OnMouseEvent( wxM
      * MIN_DRAG_COUNT_FOR_START_BLOCK_COMMAND in order to avoid spurious block
      * commands. */
     static int MinDragEventCount;
+#if DEBUG_BLOCKS
+        std::cout << "Left button pressed: " << event.LeftDown() << " Middle button pressed: " << event.MiddleDown() << std::endl
+                << "Left button down: " << event.LeftIsDown() << "Middle Button down: " << event.MiddleIsDown() << std::endl
+                << "event.Leaving: " << event.Leaving() << " event.Entering:" << event.Entering() << " Can start block: " << m_CanStartBlock << std::endl << std::endl;
+#endif
     if( event.Leaving() || event.Entering() )
     {
+#if FLUXBOX_WORKAROUND
+        // when using fluxbox (and probably windowmaker, fwvm) we get two events on a mouse left click. Ignore the entering event in this case.
+        // (there won't be an event on entering until we release the left mouse button anyway)
+        if(event.LeftIsDown())
+        {
+            return;
+        }
+#endif
         m_CanStartBlock = -1;
     }
 
--- kicad/common/drawpanel.cpp	2010-08-13 15:15:02.000000000 +0200
+++ kicad_new/common/drawpanel.cpp	2010-08-13 15:04:14.000000000 +0200
@@ -1147,7 +1164,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxM
         s_IgnoreNextLeftButtonRelease = false;
     }
 
-    if( event.ButtonUp( 2 )
+    if( event.ButtonUp( wxMOUSE_BTN_MIDDLE )
        && (screen->m_BlockLocate.m_State == STATE_NO_BLOCK) )
     {
         // The middle button has been released, with no block command:
@@ -1250,7 +1267,7 @@ void WinEDA_DrawPanel::OnMouseEvent( wxM
             }
         }
 
-        if( event.ButtonUp( 1 ) || event.ButtonUp( 2 ) )
+        if( event.ButtonUp( wxMOUSE_BTN_LEFT ) || event.ButtonUp( wxMOUSE_BTN_MIDDLE ) )
         {
             /* Release the mouse button: end of block.
              * The command can finish (DELETE) or have a next command (MOVE,

Attachment: fluxbox_events.patch.sig
Description: PGP signature

Attachment: magic_numbers_cleanup.patch.sig
Description: PGP signature


Follow ups