diff options
author | Chase Douglas <chase.douglas@canonical.com> | 2011-01-10 18:39:21 -0500 |
---|---|---|
committer | Chase Douglas <chase.douglas@canonical.com> | 2011-01-10 18:39:21 -0500 |
commit | 24b75514035b10b732e2bcaf386673850797e100 (patch) | |
tree | f4d2b4902574d0dd6b7937f087aaad3f69f93c83 | |
parent | 2a8f16a63e939f8991c6a92bf20aec31f23bdef8 (diff) |
Watch for resize events, clear screen, and draw correctly
-rw-r--r-- | tools/mtview.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/tools/mtview.c b/tools/mtview.c index 0cfbc57..4fb8861 100644 --- a/tools/mtview.c +++ b/tools/mtview.c @@ -192,6 +192,8 @@ static void run_window_xi2(struct windata *w, fprintf(stderr, "xi2 running\n"); + XSelectInput(w->dsp, w->win, StructureNotifyMask); + mask.deviceid = XIAllDevices; mask.mask_len = XIMaskLen(XI_TouchMotion); mask.mask = calloc(mask.mask_len, sizeof(char)); @@ -203,18 +205,34 @@ static void run_window_xi2(struct windata *w, while (1) { XEvent ev; - XIDeviceEvent *event = (void*)&ev; - XGenericEventCookie *cookie = &ev.xcookie; 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; - if (XGetEventData(w->dsp, cookie) && - cookie->type == GenericEvent && - cookie->extension == opcode) { - frame = utouch_frame_pump_xi2(fh, cookie->data); - if (frame) - report_frame(fh, frame, w); + default: + break; } - XFreeEventData(w->dsp, cookie); } } |