~sil2100/nux/precise_sru-1

« back to all changes in this revision

Viewing changes to NuxGraphics/GraphicsDisplayX11.cpp

  • Committer: Didier Roche
  • Date: 2012-02-03 07:31:02 UTC
  • mfrom: (159.3.33)
  • Revision ID: didier.roche@canonical.com-20120203073102-2dhbgqyn99885shx
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1024
1024
      _mouse_state |= (xevent.xcrossing.state & Button2Mask) ? NUX_STATE_BUTTON2_DOWN : 0;
1025
1025
      _mouse_state |= (xevent.xcrossing.state & Button3Mask) ? NUX_STATE_BUTTON3_DOWN : 0;
1026
1026
    }
1027
 
 
1028
1027
    m_pEvent->mouse_state = _mouse_state;
1029
1028
 
1030
1029
    return 0;
1229
1228
    if (XPending(m_X11Display))
1230
1229
    {
1231
1230
      XNextEvent(m_X11Display, &xevent);
 
1231
 
 
1232
      if (!_event_filters.empty())
 
1233
      {
 
1234
        for (auto filter : _event_filters)
 
1235
        {
 
1236
          bool result = filter.filter(xevent, filter.data);
 
1237
          if (result)
 
1238
          {
 
1239
            memcpy(evt, m_pEvent, sizeof(Event));
 
1240
            return;
 
1241
          }
 
1242
        }
 
1243
      }
1232
1244
      // Detect auto repeat keys. X11 sends a combination of KeyRelease/KeyPress(at the same time) when a key auto repeats.
1233
1245
      // Here, we make sure we process only the keyRelease when the key is effectively released.
1234
1246
      if ((xevent.type == KeyPress) || (xevent.type == KeyRelease))
1294
1306
    ProcessXEvent(xevent, false);
1295
1307
    memcpy(evt, m_pEvent, sizeof(Event));
1296
1308
  }
 
1309
 
 
1310
  void GraphicsDisplay::AddEventFilter(EventFilterArg arg)
 
1311
  {
 
1312
    _event_filters.push_back(arg);
 
1313
  }
 
1314
 
 
1315
  void GraphicsDisplay::RemoveEventFilter(void *owner)
 
1316
  {
 
1317
    std::list<EventFilterArg>::iterator it;
 
1318
    for (it = _event_filters.begin(); it != _event_filters.end(); ++it)
 
1319
    {
 
1320
      if ((*it).data == owner)
 
1321
      {
 
1322
        _event_filters.erase(it);
 
1323
        break;
 
1324
      }
 
1325
    }
 
1326
  }
1297
1327
#endif
1298
1328
 
1299
1329
  void GraphicsDisplay::ProcessForeignX11Event(XEvent *xevent, Event *nux_event)
1380
1410
 
1381
1411
  void GraphicsDisplay::RecalcXYPosition(Window TheMainWindow, XEvent xevent, int &x_recalc, int &y_recalc)
1382
1412
  {
 
1413
    x_recalc = y_recalc = 0;
1383
1414
    int main_window_x = m_WindowPosition.x;
1384
1415
    int main_window_y = m_WindowPosition.y;
1385
1416
    bool same = (TheMainWindow == xevent.xany.window);
1432
1463
        }
1433
1464
        break;
1434
1465
      }
1435
 
      
1436
 
      default:
1437
 
      {
1438
 
        x_recalc = y_recalc = 0;
1439
 
      }
1440
1466
    }
1441
1467
  }
1442
1468
 
1453
1479
    m_pEvent->type = NUX_NO_EVENT;
1454
1480
    m_pEvent->x11_window = xevent.xany.window;
1455
1481
 
1456
 
 
1457
1482
    switch(xevent.type)
1458
1483
    {
1459
1484
      case DestroyNotify:
1682
1707
        {
1683
1708
          //nuxDebugMsg("[GraphicsDisplay::ProcessXEvents]: MapNotify event.");
1684
1709
          m_pEvent->type = NUX_WINDOW_MAP;
1685
 
 
1686
 
          XSetInputFocus(xevent.xany.display,
1687
 
                          xevent.xany.window,
1688
 
                          RevertToParent,
1689
 
                          CurrentTime);
1690
 
 
1691
1710
        }
1692
1711
        
1693
1712
        break;
2727
2746
  }
2728
2747
 
2729
2748
}
2730
 
 
2731