|
|
@ -11,6 +11,7 @@
|
|
|
|
#include <wlr/interfaces/wlr_output.h>
|
|
|
|
#include <wlr/interfaces/wlr_output.h>
|
|
|
|
#include <wlr/util/log.h>
|
|
|
|
#include <wlr/util/log.h>
|
|
|
|
#include "backend/wayland.h"
|
|
|
|
#include "backend/wayland.h"
|
|
|
|
|
|
|
|
#include "xdg-shell-unstable-v6-client-protocol.h"
|
|
|
|
|
|
|
|
|
|
|
|
int os_create_anonymous_file(off_t size);
|
|
|
|
int os_create_anonymous_file(off_t size);
|
|
|
|
|
|
|
|
|
|
|
@ -136,7 +137,7 @@ static void wlr_wl_output_destroy(struct wlr_output *_output) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
eglDestroySurface(output->backend->egl.display, output->surface);
|
|
|
|
eglDestroySurface(output->backend->egl.display, output->surface);
|
|
|
|
wl_egl_window_destroy(output->egl_window);
|
|
|
|
wl_egl_window_destroy(output->egl_window);
|
|
|
|
wl_shell_surface_destroy(output->shell_surface);
|
|
|
|
// xdg_surface/toplevel destroy
|
|
|
|
wl_surface_destroy(output->surface);
|
|
|
|
wl_surface_destroy(output->surface);
|
|
|
|
free(output);
|
|
|
|
free(output);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -162,16 +163,27 @@ static struct wlr_output_impl output_impl = {
|
|
|
|
.move_cursor = wlr_wl_output_move_cursor
|
|
|
|
.move_cursor = wlr_wl_output_move_cursor
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void handle_ping(void *data, struct wl_shell_surface *ssurface, uint32_t serial) {
|
|
|
|
static void xdg_surface_handle_configure(void *data, struct zxdg_surface_v6 *xdg_surface,
|
|
|
|
|
|
|
|
uint32_t serial) {
|
|
|
|
struct wlr_wl_backend_output *output = data;
|
|
|
|
struct wlr_wl_backend_output *output = data;
|
|
|
|
assert(output && output->shell_surface == ssurface);
|
|
|
|
assert(output && output->xdg_surface == xdg_surface);
|
|
|
|
wl_shell_surface_pong(ssurface, serial);
|
|
|
|
|
|
|
|
|
|
|
|
zxdg_surface_v6_ack_configure(xdg_surface, serial);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// nothing else?
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void handle_configure(void *data, struct wl_shell_surface *wl_shell_surface,
|
|
|
|
static struct zxdg_surface_v6_listener xdg_surface_listener = {
|
|
|
|
uint32_t edges, int32_t width, int32_t height){
|
|
|
|
.configure = xdg_surface_handle_configure,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void xdg_toplevel_handle_configure(void *data, struct zxdg_toplevel_v6 *xdg_toplevel,
|
|
|
|
|
|
|
|
int32_t width, int32_t height, struct wl_array *states) {
|
|
|
|
struct wlr_wl_backend_output *output = data;
|
|
|
|
struct wlr_wl_backend_output *output = data;
|
|
|
|
assert(output && output->shell_surface == wl_shell_surface);
|
|
|
|
assert(output && output->xdg_toplevel == xdg_toplevel);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// loop over states for maximized etc?
|
|
|
|
|
|
|
|
|
|
|
|
wl_egl_window_resize(output->egl_window, width, height, 0, 0);
|
|
|
|
wl_egl_window_resize(output->egl_window, width, height, 0, 0);
|
|
|
|
output->wlr_output.width = width;
|
|
|
|
output->wlr_output.width = width;
|
|
|
|
output->wlr_output.height = height;
|
|
|
|
output->wlr_output.height = height;
|
|
|
@ -179,14 +191,16 @@ void handle_configure(void *data, struct wl_shell_surface *wl_shell_surface,
|
|
|
|
wl_signal_emit(&output->wlr_output.events.resolution, output);
|
|
|
|
wl_signal_emit(&output->wlr_output.events.resolution, output);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void handle_popup_done(void *data, struct wl_shell_surface *wl_shell_surface) {
|
|
|
|
static void xdg_toplevel_handle_close(void *data, struct zxdg_toplevel_v6 *xdg_toplevel) {
|
|
|
|
wlr_log(L_ERROR, "Unexpected wl_shell_surface.popup_done event");
|
|
|
|
struct wlr_wl_backend_output *output = data;
|
|
|
|
|
|
|
|
assert(output && output->xdg_toplevel == xdg_toplevel);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wl_display_terminate(output->backend->local_display);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static struct wl_shell_surface_listener shell_surface_listener = {
|
|
|
|
static struct zxdg_toplevel_v6_listener xdg_toplevel_listener = {
|
|
|
|
.ping = handle_ping,
|
|
|
|
.configure = xdg_toplevel_handle_configure,
|
|
|
|
.configure = handle_configure,
|
|
|
|
.close = xdg_toplevel_handle_close,
|
|
|
|
.popup_done = handle_popup_done
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
|
|
|
|
struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
|
|
|
@ -218,14 +232,17 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: error handling
|
|
|
|
// TODO: error handling
|
|
|
|
output->surface = wl_compositor_create_surface(backend->compositor);
|
|
|
|
output->surface = wl_compositor_create_surface(backend->compositor);
|
|
|
|
output->shell_surface =
|
|
|
|
output->xdg_surface =
|
|
|
|
wl_shell_get_shell_surface(backend->shell, output->surface);
|
|
|
|
zxdg_shell_v6_get_xdg_surface(backend->shell, output->surface);
|
|
|
|
|
|
|
|
output->xdg_toplevel =
|
|
|
|
wl_shell_surface_set_class(output->shell_surface, "sway");
|
|
|
|
zxdg_surface_v6_get_toplevel(output->xdg_surface);
|
|
|
|
wl_shell_surface_set_title(output->shell_surface, "sway-wl");
|
|
|
|
|
|
|
|
wl_shell_surface_add_listener(output->shell_surface,
|
|
|
|
// class? app_id?
|
|
|
|
&shell_surface_listener, output);
|
|
|
|
zxdg_toplevel_v6_set_title(output->xdg_toplevel, "sway-wl");
|
|
|
|
wl_shell_surface_set_toplevel(output->shell_surface);
|
|
|
|
zxdg_surface_v6_add_listener(output->xdg_surface,
|
|
|
|
|
|
|
|
&xdg_surface_listener, output);
|
|
|
|
|
|
|
|
zxdg_toplevel_v6_add_listener(output->xdg_toplevel,
|
|
|
|
|
|
|
|
&xdg_toplevel_listener, output);
|
|
|
|
|
|
|
|
|
|
|
|
output->egl_window = wl_egl_window_create(output->surface,
|
|
|
|
output->egl_window = wl_egl_window_create(output->surface,
|
|
|
|
wlr_output->width, wlr_output->height);
|
|
|
|
wlr_output->width, wlr_output->height);
|
|
|
|