Add a pointer to SLIST struct to store previous element
This will make back cycling faster
This commit is contained in:
parent
28af9e7e61
commit
f3652aaca6
|
@ -60,7 +60,7 @@ typedef struct item_t item_t;
|
||||||
struct item_t
|
struct item_t
|
||||||
{
|
{
|
||||||
char *data;
|
char *data;
|
||||||
item_t *next;
|
item_t *prev, *next;
|
||||||
Bool match;
|
Bool match;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ static void
|
||||||
redraw(void)
|
redraw(void)
|
||||||
{
|
{
|
||||||
item_t *item;
|
item_t *item;
|
||||||
Area geometry = { 0, 0, 0, 0, NULL };
|
Area geometry = { 0, 0, 0, 0, NULL, NULL };
|
||||||
Bool selected_item_is_drawn = False;
|
Bool selected_item_is_drawn = False;
|
||||||
int len, prompt_len, x_of_previous_item;
|
int len, prompt_len, x_of_previous_item;
|
||||||
|
|
||||||
|
@ -604,7 +604,7 @@ main(int argc, char **argv)
|
||||||
char *configfile = NULL, *cmd;
|
char *configfile = NULL, *cmd;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
const char *shell = getenv("SHELL");
|
const char *shell = getenv("SHELL");
|
||||||
Area geometry = { 0, 0, 0, 0, NULL };
|
Area geometry = { 0, 0, 0, 0, NULL, NULL };
|
||||||
static struct option long_options[] =
|
static struct option long_options[] =
|
||||||
{
|
{
|
||||||
{"help", 0, NULL, 'h'},
|
{"help", 0, NULL, 'h'},
|
||||||
|
|
|
@ -137,8 +137,8 @@ main(int argc, char **argv)
|
||||||
SimpleWindow *sw;
|
SimpleWindow *sw;
|
||||||
DrawCtx *ctx;
|
DrawCtx *ctx;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
Area geometry = { 0, 0, 200, 50, NULL },
|
Area geometry = { 0, 0, 200, 50, NULL, NULL },
|
||||||
icon_geometry = { -1, -1, -1, -1, NULL };
|
icon_geometry = { -1, -1, -1, -1, NULL, NULL };
|
||||||
int opt, ret;
|
int opt, ret;
|
||||||
int delay = 0;
|
int delay = 0;
|
||||||
char *configfile = NULL;
|
char *configfile = NULL;
|
||||||
|
|
|
@ -531,7 +531,7 @@ draw_image(DrawCtx *ctx, int x, int y, int wanted_h, const char *filename)
|
||||||
Area
|
Area
|
||||||
draw_get_image_size(const char *filename)
|
draw_get_image_size(const char *filename)
|
||||||
{
|
{
|
||||||
Area size = { -1, -1, -1, -1, NULL };
|
Area size = { -1, -1, -1, -1, NULL, NULL };
|
||||||
cairo_surface_t *surface;
|
cairo_surface_t *surface;
|
||||||
cairo_status_t cairo_st;
|
cairo_status_t cairo_st;
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ struct Area
|
||||||
int y;
|
int y;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
Area *next;
|
Area *prev, *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
DO_SLIST(Area, area, p_delete);
|
DO_SLIST(Area, area, p_delete);
|
||||||
|
|
|
@ -29,19 +29,25 @@
|
||||||
{ \
|
{ \
|
||||||
return item->next; \
|
return item->next; \
|
||||||
} \
|
} \
|
||||||
|
\
|
||||||
static inline type *prefix##_list_pop(type **list) \
|
static inline type *prefix##_list_pop(type **list) \
|
||||||
{ \
|
{ \
|
||||||
if (*list) \
|
if (*list) \
|
||||||
{ \
|
{ \
|
||||||
type *res = *list; \
|
type *res = *list; \
|
||||||
*list = res->next; \
|
*list = res->next; \
|
||||||
|
if(res->next) \
|
||||||
|
res->next->prev = NULL; \
|
||||||
res->next = NULL; \
|
res->next = NULL; \
|
||||||
return res; \
|
return res; \
|
||||||
} \
|
} \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
} \
|
} \
|
||||||
|
\
|
||||||
static inline void prefix##_list_push(type **list, type *item) \
|
static inline void prefix##_list_push(type **list, type *item) \
|
||||||
{ \
|
{ \
|
||||||
|
if(*list) \
|
||||||
|
(*list)->prev = item; \
|
||||||
item->next = *list; \
|
item->next = *list; \
|
||||||
*list = item; \
|
*list = item; \
|
||||||
} \
|
} \
|
||||||
|
@ -56,10 +62,14 @@
|
||||||
static inline void prefix##_list_append(type **list, type *item) \
|
static inline void prefix##_list_append(type **list, type *item) \
|
||||||
{ \
|
{ \
|
||||||
if(*(list = prefix##_list_last(list))) \
|
if(*(list = prefix##_list_last(list))) \
|
||||||
|
{ \
|
||||||
(*list)->next = item; \
|
(*list)->next = item; \
|
||||||
|
item->prev = *list; \
|
||||||
|
} \
|
||||||
else \
|
else \
|
||||||
(*list) = item; \
|
(*list) = item; \
|
||||||
} \
|
} \
|
||||||
|
\
|
||||||
static inline type *prefix##_list_rev(type *list) \
|
static inline type *prefix##_list_rev(type *list) \
|
||||||
{ \
|
{ \
|
||||||
type *l = NULL; \
|
type *l = NULL; \
|
||||||
|
@ -73,6 +83,7 @@
|
||||||
*list = NULL; \
|
*list = NULL; \
|
||||||
return list; \
|
return list; \
|
||||||
} \
|
} \
|
||||||
|
\
|
||||||
static inline void prefix##_list_wipe(type **list) \
|
static inline void prefix##_list_wipe(type **list) \
|
||||||
{ \
|
{ \
|
||||||
while (*list) \
|
while (*list) \
|
||||||
|
@ -81,62 +92,83 @@
|
||||||
dtor(&item); \
|
dtor(&item); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
static inline type *prefix##_list_prev(type **list, type *item) \
|
\
|
||||||
|
static inline type *prefix##_list_prev(type **list __attribute__ ((unused)), \
|
||||||
|
type *item) \
|
||||||
{ \
|
{ \
|
||||||
type *tmp; \
|
return item->prev; \
|
||||||
if(*list == item) return NULL; \
|
|
||||||
for(tmp = *list; tmp && tmp->next != item; tmp = tmp->next); \
|
|
||||||
return tmp; \
|
|
||||||
} \
|
} \
|
||||||
static inline void prefix##_list_swap(type **list, type *item1, \
|
\
|
||||||
type *item2) \
|
static inline void prefix##_list_swap(type **list, type *item1, type *item2) \
|
||||||
{ \
|
{ \
|
||||||
if(!item1 || !item2) return; \
|
if(!item1 || !item2) return; \
|
||||||
\
|
\
|
||||||
type *i1n = item1->next; \
|
type *i1n = item1->next; \
|
||||||
type *i2n = item2->next; \
|
type *i2n = item2->next; \
|
||||||
type * i1p = prefix##_list_prev(list, item1); \
|
type *i1p = item1->prev; \
|
||||||
type * i2p = prefix##_list_prev(list, item2); \
|
type *i2p = item2->prev; \
|
||||||
item1->next = i2n == item1 ? item2 : i2n; \
|
|
||||||
item2->next = i1n == item2 ? item1 : i1n; \
|
|
||||||
\
|
\
|
||||||
\
|
if(item1 == i2n) \
|
||||||
if(i1p && i1p != item2) \
|
{ \
|
||||||
i1p->next = item2; \
|
item1->next = item2; \
|
||||||
if(i2p && i2p != item1) \
|
item2->prev = item1; \
|
||||||
|
if((item1->prev = i2p)) \
|
||||||
i2p->next = item1; \
|
i2p->next = item1; \
|
||||||
\
|
if((item2->next = i1n)) \
|
||||||
|
i1n->prev = item2; \
|
||||||
|
} \
|
||||||
|
else if(item2 == i1n) \
|
||||||
|
{ \
|
||||||
|
item2->next = item1; \
|
||||||
|
item1->prev = item2; \
|
||||||
|
if((item2->prev = i1p)) \
|
||||||
|
i1p->next = item2; \
|
||||||
|
if((item1->next = i2n)) \
|
||||||
|
i2n->prev = item1; \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
if((item1->next = i2n)) \
|
||||||
|
item1->next->prev = item1; \
|
||||||
|
if((item1->prev = i2p)) \
|
||||||
|
item1->prev->next = item1; \
|
||||||
|
if((item2->prev = i1p)) \
|
||||||
|
item2->prev->next = item2; \
|
||||||
|
if((item2->next = i1n)) \
|
||||||
|
item2->next->prev = item2; \
|
||||||
|
} \
|
||||||
if(*list == item1) \
|
if(*list == item1) \
|
||||||
*list = item2; \
|
*list = item2; \
|
||||||
else if(*list == item2) \
|
else if(*list == item2) \
|
||||||
*list = item1; \
|
*list = item1; \
|
||||||
} \
|
} \
|
||||||
|
\
|
||||||
static inline type *prefix##_list_prev_cycle(type **list, type *item) \
|
static inline type *prefix##_list_prev_cycle(type **list, type *item) \
|
||||||
{ \
|
{ \
|
||||||
type *tmp = prefix##_list_prev(list, item); \
|
if(!item->prev) \
|
||||||
if(!tmp) \
|
return *prefix##_list_last(list); \
|
||||||
tmp = *prefix##_list_last(list); \
|
return item->prev; \
|
||||||
return tmp; \
|
|
||||||
} \
|
} \
|
||||||
|
\
|
||||||
static inline type *prefix##_list_next_cycle(type **list, type *item) \
|
static inline type *prefix##_list_next_cycle(type **list, type *item) \
|
||||||
{ \
|
|
||||||
if(item) \
|
|
||||||
{ \
|
{ \
|
||||||
if(item->next) \
|
if(item->next) \
|
||||||
return item->next; \
|
return item->next; \
|
||||||
else \
|
else \
|
||||||
return *list; \
|
return *list; \
|
||||||
} \
|
|
||||||
return NULL; \
|
return NULL; \
|
||||||
} \
|
} \
|
||||||
|
\
|
||||||
static inline void prefix##_list_detach(type **list, type *item) \
|
static inline void prefix##_list_detach(type **list, type *item) \
|
||||||
{ \
|
{ \
|
||||||
type *prev = prefix##_list_prev(list, item); \
|
|
||||||
if(prev) \
|
|
||||||
prev->next = item->next; \
|
|
||||||
if(item == *list) \
|
if(item == *list) \
|
||||||
*list = item->next; \
|
*list = item->next; \
|
||||||
|
else if(item->prev) \
|
||||||
|
item->prev->next = item->next; \
|
||||||
|
if(item->next) \
|
||||||
|
item->next->prev = item->prev; \
|
||||||
item->next = NULL; \
|
item->next = NULL; \
|
||||||
|
item->prev = NULL; \
|
||||||
} \
|
} \
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
2
layout.h
2
layout.h
|
@ -35,7 +35,7 @@ struct Layout
|
||||||
{
|
{
|
||||||
char *image;
|
char *image;
|
||||||
LayoutArrange *arrange;
|
LayoutArrange *arrange;
|
||||||
Layout *next;
|
Layout *prev, *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
DO_SLIST(Layout, layout, p_delete);
|
DO_SLIST(Layout, layout, p_delete);
|
||||||
|
|
|
@ -133,7 +133,7 @@ _tile(int screen, const Position position)
|
||||||
unsigned int mw = 0, mh = 0;
|
unsigned int mw = 0, mh = 0;
|
||||||
int n, i, masterwin = 0, otherwin = 0;
|
int n, i, masterwin = 0, otherwin = 0;
|
||||||
int real_ncol = 1, win_by_col = 1, current_col = 0;
|
int real_ncol = 1, win_by_col = 1, current_col = 0;
|
||||||
Area area, geometry = { 0, 0, 0, 0, NULL };
|
Area area, geometry = { 0, 0, 0, 0, NULL, NULL };
|
||||||
Client *c;
|
Client *c;
|
||||||
Tag **curtags = tags_get_current(screen);
|
Tag **curtags = tags_get_current(screen);
|
||||||
|
|
||||||
|
|
2
mouse.c
2
mouse.c
|
@ -149,7 +149,7 @@ uicb_client_resizemouse(int screen, char *arg __attribute__ ((unused)))
|
||||||
Client *c = globalconf.focus->client;
|
Client *c = globalconf.focus->client;
|
||||||
Tag **curtags = tags_get_current(screen);
|
Tag **curtags = tags_get_current(screen);
|
||||||
Layout *layout = curtags[0]->layout;
|
Layout *layout = curtags[0]->layout;
|
||||||
Area area = { 0, 0, 0, 0 , NULL}, geometry;
|
Area area = { 0, 0, 0, 0, NULL, NULL }, geometry;
|
||||||
double mwfact;
|
double mwfact;
|
||||||
|
|
||||||
/* only handle floating and tiled layouts */
|
/* only handle floating and tiled layouts */
|
||||||
|
|
|
@ -64,7 +64,7 @@ Area
|
||||||
placement_smart(Area geometry, int border, int screen)
|
placement_smart(Area geometry, int border, int screen)
|
||||||
{
|
{
|
||||||
Client *c;
|
Client *c;
|
||||||
Area newgeometry = { 0, 0, 0, 0, NULL };
|
Area newgeometry = { 0, 0, 0, 0, NULL, NULL };
|
||||||
Area *screen_geometry, *arealist = NULL, *r;
|
Area *screen_geometry, *arealist = NULL, *r;
|
||||||
Bool found = False;
|
Bool found = False;
|
||||||
|
|
||||||
|
|
2
screen.c
2
screen.c
|
@ -81,7 +81,7 @@ screen_get_area(int screen, Statusbar *statusbar, Padding *padding)
|
||||||
Area
|
Area
|
||||||
get_display_area(int screen, Statusbar *statusbar, Padding *padding)
|
get_display_area(int screen, Statusbar *statusbar, Padding *padding)
|
||||||
{
|
{
|
||||||
Area area = { 0, 0, 0, 0, NULL };
|
Area area = { 0, 0, 0, 0, NULL, NULL };
|
||||||
Statusbar *sb;
|
Statusbar *sb;
|
||||||
|
|
||||||
area.width = DisplayWidth(globalconf.display, screen);
|
area.width = DisplayWidth(globalconf.display, screen);
|
||||||
|
|
|
@ -74,7 +74,7 @@ statusbar_draw(Statusbar *statusbar)
|
||||||
int phys_screen = get_phys_screen(statusbar->screen);
|
int phys_screen = get_phys_screen(statusbar->screen);
|
||||||
Widget *widget;
|
Widget *widget;
|
||||||
int left = 0, right = 0;
|
int left = 0, right = 0;
|
||||||
Area rectangle = { 0, 0, 0, 0, NULL };
|
Area rectangle = { 0, 0, 0, 0, NULL, NULL };
|
||||||
Drawable d;
|
Drawable d;
|
||||||
|
|
||||||
/* don't waste our time */
|
/* don't waste our time */
|
||||||
|
|
31
structs.h
31
structs.h
|
@ -66,7 +66,8 @@ struct Rule
|
||||||
regex_t *prop_r;
|
regex_t *prop_r;
|
||||||
regex_t *tags_r;
|
regex_t *tags_r;
|
||||||
regex_t *xpropval_r;
|
regex_t *xpropval_r;
|
||||||
Rule *next;
|
/** Next and previous rules */
|
||||||
|
Rule *prev, *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Key bindings */
|
/** Key bindings */
|
||||||
|
@ -77,7 +78,8 @@ struct Key
|
||||||
KeyCode keycode;
|
KeyCode keycode;
|
||||||
Uicb *func;
|
Uicb *func;
|
||||||
char *arg;
|
char *arg;
|
||||||
Key *next;
|
/** Next and previous keys */
|
||||||
|
Key *prev, *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Mouse buttons bindings */
|
/** Mouse buttons bindings */
|
||||||
|
@ -88,7 +90,8 @@ struct Button
|
||||||
unsigned int button;
|
unsigned int button;
|
||||||
Uicb *func;
|
Uicb *func;
|
||||||
char *arg;
|
char *arg;
|
||||||
Button *next;
|
/** Next and previous buttons */
|
||||||
|
Button *prev, *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Widget tell status code */
|
/** Widget tell status code */
|
||||||
|
@ -138,8 +141,8 @@ struct Widget
|
||||||
Bool needs_update;
|
Bool needs_update;
|
||||||
int flags;
|
int flags;
|
||||||
} cache;
|
} cache;
|
||||||
/** Next widget */
|
/** Next and previous widgets */
|
||||||
Widget *next;
|
Widget *prev, *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Status bar */
|
/** Status bar */
|
||||||
|
@ -161,8 +164,8 @@ struct Statusbar
|
||||||
int screen;
|
int screen;
|
||||||
/** Widget list */
|
/** Widget list */
|
||||||
Widget *widgets;
|
Widget *widgets;
|
||||||
/** Next statusbar */
|
/** Next and previous statusbars */
|
||||||
Statusbar *next;
|
Statusbar *prev, *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Client type */
|
/** Client type */
|
||||||
|
@ -194,8 +197,8 @@ struct Client
|
||||||
Bool skip;
|
Bool skip;
|
||||||
/** True if the client must be skipped from task bar client list */
|
/** True if the client must be skipped from task bar client list */
|
||||||
Bool skiptb;
|
Bool skiptb;
|
||||||
/** Next client */
|
/** Next and previous clients */
|
||||||
Client *next;
|
Client *prev, *next;
|
||||||
/** Window of the client */
|
/** Window of the client */
|
||||||
Window win;
|
Window win;
|
||||||
/** Client logical screen */
|
/** Client logical screen */
|
||||||
|
@ -208,7 +211,8 @@ typedef struct client_node_t client_node_t;
|
||||||
struct client_node_t
|
struct client_node_t
|
||||||
{
|
{
|
||||||
Client *client;
|
Client *client;
|
||||||
client_node_t *next;
|
/** Next and previous client_nodes */
|
||||||
|
client_node_t *prev, *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Tag type */
|
/** Tag type */
|
||||||
|
@ -231,8 +235,8 @@ struct Tag
|
||||||
int nmaster;
|
int nmaster;
|
||||||
/** Number of columns in tile layout */
|
/** Number of columns in tile layout */
|
||||||
int ncol;
|
int ncol;
|
||||||
/** Next tag */
|
/** Next and previous tags */
|
||||||
Tag *next;
|
Tag *prev, *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** tag_client_node type */
|
/** tag_client_node type */
|
||||||
|
@ -241,7 +245,8 @@ struct tag_client_node_t
|
||||||
{
|
{
|
||||||
Tag *tag;
|
Tag *tag;
|
||||||
Client *client;
|
Client *client;
|
||||||
tag_client_node_t *next;
|
/** Next and previous tag_client_nodes */
|
||||||
|
tag_client_node_t *prev, *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Padding type */
|
/** Padding type */
|
||||||
|
|
|
@ -116,7 +116,7 @@ taglist_draw(Widget *widget,
|
||||||
widget->area.y,
|
widget->area.y,
|
||||||
flagsize,
|
flagsize,
|
||||||
flagsize,
|
flagsize,
|
||||||
NULL };
|
NULL, NULL };
|
||||||
draw_rectangle(ctx, rectangle, sel && is_client_tagged(sel, tag), colors[ColFG]);
|
draw_rectangle(ctx, rectangle, sel && is_client_tagged(sel, tag), colors[ColFG]);
|
||||||
}
|
}
|
||||||
widget->area.width += w;
|
widget->area.width += w;
|
||||||
|
|
Loading…
Reference in New Issue