Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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  }
Note: See TracChangeset for help on using the changeset viewer.