1a46c0ec8Sopenharmony_ci/* 2a46c0ec8Sopenharmony_ci * Copyright © 2021 Red Hat, Inc. 3a46c0ec8Sopenharmony_ci * Copyright © 2021 José Expósito 4a46c0ec8Sopenharmony_ci * 5a46c0ec8Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 6a46c0ec8Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 7a46c0ec8Sopenharmony_ci * to deal in the Software without restriction, including without limitation 8a46c0ec8Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9a46c0ec8Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 10a46c0ec8Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 11a46c0ec8Sopenharmony_ci * 12a46c0ec8Sopenharmony_ci * The above copyright notice and this permission notice (including the next 13a46c0ec8Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 14a46c0ec8Sopenharmony_ci * Software. 15a46c0ec8Sopenharmony_ci * 16a46c0ec8Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17a46c0ec8Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18a46c0ec8Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19a46c0ec8Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20a46c0ec8Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21a46c0ec8Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22a46c0ec8Sopenharmony_ci * DEALINGS IN THE SOFTWARE. 23a46c0ec8Sopenharmony_ci */ 24a46c0ec8Sopenharmony_ci 25a46c0ec8Sopenharmony_ci#include "config.h" 26a46c0ec8Sopenharmony_ci 27a46c0ec8Sopenharmony_ci#include "libinput-private-config.h" 28a46c0ec8Sopenharmony_ci#include "libinput-private.h" 29a46c0ec8Sopenharmony_ci 30a46c0ec8Sopenharmony_ciint 31a46c0ec8Sopenharmony_cilibinput_device_config_gesture_hold_is_available(struct libinput_device *device) 32a46c0ec8Sopenharmony_ci{ 33a46c0ec8Sopenharmony_ci if (!libinput_device_has_capability(device, 34a46c0ec8Sopenharmony_ci LIBINPUT_DEVICE_CAP_GESTURE)) 35a46c0ec8Sopenharmony_ci return 0; 36a46c0ec8Sopenharmony_ci 37a46c0ec8Sopenharmony_ci if (!device->config.gesture->get_hold_default(device)) 38a46c0ec8Sopenharmony_ci return 0; 39a46c0ec8Sopenharmony_ci 40a46c0ec8Sopenharmony_ci return 1; 41a46c0ec8Sopenharmony_ci} 42a46c0ec8Sopenharmony_ci 43a46c0ec8Sopenharmony_cienum libinput_config_status 44a46c0ec8Sopenharmony_cilibinput_device_config_gesture_set_hold_enabled(struct libinput_device *device, 45a46c0ec8Sopenharmony_ci enum libinput_config_hold_state enable) 46a46c0ec8Sopenharmony_ci{ 47a46c0ec8Sopenharmony_ci if (enable != LIBINPUT_CONFIG_HOLD_ENABLED && 48a46c0ec8Sopenharmony_ci enable != LIBINPUT_CONFIG_HOLD_DISABLED) 49a46c0ec8Sopenharmony_ci return LIBINPUT_CONFIG_STATUS_INVALID; 50a46c0ec8Sopenharmony_ci 51a46c0ec8Sopenharmony_ci if (!libinput_device_config_gesture_hold_is_available(device)) { 52a46c0ec8Sopenharmony_ci return enable ? LIBINPUT_CONFIG_STATUS_UNSUPPORTED : 53a46c0ec8Sopenharmony_ci LIBINPUT_CONFIG_STATUS_SUCCESS; 54a46c0ec8Sopenharmony_ci } 55a46c0ec8Sopenharmony_ci 56a46c0ec8Sopenharmony_ci return device->config.gesture->set_hold_enabled(device, enable); 57a46c0ec8Sopenharmony_ci} 58a46c0ec8Sopenharmony_ci 59a46c0ec8Sopenharmony_cienum libinput_config_hold_state 60a46c0ec8Sopenharmony_cilibinput_device_config_gesture_get_hold_enabled(struct libinput_device *device) 61a46c0ec8Sopenharmony_ci{ 62a46c0ec8Sopenharmony_ci if (!libinput_device_config_gesture_hold_is_available(device)) 63a46c0ec8Sopenharmony_ci return LIBINPUT_CONFIG_HOLD_DISABLED; 64a46c0ec8Sopenharmony_ci 65a46c0ec8Sopenharmony_ci return device->config.gesture->get_hold_enabled(device); 66a46c0ec8Sopenharmony_ci} 67a46c0ec8Sopenharmony_ci 68a46c0ec8Sopenharmony_cienum libinput_config_hold_state 69a46c0ec8Sopenharmony_cilibinput_device_config_gesture_get_hold_default_enabled(struct libinput_device *device) 70a46c0ec8Sopenharmony_ci{ 71a46c0ec8Sopenharmony_ci if (!libinput_device_config_gesture_hold_is_available(device)) 72a46c0ec8Sopenharmony_ci return LIBINPUT_CONFIG_HOLD_DISABLED; 73a46c0ec8Sopenharmony_ci 74a46c0ec8Sopenharmony_ci return device->config.gesture->get_hold_default(device); 75a46c0ec8Sopenharmony_ci} 76