Back to index

easystroke  0.5.5.1
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes
StrokeHandler Class Reference
Inheritance diagram for StrokeHandler:
Inheritance graph
[legend]
Collaboration diagram for StrokeHandler:
Collaboration graph
[legend]

List of all members.

Classes

struct  Connection

Public Member Functions

 StrokeHandler (guint b, RTriple e)
virtual void init ()
 ~StrokeHandler ()
virtual std::string name ()
virtual Grabber::State grab_mode ()
Handlertop ()
virtual void raw_motion (RTriple e, bool, bool)
virtual void press_master (guint b, Time t)
virtual void proximity_out ()
virtual void pong ()
void replace_child (Handler *c)

Static Public Member Functions

static bool idle ()

Public Attributes

Handlerparent

Protected Member Functions

void abort_stroke ()
virtual void pressure ()
virtual void motion (RTriple e)
virtual void press (guint b, RTriple e)
virtual void release (guint b, RTriple e)

Protected Attributes

Handlerchild

Private Types

typedef boost::shared_ptr
< Connection
RConnection

Private Member Functions

RStroke finish (guint b)
bool timeout ()
void do_instant ()
bool expired (RConnection c, double dist)

Private Attributes

guint button
RPreStroke cur
bool is_gesture
bool drawing
RTriple last
RTriple orig
bool use_timeout
int init_timeout
int final_timeout
int radius
sigc::connection init_connection
std::vector< RConnectionconnections

Detailed Description

Definition at line 819 of file main.cc.


Member Typedef Documentation

typedef boost::shared_ptr<Connection> StrokeHandler::RConnection [private]

Definition at line 835 of file main.cc.


Constructor & Destructor Documentation

StrokeHandler::StrokeHandler ( guint  b,
RTriple  e 
) [inline]

Definition at line 972 of file main.cc.

                                         : button(b), is_gesture(false), drawing(false), last(e), orig(e),
       init_timeout(prefs.init_timeout.get()), final_timeout(prefs.final_timeout.get()), radius(16) {
              const std::map<std::string, TimeoutType> &dt = prefs.device_timeout.ref();
              std::map<std::string, TimeoutType>::const_iterator j = dt.find(current_dev->name);
              if (j != dt.end())
                     get_timeouts(j->second, &init_timeout, &final_timeout);
              else
                     get_timeouts(prefs.timeout_profile.get(), &init_timeout, &final_timeout);
              use_timeout = init_timeout;
       }

Here is the call graph for this function:

Definition at line 1001 of file main.cc.

{ trace->end(); }

Member Function Documentation

void StrokeHandler::abort_stroke ( ) [inline, protected]

Definition at line 876 of file main.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

void StrokeHandler::do_instant ( ) [inline, private]

Definition at line 865 of file main.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

bool StrokeHandler::expired ( RConnection  c,
double  dist 
) [inline, private]

Definition at line 871 of file main.cc.

                                                {
              c->dist -= dist;
              return c->dist < 0;
       }

Here is the caller graph for this function:

RStroke StrokeHandler::finish ( guint  b) [inline, private]

Definition at line 839 of file main.cc.

                               {
              trace->end();
              XFlush(dpy);
              RPreStroke c = cur;
              if (!is_gesture || grabber->is_instant(button))
                     c.reset(new PreStroke);
              if (b && prefs.advanced_ignore.get())
                     c.reset(new PreStroke);
              return Stroke::create(*c, button, b, false);
       }

Here is the call graph for this function:

Here is the caller graph for this function:

virtual Grabber::State StrokeHandler::grab_mode ( ) [inline, virtual]

Implements Handler.

Definition at line 1003 of file main.cc.

{ return Grabber::NONE; }
static bool Handler::idle ( ) [inline, static, inherited]

Definition at line 135 of file main.cc.

{ return !handler->child; }

Here is the caller graph for this function:

virtual void StrokeHandler::init ( ) [inline, virtual]

Reimplemented from Handler.

Definition at line 982 of file main.cc.

                           {
              if (grabber->is_instant(button))
                     return do_instant();
              if (grabber->is_click_hold(button)) {
                     use_timeout = true;
                     init_timeout = 500;
                     final_timeout = 0;
              }
              cur = PreStroke::create();
              cur->add(orig);
              if (!use_timeout)
                     return;
              if (final_timeout && final_timeout < 32 && radius < 16*32/final_timeout) {
                     radius = 16*32/final_timeout;
                     final_timeout = final_timeout*radius/16;
              }
              init_connection = Glib::signal_timeout().connect(
                            sigc::mem_fun(*this, &StrokeHandler::timeout), init_timeout);
       }

Here is the call graph for this function:

virtual void StrokeHandler::motion ( RTriple  e) [inline, protected, virtual]

Reimplemented from Handler.

Definition at line 883 of file main.cc.

                                      {
              cur->add(e);
              float dist = hypot(e->x-orig->x, e->y-orig->y);
              if (!is_gesture && dist > 16) {
                     if (use_timeout && !final_timeout)
                            return abort_stroke();
                     init_connection.disconnect();
                     is_gesture = true;
              }
              if (!drawing && dist > 4 && (!use_timeout || final_timeout)) {
                     drawing = true;
                     bool first = true;
                     for (PreStroke::iterator i = cur->begin(); i != cur->end(); i++) {
                            Trace::Point p;
                            p.x = (*i)->x;
                            p.y = (*i)->y;
                            if (first) {
                                   trace->start(p);
                                   first = false;
                            } else {
                                   trace->draw(p);
                            }
                     }
              } else if (drawing) {
                     Trace::Point p;
                     p.x = e->x;
                     p.y = e->y;
                     trace->draw(p);
              }
              if (use_timeout && is_gesture) {
                     connections.erase(remove_if(connections.begin(), connections.end(),
                                          sigc::bind(sigc::mem_fun(*this, &StrokeHandler::expired),
                                                 hypot(e->x - last->x, e->y - last->y))), connections.end());
                     connections.push_back(RConnection(new Connection(this, radius, final_timeout)));
              }
              last = e;
       }

Here is the call graph for this function:

virtual std::string StrokeHandler::name ( ) [inline, virtual]

Implements Handler.

Definition at line 1002 of file main.cc.

{ return "Stroke"; }
virtual void Handler::pong ( ) [inline, virtual, inherited]

Reimplemented in WaitForPongHandler.

Definition at line 144 of file main.cc.

{}
virtual void StrokeHandler::press ( guint  b,
RTriple  e 
) [inline, protected, virtual]

Reimplemented from Handler.

Definition at line 921 of file main.cc.

Here is the call graph for this function:

virtual void Handler::press_master ( guint  b,
Time  t 
) [inline, virtual, inherited]

Reimplemented in SelectHandler, and ScrollHandler.

Definition at line 141 of file main.cc.

{}
virtual void StrokeHandler::pressure ( ) [inline, protected, virtual]

Reimplemented from Handler.

Definition at line 879 of file main.cc.

                               {
              abort_stroke();
              timeout();
       }

Here is the call graph for this function:

virtual void Handler::proximity_out ( ) [inline, virtual, inherited]

Reimplemented in ScrollHandler.

Definition at line 143 of file main.cc.

{}
virtual void Handler::raw_motion ( RTriple  e,
bool  ,
bool   
) [inline, virtual, inherited]

Reimplemented in ScrollHandler, and AbstractScrollHandler.

Definition at line 138 of file main.cc.

{}
virtual void StrokeHandler::release ( guint  b,
RTriple  e 
) [inline, protected, virtual]

Reimplemented from Handler.

Definition at line 926 of file main.cc.

                                                {
              RStroke s = finish(0);

              if (prefs.move_back.get() && !current_dev->absolute)
                     XTestFakeMotionEvent(dpy, DefaultScreen(dpy), orig->x, orig->y, 0);
              else
                     XTestFakeMotionEvent(dpy, DefaultScreen(dpy), e->x, e->y, 0);

              if (stroke_action) {
                     (*stroke_action)(s);
                     return parent->replace_child(NULL);
              }
              RRanking ranking;
              RAction act = actions.get_action_list(grabber->current_class->get())->handle(s, ranking);
              if (!IS_CLICK(act))
                     Ranking::queue_show(ranking, e);
              if (!act) {
                     XBell(dpy, 0);
                     return parent->replace_child(NULL);
              }
              RModifiers mods = act->prepare();
              if (IS_CLICK(act))
                     act = Button::create((Gdk::ModifierType)0, b);
              else IF_BUTTON(act, b)
                     return parent->replace_child(new ButtonHandler(mods, b));
              if (IS_IGNORE(act))
                     return parent->replace_child(new IgnoreHandler(mods));
              if (IS_SCROLL(act))
                     return parent->replace_child(new ScrollHandler(mods));
              char buf[16];
              snprintf(buf, sizeof(buf), "%d", (int)orig->x);
              setenv("EASYSTROKE_X1", buf, 1);
              snprintf(buf, sizeof(buf), "%d", (int)orig->y);
              setenv("EASYSTROKE_Y1", buf, 1);
              snprintf(buf, sizeof(buf), "%d", (int)e->x);
              setenv("EASYSTROKE_X2", buf, 1);
              snprintf(buf, sizeof(buf), "%d", (int)e->y);
              setenv("EASYSTROKE_Y2", buf, 1);
              act->run();
              unsetenv("EASYSTROKE_X1");
              unsetenv("EASYSTROKE_Y1");
              unsetenv("EASYSTROKE_X2");
              unsetenv("EASYSTROKE_Y2");
              parent->replace_child(NULL);
       }

Here is the call graph for this function:

void Handler::replace_child ( Handler c) [inline, inherited]

Definition at line 145 of file main.cc.

                                      {
              if (child)
                     delete child;
              child = c;
              if (child)
                     child->parent = this;
              if (verbosity >= 2) {
                     std::string stack;
                     for (Handler *h = child ? child : this; h; h=h->parent) {
                            stack = h->name() + " " + stack;
                     }
                     printf("New event handling stack: %s\n", stack.c_str());
              }
              Handler *new_handler = child ? child : this;
              grabber->grab(new_handler->grab_mode());
              if (child)
                     child->init();
              while (queued.size() && Handler::idle()) {
                     (*queued.begin())();
                     queued.pop_front();
              }
       }

Here is the call graph for this function:

Here is the caller graph for this function:

bool StrokeHandler::timeout ( ) [inline, private]

Definition at line 850 of file main.cc.

                      {
              if (verbosity >= 2)
                     printf("Aborting stroke...\n");
              trace->end();
              RPreStroke c = cur;
              if (!is_gesture)
                     c.reset(new PreStroke);
              RStroke s;
              if (prefs.timeout_gestures.get() || grabber->is_click_hold(button))
                     s = Stroke::create(*c, button, 0, true);
              parent->replace_child(AdvancedHandler::create(s, last, button, 0, cur));
              XFlush(dpy);
              return false;
       }

Here is the call graph for this function:

Here is the caller graph for this function:

Handler* Handler::top ( ) [inline, inherited]

Definition at line 129 of file main.cc.

                      {
              if (child)
                     return child->top();
              else
                     return this;
       }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

guint StrokeHandler::button [private]

Definition at line 820 of file main.cc.

Handler* Handler::child [protected, inherited]

Definition at line 125 of file main.cc.

std::vector<RConnection> StrokeHandler::connections [private]

Definition at line 837 of file main.cc.

Definition at line 821 of file main.cc.

bool StrokeHandler::drawing [private]

Definition at line 823 of file main.cc.

Definition at line 826 of file main.cc.

sigc::connection StrokeHandler::init_connection [private]

Definition at line 836 of file main.cc.

Definition at line 826 of file main.cc.

bool StrokeHandler::is_gesture [private]

Definition at line 822 of file main.cc.

Definition at line 824 of file main.cc.

Definition at line 824 of file main.cc.

Handler* Handler::parent [inherited]

Definition at line 127 of file main.cc.

int StrokeHandler::radius [private]

Definition at line 826 of file main.cc.

Definition at line 825 of file main.cc.


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