summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly@gmail.com>2020-04-21 21:53:25 -0500
committerDevin J. Pohly <djpohly@gmail.com>2020-04-21 21:53:34 -0500
commit1907ee3879d9dbeccad311aa3e2fc36e3a7be1d5 (patch)
treea2dfc0b1c0a950dd97ec559eeffd2f7c31381a0d
parent97f29ec67f0937dd34343fd50ff5b4fa6840f5f3 (diff)
introduce rules for monitor configuration
(with dwm, this would already have been done by the X server)
-rw-r--r--config.h11
-rw-r--r--dwl.c15
2 files changed, 25 insertions, 1 deletions
diff --git a/config.h b/config.h
index 5a8535e..0c7d727 100644
--- a/config.h
+++ b/config.h
@@ -1,3 +1,14 @@
+/* monitors */
+static const MonitorRule monrules[] = {
+ /* name scale */
+ { "X11-1", 1 },
+ { "eDP-1", 2 },
+ { "HDMI-A-1", 1 },
+ /* defaults */
+ { NULL, 1 },
+};
+
+/* keyboard */
static const struct xkb_rule_names xkb_rules = {
.rules = NULL,
.model = NULL,
diff --git a/dwl.c b/dwl.c
index 116a859..5f0ed93 100644
--- a/dwl.c
+++ b/dwl.c
@@ -81,6 +81,11 @@ typedef struct {
struct wl_listener frame;
} Monitor;
+typedef struct {
+ const char *name;
+ float scale;
+} MonitorRule;
+
/* Used to move all of the data necessary to render a surface from the top-level
* frame handler to the per-surface render function. */
struct render_data {
@@ -247,9 +252,17 @@ createmon(struct wl_listener *listener, void *data)
}
}
- /* Allocates and configures our state for this output */
+ /* Allocates and configures monitor state using configured rules */
Monitor *m = calloc(1, sizeof(*m));
m->wlr_output = wlr_output;
+ int i;
+ for (i = 0; i < LENGTH(monrules); i++) {
+ if (!monrules[i].name ||
+ !strcmp(wlr_output->name, monrules[i].name)) {
+ wlr_output_set_scale(wlr_output, monrules[i].scale);
+ break;
+ }
+ }
/* Sets up a listener for the frame notify event. */
m->frame.notify = rendermon;
wl_signal_add(&wlr_output->events.frame, &m->frame);