Commit Graph

127 Commits

Author SHA1 Message Date
Sano 70ef406d6b check for group modules array in key conversion 2024-03-23 18:39:22 +01:00
Alexis Rouillard bba8da76b6
Merge pull request #2836 from alebastr/require-gtk-layer-shell
Require gtk-layer-shell
2024-02-19 22:57:50 +01:00
Aleksei Bavshin 8a4a44896a
refactor: merge BarSurface into Bar
With only one implementation left, the abstraction is no longer
necessary.
2024-02-19 03:00:38 -08:00
Aleksei Bavshin 4420447e74
fix(bar): use std::string for mode names
`string_view` leads to UAF when reading custom mode definitions from the
configuration.
2024-02-19 01:50:40 -08:00
zjeffer a02bacdd53 fix build warning 2024-02-18 12:01:36 +01:00
Aleksei Bavshin 3cb587945a
fix: use `gtk_layer_set_keyboard_mode()`
`gtk_layer_set_keyboard_interactivity()` is deprecated and was removed
in gtk4-layer-shell.
Note that this bumps version requirement to 0.6.0
2024-02-17 11:23:19 -08:00
Aleksei Bavshin 9a21884272
feat!: drop RawSurfaceImpl with direct use of wlr-layer-shell
BREAKING CHANGE: gtk-layer-shell is now required and unconditionally
used. The corresponding config option is removed.

As a part of preparation for future versions of GTK, remove an ability
to use wlr-layer-shell directly. The APIs it required were dropped in
GTK4, and with the menus/tooltips positioning issue being practically
unsolvable it doesn't make sense to keep maintaining the code.
2024-02-17 11:23:17 -08:00
Aleksei Bavshin 2f555a6936
refactor(bar): use Gtk enums for position and orientation
Ensure that the position and the corresponding CSS class on window are
always set.
2024-02-14 22:11:21 -08:00
Erik Reider f7224d8459 Initial implementation 2023-10-26 23:22:02 +02:00
Brenno Lemos fad858782c feat: improve drawer configuration 2023-10-14 18:24:50 -03:00
Brenno Lemos 5246ab15cb feat: add drawer bool option to group 2023-10-14 17:17:52 -03:00
Brenno Lemos bbb7fb0c82 refactor: don't use a group's box directly in bar 2023-10-14 13:23:11 -03:00
Cherser-s 936937ec78 store margins and global window offset in the bar object 2023-08-25 20:37:14 +03:00
maqrrr 339bea1213 Add a new start_hidden bool 2023-05-15 07:01:00 -04:00
Alex 3bda22da72
Merge pull request #1589 from qubidt/module-group-orientation
group module: configurable orientation
2023-03-02 19:42:22 +01:00
Kauan Decarli de77787b60 Allow any module to implement signal handling 2023-01-21 21:57:28 -03:00
Bao Trinh f5a24d12e5
group module: configurable orientation
currently, the orientation of group modules is always the opposite of
the bar. Change it so that:

* the default orientation of the group module is always the opposite of
  its parent, even for nested groups
* the orientation can be overridden in the config
* css ID and class are set for the group element
2022-09-03 18:37:35 -05:00
Daan Goossens ae9fb57790 fix: vertical bar not anchored when width is set 2022-05-25 16:09:21 +02:00
Nicolas Berbiche 6851e26450
bar: don't set layer-shell anchor for edges
Don't set the anchor for certain edges when the width or the height
is not set to a value of 'auto' (1).

When the bar is vertical, the top and bottom edges are not anchored
otherwise the left and right edges are not anchored.

This resolves an issue wherein the width and height set for the
layer-shell were ignored because the layer was set to anchor to all
edges.
2022-04-17 18:19:36 -04:00
Alex f2fcadbf62 refactor: lint 2022-04-06 08:37:19 +02:00
Daniel Moore f4c6dfcddc Uses user-defined mode when toggling visibility rather than resetting to default mode 2022-03-12 13:32:08 -07:00
Andy Russell 54085dbde0
avoid use-after-free in lambda 2022-03-03 19:40:43 -05:00
ilkecan 548bd2ab1a Add `fixed-center` option
Resolves #957
2021-12-28 16:00:25 +03:00
John Fredriksson f573e32d0b bar: Fix crash when unplugging HDMI
There is a double delete situation which causes a SIGSEGV to happen
during destruction of bar.

This was introduced by the group feature patch.

The same object pointer is stored in two different vectors of
unique_ptr<AModule> element. Replace with shared_ptr to handle
reference counting correctly and avoid double delete.
2021-12-05 10:55:07 +01:00
Alex 05f7727dae
Merge branch 'master' into swaybar-ipc 2021-12-01 11:48:03 +01:00
Aleksei Bavshin b6d0a4b63f
feat(bar): allow customization of bar modes
Allow changing existing modes and adding new ones via `modes`
configuration key.
`modes` accepts a JSON object roughly described by the following type
```typescript
type BarMode = {
    layer: 'bottom' | 'top' | 'overlay';
    exclusive: bool;
    passthrough: bool;
    visible: bool;
};
type BarModeList = {
    [name: string]: BarMode;
};
```
and will be merged with the default modes defined in `bar.cpp`.

Note that with absence of other ways to set mode, only those defined in
the `sway-bar(5)`[1] documentation could be used right now.

[1]: https://github.com/swaywm/sway/blob/master/sway/sway-bar.5.scd
2021-11-28 12:19:45 -08:00
Nicolas Joyard 0c18e57937 add group feature 2021-11-25 12:01:17 +01:00
Aleksei Bavshin 2290fe10aa
fix(bar): handle ipc connection errors.
Try to use the default bar id (`bar-0`) if none is set.
2021-11-23 08:46:58 -08:00
jonbakke a015b2e3db
Clarify less than/greater than in warning.
I was seeing "[warning] Requested height: 20 exceeds the minimum height: 30 required..."
Lines 114-134 are relevant; 133 overrides the requested height with the minimum height when GTK wants more pixels to work with. So, the code is behaving as expected, and "less than" matches the code's logic.
2021-10-28 09:37:11 -07:00
Robin Ebert 0b66454d5c
Add spacing config option
This option allows to add spaces between the modules. It uses Gtk:Box's spacing property.
2021-10-20 11:30:40 +02:00
Aleksei Bavshin 7aaa3df701
feat(bar): add config flag to disable exclusive zone 2021-05-21 22:44:18 -07:00
Aleksei Bavshin 729553d3bc
feat(bar): add config flag for pointer event passthrough 2021-05-21 22:44:17 -07:00
dorgnarg 42e8667773 Better way of doing it by just moving the original delcarations after everything's for sure been set 2020-12-28 13:44:16 -07:00
dorgnarg c0361e8546 A hopeful fix to the module section classes when the bar is vertical 2020-12-28 13:34:59 -07:00
Thomas Hebb 85df7ce2da Add debug log message to print each bar's widget tree
This is very useful when writing CSS that affects more than just a
single widget. Pass `-l debug` to enable debug logging and show this
information.

Example output:

    [2020-11-30 12:38:51.141] [debug] GTK widget tree:
    window#waybar.background.bottom.eDP-1.:dir(ltr)
      decoration:dir(ltr)
      box.horizontal:dir(ltr)
        box.horizontal.modules-left:dir(ltr)
          widget:dir(ltr)
            box#workspaces.horizontal:dir(ltr)
          widget:dir(ltr)
            label#mode:dir(ltr)
          widget:dir(ltr)
            label#window:dir(ltr)
        box.horizontal.modules-center:dir(ltr)
        box.horizontal.modules-right:dir(ltr)
          widget:dir(ltr)
            box#tray.horizontal:dir(ltr)
          widget:dir(ltr)
            label#idle_inhibitor:dir(ltr)
          widget:dir(ltr)
            label#pulseaudio:dir(ltr)
          widget:dir(ltr)
            label#network:dir(ltr)
          widget:dir(ltr)
            label#cpu:dir(ltr)
          widget:dir(ltr)
            label#memory:dir(ltr)
          widget:dir(ltr)
            label#temperature:dir(ltr)
          widget:dir(ltr)
            label#backlight:dir(ltr)
          widget:dir(ltr)
            label#battery:dir(ltr)
          widget:dir(ltr)
            label#clock:dir(ltr)
2020-11-30 17:23:02 -08:00
Aleksei Bavshin 9c566564e1
fix(bar): address some of RawSurfaceImpl resizing issues 2020-10-28 08:22:26 -07:00
Aleksei Bavshin fc5906dbd4
feat(bar): change layer to `bottom` when hidden
Invisible bar on a `top` layer would still intercept pointer events and
stop them from reaching windows below. Always changing the layer to
to `bottom` along with making bar invisible would prevent that.
2020-10-28 08:18:49 -07:00
Aleksei Bavshin fe3aeb36c5
refactor(bar): wrap layer_surface pointer in unique_ptr 2020-10-28 08:15:02 -07:00
Aleksei Bavshin 591a417b7d
fix(bar): rework surface commit calls for RawSurfaceImpl
wayland log shows that some changes were committed twice and some
weren't committed until the next redraw.
2020-10-28 08:14:57 -07:00
Aleksei Bavshin f97de599dd
refactor: header cleanup
Replace a couple of header includes with forward declarations.
2020-10-28 08:08:03 -07:00
Aleksei Bavshin f01996ae99
fix(bar): CamelCase SurfaceImpl method names 2020-10-28 08:07:40 -07:00
Aleksei Bavshin 7735c80d0e
refactor(bar): Split GLS and raw layer-shell implementations
Extract two surface implementations from the bar class: GLSSurfaceImpl
and RawSurfaceImpl. This change allowed to remove _all_ surface type
conditionals and significantly simplify the Bar code.

The change also applies PImpl pattern to the Bar, allowing to remove
some headers and fields from `bar.hpp`.
2020-10-28 07:53:37 -07:00
Aleksei Bavshin 2b3d7be9cb
feat(bar): let gtk-layer-shell manage exclusive zone
Previous attempts to use auto exclusive zone from gtk-layer-shell failed
because gls was expecting real booleans (`TRUE`/`FALSE`) as set_anchor
arguments. With that being fixed, gtk_layer_auto_exclusive_zone_enable
makes gls handle everything related to the bar resizing.

The only remaining purpose of onConfigureGLS is to log warnings and bar
size changes; gtk-layer-shell code path no longer needs saved width_ or
height_ values.
2020-10-28 07:53:32 -07:00
Aleksei Bavshin 23e5181cac
feat(swaybar-ipc): add swaybar IPC client 2020-10-19 19:34:48 -07:00
Aleksei Bavshin 52361ed360
refactor(bar): make setVisible switch between "default" and "invisible" modes 2021-11-21 11:00:57 -08:00
Aleksei Bavshin 87b43c2171
feat(bar): attach CSS class `mode-{mode}` to window when setting mode 2021-11-19 20:02:57 -08:00
Aleksei Bavshin ae88d7d8dc
feat(bar): use "default" mode to store global options
Read `layer`, `exclusive`, `passthrough` into a special mode "default".
Drop `overlay` layer hacks, as it's easier to use `"mode": "overlay"`
for the same result.
2021-11-19 19:31:41 -08:00
Aleksei Bavshin 6d2ba7a75b
feat(bar): store modes as a map of presets
This allows to apply the mode atomically and adds possibility of
defining custom modes (to be implemented).
2021-11-19 19:29:51 -08:00
Aleksei Bavshin 03a641ed83
feat(bar): support swaybar `mode` for configuring window
Use `mode` (`waybar::Bar::setMode`) as a shorthand to configure bar
visibility, layer, exclusive zones and input event handling in the same
way as `swaybar` does.
See `sway-bar(5)` for a description of available modes.
2021-09-15 22:35:50 +07:00
Christoffer Noerbjerg e9b2d275c8 added module group selectors for styling 2020-10-11 22:36:30 +02:00