summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChase Douglas <chase.douglas@canonical.com>2011-01-12 15:30:43 -0500
committerChase Douglas <chase.douglas@canonical.com>2011-01-12 15:30:43 -0500
commitacad3f1a8c076979a7b34c919bed47ba5eaecd03 (patch)
treea5d9014364f0a12793ef50cbcbc3aca94ea01ef6
parent3c4dfc66e16a64a4d340fec9fb2f14c506f30553 (diff)
Stuff
-rw-r--r--tools/mtview.c52
1 files changed, 16 insertions, 36 deletions
diff --git a/tools/mtview.c b/tools/mtview.c
index f5c0418..79b8466 100644
--- a/tools/mtview.c
+++ b/tools/mtview.c
@@ -65,24 +65,15 @@ static void output_touch(utouch_frame_handle fh, struct windata *w,
minor = t->touch_minor;
angle = t->orientation;
}
- if (major == 0 && minor == 0) {
+ if (major == 0)
major = DEF_WIDTH * dy;
+ if (minor == 0)
minor = DEF_WIDTH * dx;
- }
float ac = fabs(cos(angle));
float as = fabs(sin(angle));
float mx = max(minor * ac, major * as);
float my = max(major * ac, minor * as);
- float ux = t->x - 0.5 * mx;
- float uy = t->y - 0.5 * my;
- float vx = t->x + 0.5 * mx;
- float vy = t->y + 0.5 * my;
-
- float px = (ux - x1) / dx * w->width;
- float py = (uy - y1) / dy * w->height;
- float qx = (vx - x1) / dx * w->width;
- float qy = (vy - y1) / dy * w->height;
if (w->id[t->slot] != t->id) {
w->id[t->slot] = t->id;
@@ -90,7 +81,8 @@ static void output_touch(utouch_frame_handle fh, struct windata *w,
}
XSetForeground(w->dsp, w->gc, w->color[t->slot]);
- XFillArc(w->dsp, w->win, w->gc, px, py, qx - px, qy - py, 0, 360 * 64);
+ XFillArc(w->dsp, w->win, w->gc, t->window_x - mx / 2, t->window_y - my / 2, mx, my, 0,
+ 360 * 64);
XFlush(w->dsp);
}
@@ -194,6 +186,7 @@ static void run_window_xi2(struct windata *w,
fprintf(stderr, "xi2 running\n");
XSelectInput(w->dsp, w->win, StructureNotifyMask);
+ XSelectInput(w->dsp, XDefaultRootWindow(w->dsp), StructureNotifyMask);
mask.deviceid = XIAllDevices;
mask.mask_len = XIMaskLen(XI_TouchMotion);
@@ -205,36 +198,23 @@ static void run_window_xi2(struct windata *w,
XISetMask(mask.mask, XI_TouchEnd);
XISelectEvents(w->dsp, w->win, &mask, 1);
+
+
while (1) {
XEvent ev;
XNextEvent(w->dsp, &ev);
XConfigureEvent *xce = &ev.xconfigure;
- XGenericEventCookie *cookie = (XGenericEventCookie *)&ev;
-
- switch (ev.type) {
- case ConfigureNotify:
- if (xce->width != w->width ||
- xce->height != w->height) {
- w->width = xce->width;
- w->height = xce->height;
- clear_screen(w);
- }
- break;
- case GenericEvent:
- if (!XGetEventData(w->dsp, cookie))
- break;
- if (cookie->extension == opcode) {
- frame = utouch_frame_pump_xi2(fh, cookie->data);
- if (frame)
- report_frame(fh, frame, w);
- }
- XFreeEventData(w->dsp, cookie);
- break;
-
- default:
- break;
+ if (ev.type == ConfigureNotify && (xce->width != w->width ||
+ xce->height != w->height)) {
+ w->width = xce->width;
+ w->height = xce->height;
+ clear_screen(w);
}
+
+ frame = utouch_frame_pump_xi2(fh, &ev);
+ if (frame)
+ report_frame(fh, frame, w);
}
}