summaryrefslogtreecommitdiff
path: root/lib/renderers/wayland/wayland.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/renderers/wayland/wayland.c')
-rw-r--r--lib/renderers/wayland/wayland.c97
1 files changed, 24 insertions, 73 deletions
diff --git a/lib/renderers/wayland/wayland.c b/lib/renderers/wayland/wayland.c
index 94fcfd5..9318284 100644
--- a/lib/renderers/wayland/wayland.c
+++ b/lib/renderers/wayland/wayland.c
@@ -25,12 +25,8 @@ render(const struct bm_menu *menu)
return;
}
- struct window *window;
- wl_list_for_each(window, &wayland->windows, link) {
- if (window->render_pending)
- bm_wl_window_render(window, wayland->display, menu);
- }
- wl_display_flush(wayland->display);
+ if (wayland->window.render_pending)
+ bm_wl_window_render(&wayland->window, wayland->display, menu);
struct epoll_event ep[16];
uint32_t num = epoll_wait(efd, ep, 16, -1);
@@ -45,10 +41,7 @@ render(const struct bm_menu *menu)
}
if (wayland->input.code != wayland->input.last_code) {
- wl_list_for_each(window, &wayland->windows, link) {
- bm_wl_window_schedule_render(window);
- }
-
+ bm_wl_window_render(&wayland->window, wayland->display, menu);
wayland->input.last_code = wayland->input.code;
}
}
@@ -177,49 +170,13 @@ get_displayed_count(const struct bm_menu *menu)
{
struct wayland *wayland = menu->renderer->internal;
assert(wayland);
- uint32_t max = 0;
- struct window *window;
- wl_list_for_each(window, &wayland->windows, link) {
- if (window->displayed > max)
- max = window->displayed;
- }
- return max;
+ return wayland->window.displayed;
}
static void
-set_bottom(const struct bm_menu *menu, bool bottom)
+set_fake(const struct bm_menu *menu, bool bottom)
{
- struct wayland *wayland = menu->renderer->internal;
- assert(wayland);
-
- struct window *window;
- wl_list_for_each(window, &wayland->windows, link) {
- bm_wl_window_set_bottom(window, wayland->display, bottom);
- }
-}
-
-static void
-grab_keyboard(const struct bm_menu *menu, bool grab)
-{
- struct wayland *wayland = menu->renderer->internal;
- assert(wayland);
-
- struct window *window;
- wl_list_for_each(window, &wayland->windows, link) {
- bm_wl_window_grab_keyboard(window, wayland->display, 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);
- }
+ fprintf(stderr, "fake set is called with %d\n", bottom);
}
static void
@@ -230,10 +187,7 @@ destructor(struct bm_menu *menu)
if (!wayland)
return;
- struct window *window;
- wl_list_for_each(window, &wayland->windows, link) {
- bm_wl_window_destroy(window);
- }
+ bm_wl_window_destroy(&wayland->window);
bm_wl_registry_destroy(wayland);
xkb_context_unref(wayland->input.xkb.context);
@@ -260,6 +214,9 @@ constructor(struct bm_menu *menu)
if (!(menu->renderer->internal = wayland = calloc(1, sizeof(struct wayland))))
goto fail;
+ wayland->window.width = 800;
+ wayland->window.height = 1;
+
if (!(wayland->display = wl_display_connect(NULL)))
goto fail;
@@ -269,28 +226,19 @@ constructor(struct bm_menu *menu)
if (!bm_wl_registry_register(wayland))
goto fail;
- wayland->fds.display = wl_display_get_fd(wayland->display);
- wayland->fds.repeat = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
- wayland->input.repeat_fd = &wayland->fds.repeat;
+ struct wl_surface *surface;
+ if (!(surface = wl_compositor_create_surface(wayland->compositor)))
+ goto fail;
- struct output *output;
- wl_list_for_each(output, &wayland->outputs, link) {
- struct wl_surface *surface;
- if (!(surface = wl_compositor_create_surface(wayland->compositor)))
- goto fail;
- struct window *window = calloc(1, sizeof(struct window));
- window->bottom = menu->bottom;
- if (!bm_wl_window_create(window, wayland->display, wayland->shm, output->output, wayland->layer_shell, surface))
- goto fail;
- window->notify.render = bm_cairo_paint;
- window->max_height = output->height;
- window->render_pending = true;
- wl_list_insert(&wayland->windows, &window->link);
- }
+ if (!bm_wl_window_create(&wayland->window, wayland->shm, wayland->shell, wayland->xdg_shell, surface))
+ goto fail;
if (!efd && (efd = epoll_create1(EPOLL_CLOEXEC)) < 0)
goto fail;
+ wayland->fds.display = wl_display_get_fd(wayland->display);
+ wayland->fds.repeat = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
+
struct epoll_event ep;
ep.events = EPOLLIN | EPOLLERR | EPOLLHUP;
ep.data.ptr = &wayland->fds.display;
@@ -300,6 +248,9 @@ constructor(struct bm_menu *menu)
ep2.events = EPOLLIN;
ep2.data.ptr = &wayland->fds.repeat;
epoll_ctl(efd, EPOLL_CTL_ADD, wayland->fds.repeat, &ep2);
+
+ wayland->window.notify.render = bm_cairo_paint;
+ wayland->input.repeat_fd = &wayland->fds.repeat;
return true;
fail:
@@ -315,9 +266,9 @@ register_renderer(struct render_api *api)
api->get_displayed_count = get_displayed_count;
api->poll_key = poll_key;
api->render = render;
- api->set_bottom = set_bottom;
- api->grab_keyboard = grab_keyboard;
- api->set_overlap = set_overlap;
+ api->set_bottom = set_fake;
+ api->grab_keyboard = set_fake;
+ api->set_overlap = set_fake;
api->priorty = BM_PRIO_GUI;
api->version = BM_PLUGIN_VERSION;
return "wayland";