From 0b2b70a7c529faa0c37854deb279688102fbb224 Mon Sep 17 00:00:00 2001 From: Manuel Bachmann Date: Wed, 21 May 2014 11:22:19 +0200 Subject: tz-launcher: upgrade to weston/xdg-shell 1.5.0 Change-Id: Iee4efd14966fb1495970e00a5c07b8020a1482b0 Signed-off-by: Manuel Bachmann --- tz-launcher/toytoolkit/window.c | 604 +++++++++++---------- tz-launcher/toytoolkit/window.h | 24 +- tz-launcher/toytoolkit/xdg-shell-client-protocol.h | 290 +++++----- tz-launcher/toytoolkit/xdg-shell-protocol.c | 66 +-- 4 files changed, 511 insertions(+), 473 deletions(-) diff --git a/tz-launcher/toytoolkit/window.c b/tz-launcher/toytoolkit/window.c index 19b5a76..f816ea7 100644 --- a/tz-launcher/toytoolkit/window.c +++ b/tz-launcher/toytoolkit/window.c @@ -21,7 +21,7 @@ * OF THIS SOFTWARE. */ -//#include "config.h" +/*#include "config.h"*/ #include #include @@ -65,10 +65,10 @@ typedef void *EGLContext; #include #include #include "./shared/cairo-util.h" +#include "xdg-shell-client-protocol.h" #include "text-cursor-position-client-protocol.h" #include "workspaces-client-protocol.h" #include "./shared/os-compatibility.h" -#include "xdg-shell-client-protocol.h" #include "window.h" @@ -135,16 +135,6 @@ struct display { int seat_version; }; -enum { - TYPE_NONE, - TYPE_TOPLEVEL, - TYPE_FULLSCREEN, - TYPE_MAXIMIZED, - TYPE_TRANSIENT, - TYPE_MENU, - TYPE_CUSTOM -}; - struct window_output { struct output *output; struct wl_list link; @@ -228,18 +218,17 @@ struct window { struct rectangle min_allocation; struct rectangle pending_allocation; int x, y; - int resize_edges; int redraw_needed; int redraw_task_scheduled; struct task redraw_task; int resize_needed; - int saved_type; - int type; - int focus_count; + int custom; + int focused; int resizing; - int fullscreen_method; - int configure_requests; + + int fullscreen; + int maximized; enum preferred_format preferred_format; @@ -255,6 +244,8 @@ struct window { struct xdg_surface *xdg_surface; struct xdg_popup *xdg_popup; + struct window *transient_for; + struct window_frame *frame; /* struct surface::link, contains also main_surface */ @@ -357,6 +348,8 @@ struct output { struct wl_list link; int transform; int scale; + char *make; + char *model; display_output_handler_t destroy_handler; void *user_data; @@ -384,7 +377,6 @@ struct menu { struct tooltip { struct widget *parent; - struct window *window; struct widget *widget; char *entry; struct task tooltip_task; @@ -404,22 +396,6 @@ enum { CURSOR_UNSET }; -enum window_location { - WINDOW_INTERIOR = 0, - WINDOW_RESIZING_TOP = 1, - WINDOW_RESIZING_BOTTOM = 2, - WINDOW_RESIZING_LEFT = 4, - WINDOW_RESIZING_TOP_LEFT = 5, - WINDOW_RESIZING_BOTTOM_LEFT = 6, - WINDOW_RESIZING_RIGHT = 8, - WINDOW_RESIZING_TOP_RIGHT = 9, - WINDOW_RESIZING_BOTTOM_RIGHT = 10, - WINDOW_RESIZING_MASK = 15, - WINDOW_EXTERIOR = 16, - WINDOW_TITLEBAR = 17, - WINDOW_CLIENT_AREA = 18, -}; - static const cairo_user_data_key_t shm_surface_data_key; /* #define DEBUG */ @@ -1305,7 +1281,11 @@ create_cursors(struct display *display) weston_config_destroy(config);*/ display->cursor_theme = wl_cursor_theme_load(theme, 32, display->shm); - //free(theme); + if (!display->cursor_theme) { + fprintf(stderr, "could not load theme '%s'\n", theme); + return; + } + /*free(theme);*/ display->cursors = xmalloc(ARRAY_LENGTH(cursors) * sizeof display->cursors[0]); @@ -1369,25 +1349,16 @@ surface_flush(struct surface *surface) int window_has_focus(struct window *window) { - return window->focus_count > 0; + return window->focused; } static void -window_flush(struct window *window) +window_close(struct window *window) { - struct surface *surface; - - if (window->type == TYPE_NONE) - window->type = TYPE_TOPLEVEL; - - wl_list_for_each(surface, &window->subsurface_list, link) { - if (surface == window->main_surface) - continue; - - surface_flush(surface); - } - - surface_flush(window->main_surface); + if (window->close_handler) + window->close_handler(window->user_data); + else + display_exit(window->display); } struct display * @@ -1397,7 +1368,7 @@ window_get_display(struct window *window) } static void -surface_create_surface(struct surface *surface, int dx, int dy, uint32_t flags) +surface_create_surface(struct surface *surface, uint32_t flags) { struct display *display = surface->window->display; struct rectangle allocation = surface->allocation; @@ -1417,7 +1388,7 @@ surface_create_surface(struct surface *surface, int dx, int dy, uint32_t flags) flags, &allocation); surface->cairo_surface = surface->toysurface->prepare( - surface->toysurface, dx, dy, + surface->toysurface, 0, 0, allocation.width, allocation.height, flags, surface->buffer_transform, surface->buffer_scale); } @@ -1427,8 +1398,6 @@ window_create_main_surface(struct window *window) { struct surface *surface = window->main_surface; uint32_t flags = 0; - int dx = 0; - int dy = 0; if (window->resizing) flags |= SURFACE_HINT_RESIZE; @@ -1436,17 +1405,7 @@ window_create_main_surface(struct window *window) if (window->preferred_format == WINDOW_PREFERRED_FORMAT_RGB565) flags |= SURFACE_HINT_RGB565; - if (window->resize_edges & WINDOW_RESIZING_LEFT) - dx = surface->server_allocation.width - - surface->allocation.width; - - if (window->resize_edges & WINDOW_RESIZING_TOP) - dy = surface->server_allocation.height - - surface->allocation.height; - - window->resize_edges = 0; - - surface_create_surface(surface, dx, dy, flags); + surface_create_surface(surface, flags); } int @@ -1718,7 +1677,7 @@ widget_get_cairo_surface(struct widget *widget) if (surface == window->main_surface) window_create_main_surface(window); else - surface_create_surface(surface, 0, 0, 0); + surface_create_surface(surface, 0); } return surface->cairo_surface; @@ -1978,6 +1937,7 @@ tooltip_redraw_handler(struct widget *widget, void *data) int32_t width, height; cr = widget_cairo_create(widget); + cairo_translate(cr, widget->allocation.x, widget->allocation.y); cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.0); cairo_paint(cr); @@ -1997,7 +1957,7 @@ tooltip_redraw_handler(struct widget *widget, void *data) } static cairo_text_extents_t -get_text_extents(struct tooltip *tooltip) +get_text_extents(struct display *display, struct tooltip *tooltip) { cairo_t *cr; cairo_text_extents_t extents; @@ -2006,7 +1966,7 @@ get_text_extents(struct tooltip *tooltip) * created yet, and parent does not have a valid surface * outside repaint, either. */ - cr = cairo_create(tooltip->window->display->dummy_surface); + cr = cairo_create(display->dummy_surface); cairo_text_extents(cr, tooltip->entry, &extents); cairo_destroy(cr); @@ -2018,7 +1978,6 @@ window_create_tooltip(struct tooltip *tooltip) { struct widget *parent = tooltip->parent; struct display *display = parent->window->display; - struct window *window; const int offset_y = 27; const int margin = 3; cairo_text_extents_t extents; @@ -2026,18 +1985,13 @@ window_create_tooltip(struct tooltip *tooltip) if (tooltip->widget) return 0; - window = window_create_transient(display, parent->window, tooltip->x, - tooltip->y + offset_y, - WL_SHELL_SURFACE_TRANSIENT_INACTIVE); - if (!window) - return -1; - - tooltip->window = window; - tooltip->widget = window_add_widget(tooltip->window, tooltip); + tooltip->widget = window_add_subsurface(parent->window, tooltip, SUBSURFACE_DESYNCHRONIZED); - extents = get_text_extents(tooltip); + extents = get_text_extents(display, tooltip); widget_set_redraw_handler(tooltip->widget, tooltip_redraw_handler); - window_schedule_resize(window, extents.width + 20, 20 + margin * 2); + widget_set_allocation(tooltip->widget, + tooltip->x, tooltip->y + offset_y, + extents.width + 20, 20 + margin * 2); return 0; } @@ -2053,9 +2007,7 @@ widget_destroy_tooltip(struct widget *parent) if (tooltip->widget) { widget_destroy(tooltip->widget); - window_destroy(tooltip->window); tooltip->widget = NULL; - tooltip->window = NULL; } close(tooltip->tooltip_fd); @@ -2119,7 +2071,6 @@ widget_set_tooltip(struct widget *parent, char *entry, float x, float y) parent->tooltip = tooltip; tooltip->parent = parent; tooltip->widget = NULL; - tooltip->window = NULL; tooltip->x = x; tooltip->y = y; tooltip->entry = strdup(entry); @@ -2163,13 +2114,13 @@ frame_resize_handler(struct widget *widget, struct rectangle input; struct rectangle opaque; - if (widget->window->type == TYPE_FULLSCREEN) { + if (widget->window->fullscreen) { interior.x = 0; interior.y = 0; interior.width = width; interior.height = height; } else { - if (widget->window->type == TYPE_MAXIMIZED) { + if (widget->window->maximized) { frame_set_flag(frame->frame, FRAME_FLAG_MAXIMIZED); } else { frame_unset_flag(frame->frame, FRAME_FLAG_MAXIMIZED); @@ -2187,7 +2138,7 @@ frame_resize_handler(struct widget *widget, child->resize_handler(child, interior.width, interior.height, child->user_data); - if (widget->window->type == TYPE_FULLSCREEN) { + if (widget->window->fullscreen) { width = child->allocation.width; height = child->allocation.height; } else { @@ -2203,7 +2154,7 @@ frame_resize_handler(struct widget *widget, widget->surface->input_region = wl_compositor_create_region(widget->window->display->compositor); - if (widget->window->type != TYPE_FULLSCREEN) { + if (!widget->window->fullscreen) { frame_input_rect(frame->frame, &input.x, &input.y, &input.width, &input.height); wl_region_add(widget->surface->input_region, @@ -2215,7 +2166,7 @@ frame_resize_handler(struct widget *widget, widget_set_allocation(widget, 0, 0, width, height); if (child->opaque) { - if (widget->window->type != TYPE_FULLSCREEN) { + if (!widget->window->fullscreen) { frame_opaque_rect(frame->frame, &opaque.x, &opaque.y, &opaque.width, &opaque.height); @@ -2239,10 +2190,10 @@ frame_redraw_handler(struct widget *widget, void *data) struct window_frame *frame = data; struct window *window = widget->window; - if (window->type == TYPE_FULLSCREEN) + if (window->fullscreen) return; - if (window->focus_count) { + if (window->focused) { frame_set_flag(frame->frame, FRAME_FLAG_ACTIVE); } else { frame_unset_flag(frame->frame, FRAME_FLAG_ACTIVE); @@ -2261,7 +2212,7 @@ frame_get_pointer_image_for_location(struct window_frame *frame, { struct window *window = frame->widget->window; - if (window->type != TYPE_TOPLEVEL) + if (window->custom) return CURSOR_LEFT_PTR; switch (location) { @@ -2295,7 +2246,10 @@ frame_menu_func(struct window *window, struct display *display; switch (index) { - case 0: /* move to workspace above */ + case 0: /* close */ + window_close(window); + break; + case 1: /* move to workspace above */ display = window->display; if (display->workspace > 0) workspace_manager_move_surface( @@ -2303,7 +2257,7 @@ frame_menu_func(struct window *window, window->main_surface->surface, display->workspace - 1); break; - case 1: /* move to workspace below */ + case 2: /* move to workspace below */ display = window->display; if (display->workspace < display->workspace_count - 1) workspace_manager_move_surface( @@ -2311,7 +2265,7 @@ frame_menu_func(struct window *window, window->main_surface->surface, display->workspace + 1); break; - case 2: /* fullscreen */ + case 3: /* fullscreen */ /* we don't have a way to get out of fullscreen for now */ if (window->fullscreen_handler) window->fullscreen_handler(window, window->user_data); @@ -2327,6 +2281,7 @@ window_show_frame_menu(struct window *window, int count; static const char *entries[] = { + "Close", "Move to workspace above", "Move to workspace below", "Fullscreen" }; @@ -2403,15 +2358,12 @@ frame_handle_status(struct window_frame *frame, struct input *input, } if (status & FRAME_STATUS_MAXIMIZE) { - window_set_maximized(window, window->type != TYPE_MAXIMIZED); + window_set_maximized(window, !window->maximized); frame_status_clear(frame->frame, FRAME_STATUS_MAXIMIZE); } if (status & FRAME_STATUS_CLOSE) { - if (window->close_handler) - window->close_handler(window->user_data); - else - display_exit(window->display); + window_close(window); return; } @@ -2479,7 +2431,7 @@ window_frame_create(struct window *window, void *data) struct window_frame *frame; uint32_t buttons; - if (window->type == TYPE_CUSTOM) { + if (window->custom) { buttons = FRAME_BUTTON_NONE; } else { buttons = FRAME_BUTTON_ALL; @@ -2514,9 +2466,9 @@ window_frame_set_child_size(struct widget *widget, int child_width, struct theme *t = display->theme; int decoration_width, decoration_height; int width, height; - int margin = widget->window->type == TYPE_MAXIMIZED ? 0 : t->margin; + int margin = widget->window->maximized ? 0 : t->margin; - if (widget->window->type != TYPE_FULLSCREEN) { + if (!widget->window->fullscreen) { decoration_width = (t->width + margin) * 2; decoration_height = t->width + t->titlebar_height + margin * 2; @@ -2606,6 +2558,8 @@ input_grab(struct input *input, struct widget *widget, uint32_t button) { input->grab = widget; input->grab_button = button; + + input_set_focus_widget(input, widget, input->sx, input->sy); } void @@ -2651,10 +2605,15 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer, return; } + window = wl_surface_get_user_data(surface); + if (surface != window->main_surface->surface) { + DBG("Ignoring input event from subsurface %p\n", surface); + return; + } + input->display->serial = serial; input->pointer_enter_serial = serial; - input->pointer_focus = wl_surface_get_user_data(surface); - window = input->pointer_focus; + input->pointer_focus = window; if (window->resizing) { window->resizing = 0; @@ -2690,12 +2649,12 @@ pointer_handle_motion(void *data, struct wl_pointer *pointer, float sx = wl_fixed_to_double(sx_w); float sy = wl_fixed_to_double(sy_w); - input->sx = sx; - input->sy = sy; - if (!window) return; + input->sx = sx; + input->sy = sy; + /* when making the window smaller - e.g. after a unmaximise we might * still have a pending motion event that the compositor has picked * based on the old surface dimensions @@ -2791,7 +2750,6 @@ input_remove_keyboard_focus(struct input *input) if (!window) return; - window->focus_count--; if (window->keyboard_focus_handler) (*window->keyboard_focus_handler)(window, NULL, window->user_data); @@ -2890,7 +2848,6 @@ keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, input->keyboard_focus = wl_surface_get_user_data(surface); window = input->keyboard_focus; - window->focus_count++; if (window->keyboard_focus_handler) (*window->keyboard_focus_handler)(window, input, window->user_data); @@ -2924,6 +2881,14 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard, if (!window || !input->xkb.state) return; + /* We only use input grabs for pointer events for now, so just + * ignore key presses if a grab is active. We expand the key + * event delivery mechanism to route events to widgets to + * properly handle key grabs. In the meantime, this prevents + * key event devlivery while a grab is active. */ + if (input->grab && input->grab_button == 0) + return; + num_syms = xkb_key_get_syms(input->xkb.state, code, &syms); sym = XKB_KEY_NoSymbol; @@ -2933,8 +2898,7 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard, if (sym == XKB_KEY_F5 && input->modifiers == MOD_ALT_MASK) { if (state == WL_KEYBOARD_KEY_STATE_PRESSED) - window_set_maximized(window, - window->type != TYPE_MAXIMIZED); + window_set_maximized(window, !window->maximized); } else if (sym == XKB_KEY_F11 && window->fullscreen_handler && state == WL_KEYBOARD_KEY_STATE_PRESSED) { @@ -2942,10 +2906,7 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard, } else if (sym == XKB_KEY_F4 && input->modifiers == MOD_ALT_MASK && state == WL_KEYBOARD_KEY_STATE_PRESSED) { - if (window->close_handler) - window->close_handler(window->user_data); - else - display_exit(window->display); + window_close(window); } else if (window->key_handler) { (*window->key_handler)(window, input, time, key, sym, state, window->user_data); @@ -2958,7 +2919,8 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard, its.it_value.tv_sec = 0; its.it_value.tv_nsec = 0; timerfd_settime(input->repeat_timer_fd, 0, &its, NULL); - } else if (state == WL_KEYBOARD_KEY_STATE_PRESSED) { + } else if (state == WL_KEYBOARD_KEY_STATE_PRESSED && + xkb_keymap_key_repeats(input->xkb.keymap, code)) { input->repeat_sym = sym; input->repeat_key = key; input->repeat_time = time; @@ -3022,9 +2984,18 @@ touch_handle_down(void *data, struct wl_touch *wl_touch, return; } - widget = window_find_widget(input->touch_focus, - wl_fixed_to_double(x_w), - wl_fixed_to_double(y_w)); + if (surface != input->touch_focus->main_surface->surface) { + DBG("Ignoring input event from subsurface %p\n", surface); + input->touch_focus = NULL; + return; + } + + if (input->grab) + widget = input->grab; + else + widget = window_find_widget(input->touch_focus, + wl_fixed_to_double(x_w), + wl_fixed_to_double(y_w)); if (widget) { struct touch_point *tp = xmalloc(sizeof *tp); if (tp) { @@ -3118,9 +3089,6 @@ touch_handle_frame(void *data, struct wl_touch *wl_touch) if (tp->widget->touch_frame_handler) (*tp->widget->touch_frame_handler)(tp->widget, input, tp->widget->user_data); - - wl_list_remove(&tp->link); - free(tp); } } @@ -3454,13 +3422,13 @@ input_set_pointer_image_index(struct input *input, int index) if (!buffer) return; - wl_pointer_set_cursor(input->pointer, input->pointer_enter_serial, - input->pointer_surface, - image->hotspot_x, image->hotspot_y); wl_surface_attach(input->pointer_surface, buffer, 0, 0); wl_surface_damage(input->pointer_surface, 0, 0, image->width, image->height); wl_surface_commit(input->pointer_surface); + wl_pointer_set_cursor(input->pointer, input->pointer_enter_serial, + input->pointer_surface, + image->hotspot_x, image->hotspot_y); } static const struct wl_callback_listener pointer_surface_listener; @@ -3560,7 +3528,8 @@ void input_set_selection(struct input *input, struct wl_data_source *source, uint32_t time) { - wl_data_device_set_selection(input->data_device, source, time); + if (input->data_device) + wl_data_device_set_selection(input->data_device, source, time); } void @@ -3796,6 +3765,9 @@ window_do_resize(struct window *window) surface_set_synchronized(surface); surface_resize(surface); } + + if (!window->fullscreen && !window->maximized) + window->saved_allocation = window->pending_allocation; } static void @@ -3876,62 +3848,127 @@ widget_schedule_resize(struct widget *widget, int32_t width, int32_t height) } static void -handle_surface_ping(void *data, struct xdg_surface *xdg_surface, - uint32_t serial) +handle_surface_configure(void *data, struct xdg_surface *xdg_surface, + int32_t width, int32_t height) { - xdg_surface_pong(xdg_surface, serial); + struct window *window = data; + + window_schedule_resize(window, width, height); } static void -handle_surface_configure(void *data, struct xdg_surface *xdg_surface, - uint32_t edges, int32_t width, int32_t height) +handle_surface_change_state(void *data, struct xdg_surface *xdg_surface, + uint32_t state, + uint32_t value, + uint32_t serial) { struct window *window = data; - window->resize_edges = edges; - window_schedule_resize(window, width, height); + switch (state) { + case XDG_SURFACE_STATE_MAXIMIZED: + window->maximized = value; + break; + case XDG_SURFACE_STATE_FULLSCREEN: + window->fullscreen = value; + break; + } + + if (!window->fullscreen && !window->maximized) + window_schedule_resize(window, + window->saved_allocation.width, + window->saved_allocation.height); + + xdg_surface_ack_change_state(xdg_surface, state, value, serial); + window_schedule_redraw(window); } static void -handle_surface_request_set_fullscreen(void *data, struct xdg_surface *xdg_surface) +handle_surface_activated(void *data, struct xdg_surface *xdg_surface) { + struct window *window = data; + window->focused = 1; } static void -handle_surface_request_unset_fullscreen(void *data, struct xdg_surface *xdg_surface) +handle_surface_deactivated(void *data, struct xdg_surface *xdg_surface) { + struct window *window = data; + window->focused = 0; } static void -handle_surface_request_set_maximized(void *data, struct xdg_surface *xdg_surface) +handle_surface_delete(void *data, struct xdg_surface *xdg_surface) { + struct window *window = data; + window_close(window); } +static const struct xdg_surface_listener xdg_surface_listener = { + handle_surface_configure, + handle_surface_change_state, + handle_surface_activated, + handle_surface_deactivated, + handle_surface_delete, +}; + static void -handle_surface_request_unset_maximized(void *data, struct xdg_surface *xdg_surface) +window_sync_transient_for(struct window *window) { + struct wl_surface *parent_surface; + + if (!window->xdg_surface) + return; + + if (window->transient_for) + parent_surface = window->transient_for->main_surface->surface; + else + parent_surface = NULL; + + xdg_surface_set_transient_for(window->xdg_surface, parent_surface); } static void -handle_surface_focused_set(void *data, struct xdg_surface *xdg_surface) +window_sync_margin(struct window *window) { + int margin; + + if (!window->xdg_surface) + return; + + if (!window->frame) + return; + + margin = frame_get_shadow_margin(window->frame->frame); + + /* Shadow size is the same on every side. */ + xdg_surface_set_margin(window->xdg_surface, + margin, + margin, + margin, + margin); } static void -handle_surface_focused_unset(void *data, struct xdg_surface *xdg_surface) +window_flush(struct window *window) { -} + struct surface *surface; -static const struct xdg_surface_listener xdg_surface_listener = { - handle_surface_ping, - handle_surface_configure, - handle_surface_request_set_fullscreen, - handle_surface_request_unset_fullscreen, - handle_surface_request_set_maximized, - handle_surface_request_unset_maximized, - handle_surface_focused_set, - handle_surface_focused_unset -}; + if (!window->custom) { + if (window->xdg_surface) { + window_sync_transient_for(window); + window_sync_margin(window); + } + } + + wl_list_for_each(surface, &window->subsurface_list, link) { + if (surface == window->main_surface) + continue; + + surface_flush(surface); + } + + surface_flush(window->main_surface); +} static void menu_destroy(struct menu *menu) @@ -4073,8 +4110,6 @@ idle_redraw(struct task *task, uint32_t events) static void window_schedule_redraw_task(struct window *window) { - if (window->configure_requests) - return; if (!window->redraw_task_scheduled) { window->redraw_task.run = idle_redraw; display_defer(window->display, &window->redraw_task); @@ -4098,44 +4133,7 @@ window_schedule_redraw(struct window *window) int window_is_fullscreen(struct window *window) { - return window->type == TYPE_FULLSCREEN; -} - -int -window_is_transient(struct window *window) -{ - return window->type == TYPE_TRANSIENT; -} - -static void -configure_request_completed(void *data, struct wl_callback *callback, uint32_t time) -{ - struct window *window = data; - - wl_callback_destroy(callback); - window->configure_requests--; - - if (!window->configure_requests) - window_schedule_redraw(window); -} - -static struct wl_callback_listener configure_request_listener = { - configure_request_completed, -}; - -static void -window_defer_redraw_until_configure(struct window* window) -{ - struct wl_callback *callback; - - if (window->redraw_task_scheduled) { - wl_list_remove(&window->redraw_task.link); - window->redraw_task_scheduled = 0; - } - - callback = wl_display_sync(window->display->display); - wl_callback_add_listener(callback, &configure_request_listener, window); - window->configure_requests++; + return window->fullscreen; } void @@ -4144,29 +4142,19 @@ window_set_fullscreen(struct window *window, int fullscreen) if (!window->xdg_surface) return; - if ((window->type == TYPE_FULLSCREEN) == fullscreen) + if (window->fullscreen == fullscreen) return; - if (fullscreen) { - window->saved_type = window->type; - window->type = TYPE_FULLSCREEN; - xdg_surface_set_fullscreen(window->xdg_surface); - window_defer_redraw_until_configure (window); - } else { - if (window->saved_type == TYPE_MAXIMIZED) { - window_set_maximized(window, 1); - } else { - window->type = TYPE_TOPLEVEL; - xdg_surface_unset_fullscreen(window->xdg_surface); - } - - } + xdg_surface_request_change_state(window->xdg_surface, + XDG_SURFACE_STATE_FULLSCREEN, + fullscreen ? 1 : 0, + 0); } int window_is_maximized(struct window *window) { - return window->type == TYPE_MAXIMIZED; + return window->maximized; } void @@ -4175,18 +4163,13 @@ window_set_maximized(struct window *window, int maximized) if (!window->xdg_surface) return; - if ((window->type == TYPE_MAXIMIZED) == maximized) + if (window->maximized == maximized) return; - if (window->type == TYPE_TOPLEVEL) { - xdg_surface_set_maximized(window->xdg_surface); - window->type = TYPE_MAXIMIZED; - window_defer_redraw_until_configure(window); - } else if (window->type == TYPE_MAXIMIZED) { - xdg_surface_unset_maximized(window->xdg_surface); - window->type = TYPE_TOPLEVEL; - window_defer_redraw_until_configure(window); - } + xdg_surface_request_change_state(window->xdg_surface, + XDG_SURFACE_STATE_MAXIMIZED, + maximized ? 1 : 0, + 0); } void @@ -4196,7 +4179,6 @@ window_set_minimized(struct window *window) return; xdg_surface_set_minimized(window->xdg_surface); - window_defer_redraw_until_configure(window); } void @@ -4380,8 +4362,19 @@ surface_create(struct window *window) return surface; } +static enum window_buffer_type +get_preferred_buffer_type(struct display *display) +{ +#ifdef HAVE_CAIRO_EGL + if (display->argb_device && !getenv("TOYTOOLKIT_NO_EGL")) + return WINDOW_BUFFER_TYPE_EGL_WINDOW; +#endif + + return WINDOW_BUFFER_TYPE_SHM; +} + static struct window * -window_create_internal(struct display *display, int type) +window_create_internal(struct display *display, int custom) { struct window *window; struct surface *surface; @@ -4393,37 +4386,17 @@ window_create_internal(struct display *display, int type) surface = surface_create(window); window->main_surface = surface; - if (type != TYPE_CUSTOM && type != TYPE_MENU && display->xdg_shell) { - window->xdg_surface = - xdg_shell_get_xdg_surface(display->xdg_shell, - surface->surface); - fail_on_null(window->xdg_surface); - } + assert(custom || display->xdg_shell); - window->type = type; - window->fullscreen_method = WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT; - window->configure_requests = 0; + window->custom = custom; window->preferred_format = WINDOW_PREFERRED_FORMAT_NONE; - if (display->argb_device) -#ifdef HAVE_CAIRO_EGL - surface->buffer_type = WINDOW_BUFFER_TYPE_EGL_WINDOW; -#else - surface->buffer_type = WINDOW_BUFFER_TYPE_SHM; -#endif - else - surface->buffer_type = WINDOW_BUFFER_TYPE_SHM; + surface->buffer_type = get_preferred_buffer_type(display); wl_surface_set_user_data(surface->surface, window); wl_list_insert(display->window_list.prev, &window->link); wl_list_init(&window->redraw_task.link); - if (window->xdg_surface) { - xdg_surface_set_user_data(window->xdg_surface, window); - xdg_surface_add_listener(window->xdg_surface, - &xdg_surface_listener, window); - } - wl_list_init (&window->window_output_list); return window; @@ -4432,29 +4405,40 @@ window_create_internal(struct display *display, int type) struct window * window_create(struct display *display) { - return window_create_internal(display, TYPE_NONE); + struct window *window; + + window = window_create_internal(display, 0); + + window->xdg_surface = + xdg_shell_get_xdg_surface(window->display->xdg_shell, + window->main_surface->surface); + fail_on_null(window->xdg_surface); + + xdg_surface_set_user_data(window->xdg_surface, window); + xdg_surface_add_listener(window->xdg_surface, + &xdg_surface_listener, window); + + return window; } struct window * window_create_custom(struct display *display) { - return window_create_internal(display, TYPE_CUSTOM); + return window_create_internal(display, 1); } -struct window * -window_create_transient(struct display *display, struct window *parent, - int32_t x, int32_t y, uint32_t flags) +void +window_set_transient_for(struct window *window, + struct window *parent_window) { - struct window *window; - - window = window_create_internal(parent->display, TYPE_TRANSIENT); - - if (display->xdg_shell) - xdg_surface_set_transient_for( - window->xdg_surface, - parent->main_surface->surface); + window->transient_for = parent_window; + window_sync_transient_for(window); +} - return window; +struct window * +window_get_transient_for(struct window *window) +{ + return window->transient_for; } static void @@ -4527,6 +4511,20 @@ menu_button_handler(struct widget *widget, } } +static void +menu_touch_up_handler(struct widget *widget, + struct input *input, + uint32_t serial, + uint32_t time, + int32_t id, + void *data) +{ + struct menu *menu = data; + + input_ungrab(input); + menu_destroy(menu); +} + static void menu_redraw_handler(struct widget *widget, void *data) { @@ -4567,12 +4565,6 @@ menu_redraw_handler(struct widget *widget, void *data) cairo_destroy(cr); } -static void -handle_popup_ping(void *data, struct xdg_popup *xdg_popup, uint32_t serial) -{ - xdg_popup_pong(xdg_popup, serial); -} - static void handle_popup_popup_done(void *data, struct xdg_popup *xdg_popup, uint32_t serial) { @@ -4584,8 +4576,7 @@ handle_popup_popup_done(void *data, struct xdg_popup *xdg_popup, uint32_t serial } static const struct xdg_popup_listener xdg_popup_listener = { - handle_popup_ping, - handle_popup_popup_done + handle_popup_popup_done, }; void @@ -4602,7 +4593,7 @@ window_show_menu(struct display *display, if (!menu) return; - window = window_create_internal(parent->display, TYPE_MENU); + window = window_create_internal(parent->display, 0); if (!window) { free(menu); return; @@ -4623,7 +4614,6 @@ window_show_menu(struct display *display, menu->time = time; menu->func = func; menu->input = input; - window->type = TYPE_MENU; window->x = x; window->y = y; @@ -4634,6 +4624,7 @@ window_show_menu(struct display *display, widget_set_leave_handler(menu->widget, menu_leave_handler); widget_set_motion_handler(menu->widget, menu_motion_handler); widget_set_button_handler(menu->widget, menu_button_handler); + widget_set_touch_up_handler(menu->widget, menu_touch_up_handler); input_grab(input, menu->widget, 0); frame_resize_inside(menu->frame, 200, count * 20); @@ -4642,11 +4633,12 @@ window_show_menu(struct display *display, frame_height(menu->frame)); frame_interior(menu->frame, &ix, &iy, NULL, NULL); + window->xdg_popup = xdg_shell_get_xdg_popup(display->xdg_shell, - window->main_surface->surface, - parent->main_surface->surface, + window->main_surface->surface, + parent->main_surface->surface, input->seat, - display_get_serial(window->display), + display_get_serial(window->display), window->x - ix, window->y - iy, 0); @@ -4663,6 +4655,12 @@ window_set_buffer_type(struct window *window, enum window_buffer_type type) window->main_surface->buffer_type = type; } +enum window_buffer_type +window_get_buffer_type(struct window *window) +{ + return window->main_surface->buffer_type; +} + void window_set_preferred_format(struct window *window, enum preferred_format format) @@ -4680,6 +4678,7 @@ window_add_subsurface(struct window *window, void *data, struct wl_subcompositor *subcompo = window->display->subcompositor; surface = surface_create(window); + surface->buffer_type = window_get_buffer_type(window); widget = widget_create(window, surface, data); wl_list_init(&widget->link); surface->widget = widget; @@ -4701,6 +4700,9 @@ window_add_subsurface(struct window *window, void *data, assert(!"bad enum subsurface_mode"); } + window->resize_needed = 1; + window_schedule_redraw(window); + return widget; } @@ -4720,6 +4722,14 @@ display_handle_geometry(void *data, output->allocation.x = x; output->allocation.y = y; output->transform = transform; + + if (output->make) + free(output->make); + output->make = strdup(make); + + if (output->model) + free(output->model); + output->model = strdup(model); } static void @@ -4907,6 +4917,18 @@ output_get_scale(struct output *output) return output->scale; } +const char * +output_get_make(struct output *output) +{ + return output->make; +} + +const char * +output_get_model(struct output *output) +{ + return output->model; +} + static void fini_xkb(struct input *input) { @@ -4934,11 +4956,14 @@ display_add_input(struct display *d, uint32_t id) wl_seat_add_listener(input->seat, &seat_listener, input); wl_seat_set_user_data(input->seat, input); - input->data_device = - wl_data_device_manager_get_data_device(d->data_device_manager, - input->seat); - wl_data_device_add_listener(input->data_device, &data_device_listener, - input); + if (d->data_device_manager) { + input->data_device = + wl_data_device_manager_get_data_device(d->data_device_manager, + input->seat); + wl_data_device_add_listener(input->data_device, + &data_device_listener, + input); + } input->pointer_surface = wl_compositor_create_surface(d->compositor); @@ -4961,7 +4986,8 @@ input_destroy(struct input *input) if (input->selection_offer) data_offer_destroy(input->selection_offer); - wl_data_device_destroy(input->data_device); + if (input->data_device) + wl_data_device_destroy(input->data_device); if (input->display->seat_version >= 3) { if (input->pointer) @@ -5005,6 +5031,22 @@ struct wl_shm_listener shm_listener = { shm_format }; +static void +xdg_shell_ping(void *data, struct xdg_shell *shell, uint32_t serial) +{ + xdg_shell_pong(shell, serial); +} + +static const struct xdg_shell_listener xdg_shell_listener = { + xdg_shell_ping, +}; + +#define XDG_VERSION 3 /* The version of xdg-shell that we implement */ +#ifdef static_assert +static_assert(XDG_VERSION == XDG_SHELL_VERSION_CURRENT, + "Interface version doesn't match implementation version"); +#endif + static void registry_handle_global(void *data, struct wl_registry *registry, uint32_t id, const char *interface, uint32_t version) @@ -5026,10 +5068,6 @@ registry_handle_global(void *data, struct wl_registry *registry, uint32_t id, } else if (strcmp(interface, "wl_seat") == 0) { d->seat_version = version; display_add_input(d, id); - } else if (strcmp(interface, "xdg_shell") == 0) { - d->xdg_shell = wl_registry_bind(registry, - id, &xdg_shell_interface, 1); - xdg_shell_use_unstable_version(d->xdg_shell, XDG_SHELL_VERSION_CURRENT); } else if (strcmp(interface, "wl_shm") == 0) { d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1); wl_shm_add_listener(d->shm, &shm_listener, d); @@ -5037,6 +5075,11 @@ registry_handle_global(void *data, struct wl_registry *registry, uint32_t id, d->data_device_manager = wl_registry_bind(registry, id, &wl_data_device_manager_interface, 1); + } else if (strcmp(interface, "xdg_shell") == 0) { + d->xdg_shell = wl_registry_bind(registry, id, + &xdg_shell_interface, 1); + xdg_shell_use_unstable_version(d->xdg_shell, XDG_VERSION); + xdg_shell_add_listener(d->xdg_shell, &xdg_shell_listener, d); } else if (strcmp(interface, "text_cursor_position") == 0) { d->text_cursor_position = wl_registry_bind(registry, id, @@ -5427,7 +5470,10 @@ display_get_egl_display(struct display *d) struct wl_data_source * display_create_data_source(struct display *display) { - return wl_data_device_manager_create_data_source(display->data_device_manager); + if (display->data_device_manager) + return wl_data_device_manager_create_data_source(display->data_device_manager); + else + return NULL; } EGLConfig diff --git a/tz-launcher/toytoolkit/window.h b/tz-launcher/toytoolkit/window.h index d264f4d..6fcd2a3 100644 --- a/tz-launcher/toytoolkit/window.h +++ b/tz-launcher/toytoolkit/window.h @@ -23,9 +23,12 @@ #ifndef _WINDOW_H_ #define _WINDOW_H_ +/*#include "config.h"*/ + #include #include #include +/*#include "./shared/config-parser.h"*/ #include "./shared/zalloc.h" #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) @@ -269,11 +272,13 @@ typedef void (*widget_axis_handler_t)(struct widget *widget, 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); +void +window_set_transient_for(struct window *window, struct window *parent_window); +struct window * +window_get_transient_for(struct window *window); + int window_has_focus(struct window *window); @@ -361,8 +366,8 @@ 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_transient(struct window *window); +enum window_buffer_type +window_get_buffer_type(struct window *window); int window_is_fullscreen(struct window *window); @@ -370,9 +375,6 @@ window_is_fullscreen(struct window *window); void window_set_fullscreen(struct window *window, int fullscreen); -void -window_set_fullscreen_method(struct window *window, - enum wl_shell_surface_fullscreen_method method); int window_is_maximized(struct window *window); @@ -605,6 +607,12 @@ output_get_transform(struct output *output); uint32_t output_get_scale(struct output *output); +const char * +output_get_make(struct output *output); + +const char * +output_get_model(struct output *output); + void keysym_modifiers_add(struct wl_array *modifiers_map, const char *name); diff --git a/tz-launcher/toytoolkit/xdg-shell-client-protocol.h b/tz-launcher/toytoolkit/xdg-shell-client-protocol.h index 353d38a..6ae0d9d 100644 --- a/tz-launcher/toytoolkit/xdg-shell-client-protocol.h +++ b/tz-launcher/toytoolkit/xdg-shell-client-protocol.h @@ -54,17 +54,55 @@ extern const struct wl_interface xdg_popup_interface; * xdg_shell_version - latest protocol version * @XDG_SHELL_VERSION_CURRENT: Always the latest version * - * Use this enum to check the protocol version, and it will be updated - * automatically. + * The 'current' member of this enum gives the version of the protocol. + * Implementations can compare this to the version they implement using + * static_assert to ensure the protocol and implementation versions match. */ enum xdg_shell_version { - XDG_SHELL_VERSION_CURRENT = 1, + XDG_SHELL_VERSION_CURRENT = 3, }; #endif /* XDG_SHELL_VERSION_ENUM */ +/** + * xdg_shell - create desktop-style surfaces + * @ping: check if the client is alive + * + * This interface is implemented by servers that provide desktop-style + * user interfaces. + * + * It allows clients to associate a xdg_surface with a basic surface. + */ +struct xdg_shell_listener { + /** + * ping - check if the client is alive + * @serial: pass this to the callback + * + * The ping event asks the client if it's still alive. Pass the + * serial specified in the event back to the compositor by sending + * a "pong" request back with the specified serial. + * + * Compositors can use this to determine if the client is still + * alive. It's unspecified what will happen if the client doesn't + * respond to the ping request, or in what timeframe. Clients + * should try to respond in a reasonable amount of time. + */ + void (*ping)(void *data, + struct xdg_shell *xdg_shell, + uint32_t serial); +}; + +static inline int +xdg_shell_add_listener(struct xdg_shell *xdg_shell, + const struct xdg_shell_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) xdg_shell, + (void (**)(void)) listener, data); +} + #define XDG_SHELL_USE_UNSTABLE_VERSION 0 #define XDG_SHELL_GET_XDG_SURFACE 1 #define XDG_SHELL_GET_XDG_POPUP 2 +#define XDG_SHELL_PONG 3 static inline void xdg_shell_set_user_data(struct xdg_shell *xdg_shell, void *user_data) @@ -113,6 +151,13 @@ xdg_shell_get_xdg_popup(struct xdg_shell *xdg_shell, struct wl_surface *surface, return (struct xdg_popup *) id; } +static inline void +xdg_shell_pong(struct xdg_shell *xdg_shell, uint32_t serial) +{ + wl_proxy_marshal((struct wl_proxy *) xdg_shell, + XDG_SHELL_PONG, serial); +} + #ifndef XDG_SURFACE_RESIZE_EDGE_ENUM #define XDG_SURFACE_RESIZE_EDGE_ENUM /** @@ -144,22 +189,45 @@ enum xdg_surface_resize_edge { }; #endif /* XDG_SURFACE_RESIZE_EDGE_ENUM */ +#ifndef XDG_SURFACE_STATE_ENUM +#define XDG_SURFACE_STATE_ENUM +/** + * xdg_surface_state - types of state on the surface + * @XDG_SURFACE_STATE_MAXIMIZED: the surface is maximized + * @XDG_SURFACE_STATE_FULLSCREEN: the surface is fullscreen + * + * The different state values used on the surface. This is designed for + * state values like maximized, fullscreen. It is paired with the + * request_change_state event to ensure that both the client and the + * compositor setting the state can be synchronized. + * + * States set in this way are double-buffered. They will get applied on the + * next commit. + * + * Desktop environments may extend this enum by taking up a range of values + * and documenting the range they chose in this description. They are not + * required to document the values for the range that they chose. Ideally, + * any good extensions from a desktop environment should make its way into + * standardization into this enum. + * + * The current reserved ranges are: + * + * 0x0000 - 0x0FFF: xdg-shell core values, documented below. 0x1000 - + * 0x1FFF: GNOME + */ +enum xdg_surface_state { + XDG_SURFACE_STATE_MAXIMIZED = 1, + XDG_SURFACE_STATE_FULLSCREEN = 2, +}; +#endif /* XDG_SURFACE_STATE_ENUM */ + /** * xdg_surface - desktop-style metadata interface - * @ping: ping client * @configure: suggest resize - * @request_set_fullscreen: server requests that the client set - * fullscreen - * @request_unset_fullscreen: server requests that the client unset - * fullscreen - * @request_set_maximized: server requests that the client set maximized - * @request_unset_maximized: server requests that the client unset - * maximized - * @request_set_minimized: server requests that the client set minimized - * @request_unset_minimized: server requests that the client unset - * maximized - * @focused_set: surface was focused - * @focused_unset: surface was unfocused + * @change_state: compositor wants to change a surface's state + * @activated: surface was activated + * @deactivated: surface was deactivated + * @close: surface wants to be closed * * An interface that may be implemented by a wl_surface, for * implementations that provide a desktop-style user interface. @@ -173,19 +241,8 @@ enum xdg_surface_resize_edge { * must be called before destroying the wl_surface object. */ struct xdg_surface_listener { - /** - * ping - ping client - * @serial: (none) - * - * Ping a client to check if it is receiving events and sending - * requests. A client is expected to reply with a pong request. - */ - void (*ping)(void *data, - struct xdg_surface *xdg_surface, - uint32_t serial); /** * configure - suggest resize - * @edges: (none) * @width: (none) * @height: (none) * @@ -195,12 +252,6 @@ struct xdg_surface_listener { * ignore it if it doesn't resize, pick a smaller size (to satisfy * aspect ratio or resize in steps of NxM pixels). * - * The edges parameter provides a hint about how the surface was - * resized. The client may use this information to decide how to - * adjust its content to the new size (e.g. a scrolling area might - * adjust its content position to leave the viewable content - * unmoved). Valid edge values are from resize_edge enum. - * * The client is free to dismiss all but the last configure event * it received. * @@ -209,86 +260,62 @@ struct xdg_surface_listener { */ void (*configure)(void *data, struct xdg_surface *xdg_surface, - uint32_t edges, int32_t width, int32_t height); /** - * request_set_fullscreen - server requests that the client set - * fullscreen - * - * Event sent from the compositor to the client requesting that - * the client goes to a fullscreen state. It's the client job to - * call set_fullscreen and really trigger the fullscreen state. - */ - void (*request_set_fullscreen)(void *data, - struct xdg_surface *xdg_surface); - /** - * request_unset_fullscreen - server requests that the client - * unset fullscreen - * - * Event sent from the compositor to the client requesting that - * the client leaves the fullscreen state. It's the client job to - * call unset_fullscreen and really leave the fullscreen state. - */ - void (*request_unset_fullscreen)(void *data, - struct xdg_surface *xdg_surface); - /** - * request_set_maximized - server requests that the client set - * maximized - * - * Event sent from the compositor to the client requesting that - * the client goes to a maximized state. It's the client job to - * call set_maximized and really trigger the maximized state. - */ - void (*request_set_maximized)(void *data, - struct xdg_surface *xdg_surface); - /** - * request_unset_maximized - server requests that the client - * unset maximized - * - * Event sent from the compositor to the client requesting that - * the client leaves the maximized state. It's the client job to - * call unset_maximized and really leave the maximized state. - */ - void (*request_unset_maximized)(void *data, - struct xdg_surface *xdg_surface); - /** - * request_set_minimized - server requests that the client set - * minimized + * change_state - compositor wants to change a surface's state + * @state_type: the state to set + * @value: the value to change the state to + * @serial: a serial for the compositor's own tracking * - * Event sent from the compositor to the client requesting that - * the client goes to a minimized state. It's the client job to - * call set_minimized and trigger its minimized state. + * This event tells the client to change a surface's state. The + * client should respond with an ack_change_state request to the + * compositor to guarantee that the compositor knows that the + * client has seen it. */ - void (*request_set_minimized)(void *data, - struct xdg_surface *xdg_surface); + void (*change_state)(void *data, + struct xdg_surface *xdg_surface, + uint32_t state_type, + uint32_t value, + uint32_t serial); /** - * request_unset_minimized - server requests that the client - * unset maximized + * activated - surface was activated * - * Event sent from the compositor to the client requesting that - * the client leaves the minimized state. It's the client job to - * call unset_maximized and leave its minimized state. + * The activated_set event is sent when this surface has been + * activated, which means that the surface has user attention. + * Window decorations should be updated accordingly. You should not + * use this event for anything but the style of decorations you + * display, use wl_keyboard.enter and wl_keyboard.leave for + * determining keyboard focus. */ - void (*request_unset_minimized)(void *data, - struct xdg_surface *xdg_surface); + void (*activated)(void *data, + struct xdg_surface *xdg_surface); /** - * focused_set - surface was focused + * deactivated - surface was deactivated * - * The focused_set event is sent when this surface has been - * activated. Window decorations should be updated accordingly. + * The deactivate event is sent when this surface has been + * deactivated, which means that the surface lost user attention. + * Window decorations should be updated accordingly. You should not + * use this event for anything but the style of decorations you + * display, use wl_keyboard.enter and wl_keyboard.leave for + * determining keyboard focus. */ - void (*focused_set)(void *data, + void (*deactivated)(void *data, struct xdg_surface *xdg_surface); /** - * focused_unset - surface was unfocused + * close - surface wants to be closed * - * The focused_unset event is sent when this surface has been - * deactivated, because another surface has been activated. Window - * decorations should be updated accordingly. + * The close event is sent by the compositor when the user wants + * the surface to be closed. This should be equivalent to the user + * clicking the close button in client-side decorations, if your + * application has any... + * + * This is only a request that the user intends to close your + * window. The client may choose to ignore this request, or show a + * dialog to ask the user to save their data... */ - void (*focused_unset)(void *data, - struct xdg_surface *xdg_surface); + void (*close)(void *data, + struct xdg_surface *xdg_surface); }; static inline int @@ -301,17 +328,15 @@ xdg_surface_add_listener(struct xdg_surface *xdg_surface, #define XDG_SURFACE_DESTROY 0 #define XDG_SURFACE_SET_TRANSIENT_FOR 1 -#define XDG_SURFACE_SET_TITLE 2 -#define XDG_SURFACE_SET_APP_ID 3 -#define XDG_SURFACE_PONG 4 +#define XDG_SURFACE_SET_MARGIN 2 +#define XDG_SURFACE_SET_TITLE 3 +#define XDG_SURFACE_SET_APP_ID 4 #define XDG_SURFACE_MOVE 5 #define XDG_SURFACE_RESIZE 6 #define XDG_SURFACE_SET_OUTPUT 7 -#define XDG_SURFACE_SET_FULLSCREEN 8 -#define XDG_SURFACE_UNSET_FULLSCREEN 9 -#define XDG_SURFACE_SET_MAXIMIZED 10 -#define XDG_SURFACE_UNSET_MAXIMIZED 11 -#define XDG_SURFACE_SET_MINIMIZED 12 +#define XDG_SURFACE_REQUEST_CHANGE_STATE 8 +#define XDG_SURFACE_ACK_CHANGE_STATE 9 +#define XDG_SURFACE_SET_MINIMIZED 10 static inline void xdg_surface_set_user_data(struct xdg_surface *xdg_surface, void *user_data) @@ -342,24 +367,24 @@ xdg_surface_set_transient_for(struct xdg_surface *xdg_surface, struct wl_surface } static inline void -xdg_surface_set_title(struct xdg_surface *xdg_surface, const char *title) +xdg_surface_set_margin(struct xdg_surface *xdg_surface, int32_t left_margin, int32_t right_margin, int32_t top_margin, int32_t bottom_margin) { wl_proxy_marshal((struct wl_proxy *) xdg_surface, - XDG_SURFACE_SET_TITLE, title); + XDG_SURFACE_SET_MARGIN, left_margin, right_margin, top_margin, bottom_margin); } static inline void -xdg_surface_set_app_id(struct xdg_surface *xdg_surface, const char *app_id) +xdg_surface_set_title(struct xdg_surface *xdg_surface, const char *title) { wl_proxy_marshal((struct wl_proxy *) xdg_surface, - XDG_SURFACE_SET_APP_ID, app_id); + XDG_SURFACE_SET_TITLE, title); } static inline void -xdg_surface_pong(struct xdg_surface *xdg_surface, uint32_t serial) +xdg_surface_set_app_id(struct xdg_surface *xdg_surface, const char *app_id) { wl_proxy_marshal((struct wl_proxy *) xdg_surface, - XDG_SURFACE_PONG, serial); + XDG_SURFACE_SET_APP_ID, app_id); } static inline void @@ -384,31 +409,17 @@ xdg_surface_set_output(struct xdg_surface *xdg_surface, struct wl_output *output } static inline void -xdg_surface_set_fullscreen(struct xdg_surface *xdg_surface) +xdg_surface_request_change_state(struct xdg_surface *xdg_surface, uint32_t state_type, uint32_t value, uint32_t serial) { wl_proxy_marshal((struct wl_proxy *) xdg_surface, - XDG_SURFACE_SET_FULLSCREEN); + XDG_SURFACE_REQUEST_CHANGE_STATE, state_type, value, serial); } static inline void -xdg_surface_unset_fullscreen(struct xdg_surface *xdg_surface) +xdg_surface_ack_change_state(struct xdg_surface *xdg_surface, uint32_t state_type, uint32_t value, uint32_t serial) { wl_proxy_marshal((struct wl_proxy *) xdg_surface, - XDG_SURFACE_UNSET_FULLSCREEN); -} - -static inline void -xdg_surface_set_maximized(struct xdg_surface *xdg_surface) -{ - wl_proxy_marshal((struct wl_proxy *) xdg_surface, - XDG_SURFACE_SET_MAXIMIZED); -} - -static inline void -xdg_surface_unset_maximized(struct xdg_surface *xdg_surface) -{ - wl_proxy_marshal((struct wl_proxy *) xdg_surface, - XDG_SURFACE_UNSET_MAXIMIZED); + XDG_SURFACE_ACK_CHANGE_STATE, state_type, value, serial); } static inline void @@ -420,7 +431,6 @@ xdg_surface_set_minimized(struct xdg_surface *xdg_surface) /** * xdg_popup - desktop-style metadata interface - * @ping: ping client * @popup_done: popup interaction is done * * An interface that may be implemented by a wl_surface, for @@ -443,16 +453,6 @@ xdg_surface_set_minimized(struct xdg_surface *xdg_surface) * xdg_popup surfaces are always transient for another surface. */ struct xdg_popup_listener { - /** - * ping - ping client - * @serial: (none) - * - * Ping a client to check if it is receiving events and sending - * requests. A client is expected to reply with a pong request. - */ - void (*ping)(void *data, - struct xdg_popup *xdg_popup, - uint32_t serial); /** * popup_done - popup interaction is done * @serial: serial of the implicit grab on the pointer @@ -475,7 +475,6 @@ xdg_popup_add_listener(struct xdg_popup *xdg_popup, } #define XDG_POPUP_DESTROY 0 -#define XDG_POPUP_PONG 1 static inline void xdg_popup_set_user_data(struct xdg_popup *xdg_popup, void *user_data) @@ -498,13 +497,6 @@ xdg_popup_destroy(struct xdg_popup *xdg_popup) wl_proxy_destroy((struct wl_proxy *) xdg_popup); } -static inline void -xdg_popup_pong(struct xdg_popup *xdg_popup, uint32_t serial) -{ - wl_proxy_marshal((struct wl_proxy *) xdg_popup, - XDG_POPUP_PONG, serial); -} - #ifdef __cplusplus } #endif diff --git a/tz-launcher/toytoolkit/xdg-shell-protocol.c b/tz-launcher/toytoolkit/xdg-shell-protocol.c index ef72997..242e6c3 100644 --- a/tz-launcher/toytoolkit/xdg-shell-protocol.c +++ b/tz-launcher/toytoolkit/xdg-shell-protocol.c @@ -30,21 +30,17 @@ #include #include "wayland-util.h" -extern const struct wl_interface xdg_surface_interface; -extern const struct wl_interface wl_surface_interface; -extern const struct wl_interface xdg_popup_interface; -extern const struct wl_interface wl_surface_interface; -extern const struct wl_interface wl_surface_interface; +extern const struct wl_interface wl_output_interface; extern const struct wl_interface wl_seat_interface; extern const struct wl_interface wl_surface_interface; -extern const struct wl_interface wl_seat_interface; -extern const struct wl_interface wl_seat_interface; -extern const struct wl_interface wl_output_interface; +extern const struct wl_interface xdg_popup_interface; +extern const struct wl_interface xdg_surface_interface; static const struct wl_interface *types[] = { NULL, NULL, NULL, + NULL, &xdg_surface_interface, &wl_surface_interface, &xdg_popup_interface, @@ -66,64 +62,60 @@ static const struct wl_interface *types[] = { static const struct wl_message xdg_shell_requests[] = { { "use_unstable_version", "i", types + 0 }, - { "get_xdg_surface", "no", types + 3 }, - { "get_xdg_popup", "nooouiiu", types + 5 }, + { "get_xdg_surface", "no", types + 4 }, + { "get_xdg_popup", "nooouiiu", types + 6 }, + { "pong", "u", types + 0 }, +}; + +static const struct wl_message xdg_shell_events[] = { + { "ping", "u", types + 0 }, }; WL_EXPORT const struct wl_interface xdg_shell_interface = { "xdg_shell", 1, - 3, xdg_shell_requests, - 0, NULL, + 4, xdg_shell_requests, + 1, xdg_shell_events, }; static const struct wl_message xdg_surface_requests[] = { { "destroy", "", types + 0 }, - { "set_transient_for", "?o", types + 13 }, + { "set_transient_for", "?o", types + 14 }, + { "set_margin", "iiii", types + 0 }, { "set_title", "s", types + 0 }, { "set_app_id", "s", types + 0 }, - { "pong", "u", types + 0 }, - { "move", "ou", types + 14 }, - { "resize", "ouu", types + 16 }, - { "set_output", "?o", types + 19 }, - { "set_fullscreen", "", types + 0 }, - { "unset_fullscreen", "", types + 0 }, - { "set_maximized", "", types + 0 }, - { "unset_maximized", "", types + 0 }, + { "move", "ou", types + 15 }, + { "resize", "ouu", types + 17 }, + { "set_output", "?o", types + 20 }, + { "request_change_state", "uuu", types + 0 }, + { "ack_change_state", "uuu", types + 0 }, { "set_minimized", "", types + 0 }, }; static const struct wl_message xdg_surface_events[] = { - { "ping", "u", types + 0 }, - { "configure", "uii", types + 0 }, - { "request_set_fullscreen", "", types + 0 }, - { "request_unset_fullscreen", "", types + 0 }, - { "request_set_maximized", "", types + 0 }, - { "request_unset_maximized", "", types + 0 }, - { "request_set_minimized", "", types + 0 }, - { "request_unset_minimized", "", types + 0 }, - { "focused_set", "", types + 0 }, - { "focused_unset", "", types + 0 }, + { "configure", "ii", types + 0 }, + { "change_state", "uuu", types + 0 }, + { "activated", "", types + 0 }, + { "deactivated", "", types + 0 }, + { "close", "", types + 0 }, }; WL_EXPORT const struct wl_interface xdg_surface_interface = { "xdg_surface", 1, - 13, xdg_surface_requests, - 10, xdg_surface_events, + 11, xdg_surface_requests, + 5, xdg_surface_events, }; static const struct wl_message xdg_popup_requests[] = { { "destroy", "", types + 0 }, - { "pong", "u", types + 0 }, }; static const struct wl_message xdg_popup_events[] = { - { "ping", "u", types + 0 }, { "popup_done", "u", types + 0 }, }; WL_EXPORT const struct wl_interface xdg_popup_interface = { "xdg_popup", 1, - 2, xdg_popup_requests, - 2, xdg_popup_events, + 1, xdg_popup_requests, + 1, xdg_popup_events, }; -- cgit v1.2.3