summaryrefslogtreecommitdiff
path: root/lib/renderers/wayland
diff options
context:
space:
mode:
authorJari Vetoniemi <mailroxas@gmail.com>2014-11-02 07:58:34 +0200
committerJari Vetoniemi <mailroxas@gmail.com>2014-11-02 07:58:34 +0200
commite8fc51d80cdd955f47113f63e22068f3a00d4224 (patch)
treec6cd4ce8e3037004b8dd5da63933bba935a066bd /lib/renderers/wayland
parentdfda59ad188f60acbc0e184aeca28a38f0649446 (diff)
downloadbemenu-e8fc51d80cdd955f47113f63e22068f3a00d4224.tar.gz
bemenu-e8fc51d80cdd955f47113f63e22068f3a00d4224.tar.bz2
bemenu-e8fc51d80cdd955f47113f63e22068f3a00d4224.zip
Get output width and height.
Diffstat (limited to 'lib/renderers/wayland')
-rw-r--r--lib/renderers/wayland/registry.c44
-rw-r--r--lib/renderers/wayland/wayland.c3
-rw-r--r--lib/renderers/wayland/wayland.h3
-rw-r--r--lib/renderers/wayland/window.c20
4 files changed, 51 insertions, 19 deletions
diff --git a/lib/renderers/wayland/registry.c b/lib/renderers/wayland/registry.c
index 1faef18..9521374 100644
--- a/lib/renderers/wayland/registry.c
+++ b/lib/renderers/wayland/registry.c
@@ -236,8 +236,45 @@ seat_handle_name(void *data, struct wl_seat *seat, const char *name)
}
static const struct wl_seat_listener seat_listener = {
- seat_handle_capabilities,
- seat_handle_name
+ .capabilities = seat_handle_capabilities,
+ .name = seat_handle_name
+};
+
+static void
+display_handle_geometry(void *data, struct wl_output *wl_output, int x, int y, int physical_width, int physical_height, int subpixel, const char *make, const char *model, int transform)
+{
+ (void)data, (void)wl_output, (void)x, (void)y, (void)physical_width, (void)physical_height, (void)subpixel, (void)make, (void)model, (void)transform;
+}
+
+static void
+display_handle_done(void *data, struct wl_output *wl_output)
+{
+ (void)data, (void)wl_output;
+}
+
+static void
+display_handle_scale(void *data, struct wl_output *wl_output, int32_t scale)
+{
+ (void)data, (void)wl_output, (void)scale;
+}
+
+static void
+display_handle_mode(void *data, struct wl_output *wl_output, uint32_t flags, int width, int height, int refresh)
+{
+ (void)wl_output, (void)refresh, (void)height;
+ struct wayland *wayland = data;
+
+ if (flags & WL_OUTPUT_MODE_CURRENT) {
+ wayland->window.width = width;
+ wayland->window.max_height = height;
+ }
+}
+
+static const struct wl_output_listener output_listener = {
+ .geometry = display_handle_geometry,
+ .mode = display_handle_mode,
+ .done = display_handle_done,
+ .scale = display_handle_scale
};
static void
@@ -260,6 +297,9 @@ registry_handle_global(void *data, struct wl_registry *registry, uint32_t id, co
} else if (strcmp(interface, "wl_shm") == 0) {
wayland->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
wl_shm_add_listener(wayland->shm, &shm_listener, data);
+ } else if (strcmp(interface, "wl_output") == 0) {
+ wayland->output = wl_registry_bind(registry, id, &wl_output_interface, 2);
+ wl_output_add_listener(wayland->output, &output_listener, wayland);
}
}
diff --git a/lib/renderers/wayland/wayland.c b/lib/renderers/wayland/wayland.c
index c447b6e..2cdedec 100644
--- a/lib/renderers/wayland/wayland.c
+++ b/lib/renderers/wayland/wayland.c
@@ -183,6 +183,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 = 14;
+
if (!(wayland->display = wl_display_connect(NULL)))
goto fail;
diff --git a/lib/renderers/wayland/wayland.h b/lib/renderers/wayland/wayland.h
index db837e9..50455b5 100644
--- a/lib/renderers/wayland/wayland.h
+++ b/lib/renderers/wayland/wayland.h
@@ -80,7 +80,7 @@ struct window {
struct xdg_surface *xdg_surface;
struct wl_shm *shm;
struct buffer buffers[2];
- uint32_t width, height;
+ uint32_t width, height, max_height;
uint32_t displayed;
struct {
@@ -97,6 +97,7 @@ struct wayland {
struct wl_display *display;
struct wl_registry *registry;
struct wl_compositor *compositor;
+ struct wl_output *output;
struct wl_seat *seat;
struct xdg_shell *xdg_shell;
struct wl_shell *shell;
diff --git a/lib/renderers/wayland/window.c b/lib/renderers/wayland/window.c
index 057863d..bfd1715 100644
--- a/lib/renderers/wayland/window.c
+++ b/lib/renderers/wayland/window.c
@@ -195,24 +195,16 @@ next_buffer(struct window *window)
}
static void
-resize(struct window *window, uint32_t width, uint32_t height)
-{
- window->width = width;
- window->height = height;
-}
-
-static void
shell_surface_ping(void *data, struct wl_shell_surface *surface, uint32_t serial)
{
- (void)data;
+ (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)surface, (void)edges;
- resize(data, width, height);
+ (void)data, (void)surface, (void)edges, (void)width, (void)height;
}
static void
@@ -230,8 +222,7 @@ static const struct wl_shell_surface_listener shell_surface_listener = {
static void
xdg_surface_configure(void *data, struct xdg_surface *surface, int32_t width, int32_t height, struct wl_array *states, uint32_t serial)
{
- (void)states;
- resize(data, width, height);
+ (void)data, (void)states, (void)width, (void)height, (void)states, (void)serial;
xdg_surface_ack_configure(surface, serial);
}
@@ -273,7 +264,7 @@ bm_wl_window_render(struct window *window, const struct bm_menu *menu, uint32_t
cairo_font_extents_t fe;
bm_cairo_get_font_extents(&buffer->cairo, &menu->font, &fe);
- window->height = lines * (fe.height + 4);
+ window->height = MIN(lines * (fe.height + 4), window->max_height);
if (window->height != buffer->height && !(buffer = next_buffer(window)))
return;
@@ -325,9 +316,6 @@ bm_wl_window_create(struct window *window, struct wl_shm *shm, struct wl_shell *
return false;
}
- window->width = 800;
- window->height = 240;
-
window->shm = shm;
window->surface = surface;
wl_surface_damage(surface, 0, 0, window->width, window->height);