From d5c338d9ee9d0d4f83e436d2e161f8cde3c6a1b4 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 10 Mar 2017 21:40:04 -0500 Subject: [PATCH 1/4] Correct indentation --- include/client/registry.h | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/include/client/registry.h b/include/client/registry.h index 24b4d358e..9dfbd835d 100644 --- a/include/client/registry.h +++ b/include/client/registry.h @@ -31,17 +31,17 @@ enum mask { }; struct output_state { - struct wl_output *output; - uint32_t flags; - uint32_t width, height; - uint32_t scale; + struct wl_output *output; + uint32_t flags; + uint32_t width, height; + uint32_t scale; }; struct xkb { - struct xkb_state *state; - struct xkb_context *context; - struct xkb_keymap *keymap; - xkb_mod_mask_t masks[MASK_LAST]; + struct xkb_state *state; + struct xkb_context *context; + struct xkb_keymap *keymap; + xkb_mod_mask_t masks[MASK_LAST]; }; struct input { @@ -56,17 +56,17 @@ struct input { }; struct registry { - struct wl_compositor *compositor; - struct wl_display *display; - struct wl_pointer *pointer; - struct wl_keyboard *keyboard; - struct wl_seat *seat; - struct wl_shell *shell; - struct wl_shm *shm; - struct desktop_shell *desktop_shell; - struct lock *swaylock; - struct input *input; - list_t *outputs; + struct wl_compositor *compositor; + struct wl_display *display; + struct wl_pointer *pointer; + struct wl_keyboard *keyboard; + struct wl_seat *seat; + struct wl_shell *shell; + struct wl_shm *shm; + struct desktop_shell *desktop_shell; + struct lock *swaylock; + struct input *input; + list_t *outputs; }; struct registry *registry_poll(void); From 74d4f1bec9a70bc800ecd7b15c9c6c0d7a5ce918 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 10 Mar 2017 21:41:14 -0500 Subject: [PATCH 2/4] Further indentation corrections --- sway/config.c | 2 +- sway/container.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sway/config.c b/sway/config.c index 88e6fad1a..98351b1ef 100644 --- a/sway/config.c +++ b/sway/config.c @@ -487,7 +487,7 @@ static bool load_config(const char *path, struct sway_config *config) { } static int qstrcmp(const void* a, const void* b) { - return strcmp(*((char**) a), *((char**) b)); + return strcmp(*((char**) a), *((char**) b)); } bool load_main_config(const char *file, bool is_active) { diff --git a/sway/container.c b/sway/container.c index 2f656bd8e..9b1eac605 100644 --- a/sway/container.c +++ b/sway/container.c @@ -401,9 +401,9 @@ void floating_view_sane_size(swayc_t *view) { config->floating_maximum_height = swayc_active_workspace()->height; } else if (config->floating_maximum_height != -1 && - view->desired_height > config->floating_maximum_height) { - view->desired_height = config->floating_maximum_height; - } + view->desired_height > config->floating_maximum_height) { + view->desired_height = config->floating_maximum_height; + } // if 0 do not resize, only enforce max value if (config->floating_maximum_width == 0) { From 9aed9d93596cdc72e305338d82ccc0dcaf85c6e2 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 10 Mar 2017 23:41:24 -0500 Subject: [PATCH 3/4] UnGNUify the codebase --- CMakeLists.txt | 11 ----------- common/CMakeLists.txt | 7 ------- common/ipc-client.c | 3 ++- common/log.c | 1 + common/stringop.c | 1 + common/util.c | 1 + sway/commands.c | 1 + sway/commands/assign.c | 1 + sway/commands/bar.c | 1 + sway/commands/bar/binding_mode_indicator.c | 1 + sway/commands/bar/hidden_state.c | 2 ++ sway/commands/bar/id.c | 1 + sway/commands/bar/mode.c | 2 ++ sway/commands/bar/output.c | 1 + sway/commands/bar/pango_markup.c | 1 + sway/commands/bar/position.c | 1 + sway/commands/bar/separator_symbol.c | 1 + sway/commands/bar/strip_workspace_numbers.c | 1 + sway/commands/bar/tray_padding.c | 1 + sway/commands/bar/workspace_buttons.c | 1 + sway/commands/bar/wrap_scroll.c | 1 + sway/commands/border.c | 1 + sway/commands/debuglog.c | 1 + sway/commands/exec_always.c | 1 + sway/commands/floating.c | 1 + sway/commands/floating_mod.c | 1 + sway/commands/floating_scroll.c | 2 ++ sway/commands/focus.c | 1 + sway/commands/focus_follows_mouse.c | 1 + sway/commands/font.c | 1 + sway/commands/for_window.c | 1 + sway/commands/force_focus_wrapping.c | 1 + sway/commands/gaps.c | 1 + sway/commands/hide_edge_borders.c | 1 + sway/commands/input.c | 1 + sway/commands/input/accel_profile.c | 1 + sway/commands/input/click_method.c | 1 + sway/commands/input/drag_lock.c | 1 + sway/commands/input/dwt.c | 1 + sway/commands/input/events.c | 1 + sway/commands/input/left_handed.c | 1 + sway/commands/input/middle_emulation.c | 1 + sway/commands/input/natural_scroll.c | 1 + sway/commands/input/scroll_method.c | 1 + sway/commands/input/tap.c | 1 + sway/commands/layout.c | 1 + sway/commands/log_colors.c | 1 + sway/commands/mode.c | 2 ++ sway/commands/mouse_warping.c | 1 + sway/commands/move.c | 1 + sway/commands/new_float.c | 1 + sway/commands/new_window.c | 1 + sway/commands/orientation.c | 1 + sway/commands/output.c | 2 ++ sway/commands/resize.c | 1 + sway/commands/scratchpad.c | 1 + sway/commands/seamless_mouse.c | 1 + sway/commands/set.c | 12 +++++++----- sway/commands/smart_gaps.c | 1 + sway/commands/split.c | 1 + sway/commands/workspace.c | 2 ++ sway/commands/workspace_auto_back_and_forth.c | 1 + sway/commands/workspace_layout.c | 1 + sway/config.c | 14 +++++++++----- sway/container.c | 2 +- sway/criteria.c | 1 + sway/handlers.c | 2 ++ sway/input.c | 1 + sway/ipc-server.c | 7 +++++++ sway/layout.c | 1 + sway/main.c | 2 ++ sway/security.c | 2 ++ sway/workspace.c | 1 + swaybar/bar.c | 2 ++ swaybar/config.c | 2 +- swaybar/ipc.c | 2 ++ swaybar/main.c | 1 + swaybar/status_line.c | 1 + swaygrab/json.c | 2 ++ swaygrab/main.c | 2 ++ swaylock/main.c | 9 +++++++-- swaymsg/main.c | 2 ++ wayland/buffers.c | 1 + wayland/registry.c | 1 + 84 files changed, 123 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 685e8fc71..ec2c73a26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,9 +7,6 @@ set(CMAKE_C_STANDARD 99) set(CMAKE_C_EXTENSIONS OFF) set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) -add_definitions( - -D_GNU_SOURCE - ) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter") @@ -70,14 +67,6 @@ find_package(PAM) find_package(LibInput REQUIRED) -find_package(Backtrace) -if(Backtrace_FOUND) - include_directories("${Backtrace_INCLUDE_DIRS}") - add_definitions(-DSWAY_Backtrace_FOUND=1) - set(LINK_LIBRARIES, "${LINK_LIBRARIES} ${Backtrace_LIBRARIES}") - set(SWAY_Backtrace_HEADER "${Backtrace_HEADER}") -endif() - if (CMAKE_SYSTEM_NAME STREQUAL FreeBSD) find_package(EpollShim REQUIRED) endif (CMAKE_SYSTEM_NAME STREQUAL FreeBSD) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 3d6e0fb93..11119eeb1 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -13,10 +13,3 @@ add_library(sway-common STATIC ) target_link_libraries(sway-common m) - -if(Backtrace_FOUND) - set_target_properties(sway-common - PROPERTIES - COMPILE_FLAGS "-include ${Backtrace_HEADER}" - ) -endif() diff --git a/common/ipc-client.c b/common/ipc-client.c index d011bd26d..1ab6627bd 100644 --- a/common/ipc-client.c +++ b/common/ipc-client.c @@ -1,5 +1,6 @@ -#include +#define _POSIX_C_SOURCE 2 #include +#include #include #include #include diff --git a/common/log.c b/common/log.c index 825b176b0..c3809c69d 100644 --- a/common/log.c +++ b/common/log.c @@ -1,3 +1,4 @@ +#define _POSIX_C_SOURCE 1 #include #include #include diff --git a/common/stringop.c b/common/stringop.c index 432bee7ff..99e9636d8 100644 --- a/common/stringop.c +++ b/common/stringop.c @@ -1,3 +1,4 @@ +#define _XOPEN_SOURCE 500 #include #include #include diff --git a/common/util.c b/common/util.c index 73704afde..12ed0cdc5 100644 --- a/common/util.c +++ b/common/util.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include "log.h" diff --git a/sway/commands.c b/sway/commands.c index 068e8866b..dbb34705e 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -1,3 +1,4 @@ +#define _XOPEN_SOURCE 500 #include #include #include diff --git a/sway/commands/assign.c b/sway/commands/assign.c index 992b46923..ec262bb8b 100644 --- a/sway/commands/assign.c +++ b/sway/commands/assign.c @@ -1,3 +1,4 @@ +#define _XOPEN_SOURCE 500 #include #include #include "sway/commands.h" diff --git a/sway/commands/bar.c b/sway/commands/bar.c index e8d24084c..04745a6ef 100644 --- a/sway/commands/bar.c +++ b/sway/commands/bar.c @@ -1,5 +1,6 @@ #include #include +#include #include "sway/commands.h" #include "sway/config.h" #include "log.h" diff --git a/sway/commands/bar/binding_mode_indicator.c b/sway/commands/bar/binding_mode_indicator.c index 6f67e15d1..64f5b84f8 100644 --- a/sway/commands/bar/binding_mode_indicator.c +++ b/sway/commands/bar/binding_mode_indicator.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "log.h" diff --git a/sway/commands/bar/hidden_state.c b/sway/commands/bar/hidden_state.c index e52a123f7..0b49aa6b6 100644 --- a/sway/commands/bar/hidden_state.c +++ b/sway/commands/bar/hidden_state.c @@ -1,4 +1,6 @@ +#define _XOPEN_SOURCE 500 #include +#include #include "sway/commands.h" #include "sway/config.h" #include "sway/ipc-server.h" diff --git a/sway/commands/bar/id.c b/sway/commands/bar/id.c index d62a09617..1221ebf65 100644 --- a/sway/commands/bar/id.c +++ b/sway/commands/bar/id.c @@ -1,3 +1,4 @@ +#define _XOPEN_SOURCE 500 #include #include "sway/commands.h" #include "log.h" diff --git a/sway/commands/bar/mode.c b/sway/commands/bar/mode.c index 3fd6587f8..36816b939 100644 --- a/sway/commands/bar/mode.c +++ b/sway/commands/bar/mode.c @@ -1,4 +1,6 @@ +#define _XOPEN_SOURCE 500 #include +#include #include "sway/commands.h" #include "sway/config.h" #include "sway/ipc-server.h" diff --git a/sway/commands/bar/output.c b/sway/commands/bar/output.c index 01a23d9c6..a5710bc0b 100644 --- a/sway/commands/bar/output.c +++ b/sway/commands/bar/output.c @@ -1,3 +1,4 @@ +#define _XOPEN_SOURCE 500 #include #include "sway/commands.h" #include "list.h" diff --git a/sway/commands/bar/pango_markup.c b/sway/commands/bar/pango_markup.c index 69213c7b6..f69e882fd 100644 --- a/sway/commands/bar/pango_markup.c +++ b/sway/commands/bar/pango_markup.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "log.h" diff --git a/sway/commands/bar/position.c b/sway/commands/bar/position.c index 4d0171ba5..50de58e25 100644 --- a/sway/commands/bar/position.c +++ b/sway/commands/bar/position.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "log.h" diff --git a/sway/commands/bar/separator_symbol.c b/sway/commands/bar/separator_symbol.c index 2249da52f..2766d8a23 100644 --- a/sway/commands/bar/separator_symbol.c +++ b/sway/commands/bar/separator_symbol.c @@ -1,3 +1,4 @@ +#define _XOPEN_SOURCE 500 #include #include "sway/commands.h" #include "log.h" diff --git a/sway/commands/bar/strip_workspace_numbers.c b/sway/commands/bar/strip_workspace_numbers.c index 7cd19d60a..9ac32482c 100644 --- a/sway/commands/bar/strip_workspace_numbers.c +++ b/sway/commands/bar/strip_workspace_numbers.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "log.h" diff --git a/sway/commands/bar/tray_padding.c b/sway/commands/bar/tray_padding.c index 32f8eebae..8c559f653 100644 --- a/sway/commands/bar/tray_padding.c +++ b/sway/commands/bar/tray_padding.c @@ -1,5 +1,6 @@ #include #include +#include #include "sway/commands.h" #include "log.h" diff --git a/sway/commands/bar/workspace_buttons.c b/sway/commands/bar/workspace_buttons.c index a0e0549d4..67dd2d319 100644 --- a/sway/commands/bar/workspace_buttons.c +++ b/sway/commands/bar/workspace_buttons.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "log.h" diff --git a/sway/commands/bar/wrap_scroll.c b/sway/commands/bar/wrap_scroll.c index caa856605..4ed1f12a6 100644 --- a/sway/commands/bar/wrap_scroll.c +++ b/sway/commands/bar/wrap_scroll.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "log.h" diff --git a/sway/commands/border.c b/sway/commands/border.c index 68ae58a6f..0211e40c9 100644 --- a/sway/commands/border.c +++ b/sway/commands/border.c @@ -1,6 +1,7 @@ #include #include #include +#include #include "sway/commands.h" #include "sway/container.h" #include "sway/focus.h" diff --git a/sway/commands/debuglog.c b/sway/commands/debuglog.c index 76192fb0a..658d61657 100644 --- a/sway/commands/debuglog.c +++ b/sway/commands/debuglog.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "log.h" diff --git a/sway/commands/exec_always.c b/sway/commands/exec_always.c index 1d7cd4946..ab2d8622a 100644 --- a/sway/commands/exec_always.c +++ b/sway/commands/exec_always.c @@ -1,3 +1,4 @@ +#define _XOPEN_SOURCE 500 #include #include #include diff --git a/sway/commands/floating.c b/sway/commands/floating.c index 612b8641d..113c8b711 100644 --- a/sway/commands/floating.c +++ b/sway/commands/floating.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "sway/container.h" #include "sway/ipc-server.h" diff --git a/sway/commands/floating_mod.c b/sway/commands/floating_mod.c index b6360d9a2..b8e81ab92 100644 --- a/sway/commands/floating_mod.c +++ b/sway/commands/floating_mod.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "sway/input_state.h" #include "list.h" diff --git a/sway/commands/floating_scroll.c b/sway/commands/floating_scroll.c index 5705cfeec..8c50c5bd5 100644 --- a/sway/commands/floating_scroll.c +++ b/sway/commands/floating_scroll.c @@ -1,4 +1,6 @@ +#define _XOPEN_SOURCE 500 #include +#include #include "sway/commands.h" #include "log.h" #include "stringop.h" diff --git a/sway/commands/focus.c b/sway/commands/focus.c index 0be442caa..12c5d02cb 100644 --- a/sway/commands/focus.c +++ b/sway/commands/focus.c @@ -1,4 +1,5 @@ #include +#include #include #include "sway/commands.h" #include "sway/container.h" diff --git a/sway/commands/focus_follows_mouse.c b/sway/commands/focus_follows_mouse.c index 8ccefa597..7c9c2b133 100644 --- a/sway/commands/focus_follows_mouse.c +++ b/sway/commands/focus_follows_mouse.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" struct cmd_results *cmd_focus_follows_mouse(int argc, char **argv) { diff --git a/sway/commands/font.c b/sway/commands/font.c index 1ee063964..32994f8a1 100644 --- a/sway/commands/font.c +++ b/sway/commands/font.c @@ -1,3 +1,4 @@ +#define _XOPEN_SOURCE 500 #include #include "sway/border.h" #include "sway/commands.h" diff --git a/sway/commands/for_window.c b/sway/commands/for_window.c index 8c5722fda..d1fd1641a 100644 --- a/sway/commands/for_window.c +++ b/sway/commands/for_window.c @@ -1,3 +1,4 @@ +#define _XOPEN_SOURCE 500 #include #include "sway/commands.h" #include "sway/criteria.h" diff --git a/sway/commands/force_focus_wrapping.c b/sway/commands/force_focus_wrapping.c index 23019cd37..f19dd1631 100644 --- a/sway/commands/force_focus_wrapping.c +++ b/sway/commands/force_focus_wrapping.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" struct cmd_results *cmd_force_focus_wrapping(int argc, char **argv) { diff --git a/sway/commands/gaps.c b/sway/commands/gaps.c index fe06add40..0a48592da 100644 --- a/sway/commands/gaps.c +++ b/sway/commands/gaps.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "sway/commands.h" #include "sway/container.h" #include "sway/focus.h" diff --git a/sway/commands/hide_edge_borders.c b/sway/commands/hide_edge_borders.c index cb4f052de..ee2a2644f 100644 --- a/sway/commands/hide_edge_borders.c +++ b/sway/commands/hide_edge_borders.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" struct cmd_results *cmd_hide_edge_borders(int argc, char **argv) { diff --git a/sway/commands/input.c b/sway/commands/input.c index f584bb77c..ad53d2721 100644 --- a/sway/commands/input.c +++ b/sway/commands/input.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "sway/input.h" #include "log.h" diff --git a/sway/commands/input/accel_profile.c b/sway/commands/input/accel_profile.c index 290129f5d..8288c1ada 100644 --- a/sway/commands/input/accel_profile.c +++ b/sway/commands/input/accel_profile.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "sway/input.h" diff --git a/sway/commands/input/click_method.c b/sway/commands/input/click_method.c index 0a7b7d237..5e9d3dcb1 100644 --- a/sway/commands/input/click_method.c +++ b/sway/commands/input/click_method.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "sway/input.h" #include "log.h" diff --git a/sway/commands/input/drag_lock.c b/sway/commands/input/drag_lock.c index 0d100dd0d..f5a7beb49 100644 --- a/sway/commands/input/drag_lock.c +++ b/sway/commands/input/drag_lock.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "sway/input.h" diff --git a/sway/commands/input/dwt.c b/sway/commands/input/dwt.c index 820137308..557b22073 100644 --- a/sway/commands/input/dwt.c +++ b/sway/commands/input/dwt.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "sway/input.h" diff --git a/sway/commands/input/events.c b/sway/commands/input/events.c index 2f13e30a4..9d54287a7 100644 --- a/sway/commands/input/events.c +++ b/sway/commands/input/events.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "sway/input.h" #include "log.h" diff --git a/sway/commands/input/left_handed.c b/sway/commands/input/left_handed.c index 3278bd332..6c913e703 100644 --- a/sway/commands/input/left_handed.c +++ b/sway/commands/input/left_handed.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "sway/input.h" diff --git a/sway/commands/input/middle_emulation.c b/sway/commands/input/middle_emulation.c index b2e554685..33cdd7d60 100644 --- a/sway/commands/input/middle_emulation.c +++ b/sway/commands/input/middle_emulation.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "sway/input.h" diff --git a/sway/commands/input/natural_scroll.c b/sway/commands/input/natural_scroll.c index ac8cec120..7bc8b8d07 100644 --- a/sway/commands/input/natural_scroll.c +++ b/sway/commands/input/natural_scroll.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "sway/input.h" diff --git a/sway/commands/input/scroll_method.c b/sway/commands/input/scroll_method.c index de032b64b..5c6c3d7af 100644 --- a/sway/commands/input/scroll_method.c +++ b/sway/commands/input/scroll_method.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "sway/input.h" diff --git a/sway/commands/input/tap.c b/sway/commands/input/tap.c index 9b559447f..9e3ca2af8 100644 --- a/sway/commands/input/tap.c +++ b/sway/commands/input/tap.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "sway/input.h" #include "log.h" diff --git a/sway/commands/layout.c b/sway/commands/layout.c index d04bb4dc0..570cd2079 100644 --- a/sway/commands/layout.c +++ b/sway/commands/layout.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "sway/container.h" #include "sway/layout.h" diff --git a/sway/commands/log_colors.c b/sway/commands/log_colors.c index 6ef99da72..815d1942d 100644 --- a/sway/commands/log_colors.c +++ b/sway/commands/log_colors.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" #include "log.h" diff --git a/sway/commands/mode.c b/sway/commands/mode.c index ed3f432f7..d2985c54d 100644 --- a/sway/commands/mode.c +++ b/sway/commands/mode.c @@ -1,5 +1,7 @@ +#define _XOPEN_SOURCE 500 #include #include +#include #include "sway/commands.h" #include "sway/config.h" #include "sway/ipc-server.h" diff --git a/sway/commands/mouse_warping.c b/sway/commands/mouse_warping.c index ef71d5957..5596d4836 100644 --- a/sway/commands/mouse_warping.c +++ b/sway/commands/mouse_warping.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" struct cmd_results *cmd_mouse_warping(int argc, char **argv) { diff --git a/sway/commands/move.c b/sway/commands/move.c index 1a8a321ee..97e10f106 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c @@ -1,4 +1,5 @@ #include +#include #include #include "sway/commands.h" #include "sway/container.h" diff --git a/sway/commands/new_float.c b/sway/commands/new_float.c index 8e4e354f8..432af436c 100644 --- a/sway/commands/new_float.c +++ b/sway/commands/new_float.c @@ -1,5 +1,6 @@ #include #include +#include #include "sway/commands.h" #include "sway/container.h" diff --git a/sway/commands/new_window.c b/sway/commands/new_window.c index 423b5af01..722d7d751 100644 --- a/sway/commands/new_window.c +++ b/sway/commands/new_window.c @@ -1,5 +1,6 @@ #include #include +#include #include "sway/commands.h" #include "sway/container.h" diff --git a/sway/commands/orientation.c b/sway/commands/orientation.c index b6d7202e7..e54b60ee5 100644 --- a/sway/commands/orientation.c +++ b/sway/commands/orientation.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" struct cmd_results *cmd_orientation(int argc, char **argv) { diff --git a/sway/commands/output.c b/sway/commands/output.c index 01ac9f4e8..e5d4b3170 100644 --- a/sway/commands/output.c +++ b/sway/commands/output.c @@ -1,7 +1,9 @@ +#define _XOPEN_SOURCE 500 #include #include #include #include +#include #include #include #include "sway/commands.h" diff --git a/sway/commands/resize.c b/sway/commands/resize.c index 28b20dc49..61af080cd 100644 --- a/sway/commands/resize.c +++ b/sway/commands/resize.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "sway/commands.h" #include "sway/layout.h" diff --git a/sway/commands/scratchpad.c b/sway/commands/scratchpad.c index d43ef82d7..d5e888b8a 100644 --- a/sway/commands/scratchpad.c +++ b/sway/commands/scratchpad.c @@ -1,4 +1,5 @@ #include +#include #include #include "sway/commands.h" #include "sway/container.h" diff --git a/sway/commands/seamless_mouse.c b/sway/commands/seamless_mouse.c index 4d4bcc02d..7760e88d0 100644 --- a/sway/commands/seamless_mouse.c +++ b/sway/commands/seamless_mouse.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" struct cmd_results *cmd_seamless_mouse(int argc, char **argv) { diff --git a/sway/commands/set.c b/sway/commands/set.c index 8b2938258..1d6bce04e 100644 --- a/sway/commands/set.c +++ b/sway/commands/set.c @@ -1,5 +1,7 @@ +#define _XOPEN_SOURCE 500 #include #include +#include #include "sway/commands.h" #include "sway/config.h" #include "list.h" @@ -14,7 +16,6 @@ static int compare_set_qsort(const void *_l, const void *_r) { struct cmd_results *cmd_set(int argc, char **argv) { char *tmp; - int size; struct cmd_results *error = NULL; if (!config->reading) return cmd_results_new(CMD_FAILURE, "set", "Can only be used in config file."); if ((error = checkarg(argc, "set", EXPECTED_AT_LEAST, 2))) { @@ -24,13 +25,14 @@ struct cmd_results *cmd_set(int argc, char **argv) { if (argv[0][0] != '$') { sway_log(L_INFO, "Warning: variable '%s' doesn't start with $", argv[0]); - size = asprintf(&tmp, "%s%s", "$", argv[0]); - if (size == -1) { + size_t size = snprintf(NULL, 0, "$%s", argv[0]); + tmp = malloc(size + 1); + if (!tmp) { return cmd_results_new(CMD_FAILURE, "set", "Not possible to create variable $'%s'", argv[0]); } + snprintf(tmp, size, "$%s", argv[0]); - argv[0] = strdup(tmp); - free(tmp); + argv[0] = tmp; } struct sway_variable *var = NULL; diff --git a/sway/commands/smart_gaps.c b/sway/commands/smart_gaps.c index bd50d6bc8..815fc501b 100644 --- a/sway/commands/smart_gaps.c +++ b/sway/commands/smart_gaps.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" struct cmd_results *cmd_smart_gaps(int argc, char **argv) { diff --git a/sway/commands/split.c b/sway/commands/split.c index f3e58fbfa..e7da93d76 100644 --- a/sway/commands/split.c +++ b/sway/commands/split.c @@ -1,4 +1,5 @@ #include +#include #include #include "sway/border.h" #include "sway/commands.h" diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c index b49a3a69a..c831bdfd6 100644 --- a/sway/commands/workspace.c +++ b/sway/commands/workspace.c @@ -1,4 +1,6 @@ +#define _XOPEN_SOURCE 500 #include +#include #include "sway/commands.h" #include "sway/config.h" #include "sway/input_state.h" diff --git a/sway/commands/workspace_auto_back_and_forth.c b/sway/commands/workspace_auto_back_and_forth.c index 22a66678a..d58ae5c84 100644 --- a/sway/commands/workspace_auto_back_and_forth.c +++ b/sway/commands/workspace_auto_back_and_forth.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" struct cmd_results *cmd_ws_auto_back_and_forth(int argc, char **argv) { diff --git a/sway/commands/workspace_layout.c b/sway/commands/workspace_layout.c index c93057732..a2a1a5a24 100644 --- a/sway/commands/workspace_layout.c +++ b/sway/commands/workspace_layout.c @@ -1,4 +1,5 @@ #include +#include #include "sway/commands.h" struct cmd_results *cmd_workspace_layout(int argc, char **argv) { diff --git a/sway/config.c b/sway/config.c index 98351b1ef..f46ce8822 100644 --- a/sway/config.c +++ b/sway/config.c @@ -1,3 +1,5 @@ +#define _POSIX_C_SOURCE 200809L +#define _XOPEN_SOURCE 500 #include #include #include @@ -12,6 +14,7 @@ #include #include #include +#include #include "wayland-desktop-shell-server-protocol.h" #include "sway/commands.h" #include "sway/config.h" @@ -528,11 +531,13 @@ bool load_main_config(const char *file, bool is_active) { list_t *secconfigs = create_list(); char *base = SYSCONFDIR "/sway/security.d/"; struct dirent *ent = readdir(dir); + struct stat s; while (ent != NULL) { - if (ent->d_type == DT_REG) { - char *_path = malloc(strlen(ent->d_name) + strlen(base) + 1); - strcpy(_path, base); - strcat(_path, ent->d_name); + char *_path = malloc(strlen(ent->d_name) + strlen(base) + 1); + strcpy(_path, base); + strcat(_path, ent->d_name); + lstat(_path, &s); + if (S_ISREG(s.st_mode)) { list_add(secconfigs, _path); } ent = readdir(dir); @@ -542,7 +547,6 @@ bool load_main_config(const char *file, bool is_active) { list_qsort(secconfigs, qstrcmp); for (int i = 0; i < secconfigs->length; ++i) { char *_path = secconfigs->items[i]; - struct stat s; if (stat(_path, &s) || s.st_uid != 0 || s.st_gid != 0 || (s.st_mode & 0777) != 0644) { sway_log(L_ERROR, "Refusing to load %s - it must be owned by root and mode 644", _path); success = false; diff --git a/sway/container.c b/sway/container.c index 9b1eac605..d43ee35e0 100644 --- a/sway/container.c +++ b/sway/container.c @@ -1,3 +1,4 @@ +#define _XOPEN_SOURCE 500 #include #include #include @@ -18,7 +19,6 @@ #define ASSERT_NONNULL(PTR) \ sway_assert (PTR, #PTR "must be non-null") - static swayc_t *new_swayc(enum swayc_types type) { // next id starts at 1 because 0 is assigned to root_container in layout.c static size_t next_id = 1; diff --git a/sway/criteria.c b/sway/criteria.c index 5c305193c..bc0523cef 100644 --- a/sway/criteria.c +++ b/sway/criteria.c @@ -1,3 +1,4 @@ +#define _XOPEN_SOURCE 500 #include #include #include diff --git a/sway/handlers.c b/sway/handlers.c index d74d6252a..5862c2b9a 100644 --- a/sway/handlers.c +++ b/sway/handlers.c @@ -1,4 +1,6 @@ +#define _XOPEN_SOURCE 500 #include +#include #include #include #include diff --git a/sway/input.c b/sway/input.c index 249d95c65..4f1ef7606 100644 --- a/sway/input.c +++ b/sway/input.c @@ -1,3 +1,4 @@ +#define _XOPEN_SOURCE 500 #include #include #include diff --git a/sway/ipc-server.c b/sway/ipc-server.c index eddae4613..0cacc5159 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c @@ -13,6 +13,13 @@ #include #include #include +#ifdef __linux__ +struct ucred { + pid_t pid; + uid_t uid; + gid_t gid; +}; +#endif #include "sway/ipc-json.h" #include "sway/ipc-server.h" #include "sway/security.h" diff --git a/sway/layout.c b/sway/layout.c index e196ebd36..473b74f71 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -1,3 +1,4 @@ +#define _XOPEN_SOURCE 500 #include #include #include diff --git a/sway/main.c b/sway/main.c index 5e3b24152..55b71fa4b 100644 --- a/sway/main.c +++ b/sway/main.c @@ -1,3 +1,5 @@ +#define _XOPEN_SOURCE 500 +#define _POSIX_C_SOURCE 200112L #include #include #include diff --git a/sway/security.c b/sway/security.c index 9dfc7d2de..f8a96ba7f 100644 --- a/sway/security.c +++ b/sway/security.c @@ -1,3 +1,5 @@ +#define _XOPEN_SOURCE 500 +#include #include #include #include "sway/config.h" diff --git a/sway/workspace.c b/sway/workspace.c index d804126ba..29cacce99 100644 --- a/sway/workspace.c +++ b/sway/workspace.c @@ -1,3 +1,4 @@ +#define _XOPEN_SOURCE 500 #include #include #include diff --git a/swaybar/bar.c b/swaybar/bar.c index 7ec3e0ea7..abde1cc94 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c @@ -1,9 +1,11 @@ +#define _XOPEN_SOURCE 500 #include #include #include #include #include #include +#include #include #include "swaybar/ipc.h" #include "swaybar/render.h" diff --git a/swaybar/config.c b/swaybar/config.c index 7959b1ca4..1d8020223 100644 --- a/swaybar/config.c +++ b/swaybar/config.c @@ -1,6 +1,6 @@ +#define _XOPEN_SOURCE 500 #include #include - #include "wayland-desktop-shell-client-protocol.h" #include "log.h" #include "swaybar/config.h" diff --git a/swaybar/ipc.c b/swaybar/ipc.c index f2da7392b..b08eeea89 100644 --- a/swaybar/ipc.c +++ b/swaybar/ipc.c @@ -1,4 +1,6 @@ +#define _XOPEN_SOURCE 500 #include +#include #include #include "swaybar/config.h" #include "swaybar/ipc.h" diff --git a/swaybar/main.c b/swaybar/main.c index c9a554a37..a21687431 100644 --- a/swaybar/main.c +++ b/swaybar/main.c @@ -1,3 +1,4 @@ +#define _XOPEN_SOURCE 500 #include #include #include diff --git a/swaybar/status_line.c b/swaybar/status_line.c index c7055d4c1..83e8ce2c7 100644 --- a/swaybar/status_line.c +++ b/swaybar/status_line.c @@ -1,3 +1,4 @@ +#define _XOPEN_SOURCE 500 #include #include #include diff --git a/swaygrab/json.c b/swaygrab/json.c index 7cd73cbe4..563b8ba35 100644 --- a/swaygrab/json.c +++ b/swaygrab/json.c @@ -1,3 +1,5 @@ +#define _XOPEN_SOURCE 500 +#include #include #include #include diff --git a/swaygrab/main.c b/swaygrab/main.c index a88a6bcc3..3b8c5651e 100644 --- a/swaygrab/main.c +++ b/swaygrab/main.c @@ -1,3 +1,5 @@ +#define _XOPEN_SOURCE 500 +#define _POSIX_C_SOURCE 199309L #include #include #include diff --git a/swaylock/main.c b/swaylock/main.c index 49b24a3a4..9b33aab92 100644 --- a/swaylock/main.c +++ b/swaylock/main.c @@ -1,3 +1,4 @@ +#define _XOPEN_SOURCE 500 #include "wayland-swaylock-client-protocol.h" #include #include @@ -460,12 +461,16 @@ int main(int argc, char **argv) { case 'u': show_indicator = false; break; - case 'f': - if (daemon(0, 0) != 0) { + case 'f': { + pid_t t = fork(); + if (t == -1) { sway_log(L_ERROR, "daemon call failed"); exit(EXIT_FAILURE); + } else if (t > 0) { + exit(0); } break; + } case 'r': if (line_source != LINE_SOURCE_DEFAULT) { sway_log(L_ERROR, "line source options conflict"); diff --git a/swaymsg/main.c b/swaymsg/main.c index 29e80f027..2c418127d 100644 --- a/swaymsg/main.c +++ b/swaymsg/main.c @@ -1,6 +1,8 @@ +#define _XOPEN_SOURCE 500 #include #include #include +#include #include #include #include diff --git a/wayland/buffers.c b/wayland/buffers.c index 23bed5552..e97809971 100644 --- a/wayland/buffers.c +++ b/wayland/buffers.c @@ -1,3 +1,4 @@ +#define _XOPEN_SOURCE 500 #include #include #include diff --git a/wayland/registry.c b/wayland/registry.c index 43e41f0cb..1ebc46e7d 100644 --- a/wayland/registry.c +++ b/wayland/registry.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include "wayland-desktop-shell-client-protocol.h" #include "wayland-swaylock-client-protocol.h" From a0711d9c94495df6f723f8370c59e1ff129db330 Mon Sep 17 00:00:00 2001 From: John Chen Date: Mon, 13 Mar 2017 10:32:27 +0800 Subject: [PATCH 4/4] Fix trivial typo in sway.5.txt (right_ -> _right_) as title --- sway/sway.5.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway/sway.5.txt b/sway/sway.5.txt index 8e3f64ab6..9c60af714 100644 --- a/sway/sway.5.txt +++ b/sway/sway.5.txt @@ -86,7 +86,7 @@ They are expected to be used with **bindsym** or at runtime through **swaymsg**( _splitv_, _toggle split_, _stacking_, _tabbed_. **layout** auto :: - Sets layout to one of the auto modes, i.e. one of _left_, right_, _top_, + Sets layout to one of the auto modes, i.e. one of _left_, _right_, _top_, or _bottom_. **layout** auto ::