summaryrefslogtreecommitdiff
path: root/common
AgeCommit message (Collapse)AuthorLines
2019-01-17stringop.c: refactor a few functionsFurkan Sahin-8/+5
2019-01-17stringop.c: clean up headersFurkan Sahin-5/+5
2019-01-17stringop.c: remove unused functionsFurkan Sahin-115/+0
The only use of `join_list` in swaybar/tray/icon.c has been rewritten.
2019-02-05output_cmd_background: fix no file + valid modeFurkan Sahin-0/+3
If output_cmd_background is given a valid mode as the first argument, then there is no file given and an error should be returned. join_args should not be called with an argc of zero since it sets the last character to the null terminator. With an argc of zero, the length is zero causing a heap buffer overflow when setting the byte before the start of argv to '\0'. This probably will not ever generate a segfault, but may cause data corruption to whatever is directly before it in memory. To make other such cases easier to detect, this also adds a sway_assert in join_args when argc is zero.
2019-01-22background-image.c: remove stdbool headerFurkan Sahin-2/+1
2019-01-22util.c: remove numlen functionFurkan Sahin-9/+0
Its uses have been replaced by snprintf, which is more in line with its usage.
2019-01-21Removed unused wlroots dependency for sway(bg|bar|msg|nag)Furkan Sahin-2/+1
Also remove direct libm dependency where unused.
2019-01-21Fix edge case bug in numlen, dropping use of math.h functionsFurkan Sahin-4/+5
(Specifically, numlen when called with INT_MIN gave an incorrect result, because abs(INT_MIN) == INT_MIN < 0.)
2019-01-21Move sway-specific functions in common/util.c into sway/Furkan Sahin-105/+0
Modifier handling functions were moved into sway/input/keyboard.c; opposite_direction for enum wlr_direction into sway/tree/output.c; and get_parent_pid into sway/tree/root.c .
2019-01-20Replace wlr_log with sway_logFurkan Sahin-18/+99
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-20Allocate minimum size necessary in pango text functions. (#3473)Furkan Sahin-12/+22
* Allocate minimum size necessary in pango text functions. * Handle malloc failure.
2019-01-19Fix backup methods in get_socketpath for IPC clientFurkan Sahin-4/+12
Previously, the success of `getline` was tested by checking if the buffer it allocates is nonempty and has a nonzero first byte. As `getline` does not explicitly zero out its memory buffer, this may fail (e.g., with AddressSanitizer). Instead, we check that at least one character was returned on standard output. Also, trailing newlines (if present) are now removed.
2019-01-17Remove unicode.cFurkan Sahin-102/+0
2019-01-16Use static arrays where possible.Furkan Sahin-18/+13
2019-01-16Remove usage of VLAs.Furkan Sahin-6/+15
2019-01-02fixup! stringop.c: rewrite strip_whitespaceFurkan Sahin-4/+4
2018-12-09Remove readline.cFurkan Sahin-80/+8
All occurrences of read_line have been replaced by getline. peek_line has been absorbed into detect_brace.
2018-12-09stringop.c: rewrite strip_whitespaceFurkan Sahin-17/+10
2018-12-09Merge pull request #3271 from ianyfan/list-cleanupFurkan Sahin-23/+15
list.c: Remove list_foreach
2018-12-09list.c: rename free_flat_list to list_free_items_and_destroyFurkan Sahin-3/+3
2018-12-08Cleanup list codeFurkan Sahin-2/+1
2018-12-08list.c: Remove list_foreachFurkan Sahin-21/+14
Most occurrences have been replaced by `free_flat_list` which has been moved from stringop.c to list.c. The rest have been replaced by for loops.
2018-12-06list: double list capacity when resizing instead of incrementingFurkan Sahin-1/+1
This is the industry standard since it allows insertion to be amortized O(1) time.
2018-11-25Replace _XOPEN_SOURCE with _POSIX_C_SOURCEFurkan Sahin-1/+1
And make sure we don't define both in the same source file.
2018-11-19Merge pull request #3083 from c-edw/feature/StripWorkspaceNameFurkan Sahin-2/+3
Implement strip_workspace_name.
2018-11-17Add scroll factor config option.Furkan Sahin-0/+12
2018-11-18Use #if instead of #ifdefFurkan Sahin-7/+7
2018-11-17Implement strip_workspace_name.Furkan Sahin-2/+3
2018-11-01Wrap to fartherest output when running focus outputFurkan Sahin-0/+16
Also moves the `opposite_direction` function into `util.c` as it's used in two places now.
2018-10-27Revert "Add resolve_path() to utils"Furkan Sahin-37/+0
This reverts commit 619145b12ce433feceacded9eed1da4ac6f145a5.
2018-10-30Remove enum movement_directionFurkan Sahin-21/+0
There's no point having both movement_direction and wlr_direction. This replaces the former with the latter. As movement_direction also contained MOVE_PARENT and MOVE_CHILD items, these are now checked specifically in the focus command and handled in separate functions, just like the other focus variants.
2018-10-17Merge pull request #2864 from sghctoma/freebsd-fixesFurkan Sahin-1/+1
FreeBSD fixes
2018-10-17Fix stringop-overflow warningsFurkan Sahin-1/+1
2018-10-17Increase _POSIX_C_SOURCE to 200112LFurkan Sahin-1/+1
CLOCK_MONOTONIC appeared in IEEE Std. 1003.1-200x, it was not part of POSIX.1b (the 1993 version), and FreeBSD treats it accordingly.
2018-10-16Truncate message, append buffer overflow message if too long.Furkan Sahin-6/+9
Increase buffer size, remove macros. Make variables lowercase. Some more feedback.
2018-10-15common/loop.c: add _POSIX_C_SOURCE for clock_gettime and CLOCK_MONOTONICFurkan Sahin-0/+1
2018-10-15Event loop: Fix memmove and remove extraneous declarationFurkan Sahin-1/+1
2018-10-14Event loop: Free fds and fix race conditionFurkan Sahin-0/+4
2018-10-14Remove timerfd from loop implementationFurkan Sahin-43/+100
timerfd doesn't work on the BSDs, so this replaces it with a timespec for the expiry and uses a poll timeout to check the timers when needed.
2018-10-13swaylock: Remove indicator after 3 secondsFurkan Sahin-3/+16
2018-10-13Move swaybar's event loop to common directory and refactorFurkan Sahin-0/+106
* The loop functions are now prefixed with `loop_`. * It is now easy to add timers to the loop. * Timers are implemented using pollfd and timerfd, rather than manually checking them when any other event happens to arrive.
2018-09-23swaybg: fix increasingly smaller bg on hotplugFurkan Sahin-0/+2
render_background_image alters the scale that cairo uses. Depending on the image mode, resolution, and image size, this may cause the surface to be rendered increasingly smaller. By calling cairo_save and cairo_restore, any changes to the cairo settings by the function are not kept as a side effect. The surface that swaybg uses is also now cleared before rendering a frame. This is needed to avoid artifacts on resolution or scale changes with certain combinations of image modes, resolutions, and image sizes. This was also part of the increasingly smaller background visual since it made it so it was not obvious the region being rendered to was smaller and caused an increasing number of smaller images to be appear for each hotplug.
2018-09-22Call pango_cairo_context_set_font_options().Furkan Sahin-0/+5
Call pango_cairo_context_set_font_options() before pango_cairo_update_layout() and pango_cairo_show_layout(). By default, Pango "merges" the Cario font options with its own, which doesn't enable full hinting.
2018-09-20swaybar, swaylock, & tree/container: Set cairo font options to render text ↵Furkan Sahin-0/+16
and lines with subpixel hinting (if available).
2018-09-22Use pango_layout_set_text instead of pango_layout_set_markupFurkan Sahin-2/+4
2018-09-21Fix pango escaping and refactor escape_markup_textFurkan Sahin-40/+17
Fixes #2674. The cause of the issue was in get_pango_layout. When we call pango_parse_markup, `text` is the escaped string, and the unescaped string is then computed and written to `buf`. We were then passing the unescaped string to pango_layout_set_markup, but this function needs the escaped string. `buf` is not needed and has been removed. The other part of this PR refactors escape_markup_text to remove the dest_length argument and removes the -1 return value on error. It now assumes that you've allocated dest to the correct length.
2018-09-17swaybar: rewrite protocol determinationFurkan Sahin-25/+0
This now uses the getline function to receive the header, replacing read_line_buffer, which has been deleted since it is otherwise unused. Furthermore, once the protocol has been determined, the current status is handled immediately to be shown (though this has not been added for the i3bar protocol since it has not yet been rewritten to handle this).
2018-09-08Align titles to baselineFurkan Sahin-1/+4
This does the following: * Adds a baseline argument to get_text_size (the baseline is the distance from the top of the texture to the baseline). * Stores the baseline in the container when calculating the title height. * Takes the baseline into account when calculating the config's max font height. * When rendering, pads the textures according to the baseline so they line up.
2018-09-02prevent ub caused by misaligned stores/loadsFurkan Sahin-4/+4
2018-09-01Allow reload command to exist anywhere in the command stringFurkan Sahin-0/+14
This fixes a crash if you have commands where reload appears in the middle or at the end, such as `bindsym r mode default, reload`.