neuswc

patched neuswc library (tracked)
git clone https://git.daat.foo/neuswc.git
Log | Files | Refs | README | LICENSE

pointer.h (3760B)


      1 /* swc: libswc/pointer.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_POINTER_H
     25 #define SWC_POINTER_H
     26 
     27 #include "input.h"
     28 #include "view.h"
     29 
     30 #include <pixman.h>
     31 #include <wayland-server.h>
     32 
     33 struct button {
     34 	struct press press;
     35 	struct pointer_handler *handler;
     36 };
     37 
     38 struct pointer_handler {
     39 	bool (*motion)(struct pointer_handler *handler, uint32_t time, wl_fixed_t x,
     40 	               wl_fixed_t y);
     41 	bool (*button)(struct pointer_handler *handler, uint32_t time,
     42 	               struct button *button, uint32_t state);
     43 	bool (*axis)(struct pointer_handler *handler, uint32_t time,
     44 	             enum wl_pointer_axis axis, enum wl_pointer_axis_source source,
     45 	             wl_fixed_t value, int value120);
     46 	void (*frame)(struct pointer_handler *handler);
     47 
     48 	int pending;
     49 	struct wl_list link;
     50 };
     51 
     52 struct pointer {
     53 	struct input_focus focus;
     54 	struct input_focus_handler focus_handler;
     55 
     56 	struct {
     57 		struct view view;
     58 		struct surface *surface;
     59 		struct wl_listener destroy_listener;
     60 		struct wld_buffer *buffer;
     61 
     62 		/* Used for cursors set with pointer_set_cursor */
     63 		struct wld_buffer *internal_buffer;
     64 
     65 		struct {
     66 			int32_t x, y;
     67 		} hotspot;
     68 	} cursor;
     69 
     70 	struct wl_array buttons;
     71 	struct wl_list handlers;
     72 	struct pointer_handler client_handler;
     73 	enum wl_pointer_axis_source client_axis_source;
     74 
     75 	wl_fixed_t x, y;
     76 	pixman_region32_t region;
     77 };
     78 
     79 bool
     80 pointer_initialize(struct pointer *pointer);
     81 void
     82 pointer_finalize(struct pointer *pointer);
     83 void
     84 pointer_set_focus(struct pointer *pointer, struct compositor_view *view);
     85 void
     86 pointer_set_region(struct pointer *pointer, pixman_region32_t *region);
     87 void
     88 pointer_set_cursor(struct pointer *pointer, uint32_t id);
     89 void
     90 pointer_set_shape(struct pointer *pointer, const char *name);
     91 void
     92 pointer_motion_notify(int32_t x, int32_t y);
     93 
     94 struct button *
     95 pointer_get_button(struct pointer *pointer, uint32_t serial);
     96 
     97 struct wl_resource *
     98 pointer_bind(struct pointer *pointer, struct wl_client *client,
     99              uint32_t version, uint32_t id);
    100 void
    101 pointer_handle_button(struct pointer *pointer, uint32_t time, uint32_t button,
    102                       uint32_t state);
    103 void
    104 pointer_handle_axis(struct pointer *pointer, uint32_t time,
    105                     enum wl_pointer_axis axis,
    106                     enum wl_pointer_axis_source source, wl_fixed_t value,
    107                     int value120);
    108 void
    109 pointer_handle_relative_motion(struct pointer *pointer, uint32_t time,
    110                                wl_fixed_t dx, wl_fixed_t dy);
    111 void
    112 pointer_handle_absolute_motion(struct pointer *pointer, uint32_t time,
    113                                wl_fixed_t x, wl_fixed_t y);
    114 void
    115 pointer_handle_frame(struct pointer *pointer);
    116 
    117 #endif