summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémie Courrèges-Anglas <jca@wxcvbn.org>2017-09-18 06:56:12 +0200
committerJérémie Courrèges-Anglas <jca@wxcvbn.org>2017-09-18 06:56:12 +0200
commitcbd91e801bf71eb0e7b2d5a2264c36007a3e12cc (patch)
tree482d38dbd98a11bcd9f8ad02557f3f16a0b0e7c2
parent0a90c2ac60cbb511ec24a52d723291d82a0124ba (diff)
downloadratpoison-cbd91e801bf71eb0e7b2d5a2264c36007a3e12cc.zip
Move #ifdef HAVE_XRANDR in xrandr.c
- always build xrandr.c - provide stubs in xrandr.c; only init_xrandr() anc xrandr_fill_screen() are safe to call if XRandR support is not built in Code that wants to use XRandR outside xrandr.c should test rp_have_xrandr.
-rw-r--r--configure.ac6
-rw-r--r--src/Makefile.am8
-rw-r--r--src/events.c2
-rw-r--r--src/main.c4
-rw-r--r--src/screen.c19
-rw-r--r--src/xrandr.c46
6 files changed, 56 insertions, 29 deletions
diff --git a/configure.ac b/configure.ac
index 76cb5c1..2ea4315 100644
--- a/configure.ac
+++ b/configure.ac
@@ -184,17 +184,13 @@ CPPFLAGS="$mysavedCPPFLAGS"
AC_CHECK_LIB(Xrandr, XRRGetScreenResources, [libxrandr=yes], [libxrandr=no], [$X_LIBS $X_EXTRA_LIBS])
-compile_xrandr=no
AS_CASE(["$with_xrandr:$xrandr_h:$libxrandr"],
[yes:no:*], [AC_MSG_ERROR([*** Can't enable Xrandr support, header Xrandr.h not found.])],
[yes:*:no], [AC_MSG_ERROR([*** Can't enable Xrandr support, libXrandr not found.])],
[check:no:*], [AC_MSG_ERROR([*** Header Xrandr.h not found, use ./configure --without-xrandr to build without multiple screens support.])],
[check:*:no], [AC_MSG_ERROR([*** libXrandr not found, use ./configure --without-xrandr to build without multiple screens support.])],
[yes:yes:yes|check:yes:yes], [X_LIBS="-lXrandr $X_LIBS"
- AC_DEFINE(HAVE_XRANDR, 1, [Define to 1 if you want Xrandr support.])
- compile_xrandr=yes])
-
-AM_CONDITIONAL(HAVE_XRANDR, [test "$compile_xrandr" = yes])
+ AC_DEFINE(HAVE_XRANDR, 1, [Define to 1 if you want Xrandr support.])])
AC_SUBST(X_LIBS)
AC_SUBST(X_EXTRA_LIBS)
diff --git a/src/Makefile.am b/src/Makefile.am
index 5bb1934..7c508a1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -74,11 +74,9 @@ ratpoison_SOURCES = actions.c \
util.c \
util.h \
window.c \
- window.h
-
-if HAVE_XRANDR
-ratpoison_SOURCES += xrandr.c xrandr.h
-endif
+ window.h \
+ xrandr.c \
+ xrandr.h
TESTS = test-sbuf-utf8-nconcat
check_PROGRAMS = test-sbuf-utf8-nconcat
diff --git a/src/events.c b/src/events.c
index e87bce2..4808d29 100644
--- a/src/events.c
+++ b/src/events.c
@@ -785,10 +785,8 @@ static void
delegate_event (XEvent *ev)
{
-#ifdef HAVE_XRANDR
if (rp_have_xrandr)
xrandr_notify (ev);
-#endif
switch (ev->type)
{
diff --git a/src/main.c b/src/main.c
index db83f74..dbd4519 100644
--- a/src/main.c
+++ b/src/main.c
@@ -420,11 +420,7 @@ main (int argc, char *argv[])
init_xkb ();
init_groups ();
init_window_stuff ();
-
-#ifdef HAVE_XRANDR
init_xrandr ();
-#endif
-
init_screens ();
init_frame_lists ();
diff --git a/src/screen.c b/src/screen.c
index 65cca2e..1e62964 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -258,7 +258,6 @@ screen_select_primary (void)
if (!rp_current_screen)
rp_current_screen = cur;
-#ifdef HAVE_XRANDR
if (!rp_have_xrandr)
return;
@@ -271,7 +270,6 @@ screen_select_primary (void)
break;
}
}
-#endif
}
static void
@@ -298,13 +296,10 @@ init_screens (void)
rp_screen *screen;
/* Get the number of screens */
- if (rp_have_xrandr) {
-#ifdef HAVE_XRANDR
+ if (rp_have_xrandr)
screen_count = xrandr_query_screen (&rr_outputs);
-#endif
- } else {
+ else
screen_count = ScreenCount (dpy);
- }
/* Create our global frame numset */
rp_frame_numset = numset_new();
@@ -316,10 +311,11 @@ init_screens (void)
screen = xmalloc (sizeof(*screen));
list_add (&screen->node, &rp_screens);
-#ifdef HAVE_XRANDR
if (rp_have_xrandr)
xrandr_fill_screen (rr_outputs[i], screen);
-#endif
+ else
+ xrandr_fill_screen (i, screen);
+
init_screen (screen);
}
@@ -635,10 +631,7 @@ screen_add (int rr_output)
screen->number = numset_request (rp_glob_screen.numset);
-#ifdef HAVE_XRANDR
- if (rp_have_xrandr)
- xrandr_fill_screen (rr_output, screen);
-#endif
+ xrandr_fill_screen (rr_output, screen);
init_screen (screen);
init_frame_list (screen);
diff --git a/src/xrandr.c b/src/xrandr.c
index 365602d..c369dbc 100644
--- a/src/xrandr.c
+++ b/src/xrandr.c
@@ -21,6 +21,8 @@
#include "ratpoison.h"
+#ifdef HAVE_XRANDR
+
#include <X11/extensions/Xrandr.h>
static int xrandr_evbase;
@@ -262,3 +264,47 @@ xrandr_notify (XEvent *ev)
break;
}
}
+
+#else /* HAVE_XRANDR */
+
+void
+init_xrandr(void)
+{
+ /* Nothing */
+}
+
+int
+xrandr_query_screen (int **outputs)
+{
+ (void)outputs;
+ fatal("xrandr_query_screen shouldn't be called. This is a BUG.");
+ return 0;
+}
+
+int
+xrandr_is_primary (rp_screen *screen)
+{
+ (void)screen;
+ fatal("xrandr_is_primary shouldn't be called. This is a BUG.");
+ return 0;
+}
+
+void
+xrandr_fill_screen (int rr_output, rp_screen *screen)
+{
+ (void)rr_output;
+ memset(&screen->xrandr, 0, sizeof(screen->xrandr));
+ screen->xrandr.primary = (rr_output == 0);
+ screen->xrandr.output = rr_output;
+ screen->xrandr.name = sbuf_new (0);
+ sbuf_concat (screen->xrandr.name, "N/A");
+}
+
+void
+xrandr_notify (XEvent *ev)
+{
+ (void)ev;
+ fatal("xrandr_notify shouldn't be called. This is a BUG.");
+}
+
+#endif /* HAVE_XRANDR */