input.h (2519B)
1 /* swc: input.h 2 * 3 * Copyright (c) 2013, 2014 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_INPUT_H 25 #define SWC_INPUT_H 26 27 #include <stdbool.h> 28 #include <wayland-server.h> 29 30 /* Focus {{{ */ 31 32 enum { INPUT_FOCUS_EVENT_CHANGED }; 33 34 struct input_focus_event_data { 35 struct compositor_view *old, *new; 36 }; 37 38 struct input_focus_handler { 39 void (*enter)(struct input_focus_handler *handler, 40 struct wl_list *resources, struct compositor_view *view); 41 void (*leave)(struct input_focus_handler *handler, 42 struct wl_list *resources, struct compositor_view *view); 43 }; 44 45 struct input_focus { 46 struct wl_client *client; 47 struct compositor_view *view; 48 struct wl_listener view_destroy_listener; 49 50 struct input_focus_handler *handler; 51 struct wl_list active, inactive; 52 53 struct wl_signal event_signal; 54 }; 55 56 bool 57 input_focus_initialize(struct input_focus *input_focus, 58 struct input_focus_handler *input_handler); 59 void 60 input_focus_finalize(struct input_focus *input_focus); 61 void 62 input_focus_add_resource(struct input_focus *input_focus, 63 struct wl_resource *resource); 64 void 65 input_focus_remove_resource(struct input_focus *input_focus, 66 struct wl_resource *resource); 67 void 68 input_focus_set(struct input_focus *input_focus, struct compositor_view *view); 69 70 /* }}} */ 71 72 /* Key/button handling {{{ */ 73 74 struct press { 75 uint32_t value; 76 uint32_t serial; 77 void *data; 78 }; 79 80 /* }}} */ 81 82 #endif