Commit graph

196 commits

Author SHA1 Message Date
M Stoeckl 62260ab56e Fix backup methods in get_socketpath for IPC client
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-19 18:45:25 +01:00
emersion f951c2357f
Remove unicode.c 2019-01-17 12:45:41 +01:00
Connor E de6f5b3453 Use static arrays where possible. 2019-01-16 13:02:26 +01:00
Connor E aa9d7d8ca1 Remove usage of VLAs. 2019-01-16 13:02:26 +01:00
Ian Fan 5bef06adfd fixup! stringop.c: rewrite strip_whitespace 2019-01-02 18:47:22 +00:00
Ian Fan a82b8a3c14 Remove readline.c
All occurrences of read_line have been replaced by getline.
peek_line has been absorbed into detect_brace.
2019-01-01 09:01:25 +00:00
Ian Fan 967566e37f stringop.c: rewrite strip_whitespace 2019-01-01 09:01:24 +00:00
Ryan Dwyer b61a936c80
Merge pull request #3271 from ianyfan/list-cleanup
list.c: Remove list_foreach
2018-12-09 21:50:19 +10:00
Ian Fan 98c1e19466 list.c: rename free_flat_list to list_free_items_and_destroy 2018-12-09 01:15:38 +00:00
Ian Fan c8776fac42 Cleanup list code 2018-12-09 01:15:38 +00:00
Ian Fan 19e831ed3d list.c: Remove list_foreach
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-09 00:37:50 +00:00
Ian Fan bd6a639667 list: double list capacity when resizing instead of incrementing
This is the industry standard since it allows insertion to be amortized
O(1) time.
2018-12-06 12:02:55 +00:00
emersion 3a310f92ab
Replace _XOPEN_SOURCE with _POSIX_C_SOURCE
And make sure we don't define both in the same source file.
2018-11-25 17:19:43 +01:00
emersion bf7af9c690
Merge pull request #3083 from c-edw/feature/StripWorkspaceName
Implement strip_workspace_name.
2018-11-19 17:56:18 +01:00
Spencer Michaels 70bc4c3ab6 Add scroll factor config option. 2018-11-18 13:49:30 -05:00
emersion cad851805b
Use #if instead of #ifdef 2018-11-18 00:33:06 +01:00
Connor E 4bd46fb079 Implement strip_workspace_name. 2018-11-17 16:11:28 +00:00
Ryan Dwyer bf19f63a79 Wrap to fartherest output when running focus output
Also moves the `opposite_direction` function into `util.c` as it's used
in two places now.
2018-11-01 08:29:45 +10:00
madblobfish 1f23ec2d05 Revert "Add resolve_path() to utils"
This reverts commit c9694ee63d.
2018-10-31 13:04:08 +01:00
Ryan Dwyer 7be309710d Remove enum movement_direction
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-30 23:27:49 +10:00
Drew DeVault 46dafbf74a
Merge pull request #2864 from sghctoma/freebsd-fixes
FreeBSD fixes
2018-10-17 16:14:35 +02:00
Niccolò Scatena 8c86fff6dc
Fix stringop-overflow warnings 2018-10-17 13:00:12 +02:00
sghctoma 2694fd72b6 Increase _POSIX_C_SOURCE to 200112L
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-17 11:09:58 +02:00
Connor E cfc533aa9c Truncate message, append buffer overflow message if too long.
Increase buffer size, remove macros.

Make variables lowercase.

Some more feedback.
2018-10-16 20:20:45 +01:00
Cole Mickens a9a9df75ec common/loop.c: add _POSIX_C_SOURCE for clock_gettime and CLOCK_MONOTONIC 2018-10-15 13:42:24 -07:00
Ryan Dwyer c6f153d8f9 Event loop: Fix memmove and remove extraneous declaration 2018-10-15 00:26:27 +10:00
Ryan Dwyer 893f61d03a Event loop: Free fds and fix race condition 2018-10-15 00:26:27 +10:00
Ryan Dwyer 6921fdc6d6 Remove timerfd from loop implementation
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-15 00:26:27 +10:00
Ryan Dwyer c242712262 swaylock: Remove indicator after 3 seconds 2018-10-15 00:26:27 +10:00
Ryan Dwyer 4056c09e13 Move swaybar's event loop to common directory and refactor
* 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-10-15 00:26:27 +10:00
Brian Ashworth 9ea99a5d36 swaybg: fix increasingly smaller bg on hotplug
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-23 15:17:36 -04:00
Geoff Greer 987e0054ac Call pango_cairo_context_set_font_options().
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-22 15:33:03 -07:00
Geoff Greer c495164f60 swaybar, swaylock, & tree/container: Set cairo font options to render text and lines with subpixel hinting (if available). 2018-09-22 11:34:21 -07:00
Ryan Dwyer 2f36502828 Use pango_layout_set_text instead of pango_layout_set_markup 2018-09-22 18:40:19 +10:00
Ryan Dwyer 10ef118e09 Fix pango escaping and refactor escape_markup_text
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-22 18:33:28 +10:00
Ian Fan 8cbce77e1d swaybar: rewrite protocol determination
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-18 11:36:33 +01:00
Ryan Dwyer 9215ca0f01 Align titles to baseline
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-08 16:25:07 +10:00
taiyu d625d68d4a
prevent ub caused by misaligned stores/loads 2018-09-02 17:07:12 -07:00
Ryan Dwyer 7e81e58e7d Allow reload command to exist anywhere in the command string
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`.
2018-09-01 11:45:48 +10:00
Ryan Dwyer 5dbbab7bdc Remove layout.c
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.
2018-08-26 12:05:16 +10:00
Ryan Dwyer 701fcafc70 Use list_find in more places and refactor/fix workspace prev_next functions
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).
2018-08-15 15:14:35 +10:00
Ryan Dwyer b4a0363d17 Implement resizing tiled containers via cursor
* 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.
2018-08-12 10:45:54 +10:00
Ian Fan baf4604629 ipc-client: fix memory leaks in get_socketpath 2018-08-06 17:30:24 +01:00
Brian Ashworth 9ec1d6cf79 Address review comments on parse_boolean 2018-07-23 21:37:53 -04:00
Brian Ashworth d56d62c1c0 Remove unneeded const 2018-07-23 21:33:17 -04:00
Brian Ashworth 863914ec95 Switch to using a function to parse booleans 2018-07-23 21:33:17 -04:00
Ryan Dwyer 15dc5286e2 Move floating windows to front when focused 2018-07-11 19:50:02 +10:00
emersion 63b4bf5000
Update for swaywm/wlroots#1126 2018-07-09 22:54:30 +01:00
Dominique Martinet 971b2f11f9 utf8_size: fix loop boundary
Found through static analysis
2018-07-02 08:03:41 +09:00
Dominique Martinet f0d1d26320 get_parent_pid: fix memory leak
Found through static analysis.
2018-07-02 08:03:41 +09:00
Brian Ashworth 85a5c8dabd Fix infinite loop in peek_line for EOF blanks 2018-06-02 08:07:44 -04:00
Brian Ashworth af87c7a1af Address emersion's feedback on peek_line 2018-06-02 08:07:44 -04:00
Brian Ashworth fbca3bbacb Fix condition in peek_line 2018-06-02 08:07:44 -04:00
Brian Ashworth 8bfa2def88 Address first round of review for generic blocks 2018-06-02 08:07:44 -04:00
Brian Ashworth 51bb9d8573 Support braces on next line for config blocks 2018-06-02 08:07:44 -04:00
Ryan Dwyer db38b9bbf3 Clean up container title functions
* Add and use lenient_strcat and lenient_strncat functions
* Rename `concatenate_child_titles` function as that's no longer what it
does
* Rename `container_notify_child_title_changed` because we only need to
notify that the tree structure has changed, not titles
* Don't notify parents when a child changes its title
* Update ancestor titles when changing a container's layout
	* Eg. create nested tabs and change the inner container to stacking
* No need to store tree presentation in both container->name and
formatted_title
2018-05-25 21:07:59 +10:00
Brian Ashworth 0944d3fd9c Change scale from int32_t to double for pango 2018-05-16 12:01:04 -04:00
emersion 6eda10e4ca
Fix pango markup
The condition checking if the markup is valid was inverted.

This commit also adds better error handling: if the markup cannot
be parsed, it fallbacks to plain text.
2018-05-13 16:52:02 +01:00
Heghedus Razvan 789a877b37 Fix crash when using pango markup font
The characters & < > ' " needs to be escaped when using pango markup

Signed-off-by: Heghedus Razvan <heghedus.razvan@gmail.com>
2018-05-13 17:53:45 +03:00
Dominique Martinet 25af959fe9 Fix gcc string truncation warnings 2018-04-13 22:47:27 +09:00
Drew DeVault d053acbed6 R E N D E R I N G 2018-04-04 18:47:48 -04:00
Drew DeVault 066143adef Add password buffer, refactor rendering/surfaces 2018-04-04 18:47:48 -04:00
Drew DeVault b32bf595ae Initial swaylock port 2018-04-04 18:47:48 -04:00
Drew DeVault a28730edee Move swaybg background rendering into common/
swaylock will use it too
2018-04-04 18:47:48 -04:00
Drew DeVault c507727ad2 Fix use-after-free with block hotspots 2018-04-02 11:53:56 -04:00
Drew DeVault 849c3515ab Use statically allocated text buffer 2018-03-29 22:11:08 -04:00
Drew DeVault cab1352801 Start port of swaybar to layer shell
This starts up the event loop and wayland display and shims out the
basic top level rendering concepts. Also includes some changes to
incorporate pango into the 1.x codebase properly.
2018-03-29 22:11:08 -04:00
Drew DeVault 382e8af418 Allow sway IPC clients to fall back to i3 socket 2018-03-29 22:11:08 -04:00
Drew DeVault d39bda76c4 Address review comments 2018-03-28 14:43:23 -04:00
Drew DeVault 632bb948b7 Add solid-color rendering to swaybg 2018-03-28 14:25:19 -04:00
Dominique Martinet d4ddfec32e common/log: finish removing most log functions
Keep sway_abort and sway_assert and convert them to use wlr_log
functions
2018-01-05 23:40:09 +01:00
Dominique Martinet 67985e9031 sway: change all sway_log to wlr_log 2018-01-05 23:39:46 +01:00
Dominique Martinet f9413adde7 build: add wlroots dependency to common
It is required for include path if wlroots is not built in standard path,
but found through pkg-config
2017-12-19 08:43:37 +01:00
Tony Crisci 517af37cc9 remove relevant CMakeLists.txt 2017-11-30 11:54:01 -05:00
Tony Crisci cc310cffb0 meson: common static library 2017-11-30 06:25:13 -05:00
Tony Crisci 88cc7e3178 use meson subdirectories 2017-11-30 03:39:27 -05:00
Dominique Martinet 977c1f6a30 common/util: replace WLC_BIT_MOD_* by WLR_MODIFIER_*
This removes the last wlc/wlc.h include actually in use
2017-11-23 00:23:37 +01:00
Drew DeVault 733993a651 Move everything to sway/old/ 2017-11-18 11:22:02 -05:00
Calvin Lee 016261fd64 Print log level even if STDERR is not a tty
Makes reading debug logs much easier, debug lines will start with `E`,
info lines with `I` and error lines with `E`.
2017-10-20 15:12:28 -06:00
johalun 7fef283044 FreeBSD fixes
Increase _POSIX_SOURCE value where needed.
Increase _XOPEN_SOURCE value where needed.
Conditionally link to libcap (only on Linux).
Possibly some trailing whitespace fixes (automatic).
2017-06-06 09:45:50 +02:00
Mykyta Holubakha f470fa58a3 Replace spaces with tabs in resolve_path 2017-05-11 19:38:32 +03:00
Drew DeVault 586eca0e4c Fix link to dotfiles, closes #1193 2017-04-26 10:07:32 -04:00
Jerzi Kaminsky 8ecb490679 Make sway_abort() report location 2017-04-20 19:20:40 +03:00
Jerzi Kaminsky c9694ee63d Add resolve_path() to utils 2017-04-16 17:09:53 +03:00
Jerzi Kaminsky 709b53bd43 Fix location reported by sway_assert 2017-04-16 16:39:53 +03:00
Jerzi Kaminsky eb3b1ec5f1 Fix variadic forwarding in sway_assert
_sway_assert is a variadic function which tries
to delegate to another variadic function. This
requires a vprintf-style variant of the delegate.

https://stackoverflow.com/a/150616
2017-04-16 16:39:53 +03:00
Drew DeVault 9aed9d9359 UnGNUify the codebase 2017-03-10 23:41:24 -05:00
Calvin Lee 34e2c70abc Feature for #1078: Configurable swaylock colors
Colors are configured through the command line so that swaylock conforms
to the i3lock fork 'github.com/chrjguill/i3lock-color'. Differences from
it are that one letter options '-r' and '-s' are not implimentend because
'-s' is already used by '--scaling' in swaylock.
This commit also fixed whitespace in 'include/swaylock/swaylock.h' and
changed `parse_color` in 'common/util.h' so that it can accept colors
that do not start with a hash. This was done to keep compatability with
the i3lock fork.
2017-02-21 14:12:31 -07:00
wil 1b87193c3d Added "layout promote" command. 2016-12-29 20:31:30 +01:00
Drew DeVault d75a747a3d Handle config-related allocation failures 2016-12-15 19:01:41 -05:00
Drew DeVault 4c6c65e70c Handle malloc failures from read_line 2016-12-15 19:01:40 -05:00
Drew DeVault 9ad1e6b40f Handle malloc failure in ipc_recv_response 2016-12-15 19:01:40 -05:00
Drew DeVault 416417a54c Reorganize includes 2016-09-01 08:18:37 -04:00
Johannes Lundberg 949933c5c3 Fix to make ipc client code FreeBSD compatible. 2016-08-30 16:59:36 -07:00
progandy bf4056a2c6 common: use strtoul in parse_color to avoid clamp
Some implementations of strtol may clamp the values to LONG_MAX instead of
wrapping around to negative values, so use strtoul instead to parse colors.
2016-08-04 14:37:54 +02:00
Zandr Martin 98aa59fdda
implement solid color rendering for swaybg 2016-07-30 18:50:13 -05:00
Tony Crisci 70360c5c07 Add timestamp to log messages 2016-07-28 22:15:14 -04:00
Drew DeVault c8917395c0 Remove SIGSERV and SIGABORT handler
From now on let's just let the core dumps happen and ask users to
provide them.
2016-07-17 11:29:29 -04:00
David Eklov 26842ff383 Add get_log_level() to encapsulate v (current log level)
This patch also makes all global variable in log.c static.
2016-06-27 18:56:50 -05:00
Zandr Martin 9ecb43ea3b
couple small fixes 2016-06-11 15:29:04 -05:00