Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 288125 | Differences between
and this patch

Collapse All | Expand All

(-)a/backend/src/unix/X11InputMonitor.cc (-12 / +95 lines)
Lines 1-6 Link Here
1
// X11InputMonitor.cc --- ActivityMonitor for X11
1
// X11InputMonitor.cc --- ActivityMonitor for X11
2
//
2
//
3
// Copyright (C) 2001-2007 Rob Caelers <robc@krandor.nl>
3
// Copyright (C) 2001-2007, 2009 Rob Caelers <robc@krandor.nl>
4
// All rights reserved.
4
// All rights reserved.
5
//
5
//
6
// This program is free software: you can redistribute it and/or modify
6
// This program is free software: you can redistribute it and/or modify
Lines 63-68 static const char rcsid[] = "$Id$"; Link Here
63
#include <X11/Xproto.h>
63
#include <X11/Xproto.h>
64
#include <X11/Xlib.h>
64
#include <X11/Xlib.h>
65
#include <X11/extensions/XInput.h>
65
#include <X11/extensions/XInput.h>
66
#include <X11/extensions/XIproto.h>
66
#include <X11/Intrinsic.h>
67
#include <X11/Intrinsic.h>
67
#include <X11/Xos.h>
68
#include <X11/Xos.h>
68
#include <X11/Xmu/Error.h>
69
#include <X11/Xmu/Error.h>
Lines 80-85 static const char rcsid[] = "$Id$"; Link Here
80
81
81
using namespace std;
82
using namespace std;
82
83
84
int X11InputMonitor::xi_event_base = 0;
85
83
#ifndef HAVE_APP_GTK
86
#ifndef HAVE_APP_GTK
84
//! Intercepts X11 protocol errors.
87
//! Intercepts X11 protocol errors.
85
static int
88
static int
Lines 438-444 X11InputMonitor::handle_xrecord_handle_motion_event(XRecordInterceptData *data) Link Here
438
    }
441
    }
439
}
442
}
440
443
441
442
void
444
void
443
X11InputMonitor::handle_xrecord_handle_button_event(XRecordInterceptData *data)
445
X11InputMonitor::handle_xrecord_handle_button_event(XRecordInterceptData *data)
444
{
446
{
Lines 456-461 X11InputMonitor::handle_xrecord_handle_button_event(XRecordInterceptData *data) Link Here
456
    }
458
    }
457
}
459
}
458
460
461
void
462
X11InputMonitor::handle_xrecord_handle_device_key_event(XRecordInterceptData *data)
463
{
464
  (void) data;
465
  fire_keyboard(0, 0);
466
}
467
468
void
469
X11InputMonitor::handle_xrecord_handle_device_motion_event(XRecordInterceptData *data)
470
{
471
  deviceKeyButtonPointer *event = (deviceKeyButtonPointer *)data->data;
472
473
  if (event != NULL)
474
    {
475
      int x = event->root_x;
476
      int y = event->root_y;
477
478
      fire_mouse(x, y, 0);
479
    }
480
  else
481
    {
482
      fire_action();
483
    }
484
}
485
486
void
487
X11InputMonitor::handle_xrecord_handle_device_button_event(XRecordInterceptData *data)
488
{
489
  deviceKeyButtonPointer *event = (deviceKeyButtonPointer *)data->data;
490
491
  if (event != NULL)
492
    {
493
      // FIXME: check if this is correct
494
      int b = event->state;
495
496
      fire_button(b, event->type == xi_event_base + XI_DeviceButtonPress);
497
    }
498
  else
499
    {
500
      fire_action();
501
    }
502
}
459
503
460
void
504
void
461
X11InputMonitor::handle_xrecord_callback(XPointer closure, XRecordInterceptData * data)
505
X11InputMonitor::handle_xrecord_callback(XPointer closure, XRecordInterceptData * data)
Lines 481-486 X11InputMonitor::handle_xrecord_callback(XPointer closure, XRecordInterceptData Link Here
481
        monitor->handle_xrecord_handle_button_event(data);
525
        monitor->handle_xrecord_handle_button_event(data);
482
      else if (event->u.u.type == MotionNotify)
526
      else if (event->u.u.type == MotionNotify)
483
        monitor->handle_xrecord_handle_motion_event(data);
527
        monitor->handle_xrecord_handle_motion_event(data);
528
      else if (xi_event_base != 0)
529
        {
530
          if (event->u.u.type == xi_event_base + XI_DeviceMotionNotify)
531
            {
532
              monitor->handle_xrecord_handle_device_motion_event(data);
533
            }
534
          else if (event->u.u.type == xi_event_base + XI_DeviceKeyPress ||
535
                   event->u.u.type == xi_event_base + XI_DeviceKeyRelease)
536
            {
537
              monitor->handle_xrecord_handle_device_key_event(data);
538
            }
539
          else if (event->u.u.type == xi_event_base + XI_DeviceButtonPress ||
540
                   event->u.u.type == xi_event_base + XI_DeviceButtonRelease)
541
            {
542
              monitor->handle_xrecord_handle_device_button_event(data);
543
            }
544
        }
484
      break;
545
      break;
485
    }
546
    }
486
547
Lines 518-524 bool Link Here
518
X11InputMonitor::init_xrecord()
579
X11InputMonitor::init_xrecord()
519
{
580
{
520
  TRACE_ENTER("X11InputMonitor::init_xrecord")
581
  TRACE_ENTER("X11InputMonitor::init_xrecord")
521
  use_xrecord = false;
582
    use_xrecord = false;
522
583
523
  int major, minor;
584
  int major, minor;
524
585
Lines 533-550 X11InputMonitor::init_xrecord() Link Here
533
594
534
      // Receive KeyPress, KeyRelease, ButtonPress, ButtonRelease and
595
      // Receive KeyPress, KeyRelease, ButtonPress, ButtonRelease and
535
      // MotionNotify events.
596
      // MotionNotify events.
536
      XRecordRange *recordRange = XRecordAllocRange();
597
      XRecordRange *recordRanges[2];
537
      if (recordRange != NULL)
598
      int recordRangesLen = 1;
538
        {
599
      recordRanges[0] = XRecordAllocRange();
539
          memset(recordRange, 0, sizeof(XRecordRange));
600
      memset(recordRanges[0], 0, sizeof(XRecordRange));
540
          recordRange->device_events.first = KeyPress;
601
      recordRanges[0]->device_events.first = KeyPress;
541
          recordRange->device_events.last  = MotionNotify;
602
      recordRanges[0]->device_events.last  = MotionNotify;
603
604
#ifdef XI_DeviceMotionNotify
605
      TRACE_MSG("Trying XI");
606
607
      int dummy = 0;
608
      Bool ok =  XQueryExtension(x11_display, "XInputExtension",
609
                                 &dummy, &xi_event_base, &dummy);
542
610
543
          // And create the XRECORD context.
611
      if (ok)
544
          xrecord_context = XRecordCreateContext(x11_display, 0, &client,  1, &recordRange, 1);
612
        {
613
          TRACE_MSG("XI Ok " << xi_event_base);
545
614
546
          XFree(recordRange);
615
          recordRanges[1] = XRecordAllocRange();
616
          memset(recordRanges[1], 0, sizeof(XRecordRange));
617
          recordRanges[1]->device_events.first = xi_event_base + XI_DeviceKeyPress;
618
          recordRanges[1]->device_events.last  = xi_event_base + XI_DeviceMotionNotify;
619
          recordRangesLen = 2;
547
        }
620
        }
621
#endif
622
      // And create the XRECORD context.
623
      xrecord_context = XRecordCreateContext(x11_display, 0, &client,  1, recordRanges, recordRangesLen);
624
625
      XFree(recordRanges[0]);
626
627
#ifdef DeviceMotionNotify
628
      XFree(recordRanges[1]);
629
#endif
630
548
631
549
      if (xrecord_context != 0)
632
      if (xrecord_context != 0)
550
        {
633
        {
(-)a/backend/src/unix/X11InputMonitor.hh (-2 / +6 lines)
Lines 1-6 Link Here
1
// X11InputMonitor.hh --- ActivityMonitor for X11
1
// X11InputMonitor.hh --- ActivityMonitor for X11
2
//
2
//
3
// Copyright (C) 2001, 2002, 2003, 2006, 2007, 2008 Rob Caelers <robc@krandor.nl>
3
// Copyright (C) 2001, 2002, 2003, 2006, 2007, 2008, 2009 Rob Caelers <robc@krandor.nl>
4
// All rights reserved.
4
// All rights reserved.
5
//
5
//
6
// This program is free software: you can redistribute it and/or modify
6
// This program is free software: you can redistribute it and/or modify
Lines 77-82 private: Link Here
77
  void handle_xrecord_handle_key_event(XRecordInterceptData *data);
77
  void handle_xrecord_handle_key_event(XRecordInterceptData *data);
78
  void handle_xrecord_handle_motion_event(XRecordInterceptData *data);
78
  void handle_xrecord_handle_motion_event(XRecordInterceptData *data);
79
  void handle_xrecord_handle_button_event(XRecordInterceptData *data);
79
  void handle_xrecord_handle_button_event(XRecordInterceptData *data);
80
  void handle_xrecord_handle_device_key_event(XRecordInterceptData *data);
81
  void handle_xrecord_handle_device_motion_event(XRecordInterceptData *data);
82
  void handle_xrecord_handle_device_button_event(XRecordInterceptData *data);
80
83
81
  static void handle_xrecord_callback(XPointer closure, XRecordInterceptData * data);
84
  static void handle_xrecord_callback(XPointer closure, XRecordInterceptData * data);
82
#endif
85
#endif
Lines 122-127 private: Link Here
122
125
123
  //! X Connection for event capturing.
126
  //! X Connection for event capturing.
124
  Display *xrecord_datalink;
127
  Display *xrecord_datalink;
128
129
  static int xi_event_base;
125
#endif
130
#endif
126
};
131
};
127
132
128
-

Return to bug 288125