diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2011-11-10 14:07:50 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-11-10 15:24:24 +1000 |
commit | efde9052fc2664af53e0c9292e9a487ded85bda1 (patch) | |
tree | 08cb1314484d78ec1746f5d6dc7cc133a2ea7d26 | |
parent | 2054874dbd23ecc823cdf4144eed43e00f5df728 (diff) |
Store the grab window in the grabpoint
If we get events from different windows, we need to paint them correctly.
Since grab painting is done by looping through all active grabs, store the
grab window for each grab.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | multitouch.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/multitouch.c b/multitouch.c index 33b5084..184f51c 100644 --- a/multitouch.c +++ b/multitouch.c @@ -47,6 +47,7 @@ struct grabpoint { uint32_t touchid; double startx, starty; /* x/y of TouchBegin */ double x, y; /* last recorded x/y position */ + Window grab_window; }; struct multitouch { @@ -351,7 +352,7 @@ static void paint_touch_end(struct multitouch *mt, XIDeviceEvent *event) } -static void paint_grabs(struct multitouch *mt, Window which) +static void paint_grabs(struct multitouch *mt) { const int radius = 50; struct grabpoint *grab; @@ -366,24 +367,6 @@ static void paint_grabs(struct multitouch *mt, Window which) cairo_paint(mt->cr_grabs); cairo_restore(mt->cr_grabs); - if (which == mt->blackbar) - { - r = 0; g = 0; b = 1; - offset = 0; - } else if (which == mt->whitebar) - { - r = 1; g = 0; b = 0; - offset = mt->height/4; - } else if (which == mt->blackbar_os) - { - r = 0; g = 1; b = 0; - offset = mt->height/2; - } else - { - r = 0; g = 1; b = 1; - offset = 3 * mt->height/2; - } - for (i = 0; i < mt->ngrabs; i++) { grab = &mt->grabs[i]; @@ -391,6 +374,24 @@ static void paint_grabs(struct multitouch *mt, Window which) if (grab->state == TSTATE_END) continue; + if (grab->grab_window == mt->blackbar) + { + r = 0; g = 0; b = 1; + offset = 0; + } else if (grab->grab_window == mt->whitebar) + { + r = 1; g = 0; b = 0; + offset = mt->height/4; + } else if (grab->grab_window == mt->blackbar_os) + { + r = 0; g = 1; b = 0; + offset = mt->height/2; + } else + { + r = 0; g = 1; b = 1; + offset = 3 * mt->height/2; + } + /* draw starting circle */ cairo_set_source_rgba(mt->cr_grabs, r, g, b, 1); cairo_move_to(mt->cr_grabs, grab->startx + radius, offset + grab->starty); @@ -424,6 +425,7 @@ static void handle_grabbed_event(struct multitouch *mt, XIDeviceEvent *event) grab->touchid = event->detail; grab->startx = event->event_x; grab->starty = event->event_y; + grab->grab_window = event->event; break; } else if (event->evtype != XI_TouchBegin) { if (grab->state != TSTATE_END && grab->touchid == event->detail) @@ -439,7 +441,7 @@ static void handle_grabbed_event(struct multitouch *mt, XIDeviceEvent *event) grab->x = event->event_x; grab->y = event->event_y; - paint_grabs(mt, event->event); + paint_grabs(mt); expose(mt, 0, 0, mt->width, mt->height); switch (event->evtype) |