#ifndef _WINDOW_H_
#define _WINDOW_H_
-#include <X11/extensions/XKBcommon.h>
-#include <glib.h>
+#include <xkbcommon/xkbcommon.h>
#include <wayland-client.h>
#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 item;
+struct widget;
struct display;
struct input;
struct output;
};
struct display *
-display_create(int *argc, char **argv[], const GOptionEntry *option_entries);
+display_create(int argc, char *argv[]);
+
+void
+display_destroy(struct display *display);
void
display_set_user_data(struct display *display, void *data);
struct output *
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);
/*
display_get_egl_display(struct display *d);
EGLConfig
-display_get_rgb_egl_config(struct display *d);
-
-EGLConfig
display_get_argb_egl_config(struct display *d);
int
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,
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);
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_resize_handler_t)(struct window *window,
- int32_t width, int32_t height,
- void *data);
-typedef void (*window_redraw_handler_t)(struct window *window, void *data);
-
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);
-typedef void (*window_button_handler_t)(struct window *window,
- struct input *input, uint32_t time,
- int button, int state, void *data);
-
-typedef int (*window_enter_handler_t)(struct window *window,
- struct input *input, uint32_t time,
- int32_t x, int32_t y, void *data);
-typedef void (*window_leave_handler_t)(struct window *window,
- struct input *input, uint32_t time,
- void *data);
-
-typedef int (*window_motion_handler_t)(struct window *window,
- struct input *input, uint32_t time,
- int32_t x, int32_t y,
- int32_t sx, int32_t sy, void *data);
-
typedef void (*window_data_handler_t)(struct window *window,
- struct input *input, uint32_t time,
- int32_t x, int32_t y,
+ struct input *input,
+ float x, float y,
const char **types,
void *data);
struct input *input,
int32_t x, int32_t y, void *data);
-typedef void (*window_item_focus_handler_t)(struct window *window,
- struct item *focus, 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,
+ void *data);
+typedef void (*widget_redraw_handler_t)(struct widget *widget, void *data);
+
+typedef int (*widget_enter_handler_t)(struct widget *widget,
+ struct input *input,
+ float x, float y, void *data);
+typedef void (*widget_leave_handler_t)(struct widget *widget,
+ struct input *input, void *data);
+typedef int (*widget_motion_handler_t)(struct widget *widget,
+ struct input *input, uint32_t time,
+ float x, float y, void *data);
+typedef void (*widget_button_handler_t)(struct widget *widget,
+ struct input *input, uint32_t time,
+ 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, int32_t width, int32_t height);
+window_create(struct display *display);
struct window *
window_create_transient(struct display *display, struct window *parent,
- int32_t x, int32_t y, int32_t width, int32_t height);
+ int32_t x, int32_t y, uint32_t flags);
struct window *
-window_create_menu(struct display *display, struct window *parent,
- int32_t x, int32_t y, const char **entries, int count);
-
-void
-window_destroy(struct window *window);
+window_create_custom(struct display *display);
-struct item *
-window_add_item(struct window *window, void *data);
-
-typedef void (*item_func_t)(struct item *item, void *data);
+int
+window_has_focus(struct window *window);
-typedef void (*data_func_t)(void *data, size_t len,
- int32_t x, int32_t y, void *user_data);
+typedef void (*menu_func_t)(struct window *window, int index, void *data);
void
-window_for_each_item(struct window *window, item_func_t func, void *data);
-
-struct item *
-window_get_focus_item(struct window *window);
-struct display *
-window_get_display(struct window *window);
+window_show_menu(struct display *display,
+ struct input *input, uint32_t time, struct window *parent,
+ int32_t x, int32_t y,
+ menu_func_t func, const char **entries, int count);
void
-window_move(struct window *window, struct input *input, uint32_t time);
+window_show_frame_menu(struct window *window,
+ struct input *input, uint32_t time);
void
-window_draw(struct window *window);
+window_destroy(struct window *window);
-void
-window_get_allocation(struct window *window,
- struct rectangle *allocation);
+struct widget *
+window_add_widget(struct window *window, void *data);
-void
-window_get_child_allocation(struct window *window,
- struct rectangle *allocation);
+typedef void (*data_func_t)(void *data, size_t len,
+ int32_t x, int32_t y, void *user_data);
+struct display *
+window_get_display(struct window *window);
void
-window_set_transparent(struct window *window, int transparent);
+window_move(struct window *window, struct input *input, uint32_t time);
void
-window_set_child_size(struct window *window, int32_t width, int32_t height);
+window_get_allocation(struct window *window, struct rectangle *allocation);
void
window_schedule_redraw(struct window *window);
+void
+window_schedule_resize(struct window *window, int width, int height);
void
window_damage(struct window *window, int32_t x, int32_t y,
enum window_buffer_type {
WINDOW_BUFFER_TYPE_EGL_WINDOW,
- WINDOW_BUFFER_TYPE_EGL_IMAGE,
WINDOW_BUFFER_TYPE_SHM,
};
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);
+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);
window_get_user_data(struct window *window);
void
-window_set_redraw_handler(struct window *window,
- window_redraw_handler_t handler);
-
-void
-window_set_decoration(struct window *window, int decoration);
-
-void
-window_set_resize_handler(struct window *window,
- window_resize_handler_t handler);
-
-void
window_set_key_handler(struct window *window,
window_key_handler_t handler);
void
-window_set_button_handler(struct window *window,
- window_button_handler_t handler);
-
-void
-window_set_motion_handler(struct window *window,
- window_motion_handler_t handler);
-
-void
-window_set_enter_handler(struct window *window,
- window_enter_handler_t handler);
-void
-window_set_leave_handler(struct window *window,
- window_leave_handler_t handler);
-
-void
window_set_keyboard_focus_handler(struct window *window,
window_keyboard_focus_handler_t handler);
void
-window_set_item_focus_handler(struct window *window,
- window_item_focus_handler_t handler);
-
-void
window_set_data_handler(struct window *window,
window_data_handler_t handler);
window_drop_handler_t handler);
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);
const char *
window_get_title(struct window *window);
void
-item_get_allocation(struct item *item, struct rectangle *allocation);
+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
-item_set_allocation(struct item *item,
- int32_t x, int32_t y, int32_t width, int32_t height);
+widget_destroy_tooltip(struct widget *parent);
+
+struct widget *
+widget_add_widget(struct widget *parent, void *data);
+
+void
+widget_destroy(struct widget *widget);
+void
+widget_get_allocation(struct widget *widget, struct rectangle *allocation);
+
+void
+widget_set_allocation(struct widget *widget,
+ int32_t x, int32_t y, int32_t width, int32_t height);
+void
+widget_set_size(struct widget *widget, int32_t width, int32_t height);
+void
+widget_set_transparent(struct widget *widget, int transparent);
+void
+widget_schedule_resize(struct widget *widget, int32_t width, int32_t height);
void *
-item_get_user_data(struct item *item);
+widget_get_user_data(struct widget *widget);
+
+void
+widget_set_redraw_handler(struct widget *widget,
+ widget_redraw_handler_t handler);
+void
+widget_set_resize_handler(struct widget *widget,
+ widget_resize_handler_t handler);
+void
+widget_set_enter_handler(struct widget *widget,
+ widget_enter_handler_t handler);
+void
+widget_set_leave_handler(struct widget *widget,
+ widget_leave_handler_t handler);
+void
+widget_set_motion_handler(struct widget *widget,
+ widget_motion_handler_t handler);
+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
-input_set_pointer_image(struct input *input, uint32_t time, int pointer);
+frame_set_child_size(struct widget *widget, int child_width, int child_height);
+
+void
+input_set_pointer_image(struct input *input, int pointer);
void
input_get_position(struct input *input, int32_t *x, int32_t *y);
+#define MOD_SHIFT_MASK 0x01
+#define MOD_ALT_MASK 0x02
+#define MOD_CONTROL_MASK 0x04
+
uint32_t
input_get_modifiers(struct input *input);
-struct wl_input_device *
-input_get_input_device(struct input *input);
+void
+input_grab(struct input *input, struct widget *widget, uint32_t button);
+
+void
+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);
struct wl_data_device *
input_get_data_device(struct input *input);
struct wl_data_source *source, uint32_t time);
void
-input_accept(struct input *input, uint32_t time, const char *type);
+input_accept(struct input *input, const char *type);
void
int
input_receive_selection_data(struct input *input, const char *mime_type,
data_func_t func, void *data);
+int
+input_receive_selection_data_to_fd(struct input *input,
+ const char *mime_type, int fd);
void
output_set_user_data(struct output *output, void *data);