Don't define USE*

This commit is contained in:
Jacob 2023-08-07 06:37:38 +02:00
parent 8128ba040f
commit 3bc8d85937
26 changed files with 158 additions and 206 deletions

View file

@ -188,15 +188,15 @@ void moveend(Arg *arg) {
}
void paste(Arg *arg) {
#if USEWAYLAND
#if WAYLAND
if (protocol) {
paste_wl();
} else {
#if USEX
#if X11
paste_x11(arg->i);
#endif
}
#elif USEX
#elif X11
paste_x11(arg->i);
#endif
}
@ -408,14 +408,14 @@ void setlineheight(Arg *arg) {
}
void setimgsize(Arg *arg) {
#if USEIMAGE
#if IMAGE
setimagesize(img.imagewidth + arg->i, img.imageheight + arg->i);
drawmenu();
#endif
}
void flipimg(Arg *arg) {
#if USEIMAGE
#if IMAGE
if (!image) return;
@ -427,7 +427,7 @@ void flipimg(Arg *arg) {
}
void setimgpos(Arg *arg) {
#if USEIMAGE
#if IMAGE
if (!image || hideimage) return;
if (imageposition < 3) {
@ -441,7 +441,7 @@ void setimgpos(Arg *arg) {
}
void setimggaps(Arg *arg) {
#if USEIMAGE
#if IMAGE
img.imagegaps += arg->i;
if (img.imagegaps < 0)
@ -511,7 +511,7 @@ void togglehighlight(Arg *arg) {
}
void toggleregex(Arg *arg) {
#if USEREGEX
#if REGEX
regex = !regex;
match();
@ -528,7 +528,7 @@ void togglefuzzy(Arg *arg) {
}
void toggleimg(Arg *arg) {
#if USEIMAGE
#if IMAGE
hideimage = !hideimage;
@ -538,7 +538,7 @@ void toggleimg(Arg *arg) {
}
void defaultimg(Arg *arg) {
#if USEIMAGE
#if IMAGE
if (hideimage || !image) return;

View file

@ -9,8 +9,8 @@ void readargs(int argc, char *argv[]) {
int j = 0;
int k = 0;
#if !USEX
#if !USEWAYLAND
#if !X11
#if !WAYLAND
die("Why did you think it was a good idea to compile me without support for any display server? You're an idiot. :)");
#endif
#endif
@ -40,7 +40,7 @@ void readargs(int argc, char *argv[]) {
} else if (!strcmp(argv[j], "-wl") || (!strcmp(argv[j], "--wayland"))) {
protocol = 1;
protocol_override = 1;
#if USECONFIG
#if CONFIG
} else if (!strcmp(argv[j], "-cf") || (!strcmp(argv[j], "--config-file"))) { // specify a config file
if (argv[j+1]) {
configfile = argv[++j];
@ -63,7 +63,7 @@ void readargs(int argc, char *argv[]) {
}
}
#if USECONFIG
#if CONFIG
conf_init();
#endif
@ -75,13 +75,13 @@ void readargs(int argc, char *argv[]) {
}
}
#if USEWAYLAND
#if WAYLAND
if (protocol) {
if (connect_display(&state)) {
protocol = 0;
}
}
#if USEX
#if X11
if (getenv("GNOME_SETUP_DISPLAY")) { // This is a GNOME Wayland session which doesn't implement wlr-layer-shell
protocol = 0;
}
@ -89,9 +89,9 @@ void readargs(int argc, char *argv[]) {
#endif
// init/read xrdb
#if USEX
#if X11
if (xresources && !protocol) {
#if USEXRESOURCES
#if XRESOURCES
XrmInitialize();
load_xresources();
#else
@ -285,7 +285,7 @@ void readargs(int argc, char *argv[]) {
|| !strcmp(argv[i], "--x11")
|| !strcmp(argv[i], "--load-binds")
|| !strcmp(argv[i], "--no-load-binds")
#if USECONFIG
#if CONFIG
|| !strcmp(argv[i], "-cf")
|| !strcmp(argv[i], "--config-file")
|| (configfile && !strcmp(argv[i], configfile))
@ -413,7 +413,7 @@ void readargs(int argc, char *argv[]) {
} else if (!strcmp(argv[i], "-nir") || (!strcmp(argv[i], "--no-image-resize"))) { // no image resize
imageresize = 0;
} else if (!strcmp(argv[i], "-w") || (!strcmp(argv[i], "--embed"))) { // embedding window id
#if USEX
#if X11
x11.embed = argv[++i];
#endif
} else if (!strcmp(argv[i], "-n") || (!strcmp(argv[i], "--preselect"))) { // preselected item
@ -520,7 +520,7 @@ void readargs(int argc, char *argv[]) {
|| !strcmp(argv[i], "--x11")
|| !strcmp(argv[i], "--load-binds")
|| !strcmp(argv[i], "--no-load-binds")
#if USECONFIG
#if CONFIG
|| !strcmp(argv[i], "-cf")
|| !strcmp(argv[i], "--config-file")
|| (configfile && !strcmp(argv[i], configfile))
@ -536,10 +536,10 @@ void readargs(int argc, char *argv[]) {
else
fprintf(stderr, "spmenu: Invalid argument: '%s'\n", argv[i]);
#if !USEX
#if !X11
protocol = 1;
#endif
#if !USEWAYLAND
#if !WAYLAND
protocol = 0;
#endif
if (casesensitive) {
@ -559,37 +559,37 @@ void readargs(int argc, char *argv[]) {
}
void comp_opts(void) {
#if USEWAYLAND
#if WAYLAND
fprintf(stdout, "Wayland: Supported\n");
#else
fprintf(stdout, "Wayland: Unsupported\n");
#endif
#if USEX
#if X11
fprintf(stdout, "X11: Supported\n");
#else
fprintf(stdout, "X11: Unsupported\n");
#endif
#if USERTL
#if RTL
fprintf(stdout, "RTL: Supported\n");
#else
fprintf(stdout, "RTL: Unsupported\n");
#endif
#if USEIMAGE
#if IMAGE
fprintf(stdout, "Images: Supported\n");
#else
fprintf(stdout, "Images: Unsupported\n");
#endif
#if USEXINERAMA
#if XINERAMA
fprintf(stdout, "Xinerama: Supported\n");
#else
fprintf(stdout, "Xinerama: Unsupported\n");
#endif
#if USECONFIG
#if CONFIG
fprintf(stdout, "Config: Supported\n");
#else
fprintf(stdout, "Config: Unsupported\n");
#endif
#if USEXRESOURCES
#if XRESOURCES
fprintf(stdout, "xrdb: Supported\n");
#else
fprintf(stdout, "xrdb: Unsupported\n");

View file

@ -1,5 +1,5 @@
/* See LICENSE file for copyright and license details. */
#if USECONFIG
#if CONFIG
#include <libconfig.h>
#include "config.h"
@ -63,7 +63,7 @@ int bind_init(void) {
// look up
config_setting_lookup_string(conf, "modifier", &dest);
#if USEX
#if X11
for (int j = 0; j < LENGTH(ml); j++) {
if (!strcmp(ml[j].mod, strdup(dest))) {
ckeys[i].mod = ml[j].modifier;
@ -71,7 +71,7 @@ int bind_init(void) {
}
#endif
#if USEWAYLAND
#if WAYLAND
for (int j = 0; j < LENGTH(wml); j++) {
if (!strcmp(wml[j].mod, strdup(dest))) {
wl_ckeys[i].modifier = wml[j].modifier;
@ -80,17 +80,17 @@ int bind_init(void) {
#endif
if (config_setting_lookup_int(conf, "mode", &nmode)) {
#if USEX
#if X11
ckeys[i].mode = nmode;
#endif
#if USEWAYLAND
#if WAYLAND
wl_ckeys[i].mode = nmode;
#endif
}
config_setting_lookup_string(conf, "key", &dest);
#if USEX
#if X11
for (int j = 0; j < LENGTH(kl); j++) {
if (!strcmp(kl[j].key, strdup(dest))) {
ckeys[i].keysym = kl[j].keysym;
@ -98,7 +98,7 @@ int bind_init(void) {
}
#endif
#if USEWAYLAND
#if WAYLAND
for (int j = 0; j < LENGTH(wkl); j++) {
if (!strcmp(wkl[j].key, strdup(dest))) {
wl_ckeys[i].keysym = wkl[j].keysym;
@ -110,10 +110,10 @@ int bind_init(void) {
for (int j = 0; j < LENGTH(fl); j++) {
if (!strcmp(fl[j].function, strdup(dest))) {
#if USEX
#if X11
ckeys[i].func = fl[j].func;
#endif
#if USEWAYLAND
#if WAYLAND
wl_ckeys[i].func = fl[j].func;
#endif
}
@ -123,10 +123,10 @@ int bind_init(void) {
for (int j = 0; j < LENGTH(al); j++) {
if (!strcmp(al[j].argument, strdup(dest))) {
#if USEX
#if X11
ckeys[i].arg = al[j].arg;
#endif
#if USEWAYLAND
#if WAYLAND
wl_ckeys[i].arg = al[j].arg;
#endif
}
@ -140,7 +140,7 @@ int bind_init(void) {
// load options bind.mouse
config_setting_t *mouse_bind = config_lookup(&bind, "bind.mouse");
if (mouse_bind != NULL && loadbinds) {
#if USEX
#if X11
ret = 1;
#endif
for (unsigned int i = 0; i < config_setting_length(mouse_bind); ++i) {
@ -150,10 +150,10 @@ int bind_init(void) {
for (int j = 0; j < LENGTH(ctp); j++) {
if (!strcmp(ctp[j].tclick, strdup(dest))) {
#if USEX
#if X11
cbuttons[i].click = ctp[j].click;
#endif
#if USEWAYLAND
#if WAYLAND
wl_cbuttons[i].click = ctp[j].click;
#endif
}
@ -161,7 +161,7 @@ int bind_init(void) {
config_setting_lookup_string(conf, "button", &dest);
#if USEX
#if X11
for (int j = 0; j < LENGTH(btp); j++) {
if (!strcmp(btp[j].click, strdup(dest))) {
cbuttons[i].button = btp[j].button;
@ -169,7 +169,7 @@ int bind_init(void) {
}
#endif
#if USEWAYLAND
#if WAYLAND
for (int j = 0; j < LENGTH(w_btp); j++) {
if (!strcmp(w_btp[j].click, strdup(dest))) {
wl_cbuttons[i].button = w_btp[j].button;
@ -181,10 +181,10 @@ int bind_init(void) {
for (int j = 0; j < LENGTH(fl); j++) {
if (!strcmp(fl[j].function, strdup(dest))) {
#if USEX
#if X11
cbuttons[i].func = fl[j].func;
#endif
#if USEWAYLAND
#if WAYLAND
wl_cbuttons[i].func = fl[j].func;
#endif
}
@ -194,10 +194,10 @@ int bind_init(void) {
for (int j = 0; j < LENGTH(al); j++) {
if (!strcmp(al[j].argument, strdup(dest))) {
#if USEX
#if X11
cbuttons[i].arg = al[j].arg;
#endif
#if USEWAYLAND
#if WAYLAND
wl_cbuttons[i].arg = al[j].arg;
#endif
}
@ -857,7 +857,7 @@ void conf_init(void) {
// look up
config_setting_lookup_string(conf, "modifier", &dest);
#if USEX
#if X11
for (int j = 0; j < LENGTH(ml); j++) {
if (!strcmp(ml[j].mod, strdup(dest))) {
ckeys[i].mod = ml[j].modifier;
@ -865,7 +865,7 @@ void conf_init(void) {
}
#endif
#if USEWAYLAND
#if WAYLAND
for (int j = 0; j < LENGTH(wml); j++) {
if (!strcmp(wml[j].mod, strdup(dest))) {
wl_ckeys[i].modifier = wml[j].modifier;
@ -874,17 +874,17 @@ void conf_init(void) {
#endif
if (config_setting_lookup_int(conf, "mode", &nmode)) {
#if USEX
#if X11
ckeys[i].mode = nmode;
#endif
#if USEWAYLAND
#if WAYLAND
wl_ckeys[i].mode = nmode;
#endif
}
config_setting_lookup_string(conf, "key", &dest);
#if USEX
#if X11
for (int j = 0; j < LENGTH(kl); j++) {
if (!strcmp(kl[j].key, strdup(dest))) {
ckeys[i].keysym = kl[j].keysym;
@ -892,7 +892,7 @@ void conf_init(void) {
}
#endif
#if USEWAYLAND
#if WAYLAND
for (int j = 0; j < LENGTH(wkl); j++) {
if (!strcmp(wkl[j].key, strdup(dest))) {
wl_ckeys[i].keysym = wkl[j].keysym;
@ -904,10 +904,10 @@ void conf_init(void) {
for (int j = 0; j < LENGTH(fl); j++) {
if (!strcmp(fl[j].function, strdup(dest))) {
#if USEX
#if X11
ckeys[i].func = fl[j].func;
#endif
#if USEWAYLAND
#if WAYLAND
wl_ckeys[i].func = fl[j].func;
#endif
}
@ -917,10 +917,10 @@ void conf_init(void) {
for (int j = 0; j < LENGTH(al); j++) {
if (!strcmp(al[j].argument, strdup(dest))) {
#if USEX
#if X11
ckeys[i].arg = al[j].arg;
#endif
#if USEWAYLAND
#if WAYLAND
wl_ckeys[i].arg = al[j].arg;
#endif
}
@ -945,10 +945,10 @@ void conf_init(void) {
for (int j = 0; j < LENGTH(ctp); j++) {
if (!strcmp(ctp[j].tclick, strdup(dest))) {
#if USEX
#if X11
cbuttons[i].click = ctp[j].click;
#endif
#if USEWAYLAND
#if WAYLAND
wl_cbuttons[i].click = ctp[j].click;
#endif
}
@ -956,7 +956,7 @@ void conf_init(void) {
config_setting_lookup_string(conf, "button", &dest);
#if USEX
#if X11
for (int j = 0; j < LENGTH(btp); j++) {
if (!strcmp(btp[j].click, strdup(dest))) {
cbuttons[i].button = btp[j].button;
@ -964,7 +964,7 @@ void conf_init(void) {
}
#endif
#if USEWAYLAND
#if WAYLAND
for (int j = 0; j < LENGTH(w_btp); j++) {
if (!strcmp(w_btp[j].click, strdup(dest))) {
wl_cbuttons[i].button = w_btp[j].button;
@ -976,10 +976,10 @@ void conf_init(void) {
for (int j = 0; j < LENGTH(fl); j++) {
if (!strcmp(fl[j].function, strdup(dest))) {
#if USEX
#if X11
cbuttons[i].func = fl[j].func;
#endif
#if USEWAYLAND
#if WAYLAND
wl_cbuttons[i].func = fl[j].func;
#endif
}
@ -989,10 +989,10 @@ void conf_init(void) {
for (int j = 0; j < LENGTH(al); j++) {
if (!strcmp(al[j].argument, strdup(dest))) {
#if USEX
#if X11
cbuttons[i].arg = al[j].arg;
#endif
#if USEWAYLAND
#if WAYLAND
wl_cbuttons[i].arg = al[j].arg;
#endif
}

View file

@ -1,27 +1,27 @@
/* See LICENSE file for copyright and license details. */
#if USECONFIG
#if USEX
#if CONFIG
#if X11
typedef struct {
char *key;
KeySym keysym;
} KeyList;
#endif
#if USEWAYLAND
#if WAYLAND
typedef struct {
char *key;
xkb_keysym_t keysym;
} WlKeyList;
#endif
#if USEX
#if X11
typedef struct {
char *mod;
unsigned int modifier;
} ModList;
#endif
#if USEWAYLAND
#if WAYLAND
typedef struct {
char *mod;
char *modifier;
@ -401,7 +401,7 @@ static FuncList fl[] = {
};
// list of modifiers that can be used in the config file
#if USEX
#if X11
static ModList ml[] = {
{ "Ctrl+Shift", ShiftMask|ControlMask },
{ "Ctrl+Shift+Super", ShiftMask|ControlMask|Mod4Mask },
@ -422,7 +422,7 @@ static ModList ml[] = {
};
#endif
#if USEWAYLAND
#if WAYLAND
static WlModList wml[] = {
{ "Ctrl+Shift", WL_CtrlShift },
{ "Ctrl+Shift+Super", WL_CtrlShiftSuper },
@ -443,7 +443,7 @@ static WlModList wml[] = {
// list of keys that can be used in the config file
// expand this array if you want more
#if USEX
#if X11
static KeyList kl[] = {
{ "None", 0 },
{ "Space", XK_space },
@ -549,7 +549,7 @@ static KeyList kl[] = {
// list of keys that can be used in the config file
// expand this array if you want more
#if USEWAYLAND
#if WAYLAND
static WlKeyList wkl[] = {
{ "None", 0 },
{ "Space", XKB_KEY_space },
@ -664,7 +664,7 @@ typedef struct {
unsigned int click;
} ClickType;
#if USEX
#if X11
static ButtonType btp[] = {
{ "Left Click", Button1 },
{ "Middle Click", Button2 },
@ -674,7 +674,7 @@ static ButtonType btp[] = {
};
#endif
#if USEWAYLAND
#if WAYLAND
static ButtonType w_btp[] = {
{ "Left Click", WL_Left },
{ "Middle Click", WL_Middle },
@ -694,7 +694,7 @@ static ClickType ctp[] = {
{ "ClickNumber", ClickNumber },
{ "ClickCaps", ClickCaps },
{ "ClickMode", ClickMode },
#if USEIMAGE
#if IMAGE
{ "ClickImage", ClickImage },
#endif
{ "None", ClickNone },

View file

@ -173,7 +173,7 @@ int drawitemtext(struct item *item, int x, int y, int w) {
}
}
#if USEIMAGE
#if IMAGE
if (!hideimage && !imagetype) {
draw_rect(draw, x, y, w, sp.bh, 1, 1, fgcol, bgcol, fga, bga);
int nx = draw_icon(item, x, y + sp.lrpad / 4, sp.bh - sp.lrpad / 2, sp.bh - sp.lrpad / 2);
@ -340,7 +340,7 @@ int drawitem(int x, int y, int w) {
if (!strcmp(tx.capstext, ""))
capsw = 0;
#if USEIMAGE
#if IMAGE
int ox = 0; // original x position
#endif
@ -350,7 +350,7 @@ int drawitem(int x, int y, int w) {
int rx = 0;
// draw image first
#if USEIMAGE
#if IMAGE
if (!hideimage && img.longestedge != 0 && imagetype) {
rx = ox;
rx += MAX((img.imagegaps * 2) + img.imagewidth + menumarginh, indentitems ? x : 0);
@ -617,7 +617,7 @@ int drawcaps(int x, int y, int w) {
void drawmenu(void) {
sp.isdrawing = 1;
#if USEWAYLAND
#if WAYLAND
if (protocol) {
if (listfile) {
readstdin();
@ -636,14 +636,14 @@ void drawmenu(void) {
drawmenu_layer();
#if USEIMAGE
#if IMAGE
drawimage();
#endif
commit_drawable(&state);
} else {
#endif
#if USEX
#if X11
if (listfile) {
readstdin();
@ -660,12 +660,12 @@ void drawmenu(void) {
drawmenu_layer();
#if USEIMAGE
#if IMAGE
drawimage();
#endif
draw_map(draw, win, 0, 0, sp.mw, sp.mh);
#endif
#if USEWAYLAND
#if WAYLAND
}
#endif
@ -678,7 +678,7 @@ void drawmenu_layer(void) {
sp_strncpy(tx.modetext, sp.mode ? instext : normtext, sizeof(tx.modetext));
#if USEREGEX
#if REGEX
if (regex && regextext && sp.mode) {
sp_strncpy(tx.modetext, regextext, sizeof(tx.modetext));
}

View file

@ -10,18 +10,18 @@
#include "draw.h"
#ifndef X11
#define USEX 0
#define X11 0
#else
#define USEX 1
#define X11 1
#endif
#ifndef WAYLAND
#define USEWAYLAND 0
#define WAYLAND 0
#else
#define USEWAYLAND 1
#define WAYLAND 1
#endif
#if USEX
#if X11
#include <X11/Xlib.h>
#endif
@ -37,7 +37,7 @@ void draw_cairo_set_source_hex(cairo_t* cr, const char *col, int alpha) {
cairo_set_source_rgba(cr, r, g, b, alpha / 255.0);
}
#if USEX
#if X11
Draw_t *draw_create_x11(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap, int protocol) {
Draw_t *draw = draw_calloc(1, sizeof(Draw_t));
@ -58,7 +58,7 @@ Draw_t *draw_create_x11(Display *dpy, int screen, Window root, unsigned int w, u
}
#endif
#if USEWAYLAND
#if WAYLAND
Draw_t *draw_create_wl(int protocol) {
Draw_t *draw = draw_calloc(1, sizeof(Draw_t));
@ -83,7 +83,7 @@ void draw_resize(Draw_t *draw, unsigned int w, unsigned int h) {
draw->w = w;
draw->h = h;
#if USEX
#if X11
if (draw->drawable)
XFreePixmap(draw->dpy, draw->drawable);
@ -92,7 +92,7 @@ void draw_resize(Draw_t *draw, unsigned int w, unsigned int h) {
}
void draw_free(Draw_t *draw) {
#if USEX
#if X11
if (!draw->protocol) {
XFreePixmap(draw->dpy, draw->drawable);
XFreeGC(draw->dpy, draw->gc);
@ -352,7 +352,7 @@ void draw_map(Draw_t *draw, Window win, int x, int y, unsigned int w, unsigned i
if (!draw)
return;
#if USEX
#if X11
if (!draw->protocol) {
XCopyArea(draw->dpy, draw->drawable, win, draw->gc, x, y, w, h, x, y);
XSync(draw->dpy, False);

View file

@ -1,6 +1,6 @@
/* See LICENSE file for copyright and license details. */
#if USEIMAGE
#if IMAGE
static int draw_icon(struct item *item, int x, int y, int w, int h);
int draw_icon(struct item *item, int x, int y, int w, int h) {

View file

@ -1,6 +1,6 @@
/* See LICENSE file for copyright and license details. */
#if USEIMAGE
#if IMAGE
#include <errno.h>
#include <pwd.h>
@ -16,10 +16,10 @@ static void loadimage(const char *file, int *width, int *height);
static void loadimagecache(const char *file, int *width, int *height);
static void resizetoimageheight(int imageheight);
static void store_image_vars(void);
#if USEWAYLAND
#if WAYLAND
static void resizetoimageheight_wl(int imageheight);
#endif
#if USEX
#if X11
static void resizetoimageheight_x11(int imageheight);
#endif
@ -334,20 +334,20 @@ void jumptoindex(unsigned int index) {
void resizetoimageheight(int imageheight) {
if (!imagetype) return;
#if USEX
#if X11
if (!protocol) {
resizetoimageheight_x11(imageheight);
} else {
#if USEWAYLAND
#if WAYLAND
resizetoimageheight_wl(imageheight);
#endif
}
#elif USEWAYLAND
#elif WAYLAND
resizetoimageheight_wl(imageheight);
#endif
}
#if USEX
#if X11
void resizetoimageheight_x11(int imageheight) {
int mh = sp.mh, olines = lines;
lines = img.setlines;
@ -394,7 +394,7 @@ void resizetoimageheight_x11(int imageheight) {
}
#endif
#if USEWAYLAND
#if WAYLAND
void resizetoimageheight_wl(int imageheight) {
int mh = sp.mh, olines = lines;
lines = img.setlines;

View file

@ -1,6 +1,6 @@
/* See LICENSE file for copyright and license details. */
#if USEREGEX
#if REGEX
#include "regex/regex.h"
#include "regex/regex.c"
#endif
@ -11,7 +11,7 @@ static int matchregex(const char *t, const char *itt);
static int compare_distance(const void *a, const void *b);
int matchregex(const char *t, const char *itt) {
#if USEREGEX
#if REGEX
re_t reg = re_compile(t);
int len;

View file

@ -14,7 +14,7 @@ static int mon = -1; /* Monitor to run spmenu on */
static int scrolldistance = 512; /* Distance to scroll for a scroll action to count */
/* Config file options */
#if USECONFIG
#if CONFIG
static char *configfile = NULL; /* Config file path. Default is ~/.config/spmenu/spmenu.conf */
static char *themefile = NULL; /* Theme file path. Default is ~/.config/spmenu/theme.conf */
static char *bindsfile = NULL; /* Keybind file path. Default is ~/.config/spmenu/binds.conf */

View file

@ -1,13 +1,13 @@
/* See LICENSE file for copyright and license details. */
#if USERTL
#if RTL
#include <fribidi.h>
#endif
static char fribidi_text[BUFSIZ] = "";
static void apply_fribidi(char *str);
#if USERTL
#if RTL
void apply_fribidi(char *str) {
FriBidiStrIndex len = strlen(str);
FriBidiChar logical[BUFSIZ];

View file

@ -40,21 +40,21 @@ void readstdin(void) {
o = 1;
}
#if !USEIMAGE
#if !IMAGE
if (o) {
;
}
#endif
}
#if USEIMAGE
#if IMAGE
if (!o) img.longestedge = img.imagegaps = 0;
#endif
// clean
if (items) {
items[i].text = NULL;
#if USEIMAGE
#if IMAGE
items[i].image = NULL;
#endif
}
@ -119,7 +119,7 @@ void readfile(void) {
o = 1;
}
#if !USEIMAGE
#if !IMAGE
if (o) {
;
}
@ -128,7 +128,7 @@ void readfile(void) {
lines = columns == 1 ? i : MIN(i, lines); // i = number of items
#if USEIMAGE
#if IMAGE
if (!o) img.longestedge = img.imagegaps = 0;
#endif
@ -152,13 +152,13 @@ void readfile(void) {
}
int parsemarkup(int index) {
#if USEIMAGE
#if IMAGE
int w, h;
char *limg = NULL;
#endif
// parse image markup
#if USEIMAGE
#if IMAGE
if (!strncmp("IMG:", items[index].text, strlen("IMG:")) || !strncmp("img://", items[index].text, strlen("img://"))) {
if(!(items[index].image = malloc(strlen(items[index].text)+1)))
fprintf(stderr, "spmenu: cannot malloc %lu bytes\n", strlen(items[index].text));

View file

@ -1,6 +1,6 @@
/* See LICENSE file for copyright and license details. */
#if USEWAYLAND
#if WAYLAND
#include "wayland.c"
#include "init.c"
#endif

View file

@ -1,6 +1,6 @@
/* See LICENSE file for copyright and license details. */
#if USEWAYLAND
#if WAYLAND
#include "wayland.h"
#include "init.h"
#endif

View file

@ -6,7 +6,7 @@ void prepare_window_size_wl(void) {
sp.bh = MAX(draw->font->h, draw->font->h + 2 + lineheight);
lines = MAX(lines, 0);
#if USEIMAGE
#if IMAGE
img.setlines = lines;
#endif

View file

@ -321,7 +321,7 @@ void buttonpress_wl(uint32_t button, double ex, double ey) {
}
}
#if USEIMAGE
#if IMAGE
if (!hideimage && img.longestedge != 0 && imagetype) {
x += MAX((img.imagegaps * 2) + img.imagewidth, indentitems ? sp.promptw : 0);
}
@ -349,7 +349,7 @@ void buttonpress_wl(uint32_t button, double ex, double ey) {
if (ey >= y && ey <= (y + h) && ex >= x + (powerlineitems ? sp.plw : 0) && ex <= (x + w / columns) + (powerlineitems ? sp.plw : 0)) {
click = ClickItem;
mouseitem = item;
#if USEIMAGE
#if IMAGE
} else if (ey >= y && ey <= (y + h) && ex >= x + (powerlineitems ? sp.plw : 0) - MAX((img.imagegaps * 2) + img.imagewidth, indentitems ? sp.promptw : 0) && ex <= (x - MAX((img.imagegaps * 2) + img.imagewidth, indentitems ? sp.promptw : 0) + w / columns) + (powerlineitems ? sp.plw : 0)) {
click = ClickImage;
mouseitem = item;
@ -634,7 +634,7 @@ void resizeclient_wl(struct state *state) {
ic++;
lines = MIN(ic, MAX(lines, 0));
#if USEIMAGE
#if IMAGE
img.setlines = lines;
#endif
get_mh();

View file

@ -80,7 +80,7 @@ void resizeclient_x11(void) {
ic++;
lines = MIN(ic, MAX(lines, 0));
#if USEIMAGE
#if IMAGE
img.setlines = lines;
// resize client to image height

View file

@ -1,6 +1,6 @@
/* See LICENSE file for copyright and license details. */
#if USEX
#if X11
#include "xim.c"
#include "key.c"
#include "mouse.c"

View file

@ -1,5 +1,5 @@
/* See LICENSE file for copyright and license details. */
#if USEX
#if X11
#include "lib.h"
#include "init.h"

View file

@ -9,7 +9,7 @@ void setupdisplay_x11(void) {
prepare_window_size_x11();
// resize client to image height if deemed necessary
#if USEIMAGE
#if IMAGE
if (image) resizetoimageheight(img.imageheight);
#endif
@ -18,7 +18,7 @@ void setupdisplay_x11(void) {
? pango_prompt ? TEXTWM(prompt) : TEXTW(prompt) - sp.lrpad / 4 : 0; // prompt width
// init xinerama screens
#if USEXINERAMA
#if XINERAMA
XineramaScreenInfo *info;
Window pw;
int a, n, area = 0;
@ -87,7 +87,7 @@ void setupdisplay_x11(void) {
set_window_x11();
set_prop_x11();
#if USEIMAGE
#if IMAGE
setimageopts();
#endif
@ -128,7 +128,7 @@ void prepare_window_size_x11(void) {
sp.bh = MAX(draw->font->h, draw->font->h + 2 + lineheight);
lines = MAX(lines, 0);
#if USEIMAGE
#if IMAGE
img.setlines = lines;
#endif

View file

@ -10,11 +10,11 @@
#include <X11/extensions/Xrender.h>
// include xinerama
#if USEXINERAMA
#if XINERAMA
#include <X11/extensions/Xinerama.h>
#endif
// include xresources
#if USEXRESOURCES
#if XRESOURCES
#include <X11/Xresource.h>
#endif

View file

@ -59,7 +59,7 @@ void buttonpress_x11(XEvent *e) {
}
}
#if USEIMAGE
#if IMAGE
if (!hideimage && img.longestedge != 0 && imagetype) {
x += MAX((img.imagegaps * 2) + img.imagewidth, indentitems ? sp.promptw : 0);
}
@ -88,7 +88,7 @@ void buttonpress_x11(XEvent *e) {
if (ev->y >= y && ev->y <= (y + h) && ev->x >= x + (powerlineitems ? sp.plw : 0) && ev->x <= (x + w / columns) + (powerlineitems ? sp.plw : 0)) {
click = ClickItem;
mouseitem = item;
#if USEIMAGE
#if IMAGE
} else if (ev->y >= y && ev->y <= (y + h) && ev->x >= x + (powerlineitems ? sp.plw : 0) - MAX((img.imagegaps * 2) + img.imagewidth, indentitems ? sp.promptw : 0) && ev->x <= (x - MAX((img.imagegaps * 2) + img.imagewidth, indentitems ? sp.promptw : 0) + w / columns) + (powerlineitems ? sp.plw : 0)) {
click = ClickImage;
mouseitem = item;

View file

@ -1,6 +1,6 @@
/* See LICENSE file for copyright and license details. */
#if USEXRESOURCES
#if XRESOURCES
void resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst) {
char *sdst = NULL;
int *idst = NULL;

View file

@ -1,6 +1,6 @@
/* See LICENSE file for copyright and license details. */
#if USEXRESOURCES
#if XRESOURCES
enum resource_type {
STRING = 0,
INTEGER = 1,

View file

@ -1,7 +1,7 @@
/* See LICENSE file for copyright and license details. */
// This .Xresources array is read and compared to the xrdb. Simply add to the array if you need to.
#if USEXRESOURCES
#if XRESOURCES
ResourcePref cols[] = {
{ "font", STRING, &font },
{ "color10", STRING, &col_caretfg },

View file

@ -15,54 +15,6 @@
#define VERSION "unknown"
#endif
#ifndef RTL
#define USERTL 0
#else
#define USERTL 1
#endif
#ifndef IMAGE
#define USEIMAGE 0
#else
#define USEIMAGE 1
#endif
#ifndef XINERAMA
#define USEXINERAMA 0
#else
#define USEXINERAMA 1
#endif
#ifndef CONFIG
#define USECONFIG 0
#else
#define USECONFIG 1
#endif
#ifndef XRESOURCES
#define USEXRESOURCES 0
#else
#define USEXRESOURCES 1
#endif
#ifndef WAYLAND
#define USEWAYLAND 0
#else
#define USEWAYLAND 1
#endif
#ifndef X11
#define USEX 0
#else
#define USEX 1
#endif
#ifndef REGEX
#define USEREGEX 0
#else
#define USEREGEX 1
#endif
enum {
ClickWindow,
ClickPrompt,
@ -124,7 +76,7 @@ struct mo {
int output_height; // output height
};
#if USEIMAGE
#if IMAGE
struct img {
int setlines; // actual lines
int flip; // %=
@ -142,7 +94,7 @@ struct tx {
char capstext[64]; // caps lock text
};
#if USEX
#if X11
struct x11 {
int numlockmask;
int useargb;
@ -157,10 +109,10 @@ struct x11 {
static struct sp sp = {0};
static struct tx tx = {0};
static struct mo mo = {0};
#if USEIMAGE
#if IMAGE
static struct img img = {0};
#endif
#if USEX
#if X11
static struct x11 x11 = {0};
#endif
@ -190,7 +142,7 @@ static int *sel_index = NULL;
static unsigned int sel_size = 0;
static int itemn = 0;
#if USERTL
#if RTL
static int isrtl = 1;
#else
static int isrtl = 0;
@ -246,7 +198,7 @@ static char *fonts[] = { font };
#include "libs/arg.c"
#include "libs/stream.c"
#if USEX
#if X11
static Key keys[] = {
{ -1, 0, XK_Return, selectitem, {.i = +1 } },
{ -1, Shift, XK_Return, selectitem, {0} },
@ -271,7 +223,7 @@ static Key keys[] = {
{ -1, Ctrl, XK_n, navhistory, {.i = +1 } },
};
#endif
#if USEWAYLAND
#if WAYLAND
static WlKey wl_keys[] = {
{ -1, WL_None, XKB_KEY_Return, selectitem, {.i = +1 } },
{ -1, WL_Shift, XKB_KEY_Return, selectitem, {0} },
@ -297,7 +249,7 @@ static WlKey wl_keys[] = {
};
#endif
#if USEX
#if X11
static Mouse buttons[] = {
{ ClickInput, Button1, clear, {0} },
{ ClickPrompt, Button1, clear, {0} },
@ -309,7 +261,7 @@ static Mouse buttons[] = {
{ ClickNone, Button4, moveprev, {0} },
};
#endif
#if USEWAYLAND
#if WAYLAND
static WlMouse wl_buttons[] = {
{ ClickInput, WL_Left, clear, {0} },
{ ClickPrompt, WL_Left, clear, {0} },
@ -433,7 +385,7 @@ int max_textw(void) {
void cleanup(void) {
size_t i;
#if USEIMAGE
#if IMAGE
cleanupimage(); // function frees images
#endif
@ -444,7 +396,7 @@ void cleanup(void) {
// free drawing and close the display
draw_free(draw);
#if USEX
#if X11
if (!protocol) {
cleanup_x11(dpy);
}
@ -521,15 +473,15 @@ size_t nextrune(int inc) {
}
void resizeclient(void) {
#if USEWAYLAND
#if WAYLAND
if (protocol) {
resizeclient_wl(&state);
} else {
#if USEX
#if X11
resizeclient_x11();
#endif
}
#elif USEX
#elif X11
resizeclient_x11();
#endif
}
@ -592,7 +544,7 @@ void set_mode(void) {
void handle(void) {
if (!protocol) {
#if USEX
#if X11
handle_x11();
if (!draw_font_create(draw, fonts, LENGTH(fonts))) {
@ -600,7 +552,7 @@ void handle(void) {
}
loadhistory(); // read history entries
#if USEIMAGE
#if IMAGE
store_image_vars();
#endif
// fast (-f) means we grab keyboard before reading standard input
@ -619,10 +571,10 @@ void handle(void) {
setupdisplay_x11(); // set up display and create window
eventloop_x11(); // function is a loop which checks X11 events and calls other functions accordingly
#endif
#if USEWAYLAND
#if WAYLAND
} else {
loadhistory();
#if USEIMAGE
#if IMAGE
store_image_vars();
setimageopts();
#endif