Commit graph

86 commits

Author SHA1 Message Date
Daniel Eklöf
2a0a722c13
bar/wayland: handle layer surface being closed
If the output we’re mapped on is disabled (or disconnected), the
compositor will unmap us.

Up until now, our response was to simply shutdown.

Now, we destroy the surface, remove all pending rendering buffers, and
all further calls to commit() will return immediately, without doing
anything.

If the user has configured a specific monitor to use, we wait for that
output to come back. When it does, we re-create the layer surface and
then we’re up and running again.

Bars running on the “default” monitor are handled in a similar
way. Since we don’t have an output name from the configuration, we
instead store the name of the output we were mapped on, when we’re
either unmapped from that output, or that output global is destroyed.

As soon as we see that output come back, we re-create the layer
surface.
2022-01-01 11:43:40 +01:00
Daniel Eklöf
d40220e511
bar/wayland: handle failure to set initial size in setup() 2021-11-15 18:06:10 +01:00
Daniel Eklöf
bd44e82eca
bar/wayland: coalesce “refresh” commands
This reduces the number of repaints primarily during startup, but also
when e.g. switching workspace.
2021-10-22 18:07:14 +02:00
Daniel Eklöf
939b81a4ea
bar/wayland: create comm pipe with CLOEXEC | NONBLOCK 2021-10-22 18:06:43 +02:00
Daniel Eklöf
fee0b91174
bar/wayland: remove unused member ‘bar_expose’ 2021-10-22 18:06:19 +02:00
Jan Beich
ec465ba3b3 wayland: unbreak build without memfd_create
New FreeBSD versions have memfd_create but other BSDs don't.

bar/wayland.c:774:15: error: implicit declaration of function 'memfd_create' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    pool_fd = memfd_create("yambar-wayland-shm-buffer-pool", MFD_CLOEXEC);
              ^
bar/wayland.c:774:62: error: use of undeclared identifier 'MFD_CLOEXEC'
    pool_fd = memfd_create("yambar-wayland-shm-buffer-pool", MFD_CLOEXEC);
                                                             ^
2021-10-03 23:07:23 +00:00
Baptiste Daroussin
82c92185ea memfd: linux/memfd does not exist on FreeBSD
memfd_create is defined in sys/mman.h on FreeBSD
2021-10-01 17:22:55 +02:00
Nulo
eb94c8cceb
Add layer option
Only applies to Wayland and the default is still bottom.
2021-08-25 18:42:46 +02:00
Daniel Eklöf
74016d7d33
bar: add bar->output_name(), returns the name of the output we’re on 2021-08-09 19:56:47 +02:00
Daniel Eklöf
b97ba80aea
bar: add border.{left,right,top,bottom}-width
This allows you to configure the width of each side of the border
individually. border.width can still be used, and will set all four
borders to the same width.

Closes #77
2021-07-28 11:00:04 +02:00
Daniel Eklöf
0aef2f85ee
config: add bar.trackpad-sensitivity
This is an integer that specifies the amount of scrolling that needs
to be accumulated before a wheel-up/down event is emitted.

A higher value means you need to drag your fingers a longer distance
before the event is emitted.

The default is 30.
2021-07-01 17:15:54 +02:00
Daniel Eklöf
4ce3fe2285
bar/wayland: fix mouse wheel up not being emitted
We emit mouse wheel up events when the ‘discrete’ counter is
negative. Thus, when looping, we need to loop to its *absolute* value.
2021-07-01 17:15:54 +02:00
Daniel Eklöf
530afe6cf5
bar: wayland: initial support for mouse wheel up/down 2021-07-01 17:15:54 +02:00
Daniel Eklöf
93a5bbb4a4
bar: wayland: require seat version 5, to get discrete axis events 2021-07-01 17:15:54 +02:00
Daniel Eklöf
c79ffbe057
Add support binding on-click handlers to other buttons than LEFT
One can now bind the left/middle/right mouse buttons to on-click. In
fact, you can have all three buttons bound to different handlers for
the same particle. The new syntax is

    on-click:
        left: <command>
        middle: <command>
        right: <command>

Leaving one out is the same thing as not mapping it at
all. Furthermore,

    on-click: <command>

is still valid, and is a shorthand for

    on-click:
        left: <commsnd>
2021-07-01 17:15:53 +02:00
Daniel Eklöf
dd724d1bc2
exposable: add ‘btn’ argument to on_mouse() 2021-07-01 17:15:52 +02:00
Daniel Eklöf
08fa56a0f4
bar: set thread name of the bar’s own thread 2021-06-21 18:16:22 +02:00
Daniel Eklöf
8c93b48146
bar/wayland: xdg_handle_output_name(): free previous monitor name 2021-04-07 07:58:16 +02:00
Daniel Eklöf
008235d904
bar/wayland: close command pipe FDs in cleanup 2020-11-25 20:36:45 +01:00
Daniel Eklöf
328ebe8fe9
bar/wayland: plug memory leak: free seat name 2020-11-25 20:36:45 +01:00
Daniel Eklöf
1262f1b3d1
bar/wayland: use wl_*_release() instead of wl_*_destroy()
This lets the compositor free up internal state.
2020-11-09 19:53:57 +01:00
Daniel Eklöf
588e6150d2
bar/wayland: do *not* set backend->scale in xdg_output_handle_done()
This is done by update_size(). Setting it in xdg_output_handle_done()
causes update_size() to do an early exit, and thus we end up never
actually configuring the surface.

We also never instantiate a pixman image, which led to a hard crash at
startup when the user had configured a specific output to use.
2020-07-20 17:30:20 +02:00
Daniel Eklöf
aa1b3457a1
bar/wayland: make sure we don't strcmp() a NULL pointer 2020-07-20 17:29:56 +02:00
Daniel Eklöf
e38f593acd
bar/wayland: don't try to set cursor surface if serial is 0 2020-07-11 07:39:02 +02:00
Daniel Eklöf
74933c40ee
bar/wayland: log error message when failing to load cursor (image) 2020-07-11 07:37:01 +02:00
Daniel Eklöf
84ba1c231a
bar/wayland: update cursor on pointer enter event 2020-07-10 18:38:00 +02:00
Daniel Eklöf
c03564513d
bar/wayland: seat: handle failure to create pointer surface 2020-07-10 18:37:39 +02:00
Daniel Eklöf
0a0ef8852a
bar/wayland: move seat.pointer.pointer -> seat.wl_pointer 2020-07-10 18:20:29 +02:00
Daniel Eklöf
f426155e0b
bar/wayland: explicitly refresh on scale changes
Just calling update_size() isn't enough, as that in itself doesn't
trigger a redraw.
2020-07-10 11:43:34 +02:00
Daniel Eklöf
6bf077240c
bar/wayland: update_size: release old buffer when reloading buffers 2020-07-10 11:43:12 +02:00
Daniel Eklöf
dd74b7f747
bar/wayland: don't initialize backend->scale = 1
This causes the first call to update_size() to exit early, and thus we
never configure the initial state.
2020-07-10 11:42:26 +02:00
Daniel Eklöf
31a4cddde3
bar/wayland: guess scale when no 'output' has been configured 2020-07-10 10:48:17 +02:00
Daniel Eklöf
d80fbd4084
bar/wayland: remove commented out code 2020-07-10 10:48:07 +02:00
Daniel Eklöf
d929c12ecb
bar/wayland: reload cursor theme: remember current pointer name
This allows us to avoid reloading the same pointer image again and
again.
2020-07-09 19:52:10 +02:00
Daniel Eklöf
f04b1e806c
bar: let backend check if xcursor should be updated or not
This allows the backend to support multi-seat "properly", by checking
against the correct seat. Before this, when we used a single, global
xcursor value, a seat whose pointer needed to be updated would not be
updated.
2020-07-09 19:02:02 +02:00
Daniel Eklöf
5884e665a4
bar/wayland: set-cursor: don't skip out if "old" xcursor is same as "new"
We might be setting on a different seat than before.
2020-07-09 18:55:04 +02:00
Daniel Eklöf
13c2b8296d
bar/wayland: resize surface+buffers on dynamic scale changes 2020-07-09 18:51:44 +02:00
Daniel Eklöf
40d47f8273
bar/wayland: handle seat removal 2020-07-07 20:52:25 +02:00
Daniel Eklöf
b658f577de
bar/wayland: don't roundtrip when adding globals
Instead, roundtrip once all globals have been handled. This means all
listeners have been registered.

When we detect a specific monitor to map to, and it has a non-default
scale, update the cursor theme (since it depends on the scale).
2020-07-07 20:44:17 +02:00
Daniel Eklöf
b73e3acd0a
bar/wayland: remove debug output 2020-07-07 16:42:57 +02:00
Daniel Eklöf
6f22edaba6
bar/wayland: multi-seat support
We only care about the mouse. We now track per-seat cursor positions
and cursor themes.

Any enter/leave/motion/button event will call the bar on_mouse()
method using the coordinates from the "current" seat.

Since the bar framework doesn't deal with multi-seats at all, we
internally, in the backend, track the currently active seat. This is
the seat which we last saw any kind of events from.

This is used in e.g. set_cursor(), which is called from the bar.
2020-07-07 14:09:25 +02:00
Daniel Eklöf
0678015eb1
bar/wayland: shutdown when compositor "closed" our layer surface 2020-04-28 18:58:27 +02:00
Daniel Eklöf
860ec01791
bar/wayland: log globals 2020-04-28 18:58:18 +02:00
Daniel Eklöf
c707b00a2a
bar/wayland: don't destroy pointer unnecessarily
We only need to create/destroy the pointer when the POINTER capability
changes.
2020-04-28 18:57:32 +02:00
Daniel Eklöf
c7cfb451e3
bar/wayland: spell compositor correctly 2020-04-27 20:50:36 +02:00
Daniel Eklöf
df1a004f97
bar/wayland: layer surface "namespace" is a category, not application ID 2020-02-06 19:11:16 +01:00
Daniel Eklöf
edfe7e70f9
bar/wayland: don't use wl_display_dispatch()
wl_display_dispatch() calls poll(), which is unnecessary since we
already know the FD is readable.

Use the more lower level wl_display_read_events() +
wl_display_dispatch_pending().

These require wl_display_prepare_read() to have been called.
2020-01-03 21:24:26 +01:00
Daniel Eklöf
baee3924e4
bar/wayland: let compositor choose output if user didn't
Instead of us selecting an output randomly (we used to select that
"last" output) when the user hasn't configured one, let the compositor
choose one for us.
2019-12-31 11:39:33 +01:00
Daniel Eklöf
e05d586f17
bar/wayland: WL_OUTPUT_MODE_PREFERRED doesn't meen this *output* is preferred
It means the *mode* (width, height, refresh) is the preferred one for
*this* output.
2019-12-31 11:16:23 +01:00
Daniel Eklöf
199a7ccd21
bar/wayland: change disconnected log type from warn -> info
Because being disconnected from Wayland is how we typically exit.
2019-11-23 13:50:29 +01:00