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