Changeset 20931

Show
Ignore:
Timestamp:
11/18/07 13:16:42 (1 year ago)
Author:
patrick
Message:

Fixed coding standard violations. Improved debug output. Wrapped a few long
lines. No functional changes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • juggler/trunk/modules/gadgeteer/gadget/Devices/KeyboardMouseDevice/InputWindowXWin.cpp

    r20930 r20931  
    5454bool InputWindowXWin::config(jccl::ConfigElementPtr e) 
    5555{ 
    56    unsigned required_definition_ver(1); 
    57  
    58    if (e->getVersion() < required_definition_ver
     56   const unsigned required_definition_ver(1); 
     57 
     58   if ( e->getVersion() < required_definition_ver
    5959   { 
    6060      vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) 
     
    102102      << std::endl << vprDEBUG_FLUSH; 
    103103 
    104    if (NULL == disp_sys_elt.get()
     104   if ( NULL == disp_sys_elt.get()
    105105   { 
    106106      vprDEBUG(vprDBG_ERROR, vprDBG_CONFIG_LVL) 
     
    139139   } 
    140140 
    141    if ((mXDisplayString.empty()) || (strcmp(mXDisplayString.c_str(), neg_one_STRING) == 0))    // Use display env 
    142    { 
     141   if ( mXDisplayString.empty() || 
     142        strcmp(mXDisplayString.c_str(), neg_one_STRING) == 0 ) 
     143   { 
     144      // Use the value of the DISPLAY environment variable. 
    143145      const std::string DISPLAY_str("DISPLAY"); 
    144146      vpr::System::getenv(DISPLAY_str, mXDisplayString); 
    145147   } 
     148 
    146149   return true; 
    147150} 
     
    149152bool InputWindowXWin::startSampling() 
    150153{ 
    151    if (mThread != NULL
    152    { 
    153       vprDEBUG(vprDBG_ERROR,vprDBG_CRITICAL_LVL) 
    154          << clrOutNORM(clrRED,"ERROR") 
    155          << ": gadget::InputWindowXWin: startSampling called, when already sampling.\n
    156          << vprDEBUG_FLUSH; 
     154   if ( NULL != mThread
     155   { 
     156      vprDEBUG(vprDBG_ERROR, vprDBG_CRITICAL_LVL) 
     157         << clrOutNORM(clrRED, "ERROR") 
     158         << ": [gadget::InputWindowXWin::startSampling]
     159         << "Called when already sampling.\n" << vprDEBUG_FLUSH; 
    157160      vprASSERT(false); 
    158161   } 
     
    184187{ 
    185188   // If there is a thread for us and we actually own the window 
    186    if (mThread != NULL
     189   if ( NULL != mThread
    187190   { 
    188191      mExitFlag = true; 
     
    206209void InputWindowXWin::controlLoop() 
    207210{ 
    208    vprDEBUG(gadgetDBG_INPUT_MGR,vprDBG_STATE_LVL) 
    209       << "gadget::InputWindowXWin::controlLoop: Thread started.\n" 
     211   vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL) 
     212      << "[gadget::InputWindowXWin::controlLoop()] Thread started.\n" 
    210213      << vprDEBUG_FLUSH; 
    211214 
    212    while (NULL == vpr::Thread::self()
     215   while ( NULL == vpr::Thread::self()
    213216   { 
    214217      vpr::System::usleep(50); 
    215       vprDEBUG(vprDBG_ALL,vprDBG_VERB_LVL) 
    216          << "gadget::InputWindowXWin: Waiting for (thread::self() != NULL)\n
    217          << vprDEBUG_FLUSH; 
     218      vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL) 
     219         << "[gadget::InputWindowXWin::controlLoop()]
     220         << "Waiting for (thread::self() != NULL)\n" << vprDEBUG_FLUSH; 
    218221   } 
    219222   mThread = (vpr::Thread*) vpr::Thread::self(); 
     
    228231   XSync(mXDisplay, 0); 
    229232 
    230    // If we have initial locked, then we need to lock the system 
    231    if (mLockState == Lock_LockKey)      // Means that we are in the initially locked state 
    232    { 
    233       vprDEBUG(gadgetDBG_INPUT_MGR,vprDBG_STATE_LVL) 
    234          << "gadget::InputWindowXWin::controlLoop: Mouse set to initial lock. Locking it now.\n
    235          << vprDEBUG_FLUSH; 
    236       lockMouse( NULL );                     // Lock the mouse 
     233   // If we have initial locked, then we need to lock the system. 
     234   if ( mLockState == Lock_LockKey ) 
     235   { 
     236      vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_STATE_LVL) 
     237         << "[gadget::InputWindowXWin::controlLoop()]
     238         << "Mouse set to initial lock. Locking it now.\n" << vprDEBUG_FLUSH; 
     239      lockMouse(NULL);                     // Lock the mouse 
    237240   } 
    238241 
    239242   // Loop on updating 
    240    while (!mExitFlag
     243   while ( ! mExitFlag
    241244   { 
    242245      sample(); 
    243       long usleep_time(1); // to be set... 
    244  
    245       usleep_time = mSleepTimeMS*1000; 
    246  
    247       vpr::System::usleep(usleep_time); 
     246      vpr::System::usleep(mSleepTimeMS * 1000); 
    248247   } 
    249248 
     
    259258   XCloseDisplay((::Display*) mXDisplay); 
    260259} 
    261  
    262260 
    263261/*****************************************************************/ 
     
    269267bool InputWindowXWin::openLocalWindow() 
    270268{ 
    271    int i; 
    272  
    273269   mXDisplay = XOpenDisplay(mXDisplayString.c_str());    // Open display on given XDisplay 
    274    if (NULL == mXDisplay
     270   if ( NULL == mXDisplay
    275271   { 
    276272      vprDEBUG(vprDBG_ERROR, vprDBG_CRITICAL_LVL) 
     
    279275         << "Failed to open display '" << mXDisplayString << "'" << std::endl 
    280276         << vprDEBUG_FLUSH; 
    281       return 0
     277      return false
    282278   } 
    283279 
    284280   mScreen = DefaultScreen(mXDisplay); 
    285281 
    286    XVisualInfo vTemplate, *vis_infos
    287    long vMask = VisualScreenMask
    288    vTemplate.screen = mScreen
    289    int nVisuals; 
    290  
    291    vis_infos = XGetVisualInfo(mXDisplay, vMask, &vTemplate, &nVisuals); 
     282   XVisualInfo vi_template
     283   vi_template.screen = mScreen
     284   int num_visuals(0)
     285 
     286   XVisualInfo* vis_infos = XGetVisualInfo(mXDisplay, VisualScreenMask, 
     287                                           &vi_template, &num_visuals); 
    292288 
    293289   // Verify that we got at least one visual from XGetVisualInfo(3). 
    294    if ( vis_infos != NULL && nVisuals >= 1 ) 
     290   if ( vis_infos != NULL && num_visuals >= 1 ) 
    295291   { 
    296292      XVisualInfo* p_visinfo; 
     293      int i; 
    297294 
    298295      // Try to find a visual with color depth of at least 8 bits.  Having 
    299296      // such a visual ensures that the input windows at least have a 
    300297      // black background. 
    301       for ( i = 0, p_visinfo = vis_infos; i < nVisuals; i++, p_visinfo++
     298      for ( i = 0, p_visinfo = vis_infos; i < num_visuals; ++i, ++p_visinfo
    302299      { 
    303300         if ( p_visinfo->depth >= 8 ) 
     
    310307      // If we couldn't find a visual with at least 8-bit color, just use the 
    311308      // first one in the list. 
    312       if ( i == nVisuals ) 
     309      if ( i == num_visuals ) 
    313310      { 
    314311          mVisual = vis_infos; 
     
    322319         << ": [gadget::InputWindowXWin::openTheWindow()] find visual failed" 
    323320         << std::endl << vprDEBUG_FLUSH; 
    324       return 0
     321      return false
    325322   } 
    326323 
     
    354351   XFree(vis_infos); 
    355352 
    356    return 1
     353   return true
    357354} 
    358355 
     
    408405   status = XStringListToTextProperty(&window_name, 1, &w_name); 
    409406 
    410    if (0 == status
     407   if ( 0 == status
    411408   { 
    412409      vprDEBUG(vprDBG_ERROR, vprDBG_CRITICAL_LVL) 
     
    418415   status = XStringListToTextProperty(&icon_name, 1, &i_name); 
    419416 
    420    if (0 == status
     417   if ( 0 == status
    421418   { 
    422419      vprDEBUG(vprDBG_ERROR, vprDBG_CRITICAL_LVL)