]> git.mxchange.org Git - flightgear.git/blobdiff - src/GUI/mouse.cxx
Fix line endings
[flightgear.git] / src / GUI / mouse.cxx
index 32eb57247b5300dda70139dce59470e7f48d31a3..28cdd35ec2bf746f6e9b9d8d943ccd3813bd2d69 100644 (file)
@@ -30,7 +30,7 @@
 
 #include <simgear/compiler.h>
 
-#ifdef FG_MATH_EXCEPTION_CLASH
+#ifdef SG_MATH_EXCEPTION_CLASH
 #  include <math.h>
 #endif
 
@@ -38,8 +38,7 @@
 #  include <windows.h>
 #endif
 
-#include <GL/glut.h>
-#include <simgear/xgl/xgl.h>
+#include <Main/fg_os.hxx>
 
 #if defined(FX) && defined(XMESA)
 #  include <GL/xmesa.h>
 
 #include <simgear/constants.h>
 #include <simgear/debug/logstream.hxx>
-#include <simgear/misc/fgpath.hxx>
-#include <simgear/screen/screen-dump.hxx>
+#include <simgear/misc/sg_path.hxx>
 
 #include <Include/general.hxx>
-//#include <Include/fg_memory.h>
 #include <Aircraft/aircraft.hxx>
+#include <Aircraft/controls.hxx>
 #include <Airports/simple.hxx>
-//#include <Autopilot/auto_gui.hxx>
-#include <Autopilot/newauto.hxx>
+#include <Autopilot/auto_gui.hxx>
 #include <Cockpit/panel.hxx>
-#include <Controls/controls.hxx>
 #include <FDM/flight.hxx>
 #include <Main/fg_init.hxx>
 #include <Main/fg_props.hxx>
-//#include <Main/views.hxx>
-//#include <Network/network.h>
-//#include <Time/fg_time.hxx>
-
-#if defined( WIN32 ) && !defined( __CYGWIN__ )
-#  include <simgear/screen/win32-printer.h>
-#  include <simgear/screen/GlBitmaps.h>
-#endif
+#include <Main/viewmgr.hxx>
 
 #include "gui.h"
 #include "gui_local.hxx"
 
-FG_USING_STD(string);
-
-#ifndef FG_HAVE_NATIVE_SGI_COMPILERS
-FG_USING_STD(cout);
-#endif
+SG_USING_STD(string);
+SG_USING_STD(cout);
 
 /* --------------------------------------------------------------------
 Mouse stuff
@@ -103,13 +89,10 @@ static int mouse_joystick_control = 0;
 // on second left click in MOUSE_VIEW mode
 // This has file scope so that it can be reset
 // if the little rodent is moved  NHV
-static  int _mVtoggle;
+static  int _mVtoggle = 0;
 
-// we break up the glutGetModifiers return mask
-// once per loop and stash what we need in these
-static int glut_active_shift;
-static int glut_active_ctrl;
-static int glut_active_alt;
+static int MOUSE_XSIZE = 0;
+static int MOUSE_YSIZE = 0;
 
 // uncomment this for view to exactly follow mouse in MOUSE_VIEW mode
 // else smooth out the view panning to .01 radian per frame
@@ -148,6 +131,12 @@ static double throttle_sensitivity = 1.0/250.0;
 static double rudder_sensitivity = 1.0/500.0;
 static double trim_sensitivity = 1.0/1000.0;
 
+void guiInitMouse(int width, int height)
+{
+       MOUSE_XSIZE = width;
+       MOUSE_YSIZE = height;
+}
+
 static inline int guiGetMouseButton(void)
 {
        return last_buttons;
@@ -160,36 +149,108 @@ static inline void guiGetMouse(int *x, int *y)
 };
 
 static inline int left_button( void ) {
-    return( last_buttons & (1 << GLUT_LEFT_BUTTON) );
+    return( last_buttons & (1 << MOUSE_BUTTON_LEFT) );
 }
 
 static inline int middle_button( void ) {
-    return( last_buttons & (1 << GLUT_MIDDLE_BUTTON) );
+    return( last_buttons & (1 << MOUSE_BUTTON_MIDDLE) );
 }
 
 static inline int right_button( void ) {
-    return( last_buttons & (1 << GLUT_RIGHT_BUTTON) );
+    return( last_buttons & (1 << MOUSE_BUTTON_RIGHT) );
+}
+
+static inline void set_goal_view_offset( float offset )
+{
+       globals->get_current_view()->setGoalHeadingOffset_deg(offset * SGD_RADIANS_TO_DEGREES);
+}
+
+static inline void set_view_offset( float offset )
+{
+       globals->get_current_view()->setHeadingOffset_deg(offset * SGD_RADIANS_TO_DEGREES);
+}
+
+static inline void set_goal_view_tilt( float tilt )
+{
+       globals->get_current_view()->setGoalPitchOffset_deg(tilt);
+}
+
+static inline void set_view_tilt( float tilt )
+{
+       globals->get_current_view()->setPitchOffset_deg(tilt);
+}
+
+static inline float get_view_offset() {
+       return globals->get_current_view()->getHeadingOffset_deg() * SGD_DEGREES_TO_RADIANS;
+}
+
+static inline float get_goal_view_offset() {
+       return globals->get_current_view()->getGoalHeadingOffset_deg() * SGD_DEGREES_TO_RADIANS;
+}
+
+static inline void move_brake(float offset) {
+       globals->get_controls()->move_brake_left(offset);
+       globals->get_controls()->move_brake_right(offset);
+}
+
+static inline void move_throttle(float offset) {
+       globals->get_controls()->move_throttle(FGControls::ALL_ENGINES, offset);
+}
+
+static inline void move_rudder(float offset) {
+       globals->get_controls()->move_rudder(offset);
+}
+
+static inline void move_elevator_trim(float offset) {
+       globals->get_controls()->move_elevator_trim(offset);
+}
+
+static inline void move_aileron(float offset) {
+       globals->get_controls()->move_aileron(offset);
+}
+
+static inline void move_elevator(float offset) {
+       globals->get_controls()->move_elevator(offset);
+}
+
+static inline float get_aileron() {
+       return globals->get_controls()->get_aileron();
+}
+
+static inline float get_elevator() {
+       return globals->get_controls()->get_elevator();
+}
+
+static inline bool AP_HeadingEnabled() {
+    static const SGPropertyNode *heading_enabled
+        = fgGetNode("/autopilot/locks/heading");
+    return ( strcmp( heading_enabled->getStringValue(), "" ) != 0 );
+}
+
+static inline bool AP_AltitudeEnabled() {
+    static const SGPropertyNode *altitude_enabled
+        = fgGetNode("/autopilot/locks/altitude");
+    return ( strcmp( altitude_enabled->getStringValue(), "" ) != 0 );
 }
 
 void TurnCursorOn( void )
 {
     mouse_active = ~0;
-#if defined(WIN32_CURSOR_TWEAKS)
+#if defined(WIN32)
     switch (mouse_mode) {
         case MOUSE_POINTER:
-            glutSetCursor(GLUT_CURSOR_INHERIT);
+            fgSetMouseCursor(MOUSE_CURSOR_POINTER);
             break;
         case MOUSE_YOKE:
-            glutSetCursor(GLUT_CURSOR_CROSSHAIR);
+            fgSetMouseCursor(MOUSE_CURSOR_CROSSHAIR);
             break;
         case MOUSE_VIEW:
-            glutSetCursor(GLUT_CURSOR_LEFT_RIGHT);
+            fgSetMouseCursor(MOUSE_CURSOR_LEFTRIGHT);
             break;
     }
 #endif
 #if defined(X_CURSOR_TWEAKS)
-    glutWarpPointer( fgGetInt("/sim/startup/xsize")/2,
-                    fgGetInt("/sim/startup/ysize")/2);
+    fgWarpMouse( MOUSE_XSIZE/2, MOUSE_YSIZE/2 );
 #endif
 }
 
@@ -197,16 +258,15 @@ void TurnCursorOff( void )
 {
     mouse_active = 0;
 #if defined(WIN32_CURSOR_TWEAKS)
-    glutSetCursor(GLUT_CURSOR_NONE);
+    fgSetMouseCursor(MOUSE_CURSOR_NONE);
 #elif defined(X_CURSOR_TWEAKS)
-    glutWarpPointer( fgGetInt("/sim/startup/xsize"),
-                    fgGetInt("/sim/startup/ysize"));
+    fgWarpMouse( MOUSE_XSIZE, MOUSE_YSIZE );
 #endif
 }
 
 void maybeToggleMouse( void )
 {
-#if defined(WIN32_CURSOR_TWEAKS)
+#if defined(WIN32_CURSOR_TWEAKS_OFF)
     static int first_time = ~0;
     static int mouse_changed = 0;
 
@@ -232,15 +292,15 @@ void maybeToggleMouse( void )
 // Call with FALSE to init and TRUE to restore
 void BusyCursor( int restore )
 {
-    static GLenum cursor = (GLenum) 0;
+    static int cursor = MOUSE_CURSOR_POINTER;
     if( restore ) {
-        glutSetCursor(cursor);
+        fgSetMouseCursor(cursor);
     } else {
-        cursor = (GLenum) glutGet( (GLenum) GLUT_WINDOW_CURSOR );
+        cursor = fgGetMouseCursor();
 #if defined(WIN32_CURSOR_TWEAKS)
         TurnCursorOn();
 #endif
-        glutSetCursor( GLUT_CURSOR_WAIT );
+        fgSetMouseCursor( MOUSE_CURSOR_WAIT );
     }
 }
 
@@ -249,32 +309,75 @@ void BusyCursor( int restore )
 void CenterView( void ) {
     if( mouse_mode == MOUSE_VIEW ) {
        mouse_mode = MOUSE_POINTER;
-       _savedX = fgGetInt("/sim/startup/xsize")/2;
-       _savedY = fgGetInt("/sim/startup/ysize")/2;
+       _savedX = MOUSE_XSIZE/2;
+       _savedY = MOUSE_YSIZE/2;
        _mVtoggle = 0;
        Quat0();
        build_rotmatrix(GuiQuat_mat, curGuiQuat);
-       glutSetCursor(GLUT_CURSOR_INHERIT);
+       fgSetMouseCursor(MOUSE_CURSOR_POINTER);
 
        // Is this necessary ??
+#if defined(FG_OLD_MENU)
        if( !gui_menu_on )   TurnCursorOff();
+#endif
 
-       glutWarpPointer( _savedX, _savedY );
+       fgWarpMouse( _savedX, _savedY );
     }
-    globals->get_current_view()->set_goal_view_offset(0.0);
-    globals->get_current_view()->set_view_offset(0.0);
+    set_goal_view_offset(0.0);
+    set_view_offset(0.0);
 }
 
 
+//#define TRANSLATE_HUD
+// temporary hack until pitch_offset is added to view pipeline
+void fgTranslateHud( void ) {
+#ifdef TRANSLATE_HUD
+    if(mouse_mode == MOUSE_VIEW) {
+
+        int ww = MOUSE_XSIZE;
+        int wh = MOUSE_YSIZE;
+
+        float y = 4*(_mY-(wh/2));// * ((wh/SGD_PI)*SG_RADIANS_TO_DEGREES);
+       
+        float x =  get_view_offset() * SG_RADIANS_TO_DEGREES;
+
+        if( x < -180 )     x += 360;
+        else if( x > 180 )     x -= 360;
+
+        x *= ww/90.0;
+        //     x *= ww/180.0;
+        //     x *= ww/360.0;
+
+        //     glTranslatef( x*ww/640, y*wh/480, 0 );
+        glTranslatef( x*640/ww, y*480/wh, 0 );
+    }
+#endif // TRANSLATE_HUD
+}
+
 void guiMotionFunc ( int x, int y )
 {
     int ww, wh, need_warp = 0;
     float W, H;
     double offset;
 
+    ww = MOUSE_XSIZE;
+    wh = MOUSE_YSIZE;
+
     if (mouse_mode == MOUSE_POINTER) {
+#if defined(FG_OLD_MENU)
+        // TURN MENU ON IF MOUSE AT TOP
+        if( y < 1 ) {
+            if( !gui_menu_on )
+                guiToggleMenu();                       
+        }
+        // TURN MENU OFF IF MOUSE AT BOTTOM
+        else if( y > wh-2 ) {
+            if( gui_menu_on )
+                guiToggleMenu();                       
+        }
+#endif
         puMouse ( x, y ) ;
-        glutPostRedisplay () ;
+        fgRequestRedraw () ;
     } else {
         if( x == _mX && y == _mY)
             return;
@@ -282,9 +385,6 @@ void guiMotionFunc ( int x, int y )
         // reset left click MOUSE_VIEW toggle feature
         _mVtoggle = 0;
         
-        ww = fgGetInt("/sim/startup/xsize");
-        wh = fgGetInt("/sim/startup/ysize");
-        
         switch (mouse_mode) {
             case MOUSE_YOKE:
                 if( !mouse_joystick_control ) {
@@ -292,27 +392,21 @@ void guiMotionFunc ( int x, int y )
                    fgSetString("/sim/control-mode", "mouse");
                 } else {
                     if ( left_button() ) {
-                        offset = (_mX - x) * brake_sensitivity;
-                        controls.move_brake(FGControls::ALL_WHEELS, offset);
-                        offset = (_mY - y) * throttle_sensitivity;
-                        controls.move_throttle(FGControls::ALL_ENGINES, offset);
+                        move_brake(   (_mX - x) * brake_sensitivity);
+                        move_throttle((_mY - y) * throttle_sensitivity);
                     } else if ( right_button() ) {
-                        if( ! current_autopilot->get_HeadingEnabled() ) {
-                            offset = (x - _mX) * rudder_sensitivity;
-                            controls.move_rudder(offset);
+                        if( ! AP_HeadingEnabled() ) {
+                            move_rudder((x - _mX) * rudder_sensitivity);
                         }
-                        if( ! current_autopilot->get_AltitudeEnabled() ) {
-                            offset = (_mY - y) * trim_sensitivity;
-                            controls.move_elevator_trim(offset);
+                        if( ! AP_AltitudeEnabled() ) {
+                            move_elevator_trim((_mY - y) * trim_sensitivity);
                         }
                     } else {
-                        if( ! current_autopilot->get_HeadingEnabled() ) {
-                            offset = (x - _mX) * aileron_sensitivity;
-                            controls.move_aileron(offset);
+                        if( ! AP_HeadingEnabled() ) {
+                            move_aileron((x - _mX) * aileron_sensitivity);
                         }
-                        if( ! current_autopilot->get_AltitudeEnabled() ) {
-                            offset = (_mY - y) * elevator_sensitivity;
-                            controls.move_elevator(offset);
+                        if( ! AP_AltitudeEnabled() ) {
+                            move_elevator((_mY - y) * elevator_sensitivity);
                         }
                     }
                 }
@@ -349,7 +443,7 @@ void guiMotionFunc ( int x, int y )
                     need_warp = 1;
                     x = 1;
                 }
-                // try to get FG_PI movement in each half of screen
+                // try to get SGD_PI movement in each half of screen
                 // do spherical pan
                 W = ww;
                 H = wh;
@@ -377,17 +471,19 @@ void guiMotionFunc ( int x, int y )
                 // do horizontal pan
                 // this could be done in above quat
                 // but requires redoing view pipeline
-                offset = globals->get_current_view()->get_goal_view_offset();
-                offset += ((_mX - x) * FG_2PI / W );
+                offset = get_goal_view_offset();
+                offset += ((_mX - x) * SGD_2PI / W );
                 while (offset < 0.0) {
-                    offset += FG_2PI;
+                    offset += SGD_2PI;
                 }
-                while (offset > FG_2PI) {
-                    offset -= FG_2PI;
+                while (offset > SGD_2PI) {
+                    offset -= SGD_2PI;
                 }
-                globals->get_current_view()->set_goal_view_offset(offset);
+                set_goal_view_offset(offset);
+                set_goal_view_tilt(asin( GuiQuat_mat[1][2]) * SGD_RADIANS_TO_DEGREES );
 #ifdef NO_SMOOTH_MOUSE_VIEW
-                globals->get_current_view()->set_view_offset(offset);
+                set_view_offset(offset);
+                set_view_tilt(asin( GuiQuat_mat[1][2]) * SGD_RADIANS_TO_DEGREES );
 #endif
                 break;
             
@@ -396,7 +492,7 @@ void guiMotionFunc ( int x, int y )
         }
     }
     if( need_warp)
-        glutWarpPointer(x, y);
+        fgWarpMouse(x, y);
     
     // Record the new mouse position.
     _mX = x;
@@ -406,7 +502,6 @@ void guiMotionFunc ( int x, int y )
 
 void guiMouseFunc(int button, int updown, int x, int y)
 {
-    int glutModifiers;
 
     // private MOUSE_VIEW state variables
     // to allow alternate left clicks in MOUSE_VIEW mode
@@ -416,17 +511,9 @@ void guiMouseFunc(int button, int updown, int x, int y)
     static float _quat[4];
     static double _view_offset;
     
-    // general purpose variables
-    double offset;
-            
-    glutModifiers = glutGetModifiers();
-    glut_active_shift = glutModifiers & GLUT_ACTIVE_SHIFT;
-    glut_active_ctrl  = glutModifiers & GLUT_ACTIVE_CTRL; 
-    glut_active_alt   = glutModifiers & GLUT_ACTIVE_ALT;
-    
     // Was the left button pressed?
-    if (updown == GLUT_DOWN ) {
-        if( button == GLUT_LEFT_BUTTON)
+    if ( updown == MOUSE_BUTTON_DOWN ) {
+        if( button == MOUSE_BUTTON_LEFT)
         {
             switch (mouse_mode) {
                 case MOUSE_POINTER:
@@ -440,13 +527,11 @@ void guiMouseFunc(int button, int updown, int x, int y)
                         _mY = _mVy;
                         x = _Vx;
                         y = _Vy;
-                        curGuiQuat[0] = _quat[0];
-                        curGuiQuat[1] = _quat[1];
-                        curGuiQuat[2] = _quat[2];
-                        curGuiQuat[3] = _quat[3];
-                        globals->get_current_view()->set_goal_view_offset(_view_offset);
+                        sgCopyVec4(curGuiQuat, _quat);
+                        set_goal_view_offset(_view_offset);
+                        set_goal_view_tilt(0.0);
 #ifdef NO_SMOOTH_MOUSE_VIEW
-                        globals->get_current_view()->set_view_offset(_view_offset);
+                        set_view_offset(_view_offset);
 #endif
                     } else {
                         // center view
@@ -454,85 +539,94 @@ void guiMouseFunc(int button, int updown, int x, int y)
                         _mVy = _mY;
                         _Vx = x;
                         _Vy = y;
-                        _quat[0] = curGuiQuat[0];
-                        _quat[1] = curGuiQuat[1];
-                        _quat[2] = curGuiQuat[2];
-                        _quat[3] = curGuiQuat[3];
-                        x = fgGetInt("/sim/startup/xsize")/2;
-                        y = fgGetInt("/sim/startup/ysize")/2;
+                        sgCopyVec4(_quat,curGuiQuat);
+                        x = MOUSE_XSIZE/2;
+                        y = MOUSE_YSIZE/2;
                         Quat0();
-                        _view_offset =
-                           globals->get_current_view()->get_goal_view_offset();
-                        globals->get_current_view()->set_goal_view_offset(0.0);
+                        _view_offset = get_goal_view_offset();
+                        set_goal_view_offset(0.0);
+                        set_goal_view_tilt(0.0);
 #ifdef NO_SMOOTH_MOUSE_VIEW
-                        globals->get_current_view()->set_view_offset(0.0);
+                        set_view_offset(0.0);
+                        set_view_tilt(0.0);
 #endif
                     }
-                    glutWarpPointer( x , y);
+                    fgWarpMouse( x , y);
                     build_rotmatrix(GuiQuat_mat, curGuiQuat);
                     _mVtoggle = ~_mVtoggle;
                     break;
             }
-        }else if ( button == GLUT_RIGHT_BUTTON) {
+        } else if ( button == MOUSE_BUTTON_RIGHT) {
             switch (mouse_mode) {
+                               
                 case MOUSE_POINTER:
+                    SG_LOG( SG_INPUT, SG_INFO, "Mouse in yoke mode" );
+                                       
                     mouse_mode = MOUSE_YOKE;
                     mouse_joystick_control = 0;
                     _savedX = x;
                     _savedY = y;
                     // start with zero point in center of screen
-                    _mX = fgGetInt("/sim/startup/xsize")/2;
-                    _mY = fgGetInt("/sim/startup/ysize")/2;
+                    _mX = MOUSE_XSIZE/2;
+                    _mY = MOUSE_YSIZE/2;
                     
                     // try to have the MOUSE_YOKE position
                     // reflect the current stick position
-                    offset = controls.get_aileron();
-                    x = _mX - (int)(offset * aileron_sensitivity);
-                    offset = controls.get_elevator();
-                    y = _mY - (int)(offset * elevator_sensitivity);
+                    x = _mX - (int)(get_aileron() * aileron_sensitivity);
+                    y = _mY - (int)(get_elevator() * elevator_sensitivity);
                     
-                    glutSetCursor(GLUT_CURSOR_CROSSHAIR);
-                    FG_LOG( FG_INPUT, FG_INFO, "Mouse in yoke mode" );
+                    fgSetMouseCursor(MOUSE_CURSOR_CROSSHAIR);
                     break;
                     
                 case MOUSE_YOKE:
+                    SG_LOG( SG_INPUT, SG_INFO, "Mouse in view mode" );
+                                       
                     mouse_mode = MOUSE_VIEW;
-                   fgSetString("/sim/control-mode", "joystick");
-                    x = fgGetInt("/sim/startup/xsize")/2;
-                    y = fgGetInt("/sim/startup/ysize")/2;
+                    fgSetString("/sim/control-mode", "joystick");
+                                       
+                                       // recenter cursor and reset 
+                    x = MOUSE_XSIZE/2;
+                    y = MOUSE_YSIZE/2;
                     _mVtoggle = 0;
+// #ifndef RESET_VIEW_ON_LEAVING_MOUSE_VIEW
                     Quat0();
                     build_rotmatrix(GuiQuat_mat, curGuiQuat);
-                    glutSetCursor(GLUT_CURSOR_LEFT_RIGHT);
-                    FG_LOG( FG_INPUT, FG_INFO, "Mouse in view mode" );
+// #endif
+                    fgSetMouseCursor(MOUSE_CURSOR_LEFTRIGHT);
                     break;
                     
                 case MOUSE_VIEW:
+                    SG_LOG( SG_INPUT, SG_INFO, "Mouse in pointer mode" );
+                                       
                     mouse_mode = MOUSE_POINTER;
                     x = _savedX;
                     y = _savedY;
 #ifdef RESET_VIEW_ON_LEAVING_MOUSE_VIEW
                     Quat0();
                     build_rotmatrix(GuiQuat_mat, curGuiQuat);
-                    globals->get_current_view()->set_goal_view_offset(0.0);
+                    set_goal_view_offset(0.0);
+                    set_goal_view_tilt(0.0);
 #ifdef NO_SMOOTH_MOUSE_VIEW
-                    globals->get_current_view()->set_view_offset(0.0);
-#endif
-#endif      // RESET_VIEW_ON_LEAVING_MOUSE_VIEW
-                    glutSetCursor(GLUT_CURSOR_INHERIT);
-                    
+                    set_view_offset(0.0);
+                    set_view_tilt(0.0);
+#endif // NO_SMOOTH_MOUSE_VIEW
+#endif // RESET_VIEW_ON_LEAVING_MOUSE_VIEW
+                    fgSetMouseCursor(MOUSE_CURSOR_POINTER);
+
+#if defined(FG_OLD_MENU)                    
+#if defined(WIN32_CURSOR_TWEAKS_OFF)
                     if(!gui_menu_on)
                         TurnCursorOff();
-                    
-                    FG_LOG( FG_INPUT, FG_INFO, "Mouse in pointer mode" );
+#endif // WIN32_CURSOR_TWEAKS_OFF
+#endif // FG_OLD_MENU
                     break;
-            }     
-            glutWarpPointer( x, y );
+            } // end switch (mouse_mode)
+            fgWarpMouse( x, y );
         } // END RIGHT BUTTON
-    } // END UPDOWN == GLUT_DOWN
+    } // END MOUSE DOWN
     
-    // Note which button is pressed.
-    if ( updown == GLUT_DOWN ) {
+    // Update the button state
+    if ( updown == MOUSE_BUTTON_DOWN ) {
         last_buttons |=  ( 1 << button ) ;
     } else {
         last_buttons &= ~( 1 << button ) ;
@@ -541,8 +635,10 @@ void guiMouseFunc(int button, int updown, int x, int y)
     // If we're in pointer mode, let PUI
     // know what's going on.
     if (mouse_mode == MOUSE_POINTER) {
-      if (!puMouse (button, updown, x,y)) {
-       current_panel->doMouseAction(button, updown, x, y);
+      if (!puMouse (button, updown , x,y)) {
+        if ( globals->get_current_panel() != NULL ) {
+          globals->get_current_panel()->doMouseAction(button, updown, x, y);
+        }
       }
     }
     
@@ -551,6 +647,9 @@ void guiMouseFunc(int button, int updown, int x, int y)
     _mX = x;
     _mY = y;
     
-    glutPostRedisplay ();
+    fgRequestRedraw ();
 }
 
+
+
+