data.h (2985B)
1 /* swc: data.h 2 * 3 * Copyright (c) 2013 Michael Forney 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a copy 6 * of this software and associated documentation files (the "Software"), to deal 7 * in the Software without restriction, including without limitation the rights 8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 * copies of the Software, and to permit persons to whom the Software is 10 * furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included in 13 * all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 * SOFTWARE. 22 */ 23 24 #ifndef SWC_DATA_H 25 #define SWC_DATA_H 26 27 #include <stdbool.h> 28 #include <stdint.h> 29 30 struct wl_client; 31 32 struct wl_resource * 33 data_source_new(struct wl_client *client, uint32_t version, uint32_t id); 34 struct wl_resource * 35 data_offer_new(struct wl_client *client, struct wl_resource *source, 36 uint32_t version); 37 void 38 data_send_mime_types(struct wl_resource *source, struct wl_resource *offer); 39 40 struct data; 41 42 /* a source of the compositor's own, for a selection it keeps itself: it 43 * offers types and answers each ask on its own */ 44 struct data_host { 45 void (*send)(void *data, const char *mime_type, int fd); 46 void (*cancelled)(void *data); 47 void *data; 48 }; 49 50 struct data * 51 data_host_new(const char *const *types, unsigned count, 52 const struct data_host *host, void *data); 53 void 54 data_host_free(struct data *data); 55 struct data * 56 data_of(struct wl_resource *source); 57 /* offers of a selection, host or client */ 58 struct wl_resource * 59 data_offer_for(struct wl_client *client, struct data *data, uint32_t version); 60 void 61 data_send_types(struct data *data, struct wl_resource *offer); 62 unsigned 63 data_type_count(const struct data *data); 64 const char * 65 data_type_at(const struct data *data, unsigned index); 66 /* asks the source for a type, to be written to fd (the caller closes its copy) */ 67 void 68 data_request(struct data *data, const char *mime_type, int fd); 69 /* the selection went to someone else */ 70 void 71 data_cancel(struct data *data); 72 73 /* a drag offer for source entered a client, nothing accepted yet */ 74 void 75 data_drag_enter(struct wl_resource *source, struct wl_resource *offer); 76 /* action a held key asks for, 0 for none, wins over the target preference */ 77 void 78 data_drag_choose(struct wl_resource *source, uint32_t action); 79 /* target took a type and an action both allow */ 80 bool 81 data_drag_droppable(struct wl_resource *source); 82 83 #endif