From 82e47ac1f58350c5bb0d749774547855f5efaedf Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Fri, 23 Jul 2021 21:15:55 +0100 Subject: [PATCH] Remove src/common/log.c Use wlr_log() instead --- include/common/log.h | 9 --------- include/labwc.h | 2 -- src/action.c | 4 ++-- src/common/dir.c | 2 -- src/common/log.c | 16 ---------------- src/common/meson.build | 1 - src/common/spawn.c | 6 +++--- src/config/keybind.c | 5 ++--- src/config/rcxml.c | 5 ++--- src/config/session.c | 3 +-- src/cursor.c | 5 ++--- src/keyboard.c | 1 - src/layers.c | 3 ++- src/main.c | 1 - src/menu/menu.c | 4 ++-- src/osd.c | 4 ++-- src/output.c | 11 ++++++----- src/seat.c | 4 ++-- src/server.c | 1 - src/theme.c | 6 ++---- 20 files changed, 28 insertions(+), 65 deletions(-) delete mode 100644 include/common/log.h delete mode 100644 src/common/log.c diff --git a/include/common/log.h b/include/common/log.h deleted file mode 100644 index 81ece2a7..00000000 --- a/include/common/log.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __LABWC_LOG_H -#define __LABWC_LOG_H - -/** - * warn - print warning - */ -void warn(const char *err, ...); - -#endif /* __LABWC_LOG_H */ diff --git a/include/labwc.h b/include/labwc.h index 8fc2b4f1..8956ad67 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -33,8 +33,6 @@ #include #endif #include - -#include "common/log.h" #include "config/keybind.h" #include "config/rcxml.h" diff --git a/src/action.c b/src/action.c index 75e7623f..914c557d 100644 --- a/src/action.c +++ b/src/action.c @@ -1,5 +1,5 @@ #include -#include "common/log.h" +#include #include "common/spawn.h" #include "labwc.h" #include "menu/menu.h" @@ -59,6 +59,6 @@ action(struct server *server, const char *action, const char *command) view_maximize(view, true); } } else { - warn("action (%s) not supported", action); + wlr_log(WLR_ERROR, "action (%s) not supported", action); } } diff --git a/src/common/dir.c b/src/common/dir.c index 82889af2..15000518 100644 --- a/src/common/dir.c +++ b/src/common/dir.c @@ -9,9 +9,7 @@ #include #include #include - #include "common/dir.h" -#include "common/log.h" struct dir { const char *prefix; diff --git a/src/common/log.c b/src/common/log.c deleted file mode 100644 index 2049e0f3..00000000 --- a/src/common/log.c +++ /dev/null @@ -1,16 +0,0 @@ -#include -#include -#include -#include - -void -warn(const char *err, ...) -{ - va_list params; - fprintf(stderr, "[labwc] warn: "); - va_start(params, err); - vfprintf(stderr, err, params); - va_end(params); - fprintf(stderr, "\n"); -} - diff --git a/src/common/meson.build b/src/common/meson.build index 21044fdb..02c763aa 100644 --- a/src/common/meson.build +++ b/src/common/meson.build @@ -3,7 +3,6 @@ labwc_sources += files( 'dir.c', 'font.c', 'grab-file.c', - 'log.c', 'nodename.c', 'spawn.c', 'string-helpers.c', diff --git a/src/common/spawn.c b/src/common/spawn.c index cfeb58ba..f3ee2d79 100644 --- a/src/common/spawn.c +++ b/src/common/spawn.c @@ -7,7 +7,7 @@ #include #include #include -#include "common/log.h" +#include #include "common/spawn.h" void @@ -35,7 +35,7 @@ spawn_async_no_shell(char const *command) child = fork(); switch (child) { case -1: - warn("unable to fork()"); + wlr_log(WLR_ERROR, "unable to fork()"); goto out; case 0: setsid(); @@ -47,7 +47,7 @@ spawn_async_no_shell(char const *command) execvp(argv[0], argv); _exit(0); } else if (grandchild < 0) { - warn("unable to fork()"); + wlr_log(WLR_ERROR, "unable to fork()"); } _exit(0); default: diff --git a/src/config/keybind.c b/src/config/keybind.c index 75a17781..91490928 100644 --- a/src/config/keybind.c +++ b/src/config/keybind.c @@ -3,8 +3,7 @@ #include #include #include - -#include "common/log.h" +#include #include "config/keybind.h" #include "config/rcxml.h" @@ -39,7 +38,7 @@ keybind_create(const char *keybind) xkb_keysym_t sym = xkb_keysym_from_name( symname, XKB_KEYSYM_CASE_INSENSITIVE); if (sym == XKB_KEY_NoSymbol) { - warn("unknown keybind (%s)", symname); + wlr_log(WLR_ERROR, "unknown keybind (%s)", symname); free(k); k = NULL; break; diff --git a/src/config/rcxml.c b/src/config/rcxml.c index 79178501..e76adea6 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -12,7 +12,6 @@ #include #include #include "common/dir.h" -#include "common/log.h" #include "common/nodename.h" #include "common/string-helpers.h" #include "common/zfree.h" @@ -227,7 +226,7 @@ rcxml_parse_xml(struct buf *b) { xmlDoc *d = xmlParseMemory(b->buf, b->len); if (!d) { - warn("xmlParseMemory()"); + wlr_log(WLR_ERROR, "xmlParseMemory()"); exit(EXIT_FAILURE); } xml_tree_walk(xmlDocGetRootElement(d)); @@ -330,7 +329,7 @@ rcxml_read(const char *filename) /* Reading file into buffer before parsing - better for unit tests */ stream = fopen(rcxml, "r"); if (!stream) { - warn("cannot read (%s)", rcxml); + wlr_log(WLR_ERROR, "cannot read (%s)", rcxml); goto no_config; } wlr_log(WLR_INFO, "read config file %s", rcxml); diff --git a/src/config/session.c b/src/config/session.c index 695a79e1..fcf794f9 100644 --- a/src/config/session.c +++ b/src/config/session.c @@ -7,7 +7,6 @@ #include #include #include "common/dir.h" -#include "common/log.h" #include "common/spawn.h" #include "common/string-helpers.h" @@ -99,7 +98,7 @@ session_autostart_init(void) return; } if (!isfile(autostart)) { - warn("no autostart file"); + wlr_log(WLR_ERROR, "no autostart file"); goto out; } wlr_log(WLR_INFO, "run autostart file %s", autostart); diff --git a/src/cursor.c b/src/cursor.c index ec023aeb..43a10dfb 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -75,12 +75,11 @@ static void process_cursor_move(struct server *server, uint32_t time) { damage_all_outputs(server); - /* Move the grabbed view to the new position. */ double dx = server->seat.cursor->x - server->grab_x; double dy = server->seat.cursor->y - server->grab_y; - struct view *view = server->grabbed_view; - assert(view); + + /* Move the grabbed view to the new position. */ view->impl->move(view, server->grab_box.x + dx, server->grab_box.y + dy); } diff --git a/src/keyboard.c b/src/keyboard.c index 747dd16b..2250dc67 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -1,6 +1,5 @@ #include #include -#include "common/log.h" #include "labwc.h" static void diff --git a/src/layers.c b/src/layers.c index ed70685f..0e52b3b6 100644 --- a/src/layers.c +++ b/src/layers.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "layers.h" #include "labwc.h" @@ -149,7 +150,7 @@ arrange_layer(struct wlr_output *output, struct wl_list *list, box.y -= state->margin.bottom; } if (box.width < 0 || box.height < 0) { - warn("protocol error"); + wlr_log(WLR_ERROR, "protocol error"); wlr_layer_surface_v1_close(layer); continue; } diff --git a/src/main.c b/src/main.c index 6f8092ad..6b88464d 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,4 @@ #include "common/font.h" -#include "common/log.h" #include "common/spawn.h" #include "config/session.h" #include "labwc.h" diff --git a/src/menu/menu.c b/src/menu/menu.c index 81d4c76b..c2f02a3f 100644 --- a/src/menu/menu.c +++ b/src/menu/menu.c @@ -207,7 +207,7 @@ parse_xml(const char *filename, struct menu *menu) stream = fopen(menuxml, "r"); if (!stream) { - warn("cannot read (%s)", menuxml); + wlr_log(WLR_ERROR, "cannot read %s", menuxml); return; } wlr_log(WLR_INFO, "read menu file %s", menuxml); @@ -222,7 +222,7 @@ parse_xml(const char *filename, struct menu *menu) fclose(stream); xmlDoc *d = xmlParseMemory(b.buf, b.len); if (!d) { - warn("xmlParseMemory()"); + wlr_log(WLR_ERROR, "xmlParseMemory()"); exit(EXIT_FAILURE); } xml_tree_walk(xmlDocGetRootElement(d), menu); diff --git a/src/osd.c b/src/osd.c index 705af245..b03641af 100644 --- a/src/osd.c +++ b/src/osd.c @@ -1,5 +1,5 @@ #include "config.h" -#include "common/log.h" +#include #include "config/keybind.h" #include "config/rcxml.h" #include "labwc.h" @@ -12,7 +12,7 @@ xwl_nr_parents(struct view *view) int i = 0; if (!s) { - warn("(%s) no xwayland surface\n", __func__); + wlr_log(WLR_ERROR, "no xwayland surface"); return -1; } while (s->parent) { diff --git a/src/output.c b/src/output.c index a3c1e930..d4bbcf7d 100644 --- a/src/output.c +++ b/src/output.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "labwc.h" #include "layers.h" #include "menu/menu.h" @@ -936,7 +937,7 @@ static struct wlr_output_configuration_v1 *create_output_config(struct server *s { struct wlr_output_configuration_v1 *config = wlr_output_configuration_v1_create(); if(config == NULL) { - warn("wlr_output_configuration_v1_create() returned NULL"); + wlr_log(WLR_ERROR, "wlr_output_configuration_v1_create()"); return NULL; } @@ -946,17 +947,17 @@ static struct wlr_output_configuration_v1 *create_output_config(struct server *s wlr_output_configuration_head_v1_create(config, output->wlr_output); if (head == NULL) { - warn("wlr_output_configuration_head_v1_create() returned NULL"); + wlr_log(WLR_ERROR, "wlr_output_configuration_head_v1_create()"); wlr_output_configuration_v1_destroy(config); return NULL; } struct wlr_box *box = wlr_output_layout_get_box(server->output_layout, output->wlr_output); - if(box != NULL) { + if (box != NULL) { head->state.x = box->x; head->state.y = box->y; } else { - warn("%s: failed to get box for output", __func__); + wlr_log(WLR_ERROR, "failed to get output layout box"); } } @@ -972,7 +973,7 @@ static void handle_output_layout_change(struct wl_listener *listener, void *data if(config != NULL) { wlr_output_manager_v1_set_configuration(server->output_manager, config); } else { - warn("wlr_output_manager_v1_set_configuration returned NULL"); + wlr_log(WLR_ERROR, "wlr_output_manager_v1_set_configuration()"); } } } diff --git a/src/seat.c b/src/seat.c index e5a1dbec..bcab494b 100644 --- a/src/seat.c +++ b/src/seat.c @@ -19,13 +19,13 @@ configure_libinput(struct wlr_input_device *wlr_input_device) * for the time being, lets just enable tap. */ if (!wlr_input_device) { - warn("%s:%d: no wlr_input_device", __FILE__, __LINE__); + wlr_log(WLR_ERROR, "no wlr_input_device"); return; } struct libinput_device *libinput_dev = wlr_libinput_get_device_handle(wlr_input_device); if (!libinput_dev) { - warn("%s:%d: no libinput_dev", __FILE__, __LINE__); + wlr_log(WLR_ERROR, "no libinput_dev"); return; } if (libinput_device_config_tap_get_finger_count(libinput_dev) <= 0) { diff --git a/src/server.c b/src/server.c index a9d23927..8c13a3af 100644 --- a/src/server.c +++ b/src/server.c @@ -7,7 +7,6 @@ #include #include #include -#include "common/log.h" #include "config/rcxml.h" #include "labwc.h" #include "layers.h" diff --git a/src/theme.c b/src/theme.c index ca760ed5..8d51c084 100644 --- a/src/theme.c +++ b/src/theme.c @@ -16,10 +16,8 @@ #include #include #include - #include "common/dir.h" #include "common/font.h" -#include "common/log.h" #include "common/string-helpers.h" #include "common/zfree.h" #include "config/rcxml.h" @@ -266,7 +264,7 @@ rounded_rect(struct wlr_renderer *renderer, struct rounded_corner_ctx *ctx) cairo_line_to(cairo, 0, 0); break; default: - warn("unknown corner type"); + wlr_log(WLR_ERROR, "unknown corner type"); } cairo_close_path(cairo); cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE); @@ -293,7 +291,7 @@ rounded_rect(struct wlr_renderer *renderer, struct rounded_corner_ctx *ctx) cairo_line_to(cairo, w - half_line_width, h); break; default: - warn("unknown corner type"); + wlr_log(WLR_ERROR, "unknown corner type"); } cairo_stroke(cairo);