void dump_gesture_event(GeisEvent event) { GeisSize i; GeisTouchSet touchset; GeisGroupSet groupset; GeisAttr attr; attr = geis_event_attr_by_name(event, GEIS_EVENT_ATTRIBUTE_TOUCHSET); touchset = geis_attr_value_to_pointer(attr); attr = geis_event_attr_by_name(event, GEIS_EVENT_ATTRIBUTE_GROUPSET); groupset = geis_attr_value_to_pointer(attr); printf("gesture\n"); for (i= 0; i < geis_groupset_group_count(groupset); ++i) { GeisSize j; GeisGroup group = geis_groupset_group(groupset, i); printf("+group %u\n", geis_group_id(group)); for (j=0; j < geis_group_frame_count(group); ++j) { GeisSize k; GeisFrame frame = geis_group_frame(group, j); GeisSize attr_count = geis_frame_attr_count(frame); printf("+frame %u\n", geis_frame_id(frame)); for (k = 0; k < attr_count; ++k) { print_attr(geis_frame_attr(frame, k)); } for (k = 0; k < geis_frame_touchid_count(frame); ++k) { GeisSize touchid = geis_frame_touchid(frame, k); GeisTouch touch = geis_touchset_touch_by_id(touchset, touchid); GeisSize n; printf("+touch %lu\n", k); for (n = 0; n < geis_touch_attr_count(touch); ++n) { print_attr(geis_touch_attr(touch, n)); } } } } }
void update_from_frame(GeisTouchSet touchset, GeisFrame frame) { GeisAttr attr; GeisSize k; int touches; attr = geis_frame_attr_by_name(frame, GEIS_GESTURE_ATTRIBUTE_TOUCHES); touches = geis_attr_value_to_integer(attr); num_touches = touches > num_touches ? touches : num_touches; if (touches == 2 && state != MOVING) { system(WM_START_WINDOW_MOVE_CMD); state = MOVING; } if (touches == 4 && state != RESIZING) { system(WM_START_WINDOW_RESIZE_CMD); state = RESIZING; } if ((touches > 2 && state == MOVING) || (touches > 4 && state == RESIZING)) { system(WM_STOP_TRACKING_MOUSE_CMD); state = DEFAULT; } if (state == MOVING || state == RESIZING) { for (k = 0; k < geis_frame_touchid_count(frame); ++k) { GeisSize touchid = geis_frame_touchid(frame, k); GeisTouch touch = geis_touchset_touch_by_id(touchset, touchid); update_x_y_from_touch(touch, &new_x, &new_y); } char *cmd; size_t needed = snprintf( NULL, 0, WM_UPDATE_MOUSE_CMD_FMT, (int) new_x, (int) new_y); cmd = malloc(needed); snprintf( cmd, needed, WM_UPDATE_MOUSE_CMD_FMT, (int) new_x, (int) new_y); system(cmd); free(cmd); } }