split config.h, and move DO_SLIST()

This commit is contained in:
Julien Danjou 2008-01-13 15:44:01 +01:00
parent f700e483d6
commit 0b5e3e7cd1
10 changed files with 349 additions and 318 deletions

View file

@ -83,7 +83,6 @@ awesome_SOURCES = \
tag.c tag.h \
util.c util.h \
xutil.c xutil.h \
list.h \
config.c config.h \
screen.c screen.h \
statusbar.c statusbar.h \
@ -93,7 +92,8 @@ awesome_SOURCES = \
mouse.c mouse.h \
awesome-client-common.c \
widget.c widget.h \
ewmh.c ewmh.h
ewmh.c ewmh.h \
list.h structs.h
awesome_SOURCES += $(LAYOUTS)
awesome_SOURCES += $(WIDGETS)
awesome_LDADD = $(XFT_LIBS) $(X_LIBS) $(CAIRO_LIBS) $(CONFUSE_LIBS) $(XRANDR_LIBS) $(XINERAMA_LIBS)

View file

@ -22,7 +22,7 @@
#ifndef AWESOME_CLIENT_H
#define AWESOME_CLIENT_H
#include "config.h"
#include "structs.h"
Bool client_isvisible(Client *, int);
Client * get_client_bywin(Client *, Window);
@ -50,5 +50,7 @@ Uicb uicb_client_toggleverticalmax;
Uicb uicb_client_togglehorizontalmax;
Uicb uicb_client_zoom;
DO_SLIST(Client, client, p_delete);
#endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View file

@ -26,6 +26,7 @@
#include <X11/keysym.h>
#include "statusbar.h"
#include "tag.h"
#include "util.h"
#include "rules.h"
#include "screen.h"

311
config.h
View file

@ -22,319 +22,10 @@
#ifndef AWESOME_CONFIG_H
#define AWESOME_CONFIG_H
#include <regex.h>
#include "draw.h"
#include "layout.h"
/** Bar possible position */
typedef enum
{
Top,
Bottom,
Left,
Right,
Off
} Position;
typedef enum
{
Float,
Tile,
Auto,
} RuleFloat;
/** Common colors */
enum
{ ColBorder, ColFG, ColBG, ColLast };
enum
{ CurNormal, CurResize, CurMove, CurLast }; /* cursor */
typedef struct Rule Rule;
struct Rule
{
char *icon;
char *xprop;
int screen;
RuleFloat isfloating;
Bool not_master;
regex_t *prop_r;
regex_t *tags_r;
regex_t *xpropval_r;
Rule *next;
};
DO_SLIST(Rule, rule, p_delete);
typedef struct AwesomeConf AwesomeConf;
typedef struct Key Key;
struct Key
{
unsigned long mod;
KeySym keysym;
Uicb *func;
char *arg;
Key *next;
};
#include "structs.h"
DO_SLIST(Key, key, p_delete);
typedef struct Button Button;
struct Button
{
unsigned long mod;
unsigned int button;
Uicb *func;
char *arg;
Button *next;
};
DO_SLIST(Button, button, p_delete);
/** Widget */
typedef struct Widget Widget;
typedef struct Statusbar Statusbar;
struct Widget
{
/** Widget name */
char *name;
/** Draw function */
int (*draw)(Widget *, DrawCtx *, int, int);
/** Update function */
void (*tell)(Widget *, char *);
/** ButtonPressedEvent handler */
void (*button_press)(Widget *, XButtonPressedEvent *);
/** Statusbar */
Statusbar *statusbar;
/** Alignement */
Alignment alignment;
/** Misc private data */
void *data;
/** True if user supplied coords */
Bool user_supplied_x;
Bool user_supplied_y;
/** Area */
Area area;
/** Buttons bindings */
Button *buttons;
/** Font */
XftFont *font;
/** Cache */
struct
{
Bool needs_update;
int flags;
} cache;
/** Next widget */
Widget *next;
};
DO_SLIST(Widget, widget, p_delete);
/** Status bar */
struct Statusbar
{
/** Statusbar name */
char *name;
/** Bar width */
int width;
/** Bar height */
int height;
/** Layout txt width */
int txtlayoutwidth;
/** Default position */
Position dposition;
/** Bar position */
Position position;
/** Window */
Window window;
/** Screen */
int screen;
/** Widget list */
Widget *widgets;
/** Drawable */
Drawable drawable;
/** Next statusbar */
Statusbar *next;
};
DO_SLIST(Statusbar, statusbar, p_delete);
typedef struct Client Client;
struct Client
{
/** Client name */
char name[256];
/** Window geometry */
Area geometry;
/** Floating window geometry */
Area f_geometry;
/** Max window geometry */
Area m_geometry;
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int minax, maxax, minay, maxay;
int border, oldborder;
/** Has urgency hint */
Bool isurgent;
/** Store previous floating state before maximizing */
Bool wasfloating;
/** True if the window is floating */
Bool isfloating;
/** True if the window is fixed */
Bool isfixed;
/** True if the window is maximized */
Bool ismax;
/** True if the client must be skipped from client list */
Bool skip;
/** True if the client must be skipped from task bar client list */
Bool skiptb;
/** Next client */
Client *next;
/** Window of the client */
Window win;
/** Client logical screen */
int screen;
/** True if the client is a new one */
Bool newcomer;
};
DO_SLIST(Client, client, p_delete);
typedef struct client_node_t client_node_t;
struct client_node_t
{
Client *client;
client_node_t *next;
};
DO_SLIST(client_node_t, client_node, p_delete);
/** Tag type */
typedef struct Tag Tag;
struct Tag
{
/** Tag name */
char *name;
/** True if selected */
Bool selected;
/** True if was selected before selecting others tags */
Bool was_selected;
/** Current tag layout */
Layout *layout;
/** Master width factor */
double mwfact;
/** Number of master windows */
int nmaster;
/** Number of columns in tile layout */
int ncol;
/** Next tag */
Tag *next;
};
DO_SLIST(Tag, tag, p_delete);
/** tag_client_node type */
typedef struct tag_client_node_t tag_client_node_t;
struct tag_client_node_t
{
Tag *tag;
Client *client;
tag_client_node_t *next;
};
DO_SLIST(tag_client_node_t, tag_client_node, p_delete);
/** Padding type */
typedef struct
{
/** Padding at top */
int top;
/** Padding at bottom */
int bottom;
/** Padding at left */
int left;
/** Padding at right */
int right;
} Padding;
typedef struct
{
/** Number of pixels to snap windows */
int snap;
/** Border size */
int borderpx;
/** Transparency of unfocused clients */
int opacity_unfocused;
/** Focus move pointer */
Bool focus_move_pointer;
/** Allow floats to be lowered on focus change */
Bool allow_lower_floats;
/** Respect resize hints */
Bool resize_hints;
/** Sloppy focus: focus follow mouse */
Bool sloppy_focus;
/** Focus new clients */
Bool new_get_focus;
/** True if new clients should become master */
Bool new_become_master;
/** Normal colors */
XColor colors_normal[ColLast];
/** Selected colors */
XColor colors_selected[ColLast];
/** Urgency colors */
XColor colors_urgent[ColLast];
/** Tag list */
Tag *tags;
/** Layout list */
Layout *layouts;
/** Status bar */
Statusbar *statusbar;
/** Padding */
Padding padding;
/** Font */
XftFont *font;
} VirtScreen;
/** Main configuration structure */
struct AwesomeConf
{
/** Display ref */
Display *display;
/** Logical screens */
VirtScreen *screens;
/** Number of logical screens */
int nscreens;
/** Rules list */
Rule *rules;
/** Keys bindings list */
Key *keys;
/** Mouse bindings list */
struct
{
Button *root;
Button *client;
} buttons;
/** Numlock mask */
unsigned int numlockmask;
/** Check for XShape extension */
Bool have_shape;
/** Check for XRandR extension */
Bool have_randr;
/** Cursors */
Cursor cursor[CurLast];
/** Clients list */
Client *clients;
/** Path to config file */
char *configpath;
/** Selected clients history */
client_node_t *focus;
/** Link between tags and clients */
tag_client_node_t *tclink;
/** Command line passed to awesome */
char *argv;
};
void config_parse(const char *);
#endif

View file

@ -22,7 +22,7 @@
#ifndef AWESOME_FOCUS_H
#define AWESOME_FOCUS_H
#include "config.h"
#include "structs.h"
void focus_add_client(Client *);
void focus_delete_client(Client *);
@ -31,5 +31,7 @@ Client * focus_get_current_client(int);
Uicb uicb_focus_history;
Uicb uicb_focus_client_byname;
DO_SLIST(client_node_t, client_node, p_delete);
#endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View file

@ -22,7 +22,7 @@
#ifndef AWESOME_RULES_H
#define AWESOME_RULES_H
#include "config.h"
#include "structs.h"
#define RULE_NOSCREEN -1
@ -31,5 +31,7 @@ Bool tag_match_rule(Tag *, Rule *);
RuleFloat rules_get_float_from_str(const char *);
Rule * rule_matching_client(Client *);
DO_SLIST(Rule, rule, p_delete);
#endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View file

@ -22,7 +22,7 @@
#ifndef AWESOME_STATUSBAR_H
#define AWESOME_STATUSBAR_H
#include "config.h"
#include "structs.h"
void statusbar_refresh(void);
void statusbar_init(Statusbar *, int);
@ -31,5 +31,7 @@ Position statusbar_get_position_from_str(const char *);
Uicb uicb_statusbar_toggle;
DO_SLIST(Statusbar, statusbar, p_delete);
#endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

326
structs.h Normal file
View file

@ -0,0 +1,326 @@
/*
* structs.h - basic structs header
*
* Copyright © 2007-2008 Julien Danjou <julien@danjou.info>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef AWESOME_STRUCTS_H
#define AWESOME_STRUCTS_H
#include <regex.h>
#include "draw.h"
#include "layout.h"
/** Bar possible position */
typedef enum
{
Top,
Bottom,
Left,
Right,
Off
} Position;
/** Rules for floating rule */
typedef enum
{
Float,
Tile,
Auto,
} RuleFloat;
/** Common colors */
enum
{ ColBorder, ColFG, ColBG, ColLast };
/** Cursors */
enum
{ CurNormal, CurResize, CurMove, CurLast };
/** Rule type */
typedef struct Rule Rule;
struct Rule
{
char *icon;
char *xprop;
int screen;
RuleFloat isfloating;
Bool not_master;
regex_t *prop_r;
regex_t *tags_r;
regex_t *xpropval_r;
Rule *next;
};
/** Key bindings */
typedef struct Key Key;
struct Key
{
unsigned long mod;
KeySym keysym;
Uicb *func;
char *arg;
Key *next;
};
/** Mouse buttons bindings */
typedef struct Button Button;
struct Button
{
unsigned long mod;
unsigned int button;
Uicb *func;
char *arg;
Button *next;
};
/** Widget */
typedef struct Widget Widget;
typedef struct Statusbar Statusbar;
struct Widget
{
/** Widget name */
char *name;
/** Draw function */
int (*draw)(Widget *, DrawCtx *, int, int);
/** Update function */
void (*tell)(Widget *, char *);
/** ButtonPressedEvent handler */
void (*button_press)(Widget *, XButtonPressedEvent *);
/** Statusbar */
Statusbar *statusbar;
/** Alignement */
Alignment alignment;
/** Misc private data */
void *data;
/** True if user supplied coords */
Bool user_supplied_x;
Bool user_supplied_y;
/** Area */
Area area;
/** Buttons bindings */
Button *buttons;
/** Font */
XftFont *font;
/** Cache */
struct
{
Bool needs_update;
int flags;
} cache;
/** Next widget */
Widget *next;
};
/** Status bar */
struct Statusbar
{
/** Statusbar name */
char *name;
/** Bar width */
int width;
/** Bar height */
int height;
/** Layout txt width */
int txtlayoutwidth;
/** Default position */
Position dposition;
/** Bar position */
Position position;
/** Window */
Window window;
/** Screen */
int screen;
/** Widget list */
Widget *widgets;
/** Drawable */
Drawable drawable;
/** Next statusbar */
Statusbar *next;
};
/** Client type */
typedef struct Client Client;
struct Client
{
/** Client name */
char name[256];
/** Window geometry */
Area geometry;
/** Floating window geometry */
Area f_geometry;
/** Max window geometry */
Area m_geometry;
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int minax, maxax, minay, maxay;
int border, oldborder;
/** Has urgency hint */
Bool isurgent;
/** Store previous floating state before maximizing */
Bool wasfloating;
/** True if the window is floating */
Bool isfloating;
/** True if the window is fixed */
Bool isfixed;
/** True if the window is maximized */
Bool ismax;
/** True if the client must be skipped from client list */
Bool skip;
/** True if the client must be skipped from task bar client list */
Bool skiptb;
/** Next client */
Client *next;
/** Window of the client */
Window win;
/** Client logical screen */
int screen;
/** True if the client is a new one */
Bool newcomer;
};
typedef struct client_node_t client_node_t;
struct client_node_t
{
Client *client;
client_node_t *next;
};
/** Tag type */
typedef struct Tag Tag;
struct Tag
{
/** Tag name */
char *name;
/** True if selected */
Bool selected;
/** True if was selected before selecting others tags */
Bool was_selected;
/** Current tag layout */
Layout *layout;
/** Master width factor */
double mwfact;
/** Number of master windows */
int nmaster;
/** Number of columns in tile layout */
int ncol;
/** Next tag */
Tag *next;
};
/** tag_client_node type */
typedef struct tag_client_node_t tag_client_node_t;
struct tag_client_node_t
{
Tag *tag;
Client *client;
tag_client_node_t *next;
};
/** Padding type */
typedef struct
{
/** Padding at top */
int top;
/** Padding at bottom */
int bottom;
/** Padding at left */
int left;
/** Padding at right */
int right;
} Padding;
typedef struct
{
/** Number of pixels to snap windows */
int snap;
/** Border size */
int borderpx;
/** Transparency of unfocused clients */
int opacity_unfocused;
/** Focus move pointer */
Bool focus_move_pointer;
/** Allow floats to be lowered on focus change */
Bool allow_lower_floats;
/** Respect resize hints */
Bool resize_hints;
/** Sloppy focus: focus follow mouse */
Bool sloppy_focus;
/** Focus new clients */
Bool new_get_focus;
/** True if new clients should become master */
Bool new_become_master;
/** Normal colors */
XColor colors_normal[ColLast];
/** Selected colors */
XColor colors_selected[ColLast];
/** Urgency colors */
XColor colors_urgent[ColLast];
/** Tag list */
Tag *tags;
/** Layout list */
Layout *layouts;
/** Status bar */
Statusbar *statusbar;
/** Padding */
Padding padding;
/** Font */
XftFont *font;
} VirtScreen;
/** Main configuration structure */
typedef struct AwesomeConf AwesomeConf;
struct AwesomeConf
{
/** Display ref */
Display *display;
/** Logical screens */
VirtScreen *screens;
/** Number of logical screens */
int nscreens;
/** Rules list */
Rule *rules;
/** Keys bindings list */
Key *keys;
/** Mouse bindings list */
struct
{
Button *root;
Button *client;
} buttons;
/** Numlock mask */
unsigned int numlockmask;
/** Check for XShape extension */
Bool have_shape;
/** Check for XRandR extension */
Bool have_randr;
/** Cursors */
Cursor cursor[CurLast];
/** Clients list */
Client *clients;
/** Path to config file */
char *configpath;
/** Selected clients history */
client_node_t *focus;
/** Link between tags and clients */
tag_client_node_t *tclink;
/** Command line passed to awesome */
char *argv;
};
#endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

5
tag.h
View file

@ -22,7 +22,7 @@
#ifndef AWESOME_TAG_H
#define AWESOME_TAG_H
#include "config.h"
#include "structs.h"
/** Check if a client is tiled */
#define IS_TILED(client, screen) (client && !client->isfloating && client_isvisible(client, screen))
@ -44,5 +44,8 @@ Uicb uicb_tag_viewnext;
Uicb uicb_tag_viewprev;
Uicb uicb_tag_create;
DO_SLIST(Tag, tag, p_delete);
DO_SLIST(tag_client_node_t, tag_client_node, p_delete);
#endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View file

@ -25,7 +25,7 @@
#include <confuse.h>
#include "config.h"
#include "structs.h"
#define WIDGET_CACHE_CLIENTS 1<<0
#define WIDGET_CACHE_LAYOUTS 1<<1
@ -51,6 +51,8 @@ WidgetConstructor tasklist_new;
Uicb uicb_widget_tell;
DO_SLIST(Widget, widget, p_delete);
#endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80