1
0
Fork 0
mirror of https://github.com/Cloudef/bemenu synced 2024-05-17 13:06:15 +02:00
Commit Graph

56 Commits

Author SHA1 Message Date
Joan Bruguera 8217ae024b Fix exiting when an unexpected Wayland error occurs.
If an unexpected error was returned from a Wayland API during rendering (e.g.
from wl_display_flush), the code did set input.sym = XKB_KEY_Escape, so that
the next call to poll_key would return BM_KEY_ESCAPE and bemenu would quit.

However, this has been broken since #135, because input.key_pending was not
set, so the "fake" XKB_KEY_Escape is just ignored, bemenu doesn't quit, but
instead, it enters an infinite loop and keeps a CPU core at 100% usage.

The "quick fix" would be to just set input.key_pending wherever input.sym was
set to XKB_KEY_Escape. However, to make error handling less error-prone,
decouple it from input handling and add an error flag to (bm_menu_)render.
2022-08-03 08:55:34 +09:00
Joan Bruguera 04b0d83d56 Fix Wayland event loop order to avoid missed renders
After the changes of the previous commit, the event loop flow on Wayland is:
    1. Render windows if window->render_pending is set
    2. Wait for events [NOTE: this includes the frame callback]
    3. Schedule render if menu->dirty is set
    4. Handle events (return from render) and repeat

This can still miss renders since the menu->dirty flag is set in step (4),
but the menu->dirty flag is checked in step (3). So if the event loop only
does a single iteration (quite unusual as most user actions cause multiple
events), we can get stuck on step (2) for a while.

In order to avoid this problem, this changes the event loop order to:
    1. Schedule render if menu->dirty is set
    2. Wait for events [NOTE: this includes the frame callback]
    3. Render windows if window->render_pending is set
    4. Handle events (return from render) and repeat

Script (for Sway) to reproduce the issue / verify the fix:
    #!/usr/bin/env sh
    mousesety() { swaymsg seat - cursor set 200 "$1" >/dev/null; sleep 0.2; }
    { while true; do mousesety 200; mousesety 300; mousesety 400; done } &
    trap 'kill $!' EXIT
    export BEMENU_BACKEND=wayland BEMENU_OPTS='--list 40 --hb #0000FF'
    yes | head -30 | bemenu

Fixes: #274
Fixes: #275
2022-07-05 10:06:57 +09:00
Joan Bruguera c7a5812352 Fix missed renders on Wayland on temporally close events
Despite the fix in the previous commit (3d7e47c4e6), the following command:
    { echo one; echo two; } | BEMENU_BACKEND=wayland bemenu --grab
Will likely still show the 'Loading...' text after all items are available.

A related problem (also on Wayland) is that when pressing two keys (for the
filter) almost simultaneously, sometimes only one of the keys will be rendered.
The other key will only be shown on the next render. For example:
    - Filter shows "s"
    - User presses the "o" and "n" keys simultaneously
    - Filter shows "so" ["n" appears to have been lost]
    - User presses the "g" key
    - Filter shows "song" [now the "n" has been rendered]

Both problems have the same root cause: If two events that cause a render happen
"close enough" to each other, often the second event will not cause a render.

As far as I can tell, the cause is that the "dirty && render_pending" render
check should not check the dirty flag at all, just "render_pending".

With "dirty && render_pending", if two events happen in close succession:
- On the first event, generally dirty==true, render_pending==true, a render
  will happen, the frame callback will be set, and both flags will be cleared.
- For the second event, generally dirty==true and render_pending==false.
  dirty will be unset and nothing will happen.
- When the frame triggers, render_pending is set, but no render will happen
  because dirty==false

With just "render_pending" (the change in this commit):
- On the first event, generally dirty==true, render_pending==false, the frame
  callback will be set, and dirty will be cleared.
- For the second event, generally dirty==true and render_pending==false.
  dirty will be unset and nothing will happen.
- When the frame triggers, render_pending is set, then a render will be done.
2022-06-30 09:40:08 +09:00
Stacy Harper 5a095705d2 Optimize redrawing
We add a dirty flag on the menu to track if the menu actually need a
redraw. With it, we will not redraw if the touch is hold on the same
entry by example.
2022-02-08 22:23:02 +09:00
Stacy Harper a111aa2afa mouse and touch support on wayland 2022-02-08 22:23:02 +09:00
Maxim Karasev 43255bbbe8 Add relative width option
It works on Wayland and X11 and acts as a complement to margin. Exact
behavior is as follows:
- If width factor is 0, width minus margin is used.
- If width multiplied by factor is greater than width minus margin,
  width minus is used. (so margin may be used to make sure that bemenu
  is at least N pixels away from the view border)
- Otherwise width multiplied by factor is used.

I think it's fine to disable warnings about floating point numbers
comparision. We don't do any arithmetics on them anyway, so we can't
suffer from inaccuracy.
2021-12-29 17:22:10 +09:00
Andrei E 00efc974d7 Add paste functionality 2021-11-04 09:01:29 +09:00
lunacb 21ff4e47da fixed indentation 2021-11-03 17:57:18 +09:00
lunacb a96ed87472 redesigned vertical alignment
single enum determines if the menu is at the top, in the center,
or at the bottom. implemented in wayland and x11 renderers.
2021-11-03 17:57:18 +09:00
lunacb bddeea05b6 created margin option
-M or --margin option sets the horizontal margin of the window
2021-11-03 17:57:18 +09:00
Stacy Harper a42fa97a49 add -c center mode on wayland 2021-08-16 17:46:57 +09:00
Tuyen Pham 32aa05789e add contrl-c to exit 2021-07-22 09:05:41 +09:00
Robert Günzler 4612f9d327 wayland: Allow showing the menu on the focused monitor
This adds an alias 'focused' for selecting the current monitor, which
becomes the default on x11 and wayland. The previous wayland default of
displaying on all outputs moves under '-2' or 'all'.

ref: https://github.com/Cloudef/bemenu/issues/102#issuecomment-604562234

Signed-off-by: Robert Günzler <r@gnzler.io>
2021-05-22 04:12:59 +09:00
Sören Tempel 2e922503e8 x11: Align -m argument interpretation with dmenu
With dmenu, monitor indices start at 0 and a value of -1 (the default)
is used to spawn dmenu on the current monitor. While bemenu strives to
be compatible with dmenu, bemenu monitor indices previously started at 1
and a value of 0 (the default) was used to spawn on the current monitor.

This commit aligns the behaviour of bemenu's x11 backend with dmenu. For
this purposes, the affected code in the x11 backend is synced with the
current dmenu implementation. While doing so the monitor type has also
been switched from a uint32_t to a int32_t.
2021-04-27 14:24:02 +09:00
Harley Swick e74224a406 Use -m option for setting monitor name and monitor + cleanup 2021-02-05 16:53:43 +09:00
Peter Colberg a9cee36e85 Support compilation with -fvisibility=hidden
When using a compiler with support for GNU C extensions (GCC, Clang),
explicitly mark functions shared across library boundaries as visible.

This is the default visibility and has no effect when compiling with the
default CFLAGS. When compiling with -fvisibility=hidden, however, this
exports only functions marked BM_PUBLIC and hides all others.

https://gcc.gnu.org/wiki/Visibility

This facilitates packaging for distributions that track shared library
symbols, e.g., Debian, which uses a symbol file to provide the minimal
version associated to each symbol exported by a library.

https://www.debian.org/doc/debian-policy/ch-sharedlibs.html#the-symbols-system
https://manpages.debian.org/unstable/dpkg-dev/dpkg-gensymbols.1.en.html
2020-12-13 17:09:44 +09:00
fancycade 1bd40d0a44 Add key_pending field to sync wayland keyboard event loops 2020-10-10 16:22:07 +09:00
Dominic Monroe 64c38dde50 Add custom key support 2020-08-28 21:01:22 +09:00
Jari Vetoniemi 65cea5e20a cairo: add BEMENU_SCALE env variable
Allows overriding the scaling factor for bemenu
2020-06-29 00:12:20 +09:00
Jari Vetoniemi 6343a658bb wayland: support showing bemenu on all monitors 2020-03-25 19:16:57 +02:00
Cole Helbling cd53b7bb55 x11,wayland: treat keypad enter as normal enter 2020-03-19 09:23:32 +02:00
Jari Vetoniemi 178a58253a wayland: implement set_monitor (untested) 2020-02-08 10:10:58 +02:00
Jari Vetoniemi fcce2e019a menu: left/right now moves always cursor
Use SHIFT + left/right to move selection
2020-02-07 18:28:48 +02:00
Jari Vetoniemi 5a4d364d50 Nuke CMake from existance
Welcome glorious GNU Makefile
2020-02-07 16:03:08 +02:00
sleich 9ac860b817 Add Ctrl-[ shortcut to x11 and wayland
Ctrl-[ shortcut is used to quit bemenu. It already works with ncurses backend
2020-01-08 04:47:57 +03:00
Adrian Müller 1f1aebf26a Handle HiDPI scaling on Wayland 2019-11-05 10:13:34 +01:00
Sauyon Lee c081cf7609
Add C-g shortcut to x11 and wayland 2019-07-13 00:46:18 +01:00
Tobias Kortkamp 312a606d54
Use epoll_create1() instead of epoll_create()
epoll_create() takes a size argument not a flag like EPOLL_CLOEXEC [1].

[1] https://linux.die.net/man/2/epoll_create

Signed-off-by: Tobias Kortkamp <t@tobik.me>
2019-04-23 11:41:03 +02:00
Ilia Bozhinov 38069992ec Add option to respect panel position (#48)
* implement option to make menu respect panel boundaries

* fixup! implement option to make menu respect panel boundaries
2019-03-25 23:21:17 +02:00
Ilia Bozhinov ab82afab7f wayland: implement a proper repaint cycle 2019-03-24 20:18:59 +01:00
Dominique Martinet 992e5add42 wayland renderer: Implement grab_keyboard
This avoids locking oneself out when running bemenu interactively,
as input would be grabbed too early without that and layer shell
does not allow to 'ungrab' focus by clicking on another window
2018-04-29 20:50:55 +09:00
Dominique Martinet 610b30364e wayland renderer: Fix bottom positioning
- reset size when it changes, so there is no blank below text
 - ignore exclude zone to overlap bar regardless of rendering order
2018-04-29 20:50:04 +09:00
Dominique Martinet 86f6e57bfe wayland renderer: fix indentation 2018-04-16 17:53:42 +09:00
Dominique Martinet 91bf9b4d14 wayland renderer: implement bottom 2018-04-16 17:53:11 +09:00
Drew DeVault 17aa5e21bf Port to wlroots layer shell 2018-04-08 11:05:52 -04:00
uphere cb6030f64b Add C-m -> Return bind
C-m is often bound to return and it's jarring to have all the
other keybinds but not this one
2016-12-05 16:35:29 +00:00
Mark Oteiza 0874fc5d49 Add some Emacs keybindings
* C-v to curses backend
* C-v, M-v, M-<, M-> to x11 and wayland backends

Signed-off-by: Jari Vetoniemi <mailroxas@gmail.com>
2015-04-06 23:22:12 +03:00
Jari Vetoniemi d8097c44dd Make renderers try detect whether they are in correct env. 2015-03-09 09:53:57 +02:00
Jari Vetoniemi 7d019e767b Bind alt+h and alt+l as well 2015-01-18 04:51:02 +02:00
Jari Vetoniemi bd6051073d Swap j-k 2015-01-18 04:35:26 +02:00
Jari Vetoniemi 92152cb5fb Add alt keybindings from demenu to gui backends 2015-01-18 03:34:18 +02:00
Jari Vetoniemi 074b2d1b58 Remove --backend and --prioritory options, change prioritory -> priorty
and provide BEMENU_BACKEND env variable. Change API to reflect this
change.

There is no reliable way to detect when running on terminal (especially
when stdin is a pipe), so we need to make curses backend explicit with
BEMENU_BACKEND=curses or bm_menu_new("curses"), otherwise GUI backend
will be choosed automatically.
2015-01-17 18:53:29 +02:00
Jari Vetoniemi f76cfbca4f Get rid of _DEFAULT_SOURCE #defines, set this in cmake and also use
secure_getenv where it makes sense.
2015-01-17 18:52:21 +02:00
Jari Vetoniemi 0cd1c991d2 Take monitor height into account again. 2015-01-16 01:48:47 +02:00
Jari Vetoniemi 2bf8bbfcde Working pango code. 2015-01-15 22:18:23 +02:00
Jari Vetoniemi a90bf2f512 Redraw only when input changed. 2014-11-02 07:58:45 +02:00
Jari Vetoniemi e8fc51d80c Get output width and height. 2014-11-02 07:58:34 +02:00
Jari Vetoniemi 0d5cdc2c96 Key repeats. 2014-11-02 06:48:53 +02:00
Jari Vetoniemi ee3c41f162 Make shift + tab the current tab behavior, and normal tab to cycle. 2014-11-02 04:08:40 +02:00
Jari Vetoniemi fb6a49e690 Use real font height for window height. 2014-10-26 15:41:53 +02:00