Browse Source

Build system/WMFS: WMFS does not *need* xinerama and xrandr librairies anyway, optional now.

Martin Duquesnoy 15 years ago
parent
commit
fd287cd562
7 changed files with 77 additions and 60 deletions
  1. 6 6
      src/config.h.in
  2. 12 18
      src/event.c
  3. 5 1
      src/ewmh.c
  4. 3 3
      src/launcher.c
  5. 1 0
      src/layout.c
  6. 41 29
      src/screen.c
  7. 9 3
      src/wmfs.h

+ 6 - 6
src/config.h.in

@@ -35,12 +35,12 @@
 
 #include "wmfs.h"
 
-#define WMFS_VERSION            "@WMFS_VERSION@"
-#define WMFS_COMPILE_MACHINE    "@WMFS_COMPILE_MACHINE@"
-#define WMFS_COMPILE_BY         "@WMFS_COMPILE_BY@"
-#define WMFS_COMPILE_FLAGS      "@WMFS_COMPILE_FLAGS@"
-#define WMFS_LINKED_LIBS        "@WMFS_LINKED_LIBS@"
-#define XDG_CONFIG_DIR          "@XDG_CONFIG_DIR@"
+#define WMFS_VERSION         "@WMFS_VERSION@"
+#define WMFS_COMPILE_MACHINE "@WMFS_COMPILE_MACHINE@"
+#define WMFS_COMPILE_BY      "@WMFS_COMPILE_BY@"
+#define WMFS_COMPILE_FLAGS   "@WMFS_COMPILE_FLAGS@"
+#define WMFS_LINKED_LIBS     "@WMFS_LINKED_LIBS@"
+#define XDG_CONFIG_DIR       "@XDG_CONFIG_DIR@"
 @WMFS_HAVE_XINERAMA@
 @WMFS_HAVE_XRANDR@
 

+ 12 - 18
src/event.c

@@ -500,23 +500,6 @@ unmapnotify(XUnmapEvent *ev)
      return;
 }
 
-/** Xrandr screen change notify handle event
- *\ param ev XEvent pointer
- */
-void
-xrandrnotify(XEvent *ev)
-{
-     /* Update configuration */
-     XRRUpdateConfiguration(ev);
-
-     /* Reload WMFS to update the screen(s) geometry changement */
-     quit();
-     for(; argv_global[0] && argv_global[0] == ' '; ++argv_global);
-     execlp(argv_global, argv_global, NULL);
-
-     return;
-}
-
 /** Send a client event
  *\param data Event data
  *\param atom_name Event atom name
@@ -567,9 +550,20 @@ getevent(XEvent ev)
      case PropertyNotify:   propertynotify(&ev.xproperty);         break;
      case UnmapNotify:      unmapnotify(&ev.xunmap);               break;
      default:
+
+#ifdef HAVE_XRANDR
           /* Check Xrandr event */
           if(ev.type == xrandr_event)
-               xrandrnotify(&ev);
+          {
+               /* Update xrandr configuration */
+               XRRUpdateConfiguration(&ev);
+
+               /* Reload WMFS to update the screen(s) geometry changement */
+               quit();
+               for(; argv_global[0] && argv_global[0] == ' '; ++argv_global);
+               execlp(argv_global, argv_global, NULL);
+          }
+#endif
           break;
      }
 

+ 5 - 1
src/ewmh.c

@@ -139,11 +139,13 @@ void
 ewmh_update_current_tag_prop(void)
 {
      int t;
-     char s[10] = { 0 };
+     char *s = NULL;
 
      screen_get_sel();
      t = seltag[selscreen] - 1;
 
+     s = emalloc(8, sizeof(char));
+
      /* Get current desktop (tag) */
      XChangeProperty(dpy, ROOT, net_atom[net_current_desktop], XA_CARDINAL, 32,
                      PropModeReplace, (uchar*)&t, 1);
@@ -168,6 +170,8 @@ ewmh_update_current_tag_prop(void)
                      PropModeReplace, (uchar*)tags[selscreen][seltag[selscreen]].layout.symbol,
                      strlen(tags[selscreen][seltag[selscreen]].layout.symbol));
 
+     free(s);
+
      return;
 }
 

+ 3 - 3
src/launcher.c

@@ -80,7 +80,7 @@ launcher_execute(Launcher launcher)
 
      barwin_refresh(bw);
 
-     barwin_draw_text(bw, 1, FHINFOBAR, launcher.prompt);
+     barwin_draw_text(bw, 1, FHINFOBAR - 1, launcher.prompt);
 
      while(my_guitar_gently_wheeps)
      {
@@ -192,8 +192,8 @@ launcher_execute(Launcher launcher)
                          1 + textw(launcher.prompt) + textw(" ") + textw(buf), 2,
                          1 + textw(launcher.prompt) + textw(" ") + textw(buf), INFOBARH - 4);
 
-               barwin_draw_text(bw, 1, FHINFOBAR, launcher.prompt);
-               barwin_draw_text(bw, 1 + textw(launcher.prompt) + textw(" "), FHINFOBAR, buf);
+               barwin_draw_text(bw, 1, FHINFOBAR - 1, launcher.prompt);
+               barwin_draw_text(bw, 1 + textw(launcher.prompt) + textw(" "), FHINFOBAR - 1, buf);
                barwin_refresh(bw);
           }
           else

+ 1 - 0
src/layout.c

@@ -265,6 +265,7 @@ grid(int screen)
 
           /* Set all the other size with current client info */
           cgeo.y = c->geo.y + c->geo.height + BORDH + TBARH;
+
           if(cpcols + 1 > rows)
           {
                cpcols = 0;

+ 41 - 29
src/screen.c

@@ -40,10 +40,12 @@ screen_count(void)
 {
      int n = 0;
 
+     n = ScreenCount(dpy);
+
+#ifdef HAVE_XINERAMA
      if(XineramaIsActive(dpy))
           XineramaQueryScreens(dpy, &n);
-     else
-          n = ScreenCount(dpy);
+#endif
 
      /* Set _WMFS_SCREEN_COUNT */
      XChangeProperty(dpy, ROOT, net_atom[wmfs_screen_count], XA_CARDINAL, 32,
@@ -59,13 +61,22 @@ screen_count(void)
 XRectangle
 screen_get_geo(int s)
 {
-     int n = 0;
      int barpos = tags[selscreen][seltag[selscreen]].barpos;
      XRectangle geo;
 
+     geo.x = BORDH;
+     if(barpos == IB_Hide || barpos == IB_Bottom)
+          geo.y = TBARH;
+     else
+          geo.y = INFOBARH + TBARH;
+     geo.height = MAXH - INFOBARH - TBARH;
+     geo.width = MAXW;
+
+#ifdef HAVE_XINERAMA
      if(XineramaIsActive(dpy))
      {
           XineramaScreenInfo *xsi;
+          int n = 0;
 
           xsi = XineramaQueryScreens(dpy, &n);
 
@@ -79,16 +90,7 @@ screen_get_geo(int s)
 
           XFree(xsi);
      }
-     else
-     {
-          geo.x = BORDH;
-          if(barpos == IB_Hide || barpos == IB_Bottom)
-               geo.y = TBARH;
-          else
-               geo.y = INFOBARH + TBARH;
-          geo.height = MAXH - INFOBARH - TBARH;
-          geo.width = MAXW;
-     }
+#endif
 
      return geo;
 }
@@ -135,20 +137,24 @@ screen_set_sel(int screen)
 int
 screen_get_sel(void)
 {
+     selscreen = 0;
+
+#ifdef HAVE_XINERAMA
      if(XineramaIsActive(dpy))
      {
           /* Unused variables (except x/y) */
           Window w;
-          int d, u, x, y;
+          int d, x, y;
 
-          XQueryPointer(dpy, ROOT, &w, &w, &x, &y, &d, &d, (uint *)&u);
+          XQueryPointer(dpy, ROOT, &w, &w, &x, &y, &d, &d, (uint *)&d);
 
           selscreen = screen_get_with_geo(x, y);
-
-          /* Set _WMFS_CURRENT_SCREEN */
-          XChangeProperty(dpy, ROOT, net_atom[wmfs_current_screen], XA_CARDINAL, 32,
-                          PropModeReplace, (uchar*)&selscreen, 1);
      }
+#endif
+
+     /* Set _WMFS_CURRENT_SCREEN */
+     XChangeProperty(dpy, ROOT, net_atom[wmfs_current_screen], XA_CARDINAL, 32,
+                     PropModeReplace, (uchar*)&selscreen, 1);
 
      return selscreen;
 }
@@ -158,8 +164,7 @@ screen_get_sel(void)
 void
 screen_init_geo(void)
 {
-     int i, n, d;
-     XineramaScreenInfo *xsi;
+     int i;
 
      sgeo = emalloc(screen_count(), sizeof(XRectangle));
      spgeo = emalloc(screen_count(), sizeof(XRectangle));
@@ -167,6 +172,15 @@ screen_init_geo(void)
      for(i = 0; i < screen_count(); ++i)
           sgeo[i] = screen_get_geo(i);
 
+     spgeo[0].x = 0;
+     spgeo[0].y = 0;
+     spgeo[0].width = MAXW;
+     spgeo[0].height = MAXH;
+
+#ifdef HAVE_XINERAMA
+     XineramaScreenInfo *xsi;
+     int n;
+
      if(XineramaIsActive(dpy))
      {
           xsi = XineramaQueryScreens(dpy, &n);
@@ -179,17 +193,15 @@ screen_init_geo(void)
           }
           XFree(xsi);
      }
-     else
-     {
-          spgeo[0].x = 0;
-          spgeo[0].y = 0;
-          spgeo[0].width = MAXW;
-          spgeo[0].height = MAXH;
-     }
+#endif
+
+#ifdef HAVE_XRANDR
+     /* Init xrandr stuff */
+     int d;
 
-     /* Init Xrandr stuff */
      XRRSelectInput(dpy, ROOT, 1);
      XRRQueryExtension(dpy, &xrandr_event, &d);
+#endif
 
      ewmh_set_desktop_geometry();
      ewmh_set_workarea();

+ 9 - 3
src/wmfs.h

@@ -50,13 +50,20 @@
 #include <X11/Xatom.h>
 #include <X11/cursorfont.h>
 #include <X11/Xft/Xft.h>
-#include <X11/extensions/Xinerama.h>
-#include <X11/extensions/Xrandr.h>
 
 /* Local headers */
 #include "config.h"
 #include "structs.h"
 
+#ifdef HAVE_XINERAMA
+#include <X11/extensions/Xinerama.h>
+#endif
+
+#ifdef HAVE_XRANDR
+#include <X11/extensions/Xrandr.h>
+#endif
+
+
 /* MACRO */
 #define ButtonMask   (ButtonPressMask | ButtonReleaseMask | ButtonMotionMask)
 #define MouseMask    (ButtonMask | PointerMotionMask)
@@ -203,7 +210,6 @@ void mappingnotify(XMappingEvent *ev);
 void maprequest(XMapRequestEvent *ev);
 void propertynotify(XPropertyEvent *ev);
 void unmapnotify(XUnmapEvent *ev);
-void xrandrnotify(XEvent *ev);
 void send_client_event(long data[5], char *atom_name);
 void getevent(XEvent ev);