summaryrefslogtreecommitdiff
path: root/lib/renderers/wayland/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/renderers/wayland/window.c')
-rw-r--r--lib/renderers/wayland/window.c103
1 files changed, 39 insertions, 64 deletions
diff --git a/lib/renderers/wayland/window.c b/lib/renderers/wayland/window.c
index ef515b2..c230836 100644
--- a/lib/renderers/wayland/window.c
+++ b/lib/renderers/wayland/window.c
@@ -191,6 +191,31 @@ next_buffer(struct window *window)
}
static void
+shell_surface_ping(void *data, struct wl_shell_surface *surface, uint32_t serial)
+{
+ (void)data;
+ wl_shell_surface_pong(surface, serial);
+}
+
+static void
+shell_surface_configure(void *data, struct wl_shell_surface *surface, uint32_t edges, int32_t width, int32_t height)
+{
+ (void)data, (void)surface, (void)edges, (void)width, (void)height;
+}
+
+static void
+shell_surface_popup_done(void *data, struct wl_shell_surface *surface)
+{
+ (void)data, (void)surface;
+}
+
+static const struct wl_shell_surface_listener shell_surface_listener = {
+ .ping = shell_surface_ping,
+ .configure = shell_surface_configure,
+ .popup_done = shell_surface_popup_done,
+};
+
+static void
frame_callback(void *data, struct wl_callback *callback, uint32_t time)
{
(void)time;
@@ -238,12 +263,12 @@ bm_wl_window_render(struct window *window, struct wl_display *display, const str
break;
window->height = result.height;
- zwlr_layer_surface_v1_set_size(window->layer_surface, 0, window->height);
- wl_surface_commit(window->surface);
- wl_display_roundtrip(display);
destroy_buffer(buffer);
}
+ window->frame_cb = wl_surface_frame(window->surface);
+ wl_callback_add_listener(window->frame_cb, &listener, window);
+
wl_surface_damage(window->surface, 0, 0, buffer->width, buffer->height);
wl_surface_attach(window->surface, buffer->buffer, 0, 0);
wl_surface_commit(window->surface);
@@ -259,76 +284,26 @@ bm_wl_window_destroy(struct window *window)
for (int32_t i = 0; i < 2; ++i)
destroy_buffer(&window->buffers[i]);
- if (window->layer_surface)
- zwlr_layer_surface_v1_destroy(window->layer_surface);
+ if (window->xdg_surface)
+ xdg_surface_destroy(window->xdg_surface);
+
+ if (window->shell_surface)
+ wl_shell_surface_destroy(window->shell_surface);
if (window->surface)
wl_surface_destroy(window->surface);
}
-static void
-layer_surface_configure(void *data, struct zwlr_layer_surface_v1 *layer_surface, uint32_t serial, uint32_t width, uint32_t height)
-{
- struct window *window = data;
- window->width = width;
- window->height = height;
- zwlr_layer_surface_v1_ack_configure(layer_surface, serial);
-}
-
-static void
-layer_surface_closed(void *data, struct zwlr_layer_surface_v1 *layer_surface)
-{
- struct window *window = data;
- zwlr_layer_surface_v1_destroy(layer_surface);
- wl_surface_destroy(window->surface);
- exit(1);
-}
-
-static const struct zwlr_layer_surface_v1_listener layer_surface_listener = {
- .configure = layer_surface_configure,
- .closed = layer_surface_closed,
-};
-
-void
-bm_wl_window_set_bottom(struct window *window, struct wl_display *display, bool bottom)
-{
- if (window->bottom == bottom)
- return;
-
- window->bottom = bottom;
-
- zwlr_layer_surface_v1_set_anchor(window->layer_surface, (window->bottom ? ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM : ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP) | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT);
- wl_surface_commit(window->surface);
- wl_display_roundtrip(display);
-}
-
-void
-bm_wl_window_grab_keyboard(struct window *window, struct wl_display *display, bool grab)
-{
- zwlr_layer_surface_v1_set_keyboard_interactivity(window->layer_surface, grab);
- wl_surface_commit(window->surface);
- wl_display_roundtrip(display);
-}
-
-void
-bm_wl_window_set_overlap(struct window *window, struct wl_display *display, bool overlap)
-{
- zwlr_layer_surface_v1_set_exclusive_zone(window->layer_surface, overlap ? -1 : 0);
- wl_surface_commit(window->surface);
- wl_display_roundtrip(display);
-}
-
bool
-bm_wl_window_create(struct window *window, struct wl_display *display, struct wl_shm *shm, struct wl_output *output, struct zwlr_layer_shell_v1 *layer_shell, struct wl_surface *surface)
+bm_wl_window_create(struct window *window, struct wl_shm *shm, struct wl_shell *shell, struct xdg_shell *xdg_shell, struct wl_surface *surface)
{
assert(window);
- if (layer_shell && (window->layer_surface = zwlr_layer_shell_v1_get_layer_surface(layer_shell, surface, output, ZWLR_LAYER_SHELL_V1_LAYER_TOP, "menu"))) {
- zwlr_layer_surface_v1_add_listener(window->layer_surface, &layer_surface_listener, window);
- zwlr_layer_surface_v1_set_anchor(window->layer_surface, (window->bottom ? ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM : ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP) | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT);
- zwlr_layer_surface_v1_set_size(window->layer_surface, 0, 32);
- wl_surface_commit(surface);
- wl_display_roundtrip(display);
+ if (shell && (window->shell_surface = wl_shell_get_shell_surface(shell, surface))) {
+ wl_shell_surface_add_listener(window->shell_surface, &shell_surface_listener, window);
+ wl_shell_surface_set_title(window->shell_surface, "bemenu");
+ wl_shell_surface_set_class(window->shell_surface, "bemenu");
+ wl_shell_surface_set_toplevel(window->shell_surface);
} else {
return false;
}