]> git.mdlowis.com Git - projs/tide.git/commitdiff
added cpppath and libpath in the config step window-manager
authorMichael D. Lowis <mike@mdlowis.com>
Thu, 22 Aug 2019 01:34:52 +0000 (21:34 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Thu, 22 Aug 2019 01:34:52 +0000 (21:34 -0400)
Rsconscript
src/anvil.c

index a27ba91230e0392fadbbd51121c820276dba331c..9b012078f0c4cca62b1c48f81c2afefa65d68944 100644 (file)
@@ -1,5 +1,9 @@
 configure do
   check_c_compiler "clang", "gcc"
+  check_c_header "X11/Xlib.h",
+    check_cpppath: ["/usr/X11/include"]
+  check_lib "X11",
+    check_libpath: ["/usr/X11/lib"]
   check_cfg program: "freetype-config"
 end
 
@@ -8,9 +12,8 @@ build do
   env["CC"] = "./acc"
   env["CFLAGS"] += ["-g", "-fsanitize=undefined,address"]
   env["LDFLAGS"] += ["-g", "-fsanitize=undefined,address"]
-  env["CPPPATH"] += %w[. inc /usr/X11/include]
-  env["LIBPATH"] += %w[. /usr/X11/lib]
-  #env["LIBS"] << "asan"
+  env["CPPPATH"] += %w[. inc]
+  env["LIBPATH"] += %w[.]
 
   # Build library and binaries
   env.Library("libtide.a", glob("src/lib/**/*.c"))
@@ -25,6 +28,7 @@ build do
     "CMD" => ["${_SOURCES}"],
     "CMD_DESC" => "TEST")
   env.depends("${prefix}/bin", "")
+
   # Install the compiled binaries
   Dir.glob("bin/*").each{|bin| env.Install("${prefix}/bin", bin) }
 end
index f13ed58c0a402804fb3ed3e29f93ac53b267e3f2..ecd6af33ae1c9d52b2100957e640492572b51fa0 100644 (file)
@@ -58,22 +58,22 @@ typedef struct Column {
     int flags, x, w;
 } Column;
 
-struct {
+static struct {
     Node *floated, *tiled;
 } Desktops[10] = {{0},{0},{0},{0},{0},{0},{0},{0},{0},{0}};
-int Desktop = 1;
+static int Desktop = 1;
 XConf X = {0};
-Node* All_Clients = NULL;
-Cursor Move_Cursor;
-Cursor Main_Cursor;
-int StartY = 0;
+static Node* All_Clients = NULL;
+static Cursor Move_Cursor;
+static Cursor Main_Cursor;
+static int StartY = 0;
 
 /* configuration */
-uint32_t BorderWidth = 1;
-uint32_t BorderColor = 0xFF0000;
-uint32_t BackgroundColor = 0x000077;
+static uint32_t BorderWidth = 1;
+static uint32_t BorderColor = 0xFF0000;
+static uint32_t BackgroundColor = 0x000077;
 
-Atom
+static Atom
     XA_NET_WM_WINDOW_TYPE,
     XA_NET_WM_WINDOW_TYPE_DIALOG,
     XA_WM_PROTOCOLS;
@@ -90,8 +90,8 @@ struct key {
     const Arg arg;
 };
 
-void change_desktop(const Arg arg);
-void client_to_desktop(const Arg arg);
+static void change_desktop(const Arg arg);
+static void client_to_desktop(const Arg arg);
 
 #define MOD Mod1Mask
 #define DESKTOPCHANGE(K,N) \
@@ -118,21 +118,21 @@ static struct key keys[] = {
 
 /* Utility Functions
  *****************************************************************************/
-void die(char* errstr) {
+static void die(char* errstr) {
     fprintf(stderr, "error: %s\n", errstr);
     exit(1);
 }
 
-Atom atom(XConf* x, char* s) {
+static Atom atom(XConf* x, char* s) {
     return XInternAtom(x->display, s, False);
 }
 
-void* xfree(void* p) {
+static void* xfree(void* p) {
     if (p) XFree(p);
     return NULL;
 }
 
-int get_prop(XConf* x, Window w, Atom name, Atom* type, int* format, void** data, size_t* ndata) {
+static int get_prop(XConf* x, Window w, Atom name, Atom* type, int* format, void** data, size_t* ndata) {
     unsigned long nleft;
     return XGetWindowProperty(
         x->display, w, name, 0, -1, False, AnyPropertyType, type, format, ndata, &nleft, (unsigned char**)data);
@@ -140,9 +140,10 @@ int get_prop(XConf* x, Window w, Atom name, Atom* type, int* format, void** data
 
 /* List Handling
  *****************************************************************************/
-void list_add(Node** list, Node* parent, Node* node) {
+static void list_add(Node** list, Node* parent, Node* node) {
     if (!parent) {
         node->next = *list;
+        node->prev = NULL;
         if (*list) (*list)->prev = node;
         *list = node;
     } else {
@@ -153,17 +154,18 @@ void list_add(Node** list, Node* parent, Node* node) {
     }
 }
 
-void list_del(Node** list, Node* node) {
+static void list_del(Node** list, Node* node) {
     if (node->prev) node->prev->next = node->next;
     if (node->next) node->next->prev = node->prev;
+    node->next = NULL, node->prev = NULL;
     if (*list == node) *list = node->next;
 }
 
-void* list_reduce(Node* list, Reducer rfn, void* accum) {
+static void* list_reduce(Node* list, Reducer rfn, void* accum) {
     return (list ? list_reduce(list->next, rfn, rfn(list, accum)) : accum);
 }
 
-size_t list_count(Node* curr) {
+static size_t list_count(Node* curr) {
     size_t nclients = 0;
     for (; curr; curr = curr->next, nclients++);
     return nclients;
@@ -171,23 +173,23 @@ size_t list_count(Node* curr) {
 
 /* Client Handling
  *****************************************************************************/
-void client_reconfig(XConf* xs, Client* c);
-void client_config(XConf* xs, Client* c, int x, int y, int w, int h);
+static void client_reconfig(XConf* xs, Client* c);
+static void client_config(XConf* xs, Client* c, int x, int y, int w, int h);
 
-void* biggest(Node* node, void* accum) {
+static void* biggest(Node* node, void* accum) {
     if (!accum || TCLIENT(node)->h > ((Client*)accum)->h)
         accum = TCLIENT(node);
     return accum;
 }
 
-void* find_win(Node* n, void* env) {
+static void* find_win(Node* n, void* env) {
     struct { Window w; Client* c; }* state = env;
     if ((MCLIENT(n)->frame == state->w) || (MCLIENT(n)->win == state->w))
         state->c = MCLIENT(n);
     return env;
 }
 
-void* grow_client(Node* node, void* env) {
+static void* grow_client(Node* node, void* env) {
     GrowState* state = env;
     Client* curr = TCLIENT(node);
     state->nclients--;
@@ -201,16 +203,24 @@ void* grow_client(Node* node, void* env) {
     return state;
 }
 
-int client_flags(Client* c, int mask) {
+static int client_flags(Client* c, int mask) {
     return (c->flags & mask);
 }
 
-void client_raise(XConf* x, Client* c) {
-    XMapRaised(x->display, c->frame);
-    XMapRaised(x->display, c->win);
+static void client_raise(XConf* x, Client* c) {
+    XMapWindow(x->display, c->frame);
+    XMapWindow(x->display, c->win);
+    if (!client_flags(c, FLOATING)) {
+        XLowerWindow(x->display, c->frame);
+        XLowerWindow(x->display, c->win);
+    } else {
+        XRaiseWindow(x->display, c->frame);
+        XRaiseWindow(x->display, c->win);
+    }
+    XSync(x->display, False);
 }
 
-void client_add(Client* c, int dtop) {
+static void client_add(Client* c, int dtop) {
     list_add(&All_Clients, NULL, &(c->mnode));
     if (!client_flags(c, FLOATING)) {
         Client* parent = list_reduce(Desktops[dtop].tiled, biggest, NULL);
@@ -226,7 +236,7 @@ void client_add(Client* c, int dtop) {
     }
 }
 
-void client_del(Client* c) {
+static void client_del(Client* c) {
     list_del(&All_Clients, &(c->mnode));
     if (!client_flags(c, FLOATING)) {
         list_del(&Tiled_Clients, &(c->tnode));
@@ -245,8 +255,7 @@ void client_del(Client* c) {
     }
 }
 
-void client_redraw(XConf* x, Client* c) {
-    puts("redraw");
+static void client_redraw(XConf* x, Client* c) {
     XftColor fgclr, bgclr;
     if (!c->name) return;
     xftcolor(x, &fgclr, -1);
@@ -257,7 +266,7 @@ void client_redraw(XConf* x, Client* c) {
     XftColorFree(x->display, x->visual, x->colormap, &bgclr);
 }
 
-void client_reconfig(XConf* xs, Client* c) {
+static void client_reconfig(XConf* xs, Client* c) {
     int height = BARHEIGHT(xs);
     XMoveResizeWindow(xs->display, c->frame, c->x, c->y, c->w - 2, height);
     if (c->h <= height) {
@@ -274,13 +283,13 @@ void client_reconfig(XConf* xs, Client* c) {
     XSync(xs->display, False);
 }
 
-void client_config(XConf* xs, Client* c, int x, int y, int w, int h) {
+static void client_config(XConf* xs, Client* c, int x, int y, int w, int h) {
     c->x = x, c->y = y, c->w = w, c->h = h;
     client_reconfig(xs, c);
     client_redraw(xs, c);
 }
 
-void client_initprops(XConf* x, Client* c) {
+static void client_initprops(XConf* x, Client* c) {
     int nprops = 0;
     Atom* props = XListProperties(x->display, c->win, &nprops);
     Atom type;
@@ -299,7 +308,7 @@ void client_initprops(XConf* x, Client* c) {
     }
 }
 
-void client_create(XConf* x, Window win) {
+static void client_create(XConf* x, Window win) {
     Client* c = calloc(1, sizeof(Client));
     c->win = win;
     XGrabServer(x->display);
@@ -341,7 +350,7 @@ void client_create(XConf* x, Window win) {
     XUngrabServer(x->display);
 }
 
-void client_destroy(XConf* x, Client* c) {
+static void client_destroy(XConf* x, Client* c) {
     client_del(c);
     XGrabServer(x->display);
     XftDrawDestroy(c->xft);
@@ -352,13 +361,13 @@ void client_destroy(XConf* x, Client* c) {
     XUngrabServer(x->display);
 }
 
-Client* client_find(Window win) {
+static Client* client_find(Window win) {
     struct { Window w; Client* c; } state = { .w = win };
     list_reduce(All_Clients, find_win, &state);
     return state.c;
 }
 
-void client_resize(XConf* x, Client* c, int dir) {
+static void client_resize(XConf* x, Client* c, int dir) {
     (void)x, (void)c, (void)dir;
     if (!c->tnode.prev) return;
     Client* prev = TCLIENT(c->tnode.prev);
@@ -374,7 +383,7 @@ void client_resize(XConf* x, Client* c, int dir) {
     client_reconfig(x, c);
 }
 
-void client_grow(XConf* x, Client* c) {
+static void client_grow(XConf* x, Client* c) {
     GrowState state = {
         .c = c,
         .nclients  = list_count(Tiled_Clients),
@@ -383,7 +392,7 @@ void client_grow(XConf* x, Client* c) {
     list_reduce(Tiled_Clients, grow_client, &state);
 }
 
-void client_maximize(XConf* xs, Client* c) {
+static void client_maximize(XConf* xs, Client* c) {
     int y = c->y, h = c->h;
     c->y = 0, c->h = HeightOfScreen(DefaultScreenOfDisplay(xs->display));
     client_reconfig(xs, c);
@@ -393,14 +402,14 @@ void client_maximize(XConf* xs, Client* c) {
 
 /* Desktop Management
  *****************************************************************************/
-void* hide_wins(Node* node, void* data) {
+static void* hide_wins(Node* node, void* data) {
     Client* c = TCLIENT(node);
     XUnmapWindow(X.display, c->frame);
     XUnmapWindow(X.display, c->win);
     return data;
 }
 
-void* show_wins(Node* node, void* data) {
+static void* show_wins(Node* node, void* data) {
     Client* c = TCLIENT(node);
     XMapWindow(X.display, c->frame);
     XMapWindow(X.display, c->win);
@@ -408,7 +417,7 @@ void* show_wins(Node* node, void* data) {
     return data;
 }
 
-void change_desktop(const Arg arg) {
+static void change_desktop(const Arg arg) {
     XGrabServer(X.display);
     list_reduce(Tiled_Clients,   hide_wins, NULL);
     list_reduce(Floated_Clients, hide_wins, NULL);
@@ -416,10 +425,10 @@ void change_desktop(const Arg arg) {
     list_reduce(Tiled_Clients,   show_wins, NULL);
     list_reduce(Floated_Clients, show_wins, NULL);
     XUngrabServer(X.display);
-    XSync(X.display, True);
+    XSync(X.display, False);
 }
 
-void client_to_desktop(const Arg arg) {
+static void client_to_desktop(const Arg arg) {
     int bar;
     Window foo, win;
     do{
@@ -431,7 +440,7 @@ void client_to_desktop(const Arg arg) {
     client_del(c);
     XUnmapWindow(X.display, c->frame);
     XUnmapWindow(X.display, c->win);
-    XSync(X.display, True);
+    XSync(X.display, False);
     client_add(c, arg.i);
 }