Back to index

unity  6.0.0
Public Types | Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes
unity::ui::PointerBarrierWrapper Class Reference

#include <PointerBarrier.h>

Inheritance diagram for unity::ui::PointerBarrierWrapper:
Inheritance graph
[legend]
Collaboration diagram for unity::ui::PointerBarrierWrapper:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::shared_ptr
< PointerBarrierWrapper
Ptr

Public Member Functions

 PointerBarrierWrapper ()
 ~PointerBarrierWrapper ()
void ConstructBarrier ()
void DestroyBarrier ()
void ReleaseBarrier (int event_id)

Public Attributes

nux::Property< int > x1
nux::Property< int > x2
nux::Property< int > y1
nux::Property< int > y2
nux::Property< int > threshold
nux::Property< bool > active
nux::Property< int > smoothing
nux::Property< float > max_velocity_multiplier
nux::Property< int > index
nux::Property< BarrierDirectiondirection
sigc::signal< void,
PointerBarrierWrapper
*, BarrierEvent::Ptr
barrier_event

Private Member Functions

void EmitCurrentData ()
bool HandleEvent (XEvent event)

Static Private Member Functions

static bool HandleEventWrapper (XEvent event, void *data)

Private Attributes

int last_event_
int last_x_
int last_y_
int event_base_
int error_base_
PointerBarrier barrier
int smoothing_count_
int smoothing_accum_
glib::Source::UniquePtr smoothing_timeout_

Detailed Description

Definition at line 53 of file PointerBarrier.h.


Member Typedef Documentation

Definition at line 56 of file PointerBarrier.h.


Constructor & Destructor Documentation

Definition at line 38 of file PointerBarrier.cpp.

Definition at line 50 of file PointerBarrier.cpp.

Here is the call graph for this function:


Member Function Documentation

Definition at line 55 of file PointerBarrier.cpp.

{
  if (active)
    return;

  Display *dpy = nux::GetGraphicsDisplay()->GetX11Display();

  XFixesQueryExtension(dpy, &event_base_, &error_base_);

  int maj,min;
  XFixesQueryVersion(dpy, &maj, &min);

  barrier = XFixesCreatePointerBarrierVelocity(dpy,
                                               DefaultRootWindow(dpy),
                                               x1, y1,
                                               x2, y2,
                                               (int) direction,
                                               threshold,
                                               0,
                                               NULL);

  if (!local::is_selected_for)
  {
    XFixesSelectBarrierInput(dpy, DefaultRootWindow(dpy), 0xdeadbeef);
    local::is_selected_for = true;
  }

  active = true;

  nux::GraphicsDisplay::EventFilterArg event_filter;
  event_filter.filter = &PointerBarrierWrapper::HandleEventWrapper;
  event_filter.data = this;

  nux::GetGraphicsDisplay()->AddEventFilter(event_filter);
}

Here is the call graph for this function:

Definition at line 91 of file PointerBarrier.cpp.

{
  if (!active)
    return;

  active = false;

  Display *dpy = nux::GetGraphicsDisplay()->GetX11Display();
  XFixesDestroyPointerBarrier(dpy, barrier);

  nux::GetGraphicsDisplay()->RemoveEventFilter(this);
}

Here is the caller graph for this function:

Definition at line 109 of file PointerBarrier.cpp.

{
  if (smoothing_count_ <= 0)
    return;

  BarrierEvent::Ptr event (new BarrierEvent());
  event->x = last_x_;
  event->y = last_y_;
  event->velocity = std::min<int> (600 * max_velocity_multiplier, smoothing_accum_ / smoothing_count_);
  event->event_id = last_event_;

  barrier_event.emit(this, event);

  smoothing_accum_ = 0;
  smoothing_count_ = 0;
}

Here is the caller graph for this function:

bool unity::ui::PointerBarrierWrapper::HandleEvent ( XEvent  event) [private]

Definition at line 126 of file PointerBarrier.cpp.

{
  if(xevent.type - event_base_ == XFixesBarrierNotify)
  {
    XFixesBarrierNotifyEvent *notify_event = (XFixesBarrierNotifyEvent *)&xevent;

    if (notify_event->barrier == barrier && notify_event->subtype == XFixesBarrierHitNotify)
    {
      last_x_ = notify_event->x;
      last_y_ = notify_event->y;
      last_event_ = notify_event->event_id;
      smoothing_accum_ += notify_event->velocity;
      smoothing_count_++;

      if (!smoothing_timeout_)
      {
        auto smoothing_cb = [&] ()
        {
          EmitCurrentData();

          smoothing_timeout_.reset();
          return false;
        };

        smoothing_timeout_.reset(new glib::Timeout(smoothing(), smoothing_cb));
      }

    }

    return notify_event->barrier == barrier;
  }

  return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool unity::ui::PointerBarrierWrapper::HandleEventWrapper ( XEvent  event,
void *  data 
) [static, private]

Definition at line 161 of file PointerBarrier.cpp.

{
  PointerBarrierWrapper* wrapper = (PointerBarrierWrapper*)data;
  return wrapper->HandleEvent(event);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 104 of file PointerBarrier.cpp.

{
  XFixesBarrierReleasePointer (nux::GetGraphicsDisplay()->GetX11Display(), barrier, event_id);
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 65 of file PointerBarrier.h.

Definition at line 95 of file PointerBarrier.h.

Definition at line 82 of file PointerBarrier.h.

Definition at line 73 of file PointerBarrier.h.

Definition at line 94 of file PointerBarrier.h.

Definition at line 93 of file PointerBarrier.h.

Definition at line 71 of file PointerBarrier.h.

Definition at line 89 of file PointerBarrier.h.

Definition at line 90 of file PointerBarrier.h.

Definition at line 91 of file PointerBarrier.h.

Definition at line 69 of file PointerBarrier.h.

Definition at line 67 of file PointerBarrier.h.

Definition at line 98 of file PointerBarrier.h.

Definition at line 97 of file PointerBarrier.h.

Definition at line 99 of file PointerBarrier.h.

Definition at line 63 of file PointerBarrier.h.

Definition at line 58 of file PointerBarrier.h.

Definition at line 59 of file PointerBarrier.h.

Definition at line 60 of file PointerBarrier.h.

Definition at line 61 of file PointerBarrier.h.


The documentation for this class was generated from the following files: