Commit Graph

117 Commits

Author SHA1 Message Date
Aleksei Bavshin d590d508ca
feat: add `module` class to the root elements of the modules
Previously, the only way to select all the module labels was with the
following kind of selector:
```css
.modules-left > widget > label,
.modules-center > widget > label,
.modules-right > widget > label {
    /* ... */
}
```
(and a matching block for the `box` containers).

Now, this can be expressed as
```css
label.module, box.module {
    /* ... */
}
```
2024-02-14 22:41:13 -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
Joshua Manchester 95ffc291f6
fix: hide tray event box instead of box 2024-01-14 15:06:06 +00:00
akliuxingyuan 335a736eed tray: load_icon use request_size directly 2023-11-01 22:26:52 +08:00
Tamino Bauknecht 68dfd6aa3a
scope_guard/modules: Rename scope_guard to ScopeGuard
Using pascal case for the class name keeps it more consistent with the
majority of the other class names.
2023-10-24 17:51:38 +02:00
Tamino Bauknecht dd1de3efbf
Revert "Revert "Fix potential memory leaks""
This reverts commit 2d33c20231 and
reapplies various patches for memory leaks.
The reason for the revert was a bug for a maximum duration interval
which caused sleep_for() to cause unpredictable behavior.
2023-10-24 17:51:38 +02:00
Alexis Rouillard 2d33c20231
Revert "Fix potential memory leaks" 2023-10-22 09:44:46 +02:00
Tamino Bauknecht a0b63d6b1e
modules: use scope_exit for deletion to make code more robust 2023-10-21 11:51:18 +02:00
Cherser-s 65dfabc430 sni: fix passing relative coordinates to dbus methods
Doesn't correctly handle the case with both margin and width/height being set at the same time.
2023-08-25 20:37:16 +03:00
Jan Palus c8237437d2
Explicitly cast ustring to string when passing to fmt
don't rely on implicit conversion which is no longer present in fmt
10.1.0

Fixes #2403
2023-08-15 20:57:07 +02:00
Alexis Rouillard 5ef6636237
Merge pull request #2265 from tengyifei/master
Partially revert 3af1853260 to fix use-after-free
2023-07-04 22:59:45 +02:00
André Aparício a1cd0acac5 Fix random segfault on GTK icon functions
The segfaults were happening on GTK icon theme functions, which are
called via the C++ interface functions such as Gtk::IconTheme::has_icon.

There are multiple modules and threads using this functions on the default
icon theme by calling Gtk::IconTheme::get_default(), which returns the same
object for all callers, and was causing concurrent access to the same internal
data structures on the GTK lib. Even a seemingly read-only function such as
has_icon can cause writes due to the internal icon cache being updated.

To avoid this issues, a program wide global mutex must be used to ensure
a single thread is accessing the default icon theme instance.

This commit implements wrappers for the existing IconTheme function calls,
ensuring the global lock is held while calling the underling GTK functions.
2023-07-03 22:32:24 +01:00
Yifei Teng cd49eef229 Partially revert 3af1853260 to fix use-after-free
After upgrading to the latest release of Waybar the bar will crash
whenever I close the laptop lid. After some debugging I believe it is
because the watching added by watch_name is not being correctly canceled
using unwatch_name. After the Tray object and Host object are destroyed,
additional callbacks will become use-after-free.

Looks like commit 3af1853260 removed the
unwatch_name. I'm not sure why it did that, but it seemed dangerous.

Additionally, bus_name_id_ is created by own_name. According to that
function's documentation, the correct inverse operation is unown_name.
2023-06-30 23:25:24 -07:00
Viktar Lukashonak a9779c2aa2
Happy Linter
Signed-off-by: Viktar Lukashonak <myxabeer@gmail.com>
2023-06-06 23:06:11 +03:00
Viktar Lukashonak 3af1853260
Tray module cause error g_bus_unwatch_name()
Signed-off-by: Viktar Lukashonak <myxabeer@gmail.com>
2023-06-06 23:02:36 +03:00
Alex 2111865efe
refactor: remove warning 2022-12-01 08:45:12 +01:00
asas1asas200 4a929240df style(lint): fix some files lint 2022-08-31 15:51:50 +08:00
akliuxingyuan 0d27949f0a scale icons for HiDPI monitor 2022-08-30 23:13:38 +08:00
Alex bcee4e15d3 fix: lint files 2022-08-18 15:22:25 +02:00
Alex c2ab2e6d19
Merge pull request #1627 from datMaffin/master
sni: Use the pixmap if for the given icon name an icon could not be found
2022-08-04 10:04:48 +02:00
Marvin Dostal 95b5348c24 sni: change missing icon in theme logging from info to trace 2022-08-03 17:34:34 +02:00
Marvin Dostal 04d66de866 sni: remove unnecesary parameter 2022-07-17 22:20:24 +02:00
Marvin Dostal 699f732146 sni: Remove unnecessary getIconByName call 2022-07-17 22:15:14 +02:00
Marvin Dostal f437bf96e3 sni: Prefer system icons over pixmap 2022-07-17 22:15:12 +02:00
Marvin Dostal fc9a390977 sni: Use the given pixmap even if there is a name given 2022-07-17 22:14:57 +02:00
Aleksei Bavshin 24a8332b62
fix: adapt to fmt 9.0.0 breaking changes 2022-07-13 22:36:32 -07:00
Alex f2fcadbf62 refactor: lint 2022-04-06 08:37:19 +02:00
Alex Maystrenko d4da04a750 move Glib ustring format helper to utils
this formatter is useful for other modules
which want to print Glib exceptions messages
2022-02-05 21:26:48 +01:00
Erik Reider 941cf47693 Add config option "reverse-direction" 2022-01-28 19:14:46 +01:00
Erik Reider 32d42749f9 use pack_end instead of pack_start 2022-01-28 18:42:52 +01:00
Elyes HAOUAS f18eb71ad7 Fix spelling errors
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
2021-10-02 18:13:17 +02:00
Aleksei Bavshin fbedc3d133
fix(tray): fix visibility of Passive items
`show_all` call from `Tray::update` attempts to walk the widget tree and
make every widget visible. Since we control individual tray item
visibility based on `Status` SNI property, we don't want that to happen.

Modify `Tray::update` to control the visibility of a whole tray module
only and ensure that the children of `Item` are still visible when
necessary.
2021-10-02 00:08:45 -07:00
Michael Swiger 4f76c9bd43 Only use g_memdup2 for glib >= 2.68 2021-08-29 13:11:04 -07:00
Michael Swiger cb49650ea4 Use g_memdup2 instead of g_memdup
This fixes a compile warning.

See: https://discourse.gnome.org/t/port-your-module-from-g-memdup-to-g-memdup2-now/5538
2021-08-22 14:46:40 -07:00
Michael Swiger 2d80d31527 Fix tray icon scaling on multi-display setups 2021-08-16 23:33:29 -07:00
Michael Swiger 4f6a9b1bc2 Fix incorrect tray icon scaling 2021-07-31 18:01:31 -07:00
Aleksei Bavshin a5fe6f40b8
feat(tray): handle Status property
On the `Passive` value of `Status` tray items would be hidden unless
`show-passive-items` is set to true.
On the `NeedsAttention` value of `Status` tray items will have a
`.needs-attention` CSS class.
2021-07-22 08:04:06 -07:00
Aleksei Bavshin 245f7f4b11
feat(tray): handle scroll events 2021-07-22 08:04:05 -07:00
Aleksei Bavshin 1418f96e46
feat(tray): fallback to Title for items without ToolTip 2021-07-22 08:04:04 -07:00
Aleksei Bavshin 84a8f79bbe
feat(tray): implement tooltips (text only) for tray items 2021-07-22 08:04:03 -07:00
Aleksei Bavshin 4b6253e810
refactor(tray): infer changed properties from signal name
Comparing two GVariants is too expensive; let's collect the set of
properties updated by each signal and apply them unconditionally.
2021-07-22 08:04:00 -07:00
Aleksei Bavshin 929fc16994
fix(tray): ignore unused WindowId property 2021-07-22 08:01:25 -07:00
Michael Swiger 1440ed29d4 Fix blurry tray icons for HiDPI displays 2021-07-20 22:29:34 -07:00
Jan Beich c844d7ac2e tray: drop std::filesystem dependency 2020-05-19 10:37:27 +00:00
Alex d1c4897f31 feat: update man 2020-04-12 18:38:51 +02:00
Guillaume Maudoux 047c2929c1 Use the same StatusNotifierWatcher for all trays 2020-02-19 12:06:35 +01:00
Louis des Landes 569f40de9b
Keep aspect ratio when scaling tray icons. 2020-01-09 17:27:10 +10:30
Alex f592e3d38b
Merge branch 'master' into fmt 2019-08-29 11:29:48 +02:00
Alex a257126685
Merge branch 'master' into asan-fixes 2019-08-29 11:04:24 +02:00
Jan Beich 712424f9a8 Unbreak build with fmtlib 6.0.0
In file included from ../src/factory.cpp:1:
In file included from ../include/factory.hpp:4:
../include/modules/clock.hpp:5:10: fatal error: 'fmt/time.h' file not found
 #include "fmt/time.h"
          ^~~~~~~~~~~~
In file included from ../src/bar.cpp:4:
In file included from ../include/factory.hpp:4:
In file included from ../include/modules/clock.hpp:3:
In file included from /usr/include/fmt/chrono.h:12:
/usr/include/fmt/locale.h:19:35: error: parameter type 'fmt::v5::internal::buffer' (aka 'basic_buffer<char>') is an abstract class
    const std::locale& loc, buffer<Char>& buf,
                                  ^
/usr/include/spdlog/fmt/bundled/core.h:238:16: note: unimplemented pure virtual method 'grow' in 'basic_buffer'
  virtual void grow(std::size_t capacity) = 0;
               ^
In file included from ../src/modules/sni/host.cpp:3:
/usr/include/fmt/ostream.h:22:9: error: expected member name or ';' after declaration specifiers
  buffer<Char>& buffer_;
  ~~~~~~^
/usr/include/fmt/ostream.h:25:19: error: expected ')'
  formatbuf(buffer<Char>& buf) : buffer_(buf) {}
                  ^
/usr/include/fmt/ostream.h:25:12: note: to match this '('
  formatbuf(buffer<Char>& buf) : buffer_(buf) {}
           ^
/usr/include/fmt/ostream.h:25:42: error: use of undeclared identifier 'buf'; did you mean 'prettify_handler::buf'?
  formatbuf(buffer<Char>& buf) : buffer_(buf) {}
                                         ^~~
                                         prettify_handler::buf
/usr/include/spdlog/fmt/bundled/format-inl.h:551:11: note: 'prettify_handler::buf' declared here
  buffer &buf;
          ^
2019-08-29 01:38:54 +00:00