button-test: Use wl_display_roundtrip instead of yield()
[profile/ivi/weston.git] / clients / window.h
index 162cc34..edf8c6a 100644 (file)
 #include <cairo.h>
 #include "../shared/config-parser.h"
 
+#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
+
+#define container_of(ptr, type, member) ({                             \
+       const __typeof__( ((type *)0)->member ) *__mptr = (ptr);        \
+       (type *)( (char *)__mptr - offsetof(type,member) );})
+
 struct window;
 struct widget;
 struct display;
@@ -73,6 +79,18 @@ display_get_output(struct display *display);
 uint32_t
 display_get_serial(struct display *display);
 
+typedef void (*display_global_handler_t)(struct display *display,
+                                        uint32_t name,
+                                        const char *interface,
+                                        uint32_t version, void *data);
+
+void
+display_set_global_handler(struct display *display,
+                          display_global_handler_t handler);
+void *
+display_bind(struct display *display, uint32_t name,
+            const struct wl_interface *interface, uint32_t version);
+
 typedef void (*display_output_handler_t)(struct output *output, void *data);
 
 /*
@@ -103,15 +121,10 @@ display_acquire_window_surface(struct display *display,
 void
 display_release_window_surface(struct display *display,
                               struct window *window);
-
-#ifdef HAVE_CAIRO_EGL
-EGLImageKHR
-display_get_image_for_egl_image_surface(struct display *display,
-                                       cairo_surface_t *surface);
-#endif
 #endif
 
 #define SURFACE_OPAQUE 0x01
+#define SURFACE_SHM    0x02
 
 cairo_surface_t *
 display_create_surface(struct display *display,
@@ -123,10 +136,8 @@ struct wl_buffer *
 display_get_buffer_for_surface(struct display *display,
                               cairo_surface_t *surface);
 
-cairo_surface_t *
-display_get_pointer_surface(struct display *display, int pointer,
-                           int *width, int *height,
-                           int *hotspot_x, int *hotspot_y);
+struct wl_cursor_image *
+display_get_pointer_image(struct display *display, int pointer);
 
 void
 display_defer(struct display *display, struct task *task);
@@ -136,29 +147,35 @@ display_watch_fd(struct display *display,
                 int fd, uint32_t events, struct task *task);
 
 void
+display_unwatch_fd(struct display *display, int fd);
+
+void
 display_run(struct display *d);
 
 void
 display_exit(struct display *d);
 
-enum pointer_type {
-       POINTER_BOTTOM_LEFT,
-       POINTER_BOTTOM_RIGHT,
-       POINTER_BOTTOM,
-       POINTER_DRAGGING,
-       POINTER_LEFT_PTR,
-       POINTER_LEFT,
-       POINTER_RIGHT,
-       POINTER_TOP_LEFT,
-       POINTER_TOP_RIGHT,
-       POINTER_TOP,
-       POINTER_IBEAM,
-       POINTER_HAND1,
+enum cursor_type {
+       CURSOR_BOTTOM_LEFT,
+       CURSOR_BOTTOM_RIGHT,
+       CURSOR_BOTTOM,
+       CURSOR_DRAGGING,
+       CURSOR_LEFT_PTR,
+       CURSOR_LEFT,
+       CURSOR_RIGHT,
+       CURSOR_TOP_LEFT,
+       CURSOR_TOP_RIGHT,
+       CURSOR_TOP,
+       CURSOR_IBEAM,
+       CURSOR_HAND1,
+       CURSOR_WATCH,
+
+       CURSOR_BLANK
 };
 
 typedef void (*window_key_handler_t)(struct window *window, struct input *input,
                                     uint32_t time, uint32_t key, uint32_t unicode,
-                                    uint32_t state, void *data);
+                                    enum wl_keyboard_key_state state, void *data);
 
 typedef void (*window_keyboard_focus_handler_t)(struct window *window,
                                                struct input *device, void *data);
@@ -174,6 +191,7 @@ typedef void (*window_drop_handler_t)(struct window *window,
                                      int32_t x, int32_t y, void *data);
 
 typedef void (*window_close_handler_t)(struct window *window, void *data);
+typedef void (*window_fullscreen_handler_t)(struct window *window, void *data);
 
 typedef void (*widget_resize_handler_t)(struct widget *widget,
                                        int32_t width, int32_t height,
@@ -190,14 +208,25 @@ typedef int (*widget_motion_handler_t)(struct widget *widget,
                                       float x, float y, void *data);
 typedef void (*widget_button_handler_t)(struct widget *widget,
                                        struct input *input, uint32_t time,
-                                       uint32_t button, uint32_t state,
+                                       uint32_t button,
+                                       enum wl_pointer_button_state state,
                                        void *data);
+typedef void (*widget_axis_handler_t)(struct widget *widget,
+                                     struct input *input, uint32_t time,
+                                     uint32_t axis,
+                                     wl_fixed_t value,
+                                     void *data);
 
 struct window *
 window_create(struct display *display);
 struct window *
 window_create_transient(struct display *display, struct window *parent,
                        int32_t x, int32_t y, uint32_t flags);
+struct window *
+window_create_custom(struct display *display);
+
+int
+window_has_focus(struct window *window);
 
 typedef void (*menu_func_t)(struct window *window, int index, void *data);
 
@@ -227,8 +256,6 @@ window_move(struct window *window, struct input *input, uint32_t time);
 void
 window_get_allocation(struct window *window, struct rectangle *allocation);
 void
-window_set_transparent(struct window *window, int transparent);
-void
 window_schedule_redraw(struct window *window);
 void
 window_schedule_resize(struct window *window, int width, int height);
@@ -267,14 +294,17 @@ display_surface_damage(struct display *display, cairo_surface_t *cairo_surface,
 void
 window_set_buffer_type(struct window *window, enum window_buffer_type type);
 
+int
+window_is_fullscreen(struct window *window);
+
 void
 window_set_fullscreen(struct window *window, int fullscreen);
 
-void
-window_set_maximized(struct window *window, int maximized);
+int
+window_is_maximized(struct window *window);
 
 void
-window_set_custom(struct window *window);
+window_set_maximized(struct window *window, int maximized);
 
 void
 window_set_user_data(struct window *window, void *data);
@@ -301,6 +331,9 @@ window_set_drop_handler(struct window *window,
 void
 window_set_close_handler(struct window *window,
                         window_close_handler_t handler);
+void
+window_set_fullscreen_handler(struct window *window,
+                             window_fullscreen_handler_t handler);
 
 void
 window_set_title(struct window *window, const char *title);
@@ -308,8 +341,18 @@ window_set_title(struct window *window, const char *title);
 const char *
 window_get_title(struct window *window);
 
+void
+window_set_text_cursor_position(struct window *window, int32_t x, int32_t y);
+
+int
+widget_set_tooltip(struct widget *parent, char *entry, float x, float y);
+
+void
+widget_destroy_tooltip(struct widget *parent);
+
 struct widget *
 widget_add_widget(struct widget *parent, void *data);
+
 void
 widget_destroy(struct widget *widget);
 void
@@ -346,15 +389,20 @@ widget_set_motion_handler(struct widget *widget,
 void
 widget_set_button_handler(struct widget *widget,
                          widget_button_handler_t handler);
+void
+widget_set_axis_handler(struct widget *widget,
+                       widget_axis_handler_t handler);
 
 void
 widget_schedule_redraw(struct widget *widget);
 
 struct widget *
 frame_create(struct window *window, void *data);
+void
+frame_set_child_size(struct widget *widget, int child_width, int child_height);
 
 void
-input_set_pointer_image(struct input *input, uint32_t time, int pointer);
+input_set_pointer_image(struct input *input, int pointer);
 
 void
 input_get_position(struct input *input, int32_t *x, int32_t *y);
@@ -375,6 +423,9 @@ input_ungrab(struct input *input);
 struct widget *
 input_get_focus_widget(struct input *input);
 
+struct display *
+input_get_display(struct input *input);
+
 struct wl_seat *
 input_get_seat(struct input *input);