From d1dfcccccb349cfee83a42fef94d7d2c7a57c216 Mon Sep 17 00:00:00 2001 From: Jeremy Attali Date: Sat, 28 Dec 2019 21:15:34 -0500 Subject: [PATCH] chore: cleanup messages and doc --- README.md | 3 ++- src/application.c | 17 +---------------- src/clipboard.c | 1 - src/render.c | 2 +- src/screencopy.c | 6 ------ src/wayland.c | 13 +------------ 6 files changed, 5 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index f0e557b..ee0e842 100644 --- a/README.md +++ b/README.md @@ -56,8 +56,9 @@ swappy -g "$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .re * `Ctrl+z`: Undo * `Ctrl+Shift+z` or `Ctrl+y`: Redo -* `Ctrl+s`: Save to file (see man page). +* `Ctrl+s`: Save to file (see man page) * `Ctrl+c`: Copy to clipboard +* `Escape` or `q`: Quit swappy ## Limitations diff --git a/src/application.c b/src/application.c index 652d2c1..0a59205 100644 --- a/src/application.c +++ b/src/application.c @@ -84,27 +84,22 @@ static void action_set_color_from_custom(struct swappy_state *state) { } static void switch_mode_to_brush(struct swappy_state *state) { - g_debug("switching mode to brush"); state->mode = SWAPPY_PAINT_MODE_BRUSH; } static void switch_mode_to_text(struct swappy_state *state) { - g_debug("switching mode to arrow"); state->mode = SWAPPY_PAINT_MODE_TEXT; } static void switch_mode_to_rectangle(struct swappy_state *state) { - g_debug("switching mode to rectangle"); state->mode = SWAPPY_PAINT_MODE_RECTANGLE; } static void switch_mode_to_ellipse(struct swappy_state *state) { - g_debug("switching mode to ellipse"); state->mode = SWAPPY_PAINT_MODE_ELLIPSE; } static void switch_mode_to_arrow(struct swappy_state *state) { - g_debug("switching mode to arrow"); state->mode = SWAPPY_PAINT_MODE_ARROW; } @@ -158,7 +153,6 @@ void arrow_clicked_handler(GtkWidget *widget, struct swappy_state *state) { } void application_finish(struct swappy_state *state) { - g_debug("application is shutting down"); paint_free_all(state); cairo_surface_destroy(state->cairo_surface); g_free(state->storage_path); @@ -169,12 +163,9 @@ void application_finish(struct swappy_state *state) { } static void action_save_area_to_file(struct swappy_state *state) { - g_debug("saving area to file"); - guint width = gtk_widget_get_allocated_width(state->ui->area); guint height = gtk_widget_get_allocated_height(state->ui->area); // GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(state->ui->area)); - g_debug("generating pixbuf from area"); GdkPixbuf *pixbuf = gdk_pixbuf_get_from_surface(state->cairo_surface, 0, 0, width, height); GError *error = NULL; @@ -218,9 +209,6 @@ void copy_clicked_handler(GtkWidget *widget, struct swappy_state *state) { void window_keypress_handler(GtkWidget *widget, GdkEventKey *event, struct swappy_state *state) { - g_debug("keypress_handler key pressed: keyval: %d - state: %d\n", - event->keyval, event->state); - if (event->state & GDK_CONTROL_MASK) { switch (event->keyval) { case GDK_KEY_c: @@ -245,7 +233,7 @@ void window_keypress_handler(GtkWidget *widget, GdkEventKey *event, } else { switch (event->keyval) { case GDK_KEY_Escape: - g_debug("keypress_handler: escape key pressed, ciao bye\n"); + case GDK_KEY_q: gtk_main_quit(); break; case GDK_KEY_b: @@ -339,8 +327,6 @@ gboolean draw_area_configure_handler(GtkWidget *widget, void draw_area_button_press_handler(GtkWidget *widget, GdkEventButton *event, struct swappy_state *state) { - g_debug("press event: state: %d, button: %d", event->state, event->button); - if (event->button == 1) { switch (state->mode) { case SWAPPY_PAINT_MODE_BRUSH: @@ -381,7 +367,6 @@ void draw_area_motion_notify_handler(GtkWidget *widget, GdkEventMotion *event, } void draw_area_button_release_handler(GtkWidget *widget, GdkEventButton *event, struct swappy_state *state) { - g_debug("releasing button in state: %d", event->state); if (!(event->state & GDK_BUTTON1_MASK)) { return; } diff --git a/src/clipboard.c b/src/clipboard.c index cac6ae2..c77a755 100644 --- a/src/clipboard.c +++ b/src/clipboard.c @@ -3,7 +3,6 @@ #include "notification.h" bool clipboard_copy_drawing_area_to_selection(struct swappy_state *state) { - g_debug("generating pixbuf from area"); GtkClipboard *clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); guint width = gtk_widget_get_allocated_width(state->ui->area); guint height = gtk_widget_get_allocated_height(state->ui->area); diff --git a/src/render.c b/src/render.c index 40753c2..609bb49 100644 --- a/src/render.c +++ b/src/render.c @@ -137,7 +137,7 @@ static void render_shape(cairo_t *cr, struct swappy_paint_shape shape) { render_shape_arrow(cr, shape); break; default: - g_debug("unknown shape type: %d", shape.type); + break; } cairo_restore(cr); } diff --git a/src/screencopy.c b/src/screencopy.c index 0f80585..873f07d 100644 --- a/src/screencopy.c +++ b/src/screencopy.c @@ -60,9 +60,6 @@ static struct swappy_buffer *create_buffer(struct wl_shm *shm, int32_t width, int32_t height, int32_t stride) { size_t size = stride * height; - g_debug( - "creating buffer with dimensions: %dx%d - format: 0x%08x - stride: %d", - width, height, format, stride); int fd = create_shm_file(size); if (fd == -1) { @@ -107,7 +104,6 @@ void screencopy_frame_handle_buffer(void *data, struct zwlr_screencopy_frame_v1 *frame, uint32_t format, uint32_t width, uint32_t height, uint32_t stride) { - g_debug("screencopy: frame handler buffer: %dx%d", width, height); struct swappy_output *output = data; output->buffer = @@ -123,7 +119,6 @@ void screencopy_frame_handle_buffer(void *data, void screencopy_frame_handle_flags(void *data, struct zwlr_screencopy_frame_v1 *frame, uint32_t flags) { - g_debug("screencopy: frame flags: %d", flags); struct swappy_output *output = data; output->screencopy_frame_flags = flags; } @@ -133,7 +128,6 @@ void screencopy_frame_handle_ready(void *data, uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec) { struct swappy_output *output = data; - g_debug("screencopy: frame handler is ready"); ++output->state->n_done; } diff --git a/src/wayland.c b/src/wayland.c index a5d9642..8f22015 100644 --- a/src/wayland.c +++ b/src/wayland.c @@ -29,9 +29,6 @@ static void xdg_output_handle_logical_position( void *data, struct zxdg_output_v1 *xdg_output, int32_t x, int32_t y) { struct swappy_output *output = data; - g_debug("xdg_output: logical position: received x,y: %d,%d for output %s", x, - y, output->name); - output->logical_geometry.x = x; output->logical_geometry.y = y; } @@ -59,16 +56,13 @@ static void xdg_output_handle_done(void *data, static void xdg_output_handle_name(void *data, struct zxdg_output_v1 *xdg_output, const char *name) { - g_debug("xdg_output_v1: name: %s", name); struct swappy_output *output = data; output->name = strdup(name); } static void xdg_output_handle_description(void *data, struct zxdg_output_v1 *xdg_output, - const char *name) { - g_debug("xdg_output_v1: description: %s", name); -} + const char *name) {} static const struct zxdg_output_v1_listener xdg_output_listener = { .logical_position = xdg_output_handle_logical_position, @@ -165,7 +159,6 @@ static void global_registry_handler(void *data, struct wl_registry *registry, static void global_registry_remove_handler(void *data, struct wl_registry *wl_registry, uint32_t name) { - g_debug("got a registry remove event for name: %d", name); } static struct wl_registry_listener registry_listener = { @@ -180,8 +173,6 @@ bool wayland_init(struct swappy_state *state) { return false; } - g_debug("connected to wayland display"); - wl_list_init(&state->outputs); state->registry = wl_display_get_registry(state->display); wl_registry_add_listener(state->registry, ®istry_listener, state); @@ -240,8 +231,6 @@ bool wayland_init(struct swappy_state *state) { } void wayland_finish(struct swappy_state *state) { - g_debug("cleaning up wayland resources"); - struct swappy_output *output; struct swappy_output *output_tmp; wl_list_for_each_safe(output, output_tmp, &state->outputs, link) {