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); } }
void print_attr(GeisAttr attr) { GeisString attr_name = geis_attr_name(attr); switch (geis_attr_type(attr)) { case GEIS_ATTR_TYPE_BOOLEAN: printf(" \"%s\": %s\n", attr_name, geis_attr_value_to_boolean(attr) ? "true" : "false"); break; case GEIS_ATTR_TYPE_FLOAT: printf(" \"%s\": %g\n", attr_name, geis_attr_value_to_float(attr)); break; case GEIS_ATTR_TYPE_INTEGER: printf(" \"%s\": %d\n", attr_name, geis_attr_value_to_integer(attr)); break; case GEIS_ATTR_TYPE_STRING: printf(" \"%s\": %s\n", attr_name, geis_attr_value_to_string(attr)); break; default: break; } }