struct xdg_wm_base *xdg_wm_base;
struct zxdg_decoration_manager_v1 *xdg_decoration_mgr;
struct zxdg_toplevel_decoration_v1 *toplevel_decoration;
- struct xdg_surface *xdg_surface;
+ struct wl_shell_surface *xdg_surface;
int xdg_surface_has_been_configured;
struct xdg_toplevel *xdg_toplevel;
struct wl_seat *seat;
struct wl_pointer *pointer;
struct wl_keyboard *keyboard;
+ struct wl_shell *shell;
#elif defined(VK_USE_PLATFORM_DIRECTFB_EXT)
IDirectFB *dfb;
IDirectFBSurface *window;
wl_keyboard_destroy(demo->keyboard);
wl_pointer_destroy(demo->pointer);
wl_seat_destroy(demo->seat);
- xdg_toplevel_destroy(demo->xdg_toplevel);
- xdg_surface_destroy(demo->xdg_surface);
+ //xdg_toplevel_destroy(demo->xdg_toplevel);
+ //xdg_surface_destroy(demo->xdg_surface);
wl_surface_destroy(demo->window);
- xdg_wm_base_destroy(demo->xdg_wm_base);
+ /*xdg_wm_base_destroy(demo->xdg_wm_base);
if (demo->xdg_decoration_mgr) {
zxdg_toplevel_decoration_v1_destroy(demo->toplevel_decoration);
zxdg_decoration_manager_v1_destroy(demo->xdg_decoration_mgr);
- }
+ }*/
wl_compositor_destroy(demo->compositor);
wl_registry_destroy(demo->registry);
wl_display_disconnect(demo->display);
}
}
-static void handle_surface_configure(void *data, struct xdg_surface *xdg_surface, uint32_t serial) {
- struct demo *demo = (struct demo *)data;
- xdg_surface_ack_configure(xdg_surface, serial);
- if (demo->xdg_surface_has_been_configured) {
- demo_resize(demo);
- }
- demo->xdg_surface_has_been_configured = 1;
+
+static void PingCb(void *data, struct wl_shell_surface *shell_surface,
+ uint32_t serial)
+{
+ wl_shell_surface_pong(shell_surface, serial);
}
-static const struct xdg_surface_listener xdg_surface_listener = {.configure = handle_surface_configure};
+static void ConfigureCb(void *data, struct wl_shell_surface *shell_surface,
+ uint32_t edges, int32_t width, int32_t height)
+{
-static void handle_toplevel_configure(void *data, struct xdg_toplevel *xdg_toplevel UNUSED, int32_t width, int32_t height,
- struct wl_array *states UNUSED) {
- struct demo *demo = (struct demo *)data;
- /* zero values imply the program may choose its own size, so in that case
- * stay with the existing value (which on startup is the default) */
- if (width > 0) {
- demo->width = width;
- }
- if (height > 0) {
- demo->height = height;
- }
- /* This should be followed by a surface configure */
}
-static void handle_toplevel_close(void *data, struct xdg_toplevel *xdg_toplevel UNUSED) {
- struct demo *demo = (struct demo *)data;
- demo->quit = true;
+static void PopupDoneCb(void *data, struct wl_shell_surface *shell_surface)
+{
+
}
-static const struct xdg_toplevel_listener xdg_toplevel_listener = { .configure = handle_toplevel_configure, .close = handle_toplevel_close};
static void demo_create_window(struct demo *demo) {
- if (!demo->xdg_wm_base) {
- printf("Compositor did not provide the standard protocol xdg-wm-base\n");
+ if (!demo->shell) {
+ printf("Compositor did not provide the standard protocol\n");
fflush(stdout);
exit(1);
}
exit(1);
}
- demo->xdg_surface = xdg_wm_base_get_xdg_surface(demo->xdg_wm_base, demo->window);
+ demo->xdg_surface = wl_shell_get_shell_surface(demo->shell,
+ demo->window);
+ static const struct wl_shell_surface_listener shell_surface_listener =
+ {PingCb, ConfigureCb, PopupDoneCb};
+ wl_shell_surface_add_listener(demo->xdg_surface, &shell_surface_listener, demo);
+ wl_shell_surface_set_toplevel(demo->xdg_surface);
+ wl_shell_surface_set_title(demo->xdg_surface, APP_SHORT_NAME);
+ /*demo->xdg_surface = xdg_wm_base_get_xdg_surface(demo->xdg_wm_base, demo->window);
if (!demo->xdg_surface) {
printf("Can not get xdg_surface from wayland_surface!\n");
fflush(stdout);
demo->toplevel_decoration =
zxdg_decoration_manager_v1_get_toplevel_decoration(demo->xdg_decoration_mgr, demo->xdg_toplevel);
zxdg_toplevel_decoration_v1_set_mode(demo->toplevel_decoration, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
- }
+ }*/
wl_surface_commit(demo->window);
}
uint32_t state) {
struct demo *demo = data;
if (button == BTN_LEFT && state == WL_POINTER_BUTTON_STATE_PRESSED) {
- xdg_toplevel_move(demo->xdg_toplevel, demo->seat, serial);
+ //xdg_toplevel_move(demo->xdg_toplevel, demo->seat, serial);
}
}
seat_handle_capabilities,
};
-static void wm_base_ping(void *data UNUSED, struct xdg_wm_base *xdg_wm_base, uint32_t serial) {
+/*static void wm_base_ping(void *data UNUSED, struct xdg_wm_base *xdg_wm_base, uint32_t serial) {
xdg_wm_base_pong(xdg_wm_base, serial);
}
-static const struct xdg_wm_base_listener wm_base_listener = {wm_base_ping};
+static const struct xdg_wm_base_listener wm_base_listener = {wm_base_ping};*/
static void registry_handle_global(void *data, struct wl_registry *registry, uint32_t id, const char *interface,
uint32_t version UNUSED) {
fprintf(stderr, "Wayland compositor doesn't support VK_KHR_incremental_present, disabling.\n");
demo->VK_KHR_incremental_present_enabled = false;
}
- } else if (strcmp(interface, xdg_wm_base_interface.name) == 0) {
+ } else if (strcmp(interface, "wl_shell") == 0)
+ {
+ demo->shell = (struct wl_shell *)wl_registry_bind(registry, id,
+ &wl_shell_interface, 1);
+ }
+ /*else if (strcmp(interface, xdg_wm_base_interface.name) == 0) {
demo->xdg_wm_base = wl_registry_bind(registry, id, &xdg_wm_base_interface, 1);
xdg_wm_base_add_listener(demo->xdg_wm_base, &wm_base_listener, NULL);
- } else if (strcmp(interface, wl_seat_interface.name) == 0) {
+ } */else if (strcmp(interface, wl_seat_interface.name) == 0) {
demo->seat = wl_registry_bind(registry, id, &wl_seat_interface, 1);
wl_seat_add_listener(demo->seat, &seat_listener, demo);
- } else if (strcmp(interface, zxdg_decoration_manager_v1_interface.name) == 0) {
+ } /*else if (strcmp(interface, zxdg_decoration_manager_v1_interface.name) == 0) {
demo->xdg_decoration_mgr = wl_registry_bind(registry, id, &zxdg_decoration_manager_v1_interface, 1);
- }
+ }*/
}
static void registry_handle_global_remove(void *data UNUSED, struct wl_registry *registry UNUSED, uint32_t name UNUSED) {}
wl_registry *registry;
wl_compositor *compositor;
wl_surface *window;
- xdg_wm_base *wm_base;
- zxdg_decoration_manager_v1 *xdg_decoration_mgr;
- zxdg_toplevel_decoration_v1 *toplevel_decoration;
- xdg_surface *window_surface;
+ //xdg_wm_base *wm_base;
+ //zxdg_decoration_manager_v1 *xdg_decoration_mgr;
+ //zxdg_toplevel_decoration_v1 *toplevel_decoration;
+ //xdg_surface *window_surface;
+ wl_shell_surface *window_surface;
bool xdg_surface_has_been_configured;
- xdg_toplevel *window_toplevel;
+ //xdg_toplevel *window_toplevel;
wl_seat *seat;
wl_pointer *pointer;
wl_keyboard *keyboard;
+ wl_shell *shell;
#elif defined(VK_USE_PLATFORM_DIRECTFB_EXT)
IDirectFB *dfb;
IDirectFBSurface *window;
static void pointer_handle_button(void *data, struct wl_pointer *wl_pointer, uint32_t serial, uint32_t time, uint32_t button,
uint32_t state) {
- Demo *demo = (Demo *)data;
+ //Demo *demo = (Demo *)data;
if (button == BTN_LEFT && state == WL_POINTER_BUTTON_STATE_PRESSED) {
- xdg_toplevel_move(demo->window_toplevel, demo->seat, serial);
+ //xdg_toplevel_move(demo->window_toplevel, demo->seat, serial);
}
}
// pickup wayland objects when they appear
if (strcmp(interface, wl_compositor_interface.name) == 0) {
demo->compositor = (wl_compositor *)wl_registry_bind(registry, id, &wl_compositor_interface, 1);
- } else if (strcmp(interface, xdg_wm_base_interface.name) == 0) {
+ } else if (strcmp(interface, "wl_shell") == 0)
+ {
+ demo->shell = (struct wl_shell *)wl_registry_bind(registry, id,
+ &wl_shell_interface, 1);
+ }/*else if (strcmp(interface, xdg_wm_base_interface.name) == 0) {
demo->wm_base = (xdg_wm_base *)wl_registry_bind(registry, id, &xdg_wm_base_interface, 1);
xdg_wm_base_add_listener(demo->wm_base, &wm_base_listener, nullptr);
- } else if (strcmp(interface, wl_seat_interface.name) == 0) {
+ } */else if (strcmp(interface, wl_seat_interface.name) == 0) {
demo->seat = (wl_seat *)wl_registry_bind(registry, id, &wl_seat_interface, 1);
wl_seat_add_listener(demo->seat, &seat_listener, demo);
- } else if (strcmp(interface, zxdg_decoration_manager_v1_interface.name) == 0) {
+ } /*else if (strcmp(interface, zxdg_decoration_manager_v1_interface.name) == 0) {
demo->xdg_decoration_mgr =
(zxdg_decoration_manager_v1 *)wl_registry_bind(registry, id, &zxdg_decoration_manager_v1_interface, 1);
- }
+ }*/
}
static void registry_handle_global_remove(void *data, wl_registry *registry, uint32_t name) {}
registry{nullptr},
compositor{nullptr},
window{nullptr},
- wm_base{nullptr},
- xdg_decoration_mgr{nullptr},
- toplevel_decoration{nullptr},
+ //wm_base{nullptr},
+ //xdg_decoration_mgr{nullptr},
+ //toplevel_decoration{nullptr},
window_surface{nullptr},
xdg_surface_has_been_configured{false},
- window_toplevel{nullptr},
+ //window_toplevel{nullptr},
seat{nullptr},
pointer{nullptr},
keyboard{nullptr},
wl_keyboard_destroy(keyboard);
wl_pointer_destroy(pointer);
wl_seat_destroy(seat);
- xdg_toplevel_destroy(window_toplevel);
- xdg_surface_destroy(window_surface);
+ //xdg_toplevel_destroy(window_toplevel);
+ //xdg_surface_destroy(window_surface);
+ wl_shell_surface_destroy(window_surface);
wl_surface_destroy(window);
- xdg_wm_base_destroy(wm_base);
+ /*xdg_wm_base_destroy(wm_base);
if (xdg_decoration_mgr) {
zxdg_toplevel_decoration_v1_destroy(toplevel_decoration);
zxdg_decoration_manager_v1_destroy(xdg_decoration_mgr);
- }
+ }*/
wl_compositor_destroy(compositor);
wl_registry_destroy(registry);
wl_display_disconnect(display);
static const xdg_toplevel_listener toplevel_listener = {handle_toplevel_configure, handle_toplevel_close};
+static void PingCb(void *data, struct wl_shell_surface *shell_surface,
+ uint32_t serial)
+{
+ wl_shell_surface_pong(shell_surface, serial);
+}
+
+static void ConfigureCb(void *data, struct wl_shell_surface *shell_surface,
+ uint32_t edges, int32_t width, int32_t height)
+{
+
+}
+
+static void PopupDoneCb(void *data, struct wl_shell_surface *shell_surface)
+{
+
+}
+
void Demo::create_window() {
- if (!wm_base) {
- printf("Compositor did not provide the standard protocol xdg-wm-base\n");
+ if (!shell) {
+ printf("Compositor did not provide the standard protocol\n");
fflush(stdout);
exit(1);
}
exit(1);
}
- window_surface = xdg_wm_base_get_xdg_surface(wm_base, window);
+ window_surface = wl_shell_get_shell_surface(shell, window);
+ static const struct wl_shell_surface_listener shell_surface_listener =
+ {PingCb, ConfigureCb, PopupDoneCb};
+ wl_shell_surface_add_listener(window_surface, &shell_surface_listener, this);
+ wl_shell_surface_set_toplevel(window_surface);
+ wl_shell_surface_set_title(window_surface, APP_SHORT_NAME);
+
+ /*window_surface = xdg_wm_base_get_xdg_surface(wm_base, window);
if (!window_surface) {
printf("Can not get xdg_surface from wayland_surface!\n");
fflush(stdout);
// if supported, let the compositor render titlebars for us
toplevel_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(xdg_decoration_mgr, window_toplevel);
zxdg_toplevel_decoration_v1_set_mode(toplevel_decoration, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
- }
+ }*/
wl_surface_commit(window);
}