Adding launcher patch
This commit is contained in:
81
patch/bar_launcher.c
Normal file
81
patch/bar_launcher.c
Normal file
@ -0,0 +1,81 @@
|
||||
#if BAR_STATUS2D_PATCH
|
||||
int
|
||||
width_launcher(Bar *bar, BarArg *a)
|
||||
{
|
||||
int i, x = 0;
|
||||
|
||||
for (i = 0; i < LENGTH(launchers); i++) {
|
||||
x += status2dtextlength(launchers[i].name) + lrpad / 2;
|
||||
}
|
||||
return x ? x + lrpad / 2 : 0;
|
||||
}
|
||||
|
||||
int
|
||||
draw_launcher(Bar *bar, BarArg *a)
|
||||
{
|
||||
int i, w = 0;;
|
||||
|
||||
for (i = 0; i < LENGTH(launchers); i++) {
|
||||
w = status2dtextlength(launchers[i].name);
|
||||
drawstatusbar(a, launchers[i].name);
|
||||
a->x += w + lrpad / 2;
|
||||
}
|
||||
|
||||
return a->x ;
|
||||
}
|
||||
|
||||
int
|
||||
click_launcher(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
int i, x = 0;
|
||||
|
||||
for (i = 0; i < LENGTH(launchers); i++) {
|
||||
x += status2dtextlength(launchers[i].name) + lrpad / 2;
|
||||
if (a->x < x) {
|
||||
spawn(&launchers[i].command);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
int
|
||||
width_launcher(Bar *bar, BarArg *a)
|
||||
{
|
||||
int i, x = 0;
|
||||
|
||||
for (i = 0; i < LENGTH(launchers); i++) {
|
||||
x += TEXTW(launchers[i].name);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
int
|
||||
draw_launcher(Bar *bar, BarArg *a)
|
||||
{
|
||||
int i, x = 0, w = 0;;
|
||||
|
||||
for (i = 0; i < LENGTH(launchers); i++) {
|
||||
w = TEXTW(launchers[i].name);
|
||||
drw_text(drw, x, 0, w, bh, lrpad / 2, launchers[i].name, 0, True);
|
||||
x += w;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
int
|
||||
click_launcher(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
int i, x = 0;
|
||||
|
||||
for (i = 0; i < LENGTH(launchers); i++) {
|
||||
x += TEXTW(launchers[i].name);
|
||||
if (a->x < x) {
|
||||
spawn(&launchers[i].command);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#endif // BAR_STATUS2D_PATCH
|
8
patch/bar_launcher.h
Normal file
8
patch/bar_launcher.h
Normal file
@ -0,0 +1,8 @@
|
||||
typedef struct {
|
||||
char* name;
|
||||
const Arg command;
|
||||
} Launcher;
|
||||
|
||||
static int width_launcher(Bar *bar, BarArg *a);
|
||||
static int draw_launcher(Bar *bar, BarArg *a);
|
||||
static int click_launcher(Bar *bar, Arg *arg, BarArg *a);
|
@ -15,4 +15,3 @@ click_ltsymbol(Bar *bar, Arg *arg, BarArg *a)
|
||||
{
|
||||
return ClkLtSymbol;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
static int width_ltsymbol(Bar *bar, BarArg *a);
|
||||
static int draw_ltsymbol(Bar *bar, BarArg *a);
|
||||
static int click_ltsymbol(Bar *bar, Arg *arg, BarArg *a);
|
||||
|
||||
|
@ -21,6 +21,9 @@
|
||||
#if COMBO_PATCH
|
||||
#include "combo.c"
|
||||
#endif
|
||||
#if BAR_LAUNCHER_PATCH
|
||||
#include "bar_launcher.c"
|
||||
#endif
|
||||
#if BAR_LTSYMBOL_PATCH
|
||||
#include "bar_ltsymbol.c"
|
||||
#endif
|
||||
|
@ -24,6 +24,9 @@
|
||||
#if BAR_HOLDBAR_PATCH
|
||||
#include "bar_holdbar.h"
|
||||
#endif
|
||||
#if BAR_LAUNCHER_PATCH
|
||||
#include "bar_launcher.h"
|
||||
#endif
|
||||
#if BAR_LTSYMBOL_PATCH
|
||||
#include "bar_ltsymbol.h"
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user