aboutsummaryrefslogtreecommitdiffstats
path: root/src/randr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/randr.c')
-rw-r--r--src/randr.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/randr.c b/src/randr.c
index 3ee0f42..4ee1756 100644
--- a/src/randr.c
+++ b/src/randr.c
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <stdint.h>
#include <string.h>
#ifdef ENABLE_NLS
@@ -40,8 +41,44 @@
int
-randr_init(randr_state_t *state, int screen_num, int crtc_num)
+randr_init(randr_state_t *state, char *args)
{
+ int screen_num = -1;
+ int crtc_num = -1;
+
+ /* Parse arguments. */
+ while (args != NULL) {
+ char *next_arg = strchr(args, ':');
+ if (next_arg != NULL) *(next_arg++) = '\0';
+
+ char *value = strchr(args, '=');
+ if (value != NULL) *(value++) = '\0';
+
+ if (strcasecmp(args, "screen") == 0) {
+ if (value == NULL) {
+ fprintf(stderr, _("Missing value for"
+ " parameter: `%s'.\n"),
+ args);
+ return -1;
+ }
+ screen_num = atoi(value);
+ } else if (strcasecmp(args, "crtc") == 0) {
+ if (value == NULL) {
+ fprintf(stderr, _("Missing value for"
+ " parameter: `%s'.\n"),
+ args);
+ return -1;
+ }
+ crtc_num = atoi(value);
+ } else {
+ fprintf(stderr, _("Unknown method parameter: `%s'.\n"),
+ args);
+ return -1;
+ }
+
+ args = next_arg;
+ }
+
xcb_generic_error_t *error;
/* Open X server connection */