]> git.mdlowis.com Git - proto/anvil.git/commitdiff
added dynamic monitor reconfiguration using xinerama instead of xrandr
authorMike Lowis <mike.lowis@gentex.com>
Tue, 6 Aug 2024 17:20:23 +0000 (13:20 -0400)
committerMike Lowis <mike.lowis@gentex.com>
Tue, 6 Aug 2024 17:20:23 +0000 (13:20 -0400)
anvil.c
anvil.h
build.sh

diff --git a/anvil.c b/anvil.c
index c7b1c41e2d0cf9c82b17e37e76f2403dcb0b7d88..b5ab34538c1d1f0f8f72e94d267cbcf95b440131 100644 (file)
--- a/anvil.c
+++ b/anvil.c
@@ -96,7 +96,6 @@ static void check_for_wm(void)
 {
     error_default = XSetErrorHandler(error_init);
     XSelectInput(X.disp, X.root, SubstructureRedirectMask|SubstructureNotifyMask);
-    XRRSelectInput(X.disp, X.root, RRScreenChangeNotifyMask);
     XSync(X.disp, False);
     XSetErrorHandler(error_panic);
     XSync(X.disp, False);
@@ -164,6 +163,14 @@ static void xconfigrequest(XEvent* e)
     }
 }
 
+static void xconfignotify(XEvent* e)
+{
+    XConfigureEvent* ev = &(e->xconfigure);
+    if (ev->window == X.root)
+    {
+        Monitors_Init();
+    }
+}
 
 static void xclientmsg(XEvent* e)
 {
@@ -229,13 +236,6 @@ static void xkeypress(XEvent* e)
     Keys_Process(ev);
 }
 
-static void xscreenchangenotify(XEvent* e)
-{
-    (void)e;
-    Monitors_Init();
-}
-
-
 static void init_cursors(void)
 {
     XColor csr_bdr, csr_fill;
@@ -317,12 +317,11 @@ int main(void)
     X.eventfns[MotionNotify] = xbtnmotion;
     X.eventfns[KeyPress] = xkeypress;
     X.eventfns[ConfigureRequest] = xconfigrequest;
+    X.eventfns[ConfigureNotify] = xconfignotify;
     X.eventfns[ClientMessage] = xclientmsg;
     X.eventfns[PropertyNotify] = xpropnotify;
     X.eventfns[EnterNotify] = xenternotify;
     X.eventfns[Expose] = xexpose;
-    X.eventfns[RRScreenChangeNotify] = xscreenchangenotify;
-
 
     /* main event loop */
     XSync(X.disp, False);
diff --git a/anvil.h b/anvil.h
index 3f08f62f82b75329870aa922c720dd69bea9a65b..37c26419002a4407668ac98d02d22b23f5466ad9 100644 (file)
--- a/anvil.h
+++ b/anvil.h
@@ -10,7 +10,6 @@
 #include <X11/Xproto.h>
 #include <X11/Xutil.h>
 #include <X11/extensions/Xinerama.h>
-#include <X11/extensions/Xrandr.h>
 #include <stdlib.h>
 #include <stdint.h>
 #include <stdio.h>
index 57e3872b45f3d4788a6197dc40e7aad1751ff187..85cab23debe5d08fbf7a3dd34f85e08786dbc3f4 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -2,7 +2,7 @@
 cflags="-g -Wall -Wextra -Werror"
 incpath="-I/usr/X11R6/include -Itest/"
 libpath="-L/usr/X11R6/lib"
-libs="-lX11 -lXinerama -lm -lXrandr"
+libs="-lX11 -lXinerama -lm"
 
 cc $cflags $incpath $libpath -o anvil ./*.c $libs \
     # && ./atf $incpath test/*.c