Commit graph

425 commits

Author SHA1 Message Date
Felix Weilbach
0c47d323b1 Position icon in the middle
Signed-off-by: Felix Weilbach <felix.weilbach@t-online.de>
2021-05-01 22:06:28 +02:00
Felix Weilbach
ae5f5a7e88 Remove todo
Signed-off-by: Felix Weilbach <felix.weilbach@t-online.de>
2021-05-01 13:06:14 +02:00
Felix Weilbach
66d3502769 Search for deskop files in correct directories
Signed-off-by: Felix Weilbach <felix.weilbach@t-online.de>
2021-05-01 13:04:19 +02:00
Felix Weilbach
7f2fd4a716 Cleanup render code
Signed-off-by: Felix Weilbach <felix.weilbach@t-online.de>
2021-05-01 12:54:16 +02:00
Felix Weilbach
ed66986c1c Reload focused window icon on target size change
Signed-off-by: Felix Weilbach <felix.weilbach@t-online.de>
2021-05-01 12:51:05 +02:00
Felix Weilbach
dccb7d2153 Remove redefintion of icon_theme
Signed-off-by: Felix Weilbach <felix.weilbach@t-online.de>
2021-05-01 12:26:42 +02:00
Felix Weilbach
7a20f8ed92 Load icon only from disk if window changes
Signed-off-by: Felix Weilbach <felix.weilbach@t-online.de>
2021-05-01 12:24:56 +02:00
Felix Weilbach
402706ff9d Move append_path_save in util
Signed-off-by: Felix Weilbach <felix.weilbach@t-online.de>
2021-05-01 12:24:19 +02:00
Felix Weilbach
59d245cf5b Cleanup icon theme code
Signed-off-by: Felix Weilbach <felix.weilbach@t-online.de>
2021-05-01 11:38:20 +02:00
Felix Weilbach
93b60f799b Draw icon and window title only if enough space
Signed-off-by: Felix Weilbach <felix.weilbach@t-online.de>
2021-04-30 23:29:08 +02:00
Felix Weilbach
bb9a97ace5 Check also window class name when search desktop file
Signed-off-by: Felix Weilbach <felix.weilbach@t-online.de>
2021-04-30 23:16:46 +02:00
Felix Weilbach
2ca4766bb8 Better name for variable
Signed-off-by: Felix Weilbach <felix.weilbach@t-online.de>
2021-04-30 22:43:16 +02:00
Felix Weilbach
13835cf767 Add configuration option to disable window title
Signed-off-by: Felix Weilbach <felix.weilbach@t-online.de>
2021-04-30 22:36:39 +02:00
Felix Weilbach
3d158264e2 Compile without tray support
Signed-off-by: Felix Weilbach <felix.weilbach@t-online.de>
2021-04-30 21:58:01 +02:00
Felix Weilbach
89b97c5346 Don't render a icon if the window does not provide one
Signed-off-by: Felix Weilbach <felix.weilbach@t-online.de>
2021-04-30 21:28:22 +02:00
Ronan Pigott
8fa71290af Display window title and icon in swaybar
Signed-off-by: Felix Weilbach <felix.weilbach@t-online.de>
2021-04-29 20:21:52 +02:00
Tudor Brindus
03daa53a0e swaybar: fail gracefully on tokener creation fail
This commit adds missing error-handling to the creation of the tokener
instance. The stack depth parameter is used to initialize an array that
json-c prefaults ahead of time, causing INT_MAX to result in out of
memory errors.

Also drop the depth to 256 to prevent this OOM.

Though this fix is not very satisfactory -- json-c could be made to
not prefault -- it should do for now. At the very least, swaybar will
not crash.

Fixes #6126.
2021-03-22 14:10:53 +01:00
Tudor Brindus
47f1f9b63e swaybar: use INT_MAX max JSON depth when parsing IPC response
There's no inherent limit on the nesting Sway can generate, and the
default used by `json_tokener_new`, 32, can plausibly be hit during
regular usage.

Fixes #6115.
2021-03-21 23:34:07 +01:00
Kenny Levinsen
6271bd06e9 swaybar: Use position from wl_pointer.enter
Only wl_pointer.motion was used to update pointer position, which would
cause issues if the pointer was not moved prior to wl_pointer.button.

This also fixes touch input through wl_pointer emulation, which fires
wl_pointer.button immediately after wl_pointer.enter.

Copied from a similar fix made to swaynag.

Closes: https://github.com/swaywm/sway/issues/6109
2021-03-20 11:56:13 +01:00
Pi-Yueh Chuang
6059c744f8
swaybar: silence missing IconThemePath message
IconThemePath is not a standard property in XDG's StatusNotifierItem
specification, so missing this property should not be logged as an error.

This patch changes the log level to SWAY_DEBUG when swaybar queries the
value of IconThemePath so that swaybar won't log the returned message as
an error if IconThemePath does not exist.

Closes: https://github.com/swaywm/sway/issues/6092
2021-03-17 09:49:04 +01:00
Fenveireth
837605d68d swaybar: use text subpixel antialias only where it would look good
Closes #5605

Text Subpixel antialiasing is :

- FreeType makes glyph bitmaps containing coverage percentage for each
  subpixel, instead of pixel
- Then draw by performing the blend for each subpixel, instead of pixel (e.g.
  dual-source blending in opengl)

And there's only one Alpha channel, so this extra coverage data can't
leave Cairo to reach the compositor through there.
Therefore, it can't work as intended if output text alpha != bar background
alpha. Disable it for those cases, enable it elsewhere

As for color emojis, they are RGBA bitmaps. If drawn with text alpha=1.0
and background alpha=1.0 (should be completely opaque bar), then with
'CAIRO_OPERATOR_SOURCE' then texels with alpha < 1.0 result in a blend with
whatever's behind the bar, instead of the bar background
2021-03-07 19:18:53 -05:00
Manuel Stoeckl
169b90f90b Make command line option lists const 2021-02-04 09:49:06 +01:00
Manuel Stoeckl
8f2cd3236f Make Wayland request listeners static const when possible 2021-02-04 09:49:06 +01:00
SpizzyCoder
7cf25d3b98 Changed fprintf(stdout,...) to printf(...) for more readable code 2021-01-16 20:24:41 +01:00
Mukundan314
a7414885d2 Fix #5940
Fallback to focused_statusline instead of statusline on focused output
2021-01-11 10:51:21 +01:00
Simon Ser
cbd82b4117
man: update maintainer
Also remove the AUTHORS section from swaybar-protocol(7), for
consistency with the rest of the man pages.
2021-01-08 09:33:51 +01:00
Simon Ser
fdbe98512a build: introduce sd-bus-provider option
This allows to select a specific provider for the sd-bus library.
2020-12-09 17:39:20 -05:00
Ludvig Michaelsson
d6ac30753d swaybar: don't expand separator_block_width if separator is false
When swaybar receives the following JSON body

    [
        {
            "full_text": "foo",
            "separator": false,
            "separator_block_width": 0
        },
        {
            "full_text": "bar"
        }
    ]

it should not draw any separator or any space between the two blocks.
However, since swaybar calculates that separator_block_width
0 is too small to fit any configured separator, it will override the
separator_block_width with some non-zero value. This patch changes
that such that the necessary separator_block_width is only expanded if
the block has 'separator: true'.

This should be in line to what i3 does, as its documentation of the
i3bar protocol for separator states that "[...] if you disable the
separator line, there will still be a gap after the block, unless you
also use separator_block_width".
2020-10-12 16:02:41 +02:00
Tarmack
989123a2a5 Add support for workspace_min_width bar option. 2020-10-11 19:12:42 +02:00
Hubert Hirtz
c5c632aaae Document required '\n' in swaybar-protocol
The following statusbar output is not considered by sway to be following
the swaybar-protocol:

    {"version":1}[[{"full_text":"2.89","urgent":false}],

However this one is:

    {"version":1}\n[[{"full_text":"2.89","urgent":false}],

Both outputs contain a header with the required values and an unfinished
array of objects with the required values, but the first one is showed
verbatim.
2020-08-04 10:39:29 +02:00
Charmander
66b7ac6a82 swaybar: allow status line cleanup to proceed when hidden
`determine_bar_visibility` stops and starts the status command process according to the bar’s visibility. If the bar was hidden during teardown, teardown would stall while waiting for the stopped status command process to exit.

This resumes a stopped status command during teardown and allows, for example, sway to reload or quit without leaving a swaybar instance behind each time.

Fixes #5536.

CONT before TERM as requested in review.
2020-07-22 09:40:37 +02:00
Luke Drummond
c22caa54a8 swaybar: ensure correct init order for status_line
`$WAYLAND_SOCKET` is unset by `wl_display_connect` after it has
successfully connected to the wayland socket.

However, subprocesses spawned by swaybar (status-command) don't have
access to waybar's fds as $WAYLAND_SOCKET is O_CLOEXEC. This means any
status command which itself tries to connect to wayland will fail if
this environment variable is set.

Reorder display and status-command initialization so that this variable
is not set and add an assert so we can enforce this invariant in future.
2020-06-12 14:45:40 +02:00
Milkey Mouse
45e4e92172 swaybar: add NULL check when listing workspaces
For some reason my version of sway doesn't show workspace names:

    $ swaymsg -t get_outputs
    Output HDMI-A-1 '(null) (null) (null)' (inactive)
    Output HDMI-A-2 '(null) (null) (null)' (inactive)

Which is weird, but it's no reason to crash swaybar. The field is
totally missing from the JSON, so it ends up doing strcmp(NULL, name)
which is undefined behavior.
2020-05-20 23:11:02 +02:00
James Mills
2373af77d4
Fix typo in swaybar-protocol.7.scd 2020-04-30 15:15:58 +02:00
Martin Dørum
4492e493e6 swaybar: Fix scrolling with precise trackpads 2020-04-28 21:46:37 +02:00
Ian Huang
276e0301e0 interpret "subpixel none" as CAIRO_ANTIALIAS_GRAY
See issue #5228. Currently, WL_OUTPUT_SUBPIXEL_NONE is ignored and
CAIRO_ANTIALIAS_SUBPIXEL is still set. This commit checks if subpixel is
set to none and if so, calls set_antialias with CAIRO_ANTIALIAS_GRAY.
This mirrors the functionality in Mako's
[PR261](https://github.com/emersion/mako/pull/261)
2020-04-20 09:26:37 +02:00
Ian Fan
65501f0e46 tray: track SNI callbacks
This removes any pending messages once the item is destroyed.
Furthermore, this installs SNI event calbacks asynchronously
in order to prevent sd-bus from bypassing pending messages.
2020-03-30 17:31:00 +02:00
Ian Fan
68f53cd509 tray: tidy code
This includes some refactoring and fixing a small memory leak.
2020-03-30 17:31:00 +02:00
Ian Fan
3b894c387d tray: allow themes to inherit from multiple themes 2020-03-30 17:31:00 +02:00
Ian Fan
66f0c91bb8 tray: better errors when parsing index.theme 2020-03-30 17:31:00 +02:00
Ian Fan
b54f5e170a swaybar: fix memory leaks 2020-03-30 17:31:00 +02:00
Bill Doyle
920d85d35f Only destroy swaybar surface via ipc when needed 2020-02-27 15:34:49 +01:00
Hristo Venev
7affe5c1bd swaybar: fix i3bar relative coordinates when scaling is used
24e8ba048a did not take scaling into account.
The hotspot size used pixel coordinates, the absolute coordinates were logical,
and the relative coordinates were completely wrong.

This commit makes all coordinates use logical values. If
`"float_event_coords":true` is sent in the handshake message, coordinates are
sent as floating-point values.

The "scale" field is an integer containing the scale value.
2020-02-10 18:58:09 +01:00
Hristo Venev
fca32b6334 Do not truncate pointer coordinates to int.
This increases the precision of the clicks when using i3bar.
2020-02-10 18:58:09 +01:00
Till Hofmann
0f5157668d Avoid calling strcmp on nullptr
The function group_handler may get a nullptr as `new_group`. If that's
the case, return true, as if `new_group` was the empty string.

Also make the conversion to bool explicit when calling `strcmp`.
2020-02-10 13:29:07 +01:00
Andri Yngvason
fd24b1afd8 swaybar: Fix input device removal
Before swaybar would exit with a protocol error when a pointer or touch
device was removed.
2020-01-05 19:57:05 +01:00
Whemoon Jang
ed9b4e6aeb Fix typo in swaybar-protocol.7.scd 2019-12-28 13:36:00 -05:00
Brian Ashworth
97f9f0b699 parse_color: return success + drop fallback color
This is the first in a series of commits to refactor the color handling
in sway. This changes parse_color to return whether it was success and
no longer uses 0xFFFFFFFF as the fallback color. This also verifies that
the string actually contains a valid hexadecimal number along with
the length checks.

In the process of altering the calls to parse_color, I also took the
opportunity to heavily refactor swaybar's ipc_parse_colors function.
This allowed for several lines of duplicated code to be removed.
2019-12-28 10:07:25 +01:00
Jason
939c7b2d52 Amend typos 2019-11-23 11:48:31 +01:00
Konstantin Pospelov
06fcebc542 swaybar: fix typo in the loop over pixmaps
Fixes #4665.
2019-10-23 09:53:16 +02:00