Address first round review for swaynag
This commit is contained in:
parent
72db10c2f1
commit
a4f7bf23b2
|
@ -82,7 +82,7 @@ if scdoc.found()
|
|||
'swaylock/swaylock.1.scd',
|
||||
'swaymsg/swaymsg.1.scd',
|
||||
'swayidle/swayidle.1.scd',
|
||||
'swaynagbar/swaynagbar.1.scd',
|
||||
'swaynag/swaynag.1.scd',
|
||||
]
|
||||
foreach filename : man_files
|
||||
topic = filename.split('.')[-3].split('/')[-1]
|
||||
|
@ -131,7 +131,7 @@ subdir('swaybg')
|
|||
subdir('swaybar')
|
||||
subdir('swaylock')
|
||||
subdir('swayidle')
|
||||
subdir('swaynagbar')
|
||||
subdir('swaynag')
|
||||
|
||||
config = configuration_data()
|
||||
config.set('sysconfdir', join_paths(prefix, sysconfdir))
|
||||
|
|
|
@ -214,9 +214,6 @@ void arrange_layers(struct sway_output *output) {
|
|||
wl_list_for_each(seat, &input_manager->seats, link) {
|
||||
seat_set_focus_layer(seat, topmost ? topmost->layer_surface : NULL);
|
||||
}
|
||||
|
||||
arrange_windows(output->swayc);
|
||||
transaction_commit_dirty();
|
||||
}
|
||||
|
||||
static void handle_output_destroy(struct wl_listener *listener, void *data) {
|
||||
|
@ -250,6 +247,9 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
|||
output_damage_surface(output, layer->geo.x, layer->geo.y,
|
||||
layer_surface->surface, false);
|
||||
}
|
||||
|
||||
arrange_windows(output->swayc);
|
||||
transaction_commit_dirty();
|
||||
}
|
||||
|
||||
static void unmap(struct sway_layer_surface *sway_layer) {
|
||||
|
@ -287,6 +287,8 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
|
|||
struct sway_output *output = sway_layer->layer_surface->output->data;
|
||||
if (output != NULL && output->swayc != NULL) {
|
||||
arrange_layers(output);
|
||||
arrange_windows(output->swayc);
|
||||
transaction_commit_dirty();
|
||||
}
|
||||
wl_list_remove(&sway_layer->output_destroy.link);
|
||||
sway_layer->layer_surface->output = NULL;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "log.h"
|
||||
#include "list.h"
|
||||
#include "readline.h"
|
||||
#include "swaynagbar/nagbar.h"
|
||||
#include "swaynag/nagbar.h"
|
||||
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
|
||||
|
||||
static struct sway_nagbar nagbar;
|
||||
|
@ -71,7 +71,7 @@ int main(int argc, char **argv) {
|
|||
| ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
|
||||
nagbar.type = NAGBAR_ERROR;
|
||||
set_nagbar_colors();
|
||||
nagbar.font = strdup("pango:monospace 8");
|
||||
nagbar.font = strdup("pango:monospace 10");
|
||||
nagbar.buttons = create_list();
|
||||
|
||||
struct sway_nagbar_button *button_close =
|
||||
|
@ -91,7 +91,7 @@ int main(int argc, char **argv) {
|
|||
{"edge", required_argument, NULL, 'e'},
|
||||
{"font", required_argument, NULL, 'f'},
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"detailed-message", required_argument, NULL, 'l'},
|
||||
{"detailed-message", no_argument, NULL, 'l'},
|
||||
{"detailed-button", required_argument, NULL, 'L'},
|
||||
{"message", required_argument, NULL, 'm'},
|
||||
{"output", required_argument, NULL, 'o'},
|
||||
|
@ -102,7 +102,7 @@ int main(int argc, char **argv) {
|
|||
};
|
||||
|
||||
const char *usage =
|
||||
"Usage: swaynagbar [options...]\n"
|
||||
"Usage: swaynag [options...]\n"
|
||||
"\n"
|
||||
" -b, --button <text> <action> Create a button with text that "
|
||||
"executes action when pressed. Multiple buttons can be defined.\n"
|
||||
|
@ -110,7 +110,7 @@ int main(int argc, char **argv) {
|
|||
" -e, --edge top|bottom Set the edge to use.\n"
|
||||
" -f, --font <font> Set the font to use.\n"
|
||||
" -h, --help Show help message and quit.\n"
|
||||
" -l, --detailed-message <msg> Set a detailed message.\n"
|
||||
" -l, --detailed-message Read a detailed message from stdin.\n"
|
||||
" -L, --detailed-button <text> Set the text of the detail button.\n"
|
||||
" -m, --message <msg> Set the message text.\n"
|
||||
" -o, --output <output> Set the output to use.\n"
|
||||
|
@ -119,7 +119,7 @@ int main(int argc, char **argv) {
|
|||
" -v, --version Show the version number and quit.\n";
|
||||
|
||||
while (1) {
|
||||
int c = getopt_long(argc, argv, "b:de:f:hl:L:m:o:s:t:v", opts, NULL);
|
||||
int c = getopt_long(argc, argv, "b:de:f:hlL:m:o:s:t:v", opts, NULL);
|
||||
if (c == -1) {
|
||||
break;
|
||||
}
|
||||
|
@ -162,11 +162,7 @@ int main(int argc, char **argv) {
|
|||
break;
|
||||
case 'l': // Detailed Message
|
||||
free(nagbar.details.message);
|
||||
if (strcmp(optarg, "-") == 0) {
|
||||
nagbar.details.message = read_from_stdin();
|
||||
} else {
|
||||
nagbar.details.message = strdup(optarg);
|
||||
}
|
||||
nagbar.details.message = read_from_stdin();
|
||||
nagbar.details.button_up.text = strdup("▲");
|
||||
nagbar.details.button_down.text = strdup("▼");
|
||||
break;
|
||||
|
@ -199,7 +195,7 @@ int main(int argc, char **argv) {
|
|||
set_nagbar_colors();
|
||||
break;
|
||||
case 'v': // Version
|
||||
fprintf(stdout, "sway version " SWAY_VERSION "\n");
|
||||
fprintf(stdout, "swaynag version " SWAY_VERSION "\n");
|
||||
exit_code = EXIT_SUCCESS;
|
||||
goto cleanup;
|
||||
default: // Help or unknown flag
|
|
@ -1,5 +1,5 @@
|
|||
executable(
|
||||
'swaynagbar', [
|
||||
'swaynag', [
|
||||
'main.c',
|
||||
'nagbar.c',
|
||||
'render.c',
|
|
@ -6,8 +6,8 @@
|
|||
#include <wayland-cursor.h>
|
||||
#include "log.h"
|
||||
#include "list.h"
|
||||
#include "swaynagbar/nagbar.h"
|
||||
#include "swaynagbar/render.h"
|
||||
#include "swaynag/nagbar.h"
|
||||
#include "swaynag/render.h"
|
||||
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
|
||||
|
||||
static void nop() {
|
||||
|
@ -15,7 +15,7 @@ static void nop() {
|
|||
}
|
||||
|
||||
static bool terminal_execute(char *terminal, char *command) {
|
||||
char fname[] = "/tmp/swaynagbarXXXXXX";
|
||||
char fname[] = "/tmp/swaynagXXXXXX";
|
||||
FILE *tmp= fdopen(mkstemp(fname), "w");
|
||||
if (!tmp) {
|
||||
wlr_log(WLR_ERROR, "Failed to create temp script");
|
||||
|
@ -352,7 +352,7 @@ void nagbar_setup(struct sway_nagbar *nagbar) {
|
|||
assert(nagbar->surface);
|
||||
nagbar->layer_surface = zwlr_layer_shell_v1_get_layer_surface(
|
||||
nagbar->layer_shell, nagbar->surface, nagbar->output.wl_output,
|
||||
ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM, "nagbar");
|
||||
ZWLR_LAYER_SHELL_V1_LAYER_TOP, "swaynag");
|
||||
assert(nagbar->layer_surface);
|
||||
zwlr_layer_surface_v1_add_listener(nagbar->layer_surface,
|
||||
&layer_surface_listener, nagbar);
|
|
@ -3,7 +3,7 @@
|
|||
#include "log.h"
|
||||
#include "pango.h"
|
||||
#include "pool-buffer.h"
|
||||
#include "swaynagbar/nagbar.h"
|
||||
#include "swaynag/nagbar.h"
|
||||
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
|
||||
|
||||
static uint32_t render_message(cairo_t *cairo, struct sway_nagbar *nagbar) {
|
||||
|
@ -274,7 +274,7 @@ void render_frame(struct sway_nagbar *nagbar) {
|
|||
nagbar->height * nagbar->scale);
|
||||
if (!nagbar->current_buffer) {
|
||||
wlr_log(WLR_DEBUG, "Failed to get buffer. Skipping frame.");
|
||||
return;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cairo_t *shm = nagbar->current_buffer->cairo;
|
||||
|
@ -293,6 +293,8 @@ void render_frame(struct sway_nagbar *nagbar) {
|
|||
wl_surface_commit(nagbar->surface);
|
||||
wl_display_roundtrip(nagbar->display);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
cairo_surface_destroy(recorder);
|
||||
cairo_destroy(cairo);
|
||||
}
|
|
@ -2,11 +2,11 @@ swaynagbar(1)
|
|||
|
||||
# NAME
|
||||
|
||||
swaynagbar - Show a warning or error message with buttons
|
||||
swaynag - Show a warning or error message with buttons
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
_swaynagbar_ [options...]
|
||||
_swaynag_ [options...]
|
||||
|
||||
# OPTIONS
|
||||
*-b, --button* <text> <action>
|
||||
|
@ -25,10 +25,9 @@ _swaynagbar_ [options...]
|
|||
*-h, --help*
|
||||
Show help message and quit.
|
||||
|
||||
*-l, --detailed-message <msg>*
|
||||
Set the detailed message. A button to toggle details will be added. Details
|
||||
are shown in a scrollable multi-line text area. If _msg_ is _-_, then the
|
||||
detailed message will be read from stdin.
|
||||
*-l, --detailed-message*
|
||||
Read a detailed message from stdin. A button to toggle details will be
|
||||
added. Details are shown in a scrollable multi-line text area.
|
||||
|
||||
*-L, --detailed-button <text>*
|
||||
Set the text for the button that toggles details. This has no effect if
|
Loading…
Reference in a new issue