summaryrefslogtreecommitdiff
path: root/dmenu-wl.c
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2023-07-22 16:24:26 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2023-07-22 16:24:26 +0200
commit896bb1e6576fe32b754341ddf0b49fbcfd1c116a (patch)
treedff8e0e16a344a0a27153e3f6b7b23aad4e96227 /dmenu-wl.c
parent1b9769db524afe3deb987e95db9fe6651104ffc0 (diff)
make it also working on other compositors
Diffstat (limited to 'dmenu-wl.c')
-rw-r--r--dmenu-wl.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/dmenu-wl.c b/dmenu-wl.c
index 554ddb7..e957a45 100644
--- a/dmenu-wl.c
+++ b/dmenu-wl.c
@@ -17,6 +17,7 @@
#include "drw.h"
#include "util.h"
+#include "compositor.h"
/* macro definitions */
#define MAX_LINE_LENGTH 1024
@@ -548,7 +549,9 @@ readstdin()
void
setup()
{
+ unsigned count = 0;
Monitor *mon;
+ char *compositor;
char namespace[] = "dmenu-wl";
uint32_t layer = ZWLR_LAYER_SHELL_V1_LAYER_TOP;
uint32_t anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
@@ -563,15 +566,37 @@ setup()
client.repeat.timer = timerfd_create(CLOCK_MONOTONIC, 0);
client.xkb_context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
client.display = wl_display_connect(0);
+
+ if (client.display == 0)
+ die("could not open display:");
+
client.registry = wl_display_get_registry(client.display);
+
+ if (client.registry == 0)
+ die("could not open display:");
+
wl_registry_add_listener(client.registry, &registry_listnener, &client);
wl_display_roundtrip(client.display);
- for (mon = monitors; mon; mon = mon->next) {
- mon->dwl_output = zdwl_manager_v1_get_output(client.dwl_manager, mon->output);
- zdwl_output_v1_add_listener(mon->dwl_output, &dwl_output_listener, mon);
+ for (mon = monitors; mon && count < monitor_offset;) {
+ mon = mon->next;
+ count += 1;
+ }
+
+ if (mon) {
+ active_monitor = mon;
+ } else {
+ active_monitor = monitors;
+ }
+
+ compositor = process_name_from_fd(client.display);
+ if (strcmp(compositor, "dwl") == 0) {
+ for (mon = monitors; mon; mon = mon->next) {
+ mon->dwl_output = zdwl_manager_v1_get_output(client.dwl_manager, mon->output);
+ zdwl_output_v1_add_listener(mon->dwl_output, &dwl_output_listener, mon);
+ }
+ wl_display_roundtrip(client.display);
}
- wl_display_roundtrip(client.display);
active_monitor->font = create_font(fontpath, fontsize * 1.5);