From 38069992ec97aa22da84a1e1dbb5e8ff9cd03d60 Mon Sep 17 00:00:00 2001 From: Ilia Bozhinov Date: Mon, 25 Mar 2019 22:21:17 +0100 Subject: Add option to respect panel position (#48) * implement option to make menu respect panel boundaries * fixup! implement option to make menu respect panel boundaries --- lib/renderers/wayland/wayland.c | 13 +++++++++++++ lib/renderers/wayland/wayland.h | 1 + lib/renderers/wayland/window.c | 9 ++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) (limited to 'lib/renderers') diff --git a/lib/renderers/wayland/wayland.c b/lib/renderers/wayland/wayland.c index a719c7d..442b0f6 100644 --- a/lib/renderers/wayland/wayland.c +++ b/lib/renderers/wayland/wayland.c @@ -208,6 +208,18 @@ grab_keyboard(const struct bm_menu *menu, bool grab) } } +static void +set_overlap(const struct bm_menu *menu, bool overlap) +{ + struct wayland *wayland = menu->renderer->internal; + assert(wayland); + + struct window *window; + wl_list_for_each(window, &wayland->windows, link) { + bm_wl_window_set_overlap(window, wayland->display, overlap); + } +} + static void destructor(struct bm_menu *menu) { @@ -303,6 +315,7 @@ register_renderer(struct render_api *api) api->render = render; api->set_bottom = set_bottom; api->grab_keyboard = grab_keyboard; + api->set_overlap = set_overlap; api->priorty = BM_PRIO_GUI; api->version = BM_PLUGIN_VERSION; return "wayland"; diff --git a/lib/renderers/wayland/wayland.h b/lib/renderers/wayland/wayland.h index 9defb06..c6da458 100644 --- a/lib/renderers/wayland/wayland.h +++ b/lib/renderers/wayland/wayland.h @@ -122,6 +122,7 @@ void bm_wl_window_schedule_render(struct window *window); void bm_wl_window_render(struct window *window, struct wl_display *display, const struct bm_menu *menu); void bm_wl_window_set_bottom(struct window *window, struct wl_display *display, bool bottom); void bm_wl_window_grab_keyboard(struct window *window, struct wl_display *display, bool grab); +void bm_wl_window_set_overlap(struct window *window, struct wl_display *display, bool overlap); 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); void bm_wl_window_destroy(struct window *window); diff --git a/lib/renderers/wayland/window.c b/lib/renderers/wayland/window.c index 2141eff..55b8690 100644 --- a/lib/renderers/wayland/window.c +++ b/lib/renderers/wayland/window.c @@ -310,6 +310,14 @@ bm_wl_window_grab_keyboard(struct window *window, struct wl_display *display, bo 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) { @@ -317,7 +325,6 @@ bm_wl_window_create(struct window *window, struct wl_display *display, struct wl 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_exclusive_zone(window->layer_surface, -1); 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); -- cgit v1.2.3-70-g09d2