aboutsummaryrefslogtreecommitdiffstats
path: root/common
Commit message (Collapse)AuthorAge
* output_cmd_background: fix no file + valid modeLibravatar Brian Ashworth2019-02-11
| | | | | | | | | | | | | 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.
* background-image.c: remove stdbool headerLibravatar Ian Fan2019-01-22
|
* util.c: remove numlen functionLibravatar Ian Fan2019-01-22
| | | | Its uses have been replaced by snprintf, which is more in line with its usage.
* Removed unused wlroots dependency for sway(bg|bar|msg|nag)Libravatar M Stoeckl2019-01-21
| | | | Also remove direct libm dependency where unused.
* Fix edge case bug in numlen, dropping use of math.h functionsLibravatar M Stoeckl2019-01-21
| | | | | (Specifically, numlen when called with INT_MIN gave an incorrect result, because abs(INT_MIN) == INT_MIN < 0.)
* Move sway-specific functions in common/util.c into sway/Libravatar M Stoeckl2019-01-21
| | | | | | 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 .
* Replace wlr_log with sway_logLibravatar M Stoeckl2019-01-21
| | | | | | | | | | | | | 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.
* Allocate minimum size necessary in pango text functions. (#3473)Libravatar Connor Edwards2019-01-20
| | | | | | * Allocate minimum size necessary in pango text functions. * Handle malloc failure.
* Fix backup methods in get_socketpath for IPC clientLibravatar M Stoeckl2019-01-19
| | | | | | | | | | 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.
* Remove unicode.cLibravatar emersion2019-01-17
|
* Use static arrays where possible.Libravatar Connor E2019-01-16
|
* Remove usage of VLAs.Libravatar Connor E2019-01-16
|
* fixup! stringop.c: rewrite strip_whitespaceLibravatar Ian Fan2019-01-02
|
* Remove readline.cLibravatar Ian Fan2019-01-01
| | | | | All occurrences of read_line have been replaced by getline. peek_line has been absorbed into detect_brace.
* stringop.c: rewrite strip_whitespaceLibravatar Ian Fan2019-01-01
|
* Merge pull request #3271 from ianyfan/list-cleanupLibravatar Ryan Dwyer2018-12-09
|\ | | | | list.c: Remove list_foreach
| * list.c: rename free_flat_list to list_free_items_and_destroyLibravatar Ian Fan2018-12-09
| |
| * Cleanup list codeLibravatar Ian Fan2018-12-09
| |
| * list.c: Remove list_foreachLibravatar Ian Fan2018-12-09
| | | | | | | | | | 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.
* | list: double list capacity when resizing instead of incrementingLibravatar Ian Fan2018-12-06
|/ | | | | This is the industry standard since it allows insertion to be amortized O(1) time.
* Replace _XOPEN_SOURCE with _POSIX_C_SOURCELibravatar emersion2018-11-25
| | | | And make sure we don't define both in the same source file.
* Merge pull request #3083 from c-edw/feature/StripWorkspaceNameLibravatar emersion2018-11-19
|\ | | | | Implement strip_workspace_name.
| * Implement strip_workspace_name.Libravatar Connor E2018-11-17
| |
* | Add scroll factor config option.Libravatar Spencer Michaels2018-11-18
| |
* | Use #if instead of #ifdefLibravatar emersion2018-11-18
|/
* Wrap to fartherest output when running focus outputLibravatar Ryan Dwyer2018-11-01
| | | | | Also moves the `opposite_direction` function into `util.c` as it's used in two places now.
* Revert "Add resolve_path() to utils"Libravatar madblobfish2018-10-31
| | | | This reverts commit c9694ee63d451da62dc50b234b3080a35a40e844.
* Remove enum movement_directionLibravatar Ryan Dwyer2018-10-30
| | | | | | | | | 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.
* Merge pull request #2864 from sghctoma/freebsd-fixesLibravatar Drew DeVault2018-10-17
|\ | | | | FreeBSD fixes
| * Increase _POSIX_C_SOURCE to 200112LLibravatar sghctoma2018-10-17
| | | | | | | | | | CLOCK_MONOTONIC appeared in IEEE Std. 1003.1-200x, it was not part of POSIX.1b (the 1993 version), and FreeBSD treats it accordingly.
* | Fix stringop-overflow warningsLibravatar Niccolò Scatena2018-10-17
|/
* Truncate message, append buffer overflow message if too long.Libravatar Connor E2018-10-16
| | | | | | | | Increase buffer size, remove macros. Make variables lowercase. Some more feedback.
* common/loop.c: add _POSIX_C_SOURCE for clock_gettime and CLOCK_MONOTONICLibravatar Cole Mickens2018-10-15
|
* Event loop: Fix memmove and remove extraneous declarationLibravatar Ryan Dwyer2018-10-15
|
* Event loop: Free fds and fix race conditionLibravatar Ryan Dwyer2018-10-15
|
* Remove timerfd from loop implementationLibravatar Ryan Dwyer2018-10-15
| | | | | 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.
* swaylock: Remove indicator after 3 secondsLibravatar Ryan Dwyer2018-10-15
|
* Move swaybar's event loop to common directory and refactorLibravatar Ryan Dwyer2018-10-15
| | | | | | | * 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.
* swaybg: fix increasingly smaller bg on hotplugLibravatar Brian Ashworth2018-09-23
| | | | | | | | | | | | | | | | 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.
* Call pango_cairo_context_set_font_options().Libravatar Geoff Greer2018-09-22
| | | | 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.
* swaybar, swaylock, & tree/container: Set cairo font options to render text ↵Libravatar Geoff Greer2018-09-22
| | | | and lines with subpixel hinting (if available).
* Use pango_layout_set_text instead of pango_layout_set_markupLibravatar Ryan Dwyer2018-09-22
|
* Fix pango escaping and refactor escape_markup_textLibravatar Ryan Dwyer2018-09-22
| | | | | | | | | | | | | | 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.
* swaybar: rewrite protocol determinationLibravatar Ian Fan2018-09-18
| | | | | | | | 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).
* Align titles to baselineLibravatar Ryan Dwyer2018-09-08
| | | | | | | | | | | | | 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.
* prevent ub caused by misaligned stores/loadsLibravatar taiyu2018-09-02
|
* Allow reload command to exist anywhere in the command stringLibravatar Ryan Dwyer2018-09-01
| | | | | 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`.
* Remove layout.cLibravatar Ryan Dwyer2018-08-26
| | | | | | | | | | | | | | | | | | | | | | | | | When we have type safety we'll need to have functions for workspace_add_tiling and so on. This means the existing container functions will be just for containers, so they are being moved to container.c. At this point layout.c doesn't contain much else, so I've relocated everything and removed the file. * container_swap and its static functions have been moved to the swap command and made static. * container_recursive_resize has been moved to the resize command and made static. * The following have been moved to container.c: * container_handle_fullscreen_reparent * container_insert_child * container_add_sibling * container_add_child * container_remove_child * container_replace_child * container_split * enum movement_direction and sway_dir_to_wlr have been moved to util.c. Side note: Several commands included layout.h which then included root.h. With layout.h gone, root.h has to be included by those commands.
* Use list_find in more places and refactor/fix workspace prev_next functionsLibravatar Ryan Dwyer2018-08-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The original purpose of this commit is to replace some for loops with list_find. But while doing this I found the workspace_prev_next_impl functions to be difficult to read and also contained a bug, so I refactored them and fixed the bug. To reproduce the bug: * Have two outputs, where the left output has workspaces 1, 2, 3 and the right output has workspaces 4, 5, 6. Make workspace 2 focused_inactive and workspace 4 focused. * Run `workspace prev`. * Previously it would visit the left output, then apply `workspace prev` to workspace 2, which focuses workspace 1. * Now it will focus the rightmost workspace on the left output (workspace 3). The refactoring I made to the workspace functions are: * Added the static keyword. * They now accept an int dir rather than bool, to avoid an unnecessary conversion. * Rather than preparing start and end variables for the purpose of iterating, just iterate everything. * Replace for loops with list_find. * Don't call workspace_output_prev_next_impl (this fixes the bug).
* Implement resizing tiled containers via cursorLibravatar Ryan Dwyer2018-08-12
| | | | | | | | | * The OP_RESIZE seat operation has been renamed to OP_RESIZE_FLOATING, and OP_RESIZE_TILING has been introduced. * Similar to the above, seat_begin_resize and handle_resize_motion have been renamed and tiling variants introduced. * resize.c's resize_tiled has to be used, so container_resize_tiled has been introduced in resize.c to allow external code to call it.