mirror of
https://github.com/swaywm/sway.git
synced 2026-04-27 06:46:25 -04:00
50 lines
1.3 KiB
C
50 lines
1.3 KiB
C
#define _POSIX_C_SOURCE 200809L
|
|
#include <stdbool.h>
|
|
#include <string.h>
|
|
#include <strings.h>
|
|
#include "sway/commands.h"
|
|
#include "sway/config.h"
|
|
#include "sway/ipc-server.h"
|
|
#include "list.h"
|
|
#include "log.h"
|
|
#include "stringop.h"
|
|
#include <libtouch.h>
|
|
|
|
struct cmd_results *touch_cmd_target(int argc, char **argv) {
|
|
struct cmd_results *error = NULL;
|
|
if ((error = checkarg(argc, "target", EXPECTED_EQUAL_TO, 5))) {
|
|
return error;
|
|
}
|
|
sway_log(SWAY_DEBUG, "Trying to convert");
|
|
double x = strtod(argv[1], NULL);
|
|
double y = strtod(argv[2], NULL);
|
|
double w = strtod(argv[3], NULL);
|
|
double h = strtod(argv[4], NULL);
|
|
sway_log(SWAY_DEBUG, "Converted: %f, %f, %f, %f", x,y,w,h);
|
|
|
|
if(!config->gesture_engine) {
|
|
return cmd_results_new(CMD_FAILURE, "No engine exists!");
|
|
}
|
|
|
|
struct gesture_target_config *conf = get_gesture_target_config(argv[0]);
|
|
|
|
if(!conf) {
|
|
return cmd_results_new(
|
|
CMD_FAILURE, "Could not create target: %s", argv[0]);
|
|
}
|
|
|
|
if(conf->target != NULL) {
|
|
return cmd_results_new(
|
|
CMD_FAILURE, "target %s already bound", argv[0]);
|
|
}
|
|
|
|
struct libtouch_target *target =
|
|
libtouch_target_create(config->gesture_engine, x,y,w,h);
|
|
|
|
if(!target) {
|
|
return cmd_results_new(CMD_FAILURE, "Could not create target");
|
|
}
|
|
|
|
conf->target = target;
|
|
return cmd_results_new(CMD_SUCCESS, "Created target: %s", argv[0]);
|
|
};
|