wl_shell_surface adaptation
Protocol changes in Wayland core introduced a new interface wl_shell_surface, and moved all wl_shell surface methods into it. Adapt the compositor and its Wayland backend, shell plugin, and all clients to the new interface. Depends on the Wayland core commit "protocol: introduce wl_shell_surface" Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
This commit is contained in:
committed by
Kristian Høgsberg
parent
865f9b87c9
commit
9d1613eb4a
@@ -63,6 +63,7 @@ struct window {
|
||||
|
||||
struct wl_egl_window *native;
|
||||
struct wl_surface *surface;
|
||||
struct wl_shell_surface *shell_surface;
|
||||
EGLSurface egl_surface;
|
||||
};
|
||||
|
||||
@@ -198,6 +199,8 @@ create_surface(struct window *window)
|
||||
};
|
||||
|
||||
window->surface = wl_compositor_create_surface(display->compositor);
|
||||
window->shell_surface = wl_shell_get_shell_surface(display->shell,
|
||||
window->surface);
|
||||
window->native =
|
||||
wl_egl_window_create(window->surface,
|
||||
window->geometry.width,
|
||||
@@ -208,7 +211,7 @@ create_surface(struct window *window)
|
||||
window->native,
|
||||
surface_attribs);
|
||||
|
||||
wl_shell_set_toplevel(display->shell, window->surface);
|
||||
wl_shell_surface_set_toplevel(window->shell_surface);
|
||||
|
||||
ret = eglMakeCurrent(window->display->egl.dpy, window->egl_surface,
|
||||
window->egl_surface, window->display->egl.ctx);
|
||||
|
||||
@@ -45,6 +45,7 @@ struct window {
|
||||
struct display *display;
|
||||
int width, height;
|
||||
struct wl_surface *surface;
|
||||
struct wl_shell_surface *shell_surface;
|
||||
struct wl_buffer *buffer;
|
||||
void *data;
|
||||
};
|
||||
@@ -100,12 +101,14 @@ create_window(struct display *display, int width, int height)
|
||||
window->width = width;
|
||||
window->height = height;
|
||||
window->surface = wl_compositor_create_surface(display->compositor);
|
||||
window->shell_surface = wl_shell_get_shell_surface(display->shell,
|
||||
window->surface);
|
||||
window->buffer = create_shm_buffer(display,
|
||||
width, height,
|
||||
WL_SHM_FORMAT_XRGB32,
|
||||
&window->data);
|
||||
|
||||
wl_shell_set_toplevel(display->shell, window->surface);
|
||||
wl_shell_surface_set_toplevel(window->shell_surface);
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
+29
-20
@@ -103,6 +103,7 @@ struct window {
|
||||
struct display *display;
|
||||
struct window *parent;
|
||||
struct wl_surface *surface;
|
||||
struct wl_shell_surface *shell_surface;
|
||||
char *title;
|
||||
struct rectangle allocation, saved_allocation, server_allocation;
|
||||
int x, y;
|
||||
@@ -749,19 +750,17 @@ window_get_resize_dx_dy(struct window *window, int *x, int *y)
|
||||
static void
|
||||
window_set_type(struct window *window)
|
||||
{
|
||||
struct display *display = window->display;
|
||||
|
||||
switch (window->type) {
|
||||
case TYPE_FULLSCREEN:
|
||||
wl_shell_set_fullscreen(display->shell, window->surface);
|
||||
wl_shell_surface_set_fullscreen(window->shell_surface);
|
||||
break;
|
||||
case TYPE_TOPLEVEL:
|
||||
wl_shell_set_toplevel(display->shell, window->surface);
|
||||
wl_shell_surface_set_toplevel(window->shell_surface);
|
||||
break;
|
||||
case TYPE_TRANSIENT:
|
||||
wl_shell_set_transient(display->shell, window->surface,
|
||||
window->parent->surface,
|
||||
window->x, window->y, 0);
|
||||
wl_shell_surface_set_transient(window->shell_surface,
|
||||
window->parent->shell_surface,
|
||||
window->x, window->y, 0);
|
||||
break;
|
||||
case TYPE_CUSTOM:
|
||||
break;
|
||||
@@ -1009,6 +1008,7 @@ window_destroy(struct window *window)
|
||||
input->keyboard_focus = NULL;
|
||||
}
|
||||
|
||||
wl_shell_surface_destroy(window->shell_surface);
|
||||
wl_surface_destroy(window->surface);
|
||||
wl_list_remove(&window->link);
|
||||
free(window);
|
||||
@@ -1104,6 +1104,12 @@ window_get_wl_surface(struct window *window)
|
||||
return window->surface;
|
||||
}
|
||||
|
||||
struct wl_shell_surface *
|
||||
window_get_wl_shell_surface(struct window *window)
|
||||
{
|
||||
return window->shell_surface;
|
||||
}
|
||||
|
||||
static int
|
||||
get_pointer_location(struct window *window, int32_t x, int32_t y)
|
||||
{
|
||||
@@ -1269,8 +1275,8 @@ window_handle_button(void *data,
|
||||
button == BTN_LEFT && state == 1) {
|
||||
switch (location) {
|
||||
case WINDOW_TITLEBAR:
|
||||
wl_shell_move(window->display->shell,
|
||||
window->surface, input_device, time);
|
||||
wl_shell_surface_move(window->shell_surface,
|
||||
input_device, time);
|
||||
break;
|
||||
case WINDOW_RESIZING_TOP:
|
||||
case WINDOW_RESIZING_BOTTOM:
|
||||
@@ -1280,9 +1286,9 @@ window_handle_button(void *data,
|
||||
case WINDOW_RESIZING_TOP_RIGHT:
|
||||
case WINDOW_RESIZING_BOTTOM_LEFT:
|
||||
case WINDOW_RESIZING_BOTTOM_RIGHT:
|
||||
wl_shell_resize(window->display->shell,
|
||||
window->surface, input_device, time,
|
||||
location);
|
||||
wl_shell_surface_resize(window->shell_surface,
|
||||
input_device, time,
|
||||
location);
|
||||
break;
|
||||
case WINDOW_CLIENT_AREA:
|
||||
if (window->button_handler)
|
||||
@@ -1685,17 +1691,16 @@ input_receive_selection_data(struct input *input, const char *mime_type,
|
||||
void
|
||||
window_move(struct window *window, struct input *input, uint32_t time)
|
||||
{
|
||||
if (window->display->shell)
|
||||
wl_shell_move(window->display->shell,
|
||||
window->surface, input->input_device, time);
|
||||
wl_shell_surface_move(window->shell_surface,
|
||||
input->input_device, time);
|
||||
}
|
||||
|
||||
static void
|
||||
handle_configure(void *data, struct wl_shell *shell,
|
||||
handle_configure(void *data, struct wl_shell_surface *shell_surface,
|
||||
uint32_t time, uint32_t edges,
|
||||
struct wl_surface *surface, int32_t width, int32_t height)
|
||||
int32_t width, int32_t height)
|
||||
{
|
||||
struct window *window = wl_surface_get_user_data(surface);
|
||||
struct window *window = data;
|
||||
int32_t child_width, child_height;
|
||||
|
||||
/* FIXME: this is probably the wrong place to check for width
|
||||
@@ -1722,7 +1727,7 @@ handle_configure(void *data, struct wl_shell *shell,
|
||||
}
|
||||
}
|
||||
|
||||
static const struct wl_shell_listener shell_listener = {
|
||||
static const struct wl_shell_surface_listener shell_surface_listener = {
|
||||
handle_configure,
|
||||
};
|
||||
|
||||
@@ -1961,6 +1966,8 @@ window_create_internal(struct display *display, struct window *parent,
|
||||
window->display = display;
|
||||
window->parent = parent;
|
||||
window->surface = wl_compositor_create_surface(display->compositor);
|
||||
window->shell_surface = wl_shell_get_shell_surface(display->shell,
|
||||
window->surface);
|
||||
window->allocation.x = 0;
|
||||
window->allocation.y = 0;
|
||||
window->allocation.width = width;
|
||||
@@ -1984,6 +1991,9 @@ window_create_internal(struct display *display, struct window *parent,
|
||||
wl_surface_set_user_data(window->surface, window);
|
||||
wl_list_insert(display->window_list.prev, &window->link);
|
||||
|
||||
wl_shell_surface_add_listener(window->shell_surface,
|
||||
&shell_surface_listener, window);
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
@@ -2128,7 +2138,6 @@ display_handle_global(struct wl_display *display, uint32_t id,
|
||||
display_add_input(d, id);
|
||||
} else if (strcmp(interface, "wl_shell") == 0) {
|
||||
d->shell = wl_display_bind(display, id, &wl_shell_interface);
|
||||
wl_shell_add_listener(d->shell, &shell_listener, d);
|
||||
} else if (strcmp(interface, "wl_shm") == 0) {
|
||||
d->shm = wl_display_bind(display, id, &wl_shm_interface);
|
||||
} else if (strcmp(interface, "wl_data_device_manager") == 0) {
|
||||
|
||||
@@ -228,6 +228,9 @@ window_get_surface(struct window *window);
|
||||
struct wl_surface *
|
||||
window_get_wl_surface(struct window *window);
|
||||
|
||||
struct wl_shell_surface *
|
||||
window_get_wl_shell_surface(struct window *window);
|
||||
|
||||
void
|
||||
window_flush(struct window *window);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user