Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1240


Ignore:
Timestamp:
May 6, 2008, 4:51:32 PM (16 years ago)
Author:
rgrieder
Message:

completed that SignalHandler thingy: XAutoKeyRepeat is now restored if orxonox and with it OIS crashes

Location:
code/branches/input/src/core
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/input/src/core/CorePrereqs.h

    r1238 r1240  
    149149  class InputManager;
    150150  class JoyStickHandler;
    151   class JoyStickState;
    152151  class KeyBinder;
    153   class KeyEvent;
    154152  class KeyHandler;
    155153  class MouseHandler;
    156   class MouseState;
    157154
    158155}
  • code/branches/input/src/core/SignalHandler.cc

    r1238 r1240  
    4444
    4545#include <wait.h>
     46#include <X11/Xlib.h>
     47#include <X11/Xutil.h>
     48#include <X11/keysym.h>
     49
     50bool SignalHandler::bXAutoKeyRepeatOn_ = false;
    4651
    4752SignalHandler::SignalHandler()
     
    6065
    6166  // prepare for restoring XAutoKeyRepeat
    62         if (display_ = XOpenDisplay(0))
    63   {
    64                 XGetKeyboardControl( display_, &bXAutoKeyRepeatOn_ );
    65                 XCloseDisplay(display_);
     67    Display* display;
     68        if ((display = XOpenDisplay(0)))
     69  {
     70            XKeyboardState oldState;
     71                XGetKeyboardControl(display, &oldState);
     72                if (oldState.global_auto_repeat == AutoRepeatModeOn)
     73          bXAutoKeyRepeatOn_ = true;
     74                else
     75                  bXAutoKeyRepeatOn_ = false;
     76                XCloseDisplay(display);
    6677  }
    6778  else
    6879  {
    6980    std::cout << "Warning: couldn't open X display to restore XAutoKeyRepeat." << std::endl;
    70     XAutoKeyRepeatOn_ = false;
     81    bXAutoKeyRepeatOn_ = false;
    7182  }
    7283
     
    136147  }
    137148
    138   if (XAutoKeyRepeatOn_)
     149  if (bXAutoKeyRepeatOn_)
    139150  {
    140151    std::cout << "Trying to restore XAutoKeyRepeat" << std::endl;
    141           if (display_ = XOpenDisplay(0))
    142     {
    143                         XAutoRepeatOn(display_);
    144                   XCloseDisplay(display_);
     152        Display* display;
     153          if ((display = XOpenDisplay(0)))
     154    {
     155                        XAutoRepeatOn(display);
     156                  XCloseDisplay(display);
    145157    }
    146158  }
  • code/branches/input/src/core/SignalHandler.h

    r1238 r1240  
    4444#ifndef __WIN32__
    4545#include <signal.h>
    46 #include <X11/Xlib.h>
    4746
    4847struct SignalRec
     
    8887    std::string fileName;
    8988
    90     // X Display, used to turn on KeyAutoRepeat if OIS crashes
    91                 Display *display_;
    92     bool bXAutoKeyRepeatOn_;
     89    // used to turn on KeyAutoRepeat if OIS crashes
     90    static bool bXAutoKeyRepeatOn_;
    9391};
    9492
Note: See TracChangeset for help on using the changeset viewer.