aboutsummaryrefslogtreecommitdiff
path: root/swaybar/render.c
AgeCommit message (Collapse)Author
2024-02-23Define _POSIX_C_SOURCE globallySimon Ser
See discussion in https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4555
2023-04-02swaybar: Lift background clearing out of main rendering functionAlexander Orzechowski
This avoids us from using a bogus background_color value that mutates as swaybar renders things and deciding opacity depending on that. Also remove a redundant full surface clear. Just directly write our desired background color.
2023-04-02swaybar: Set opaque region properlyAlexander Orzechowski
The opaque region is set incorrectly if updated on-the-fly if switching from an opaque to a non opaque background.
2023-02-27sway{,bar}: use default font hint stylellyyr
CAIRO_HINT_STYLE_FULL attempts to maximize contrast at the expense of fidelity, this makes most fonts that haven't been hand hinted, which makes up the majority of fonts out there, appear much worse. In the absence of explicitly set hint style, cairo will default to CAIRO_HINT_STYLE_SLIGHT, which attempts to improve contrast while retaining fidelity to the original shapes, which is what we want.
2023-01-03Use correct length for strncmp comparisonCarl Smedstad
2022-11-26swaybar: Make hotspots block bar release bindingsJoan Bruguera
The previous commit prioritized hotspots before bar bindings for press events, which matches i3's behaviour. However, since hotspots don't need to do any processing on release events, those were not handled, and simply fell through to `bindsym --release` bar bindings (if any). This is counter-intuitive, and doesn't match i3's behaviour. Instead in case a hotspot handles the press event, it should also handle the release event, doing nothing, but blocking the event from triggering a --release bar binding. E.g., in Sway, without this commit, this config. shows a text on tray clicks: bar { # ... bindsym --release button1 exec swaynag -m I_got_the_release_event. } But the same configuration in i3 (with i3-nagbar) doesn't show the text. Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
2022-07-01Reuse parsed PangoFontDescriptionHugo Osvaldo Barrera
Avoids parsing the configured font each time text is rendered.
2022-03-14swaybar: set opaque regionSimon Ser
When the background color is fully opaque, set the surface's opaque region to the whole surface.
2021-10-08swaybar: fix cairo_font_options leakNathan Schulte
2021-09-20swaybar: properly draw blocks with transparent black borderNathan Schulte
while the draw itself is a no-op, alignment must still be accounted this requires more signalling about the blocks (border_set; was the border set?)
2021-09-15swaybar: properly draw urgent block right borderNathan Schulte
introduced via #3287 -- https://github.com/swaywm/sway/pull/3287/files#diff-a1e918ce0bc71f4f7934767541319e724a51a34a5418ecdc286065e50921eda4L239 uncovered via #3394 -- https://github.com/swaywm/sway/pull/3394/files#diff-a1e918ce0bc71f4f7934767541319e724a51a34a5418ecdc286065e50921eda4R258
2021-09-13Rename pango_printf to render_textSimon Ser
This avoids using the pango_ prefix, reserved for functions coming from the Pango library.
2021-09-12Simplify swaybar/swaynag scaling codeCaduser2020
Use `cairo_scale` to set the scale factor, removing redundant multiplications by `output->scale`.
2021-05-10cairo: Replace <cairo/cairo.h> by <cairo.h>Issam E. Maghni
For full context, read https://gitlab.freedesktop.org/cairo/cairo/-/issues/479 TL;DR, cairo’s pc file adds `/cairo` to CFLAGS. So namespace cairo shouldn’t be used.
2021-03-07swaybar: use text subpixel antialias only where it would look goodFenveireth
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-01-11Fix #5940Mukundan314
Fallback to focused_statusline instead of statusline on focused output
2020-10-12swaybar: don't expand separator_block_width if separator is falseLudvig Michaelsson
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-11Add support for workspace_min_width bar option.Tarmack
2020-04-20interpret "subpixel none" as CAIRO_ANTIALIAS_GRAYIan Huang
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-02-10swaybar: fix i3bar relative coordinates when scaling is usedHristo Venev
24e8ba048aef4751c6fa1d5982ee634f921e6cf6 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.
2019-12-28parse_color: return success + drop fallback colorBrian Ashworth
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-09-20swaybar: make status block text render in the same way as othersxdavidwu
Other components like workspace button, status line (error or plain text) already render text at integer coords. This make status block also render text at integer coords.
2019-08-02Remove unused variableAntonin Décimo
2019-04-04Add margin to short_text handling.Dmitri Kourennyi
Add a 3xscale margin matching other spacing in swaybar as part of short text width calculations
2019-04-04Ensure predicted position for short text handling doesn't overflow.Dmitri Kourennyi
- Predicted status line can be negative, so corresponding variables should not be unsigned. Changed to double as position is actually calculated as double.
2019-04-04Implement handling of short_text field of i3 input protocol.Dmitri Kourennyi
Matches i3bar behavior of setting all blocks to use the short_text if the full text width does not fit.
2019-01-31Rebase #1636 against current masterv44r
2019-01-21Replace wlr_log with sway_logM Stoeckl
This commit mostly duplicates the wlr_log functions, although with a sway_* prefix. (This is very similar to PR #2009.) However, the logging function no longer needs to be replaceable, so sway_log_init's second argument is used to set the exit callback for sway_abort. wlr_log_init is still invoked in sway/main.c This commit makes it easier to remove the wlroots dependency for the helper programs swaymsg, swaybg, swaybar, and swaynag.
2019-01-13Merge pull request #3344 from RedSoxFan/bar-mouse-bindings-improvedDrew DeVault
Improve mouse button parsing: bar mouse bindings
2019-01-13Merge pull request #3397 from RedSoxFan/fix-swaybar-heightDrew DeVault
swaybar: obey height if given
2019-01-11swaybar: add status_edge_padding commandBrian Ashworth
This adds the bar subcommand `status_edge_padding <padding>` to set the padding used when the status line is on the right edge of the bar.
2019-01-11swaybar: add status_padding commandBrian Ashworth
Adds the bar subcommand `status_padding <padding>` which allows setting the padding used for swaybar. If `status_padding` is set to `0`, blocks will be able to take up the full height of the bar.
2019-01-10bar_cmd_bind: utilize mouse button helpersBrian Ashworth
This modifies `bar_cmd_bindsym` to use `get_mouse_bindsym` for parsing mouse buttons. This also introduces `cmd_bar_bindcode`, which will use `get_mouse_bindcode` for parsing mouse buttons. Like sway bindings, the two commands are encapsulated in a single file with shared code. This also modifies swaybar to operate off of event codes rather than x11 button numbers, which allows for any mouse button to be used. This introduces two new IPC properties: - For `get_bar_config`, `event_code` has been added to the `bindings` section and will include to event code for the button. If the event code can be mapped to a x11 button, `input_code` will still be the x11 button number. Otherwise, `input_code` will be `0`. - Likewise for `click_events`, `event` has been added and will include the event code for the button clicked. If the event code can be mapped to a x11 button, `button` will still be the x11 button number. Otherwise, `button` will be `0`.
2019-01-09swaybar: obey height if givenBrian Ashworth
If there is a bar height given, use that as the height rather than as a minimum height. This matches i3-gaps behavior.
2019-01-09swaybar: fix rendering of border and backgroundBrian Ashworth
This fixes the rendering of borders and backgrounds for blocks. This also makes the following changes: * both borders and padding are scaled with the output * both lines and rectangles are rendered without an antialiasing to avoid bleeding outside the desired area
2018-12-31swaybar: add tray interfaceIan Fan
2018-12-12swaybar: fix sep block width for mixed scalesBrian Ashworth
When there are outputs with mixed scales, it was possible for swaybar to alter `block->separator_block_width` for an output with a higher scale, and use the changed value for a lower scale output. This caused there to be larger than normal separation between blocks on the lower scale outputs. The issue is more obvious the larger the scale difference between the highest scale output and the lowest scale output. This fixes the issue by using a local variable that is originally set to `block->separator_block_width` for rendering, but if it needs to be increased, the local variable is the only thing touched.
2018-12-12swaybar: handle block->urgentBrian Ashworth
When `block->urgent` is set, use the urgent colors. This matches i3bar's behavior. Previously, swaybar just ignored the property. This also adds in rendering for right borders, which was missing.
2018-12-04Add relative coordinates in JSON for i3bar click eventsHristo Venev
Compatibility with i3 commit 161db6f17d734ac9deb0a20e81b78d4b2a92ce68.
2018-11-28Implement bar gapsBrian Ashworth
Adds the bar subcommand `gaps <amount>|<horizontal> <vertical>|<top> <right> <bottom> <left>` to set gaps for swaybar. Due to restrictions on margins for a layer_surface, only the sides that are anchored to an edge of the screen can have gaps. Since there is support for per-side outer gaps for workspaces, those should be able to be used instead for the last side.
2018-11-17Implement strip_workspace_name.Connor E
2018-10-25swaybar: reverse order of workspaces listIan Fan
This makes it congruent with its visual appearance, making it easier to reason about.
2018-10-20swaybar: render with minimum height, nominally text heightIan Fan
2018-10-14swaybar: when hiding bar, save old height to be restored upon reshowIan Fan
Previously, when the bar was hidden, the height would be set to 0. This meant that if the bar was empty upon reshow, it would not render since the height was still 0, which made it seem there was a problem. Now, the height is not reset, but the width is, to indicate upon reshow that the layer surface needed reconfiguring.
2018-10-14swaybar: handle mode/hidden_state changesIan Fan
As well as adding the hidden_state property to the bar config struct, this commit handles barconfig_update events when the mode or hidden_state changes, and uses a new function determine_bar_visibility to hide or show the bar as required, using, respectively, destroy_layer_surface, which is also newly added, and add_layer_surface, which has been changed to allow dynamically adding the surface.
2018-10-14swaybar: move mode & mode_pango_markup to bar structIan Fan
This distinguishes the binding mode from the distinct config mode, as well as removing mode_pango_markup from the config struct where it should not be present.
2018-10-14swaybar: add free_hotspots helper functionIan Fan
2018-09-30swaybar: synchronize rendering to output framesIan Fan
2018-09-28swaybar: trim function prototypesIan Fan
2018-09-28swaybar: move i3bar definitions into separate fileIan Fan