parsing output arguments
This commit is contained in:
parent
ace8497478
commit
24de6d4133
3 changed files with 20 additions and 4 deletions
19
glonkers.c
19
glonkers.c
|
|
@ -14,15 +14,30 @@
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
char *shader_path = NULL;
|
char *shader_path = NULL;
|
||||||
int output_type = OUTPUT_WINDOW;
|
int output_type = OUTPUT_WINDOW;
|
||||||
|
bool currently_reading_output = false;
|
||||||
|
char **output_list = NULL;
|
||||||
|
int output_count = 0;
|
||||||
// syntax: --window for a normal window or --layer for a wallpaper
|
// syntax: --window for a normal window or --layer for a wallpaper
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
if (strcmp("--window", argv[i]) == 0) {
|
if (strcmp("--window", argv[i]) == 0) {
|
||||||
output_type = OUTPUT_WINDOW;
|
output_type = OUTPUT_WINDOW;
|
||||||
|
currently_reading_output = false;
|
||||||
}
|
}
|
||||||
else if (strcmp("--layer", argv[i]) == 0) {
|
else if (strcmp("--layer", argv[i]) == 0) {
|
||||||
output_type = OUTPUT_LAYER;
|
output_type = OUTPUT_LAYER;
|
||||||
|
currently_reading_output = false;
|
||||||
}
|
}
|
||||||
else {
|
else if (strcmp("--output", argv[i]) == 0) {
|
||||||
|
output_list = &argv[i];
|
||||||
|
currently_reading_output = true;
|
||||||
|
}
|
||||||
|
else if (strcmp("--", argv[i]) == 0) {
|
||||||
|
currently_reading_output = false;
|
||||||
|
}
|
||||||
|
else if (currently_reading_output) {
|
||||||
|
output_count++;
|
||||||
|
}
|
||||||
|
else if (!currently_reading_output) {
|
||||||
// path to fragment shader
|
// path to fragment shader
|
||||||
if (shader_path != NULL) {
|
if (shader_path != NULL) {
|
||||||
fprintf(stderr, "tried supplying '%s' as a shader file while one has already been selected\n", argv[i]);
|
fprintf(stderr, "tried supplying '%s' as a shader file while one has already been selected\n", argv[i]);
|
||||||
|
|
@ -36,7 +51,7 @@ int main(int argc, char *argv[]) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct client_state *state = wayland_init(output_type);
|
struct client_state *state = wayland_init(output_type, output_list, output_count);
|
||||||
|
|
||||||
Renderer renderer = new_renderer();
|
Renderer renderer = new_renderer();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -507,7 +507,7 @@ static const struct wl_registry_listener wl_registry_listener = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Initializes wayland and creates an opengl context
|
/// Initializes wayland and creates an opengl context
|
||||||
struct client_state* wayland_init(int output_type) {
|
struct client_state* wayland_init(int output_type, char *output_list[], int output_list_len) {
|
||||||
struct client_state *state = malloc(sizeof(struct client_state));
|
struct client_state *state = malloc(sizeof(struct client_state));
|
||||||
state->running = 1;
|
state->running = 1;
|
||||||
state->output_type = output_type;
|
state->output_type = output_type;
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,8 @@ struct event {
|
||||||
} data;
|
} data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct client_state* wayland_init(int output_type);
|
/// output_list: if not NULL, only select outputs should be drawn to
|
||||||
|
struct client_state* wayland_init(int output_type, char *output_list[], int output_list_len);
|
||||||
void commit(struct client_state *state);
|
void commit(struct client_state *state);
|
||||||
struct event wait_for_event(struct client_state *state);
|
struct event wait_for_event(struct client_state *state);
|
||||||
void swap_buffers(struct client_state *state, struct surface *surface);
|
void swap_buffers(struct client_state *state, struct surface *surface);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue