1
0
Fork 0
mirror of https://github.com/Cloudef/bemenu synced 2024-05-09 00:56:18 +02:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Matt A 3bb73d8579
Merge 9740d37d17 into 1c3eeb09d5 2024-04-22 21:46:01 +05:30
Jari Vetoniemi 1c3eeb09d5 nix: update default.nix
* reduce src fileset to avoid unneccessary rebuilds
* test symbol visibility
2024-04-02 19:07:45 +09:00
Matt Allan 9740d37d17
[Wayland] Anchor top edge of menu to center
Anchor only the top edge of the menu to the center when
--center mode is used instead of centering the entire menu. This
prevents the menu from bouncing around as the list is shortened.

For this to work we only anchor to the top instead of the top and
the bottom and set a top margin equal to half of the display width.
The max height of the menu also needs to be halved to prevent drawing
a menu that overflows the bottom edge of the screen.
2022-08-12 15:31:50 -04:00
2 changed files with 20 additions and 7 deletions

View File

@ -19,10 +19,13 @@ with builtins;
with lib;
let
src = ./.;
version = readFile "${src}/VERSION";
version = readFile ./VERSION;
in stdenv.mkDerivation {
inherit src version;
src = with fileset; toSource {
root = ./.;
fileset = unions [ ./VERSION ./GNUmakefile ./bemenu.pc.in ./scripts ./lib ./man ./client ];
};
inherit version;
pname = "bemenu";
strictDeps = true;
@ -64,6 +67,11 @@ in stdenv.mkDerivation {
done
'';
doCheck = stdenv.isLinux;
checkPhase = ''
make check-symbols
'';
meta = {
homepage = "https://github.com/Cloudef/bemenu";
description = "Dynamic menu library and client program inspired by dmenu";

View File

@ -217,10 +217,8 @@ get_align_anchor(enum bm_align align)
{
uint32_t anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
if(align == BM_ALIGN_TOP) {
if(align == BM_ALIGN_TOP || align == BM_ALIGN_CENTER) {
anchor |= ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP;
} else if(align == BM_ALIGN_CENTER) {
anchor |= ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM;
} else {
anchor |= ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM;
}
@ -256,7 +254,11 @@ bm_wl_window_render(struct window *window, struct wl_display *display, struct bm
break;
struct cairo_paint_result result;
window->notify.render(&buffer->cairo, buffer->width, window->max_height, menu, &result);
uint32_t max_height = window->max_height;
if (menu->align == BM_ALIGN_CENTER) {
max_height /= 2;
}
window->notify.render(&buffer->cairo, buffer->width, max_height, menu, &result);
window->displayed = result.displayed;
if (window->height == (uint32_t) ceil(result.height / window->scale))
@ -378,6 +380,9 @@ bm_wl_window_set_align(struct window *window, struct wl_display *display, enum b
window->align_anchor = get_align_anchor(window->align);
zwlr_layer_surface_v1_set_anchor(window->layer_surface, window->align_anchor);
if (align == BM_ALIGN_CENTER) {
zwlr_layer_surface_v1_set_margin(window->layer_surface, window->max_height / 2, 0, 0, 0);
}
wl_surface_commit(window->surface);
wl_display_roundtrip(display);
}