add X11 toggle, so now Xlib, Xinerama and Xrender aren't dependencies if
you only use Wayland
This commit is contained in:
parent
e85a0b9728
commit
a9ee831159
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* X11 hardcoded keybinds */
|
/* X11 hardcoded keybinds */
|
||||||
|
#if USEX
|
||||||
static Key keys[] = {
|
static Key keys[] = {
|
||||||
/* mode modifier key function argument
|
/* mode modifier key function argument
|
||||||
*
|
*
|
||||||
|
@ -79,6 +80,7 @@ static Key keys[] = {
|
||||||
/* insert mode */
|
/* insert mode */
|
||||||
{ 1, 0, XK_Escape, switchmode, {0} },
|
{ 1, 0, XK_Escape, switchmode, {0} },
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Wayland hardcoded keybinds */
|
/* Wayland hardcoded keybinds */
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
|
|
|
@ -159,9 +159,11 @@ void moveend(Arg *arg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void paste(Arg *arg) {
|
void paste(Arg *arg) {
|
||||||
|
#if USEX
|
||||||
if (!protocol) {
|
if (!protocol) {
|
||||||
paste_x11(arg->i);
|
paste_x11(arg->i);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void viewhist(Arg *arg) {
|
void viewhist(Arg *arg) {
|
||||||
|
|
|
@ -64,13 +64,16 @@ void readargs(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if USEWAYLAND
|
||||||
if (protocol) {
|
if (protocol) {
|
||||||
if (connect_display(&state)) {
|
if (connect_display(&state)) {
|
||||||
protocol = 0;
|
protocol = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// init/read xrdb
|
// init/read xrdb
|
||||||
|
#if USEX
|
||||||
if (xresources && !protocol) {
|
if (xresources && !protocol) {
|
||||||
#if USEXRESOURCES
|
#if USEXRESOURCES
|
||||||
XrmInitialize();
|
XrmInitialize();
|
||||||
|
@ -79,6 +82,7 @@ void readargs(int argc, char *argv[]) {
|
||||||
; // avoids a warning
|
; // avoids a warning
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// no arguments
|
// no arguments
|
||||||
for (i = 1; i < argc; i++)
|
for (i = 1; i < argc; i++)
|
||||||
|
@ -367,7 +371,9 @@ void readargs(int argc, char *argv[]) {
|
||||||
imageheight = imagewidth;
|
imageheight = imagewidth;
|
||||||
|
|
||||||
} else if (!strcmp(argv[i], "-w") || (!strcmp(argv[i], "--embed"))) { // embedding window id
|
} else if (!strcmp(argv[i], "-w") || (!strcmp(argv[i], "--embed"))) { // embedding window id
|
||||||
|
#if USEX
|
||||||
embed = argv[++i];
|
embed = argv[++i];
|
||||||
|
#endif
|
||||||
} else if (!strcmp(argv[i], "-n") || (!strcmp(argv[i], "--preselect"))) { // preselected item
|
} else if (!strcmp(argv[i], "-n") || (!strcmp(argv[i], "--preselect"))) { // preselected item
|
||||||
preselected = atoi(argv[++i]);
|
preselected = atoi(argv[++i]);
|
||||||
|
|
||||||
|
@ -492,6 +498,9 @@ void readargs(int argc, char *argv[]) {
|
||||||
else
|
else
|
||||||
fprintf(stderr, "spmenu: Invalid argument: '%s'\n", argv[i]);
|
fprintf(stderr, "spmenu: Invalid argument: '%s'\n", argv[i]);
|
||||||
|
|
||||||
|
#if !USEX
|
||||||
|
protocol = 1;
|
||||||
|
#endif
|
||||||
#if !USEWAYLAND
|
#if !USEWAYLAND
|
||||||
protocol = 0;
|
protocol = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -568,11 +568,13 @@ void conf_init(void) {
|
||||||
// look up
|
// look up
|
||||||
config_setting_lookup_string(conf, "modifier", &dest);
|
config_setting_lookup_string(conf, "modifier", &dest);
|
||||||
|
|
||||||
|
#if USEX
|
||||||
for (int j = 0; j < LENGTH(ml); j++) {
|
for (int j = 0; j < LENGTH(ml); j++) {
|
||||||
if (!strcmp(ml[j].mod, strdup(dest))) {
|
if (!strcmp(ml[j].mod, strdup(dest))) {
|
||||||
ckeys[i].mod = ml[j].modifier;
|
ckeys[i].mod = ml[j].modifier;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
for (int j = 0; j < LENGTH(wml); j++) {
|
for (int j = 0; j < LENGTH(wml); j++) {
|
||||||
|
@ -583,7 +585,9 @@ void conf_init(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (config_setting_lookup_int(conf, "mode", &nmode)) {
|
if (config_setting_lookup_int(conf, "mode", &nmode)) {
|
||||||
|
#if USEX
|
||||||
ckeys[i].mode = nmode;
|
ckeys[i].mode = nmode;
|
||||||
|
#endif
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
wl_ckeys[i].mode = nmode;
|
wl_ckeys[i].mode = nmode;
|
||||||
#endif
|
#endif
|
||||||
|
@ -591,11 +595,13 @@ void conf_init(void) {
|
||||||
|
|
||||||
config_setting_lookup_string(conf, "key", &dest);
|
config_setting_lookup_string(conf, "key", &dest);
|
||||||
|
|
||||||
|
#if USEX
|
||||||
for (int j = 0; j < LENGTH(kl); j++) {
|
for (int j = 0; j < LENGTH(kl); j++) {
|
||||||
if (!strcmp(kl[j].key, strdup(dest))) {
|
if (!strcmp(kl[j].key, strdup(dest))) {
|
||||||
ckeys[i].keysym = kl[j].keysym;
|
ckeys[i].keysym = kl[j].keysym;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
for (int j = 0; j < LENGTH(wkl); j++) {
|
for (int j = 0; j < LENGTH(wkl); j++) {
|
||||||
|
@ -609,7 +615,9 @@ void conf_init(void) {
|
||||||
|
|
||||||
for (int j = 0; j < LENGTH(fl); j++) {
|
for (int j = 0; j < LENGTH(fl); j++) {
|
||||||
if (!strcmp(fl[j].function, strdup(dest))) {
|
if (!strcmp(fl[j].function, strdup(dest))) {
|
||||||
|
#if USEX
|
||||||
ckeys[i].func = fl[j].func;
|
ckeys[i].func = fl[j].func;
|
||||||
|
#endif
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
wl_ckeys[i].func = fl[j].func;
|
wl_ckeys[i].func = fl[j].func;
|
||||||
#endif
|
#endif
|
||||||
|
@ -620,7 +628,9 @@ void conf_init(void) {
|
||||||
|
|
||||||
for (int j = 0; j < LENGTH(al); j++) {
|
for (int j = 0; j < LENGTH(al); j++) {
|
||||||
if (!strcmp(al[j].argument, strdup(dest))) {
|
if (!strcmp(al[j].argument, strdup(dest))) {
|
||||||
|
#if USEX
|
||||||
ckeys[i].arg = al[j].arg;
|
ckeys[i].arg = al[j].arg;
|
||||||
|
#endif
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
wl_ckeys[i].arg = al[j].arg;
|
wl_ckeys[i].arg = al[j].arg;
|
||||||
#endif
|
#endif
|
||||||
|
@ -641,7 +651,9 @@ void conf_init(void) {
|
||||||
|
|
||||||
for (int j = 0; j < LENGTH(ctp); j++) {
|
for (int j = 0; j < LENGTH(ctp); j++) {
|
||||||
if (!strcmp(ctp[j].tclick, strdup(dest))) {
|
if (!strcmp(ctp[j].tclick, strdup(dest))) {
|
||||||
|
#if USEX
|
||||||
cbuttons[i].click = ctp[j].click;
|
cbuttons[i].click = ctp[j].click;
|
||||||
|
#endif
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
wl_cbuttons[i].click = ctp[j].click;
|
wl_cbuttons[i].click = ctp[j].click;
|
||||||
#endif
|
#endif
|
||||||
|
@ -650,11 +662,13 @@ void conf_init(void) {
|
||||||
|
|
||||||
config_setting_lookup_string(conf, "button", &dest);
|
config_setting_lookup_string(conf, "button", &dest);
|
||||||
|
|
||||||
|
#if USEX
|
||||||
for (int j = 0; j < LENGTH(btp); j++) {
|
for (int j = 0; j < LENGTH(btp); j++) {
|
||||||
if (!strcmp(btp[j].click, strdup(dest))) {
|
if (!strcmp(btp[j].click, strdup(dest))) {
|
||||||
cbuttons[i].button = btp[j].button;
|
cbuttons[i].button = btp[j].button;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
for (int j = 0; j < LENGTH(w_btp); j++) {
|
for (int j = 0; j < LENGTH(w_btp); j++) {
|
||||||
|
@ -668,7 +682,9 @@ void conf_init(void) {
|
||||||
|
|
||||||
for (int j = 0; j < LENGTH(fl); j++) {
|
for (int j = 0; j < LENGTH(fl); j++) {
|
||||||
if (!strcmp(fl[j].function, strdup(dest))) {
|
if (!strcmp(fl[j].function, strdup(dest))) {
|
||||||
|
#if USEX
|
||||||
cbuttons[i].func = fl[j].func;
|
cbuttons[i].func = fl[j].func;
|
||||||
|
#endif
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
wl_cbuttons[i].func = fl[j].func;
|
wl_cbuttons[i].func = fl[j].func;
|
||||||
#endif
|
#endif
|
||||||
|
@ -679,7 +695,9 @@ void conf_init(void) {
|
||||||
|
|
||||||
for (int j = 0; j < LENGTH(al); j++) {
|
for (int j = 0; j < LENGTH(al); j++) {
|
||||||
if (!strcmp(al[j].argument, strdup(dest))) {
|
if (!strcmp(al[j].argument, strdup(dest))) {
|
||||||
|
#if USEX
|
||||||
cbuttons[i].arg = al[j].arg;
|
cbuttons[i].arg = al[j].arg;
|
||||||
|
#endif
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
wl_cbuttons[i].arg = al[j].arg;
|
wl_cbuttons[i].arg = al[j].arg;
|
||||||
#endif
|
#endif
|
||||||
|
@ -743,7 +761,9 @@ void conf_init(void) {
|
||||||
if (key_bind != NULL && loadbinds) {
|
if (key_bind != NULL && loadbinds) {
|
||||||
int nmode = 0;
|
int nmode = 0;
|
||||||
|
|
||||||
|
#if USEX
|
||||||
memset(ckeys, '\0', LENGTH(ckeys)-1);
|
memset(ckeys, '\0', LENGTH(ckeys)-1);
|
||||||
|
#endif
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
memset(wl_ckeys, '\0', LENGTH(wl_ckeys)-1);
|
memset(wl_ckeys, '\0', LENGTH(wl_ckeys)-1);
|
||||||
#endif
|
#endif
|
||||||
|
@ -753,11 +773,13 @@ void conf_init(void) {
|
||||||
// look up
|
// look up
|
||||||
config_setting_lookup_string(conf, "modifier", &dest);
|
config_setting_lookup_string(conf, "modifier", &dest);
|
||||||
|
|
||||||
|
#if USEX
|
||||||
for (int j = 0; j < LENGTH(ml); j++) {
|
for (int j = 0; j < LENGTH(ml); j++) {
|
||||||
if (!strcmp(ml[j].mod, strdup(dest))) {
|
if (!strcmp(ml[j].mod, strdup(dest))) {
|
||||||
ckeys[i].mod = ml[j].modifier;
|
ckeys[i].mod = ml[j].modifier;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
for (int j = 0; j < LENGTH(wml); j++) {
|
for (int j = 0; j < LENGTH(wml); j++) {
|
||||||
|
@ -768,7 +790,9 @@ void conf_init(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (config_setting_lookup_int(conf, "mode", &nmode)) {
|
if (config_setting_lookup_int(conf, "mode", &nmode)) {
|
||||||
|
#if USEX
|
||||||
ckeys[i].mode = nmode;
|
ckeys[i].mode = nmode;
|
||||||
|
#endif
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
wl_ckeys[i].mode = nmode;
|
wl_ckeys[i].mode = nmode;
|
||||||
#endif
|
#endif
|
||||||
|
@ -776,11 +800,13 @@ void conf_init(void) {
|
||||||
|
|
||||||
config_setting_lookup_string(conf, "key", &dest);
|
config_setting_lookup_string(conf, "key", &dest);
|
||||||
|
|
||||||
|
#if USEX
|
||||||
for (int j = 0; j < LENGTH(kl); j++) {
|
for (int j = 0; j < LENGTH(kl); j++) {
|
||||||
if (!strcmp(kl[j].key, strdup(dest))) {
|
if (!strcmp(kl[j].key, strdup(dest))) {
|
||||||
ckeys[i].keysym = kl[j].keysym;
|
ckeys[i].keysym = kl[j].keysym;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
for (int j = 0; j < LENGTH(wkl); j++) {
|
for (int j = 0; j < LENGTH(wkl); j++) {
|
||||||
|
@ -794,7 +820,9 @@ void conf_init(void) {
|
||||||
|
|
||||||
for (int j = 0; j < LENGTH(fl); j++) {
|
for (int j = 0; j < LENGTH(fl); j++) {
|
||||||
if (!strcmp(fl[j].function, strdup(dest))) {
|
if (!strcmp(fl[j].function, strdup(dest))) {
|
||||||
|
#if USEX
|
||||||
ckeys[i].func = fl[j].func;
|
ckeys[i].func = fl[j].func;
|
||||||
|
#endif
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
wl_ckeys[i].func = fl[j].func;
|
wl_ckeys[i].func = fl[j].func;
|
||||||
#endif
|
#endif
|
||||||
|
@ -805,7 +833,9 @@ void conf_init(void) {
|
||||||
|
|
||||||
for (int j = 0; j < LENGTH(al); j++) {
|
for (int j = 0; j < LENGTH(al); j++) {
|
||||||
if (!strcmp(al[j].argument, strdup(dest))) {
|
if (!strcmp(al[j].argument, strdup(dest))) {
|
||||||
|
#if USEX
|
||||||
ckeys[i].arg = al[j].arg;
|
ckeys[i].arg = al[j].arg;
|
||||||
|
#endif
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
wl_ckeys[i].arg = al[j].arg;
|
wl_ckeys[i].arg = al[j].arg;
|
||||||
#endif
|
#endif
|
||||||
|
@ -819,7 +849,9 @@ void conf_init(void) {
|
||||||
// load options binds.mouse
|
// load options binds.mouse
|
||||||
config_setting_t *mouse_bind = config_lookup(&bind, "bind.mouse");
|
config_setting_t *mouse_bind = config_lookup(&bind, "bind.mouse");
|
||||||
if (mouse_bind != NULL && loadbinds) {
|
if (mouse_bind != NULL && loadbinds) {
|
||||||
|
#if USEX
|
||||||
memset(cbuttons, '\0', LENGTH(cbuttons)-1);
|
memset(cbuttons, '\0', LENGTH(cbuttons)-1);
|
||||||
|
#endif
|
||||||
for (unsigned int i = 0; i < config_setting_length(mouse_bind); ++i) {
|
for (unsigned int i = 0; i < config_setting_length(mouse_bind); ++i) {
|
||||||
config_setting_t *conf = config_setting_get_elem(mouse_bind, i);
|
config_setting_t *conf = config_setting_get_elem(mouse_bind, i);
|
||||||
|
|
||||||
|
@ -827,7 +859,9 @@ void conf_init(void) {
|
||||||
|
|
||||||
for (int j = 0; j < LENGTH(ctp); j++) {
|
for (int j = 0; j < LENGTH(ctp); j++) {
|
||||||
if (!strcmp(ctp[j].tclick, strdup(dest))) {
|
if (!strcmp(ctp[j].tclick, strdup(dest))) {
|
||||||
|
#if USEX
|
||||||
cbuttons[i].click = ctp[j].click;
|
cbuttons[i].click = ctp[j].click;
|
||||||
|
#endif
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
wl_cbuttons[i].click = ctp[j].click;
|
wl_cbuttons[i].click = ctp[j].click;
|
||||||
#endif
|
#endif
|
||||||
|
@ -836,11 +870,13 @@ void conf_init(void) {
|
||||||
|
|
||||||
config_setting_lookup_string(conf, "button", &dest);
|
config_setting_lookup_string(conf, "button", &dest);
|
||||||
|
|
||||||
|
#if USEX
|
||||||
for (int j = 0; j < LENGTH(btp); j++) {
|
for (int j = 0; j < LENGTH(btp); j++) {
|
||||||
if (!strcmp(btp[j].click, strdup(dest))) {
|
if (!strcmp(btp[j].click, strdup(dest))) {
|
||||||
cbuttons[i].button = btp[j].button;
|
cbuttons[i].button = btp[j].button;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
for (int j = 0; j < LENGTH(w_btp); j++) {
|
for (int j = 0; j < LENGTH(w_btp); j++) {
|
||||||
|
@ -854,7 +890,9 @@ void conf_init(void) {
|
||||||
|
|
||||||
for (int j = 0; j < LENGTH(fl); j++) {
|
for (int j = 0; j < LENGTH(fl); j++) {
|
||||||
if (!strcmp(fl[j].function, strdup(dest))) {
|
if (!strcmp(fl[j].function, strdup(dest))) {
|
||||||
|
#if USEX
|
||||||
cbuttons[i].func = fl[j].func;
|
cbuttons[i].func = fl[j].func;
|
||||||
|
#endif
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
wl_cbuttons[i].func = fl[j].func;
|
wl_cbuttons[i].func = fl[j].func;
|
||||||
#endif
|
#endif
|
||||||
|
@ -865,7 +903,9 @@ void conf_init(void) {
|
||||||
|
|
||||||
for (int j = 0; j < LENGTH(al); j++) {
|
for (int j = 0; j < LENGTH(al); j++) {
|
||||||
if (!strcmp(al[j].argument, strdup(dest))) {
|
if (!strcmp(al[j].argument, strdup(dest))) {
|
||||||
|
#if USEX
|
||||||
cbuttons[i].arg = al[j].arg;
|
cbuttons[i].arg = al[j].arg;
|
||||||
|
#endif
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
wl_cbuttons[i].arg = al[j].arg;
|
wl_cbuttons[i].arg = al[j].arg;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
#include "../theme/theme.h"
|
#include "../theme/theme.h"
|
||||||
|
|
||||||
|
#if USEX
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *key;
|
char *key;
|
||||||
KeySym keysym;
|
KeySym keysym;
|
||||||
} KeyList;
|
} KeyList;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -13,10 +15,12 @@ typedef struct {
|
||||||
} WlKeyList;
|
} WlKeyList;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if USEX
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *mod;
|
char *mod;
|
||||||
unsigned int modifier;
|
unsigned int modifier;
|
||||||
} ModList;
|
} ModList;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -353,7 +357,6 @@ static FuncList fl[] = {
|
||||||
{ "moveprev", moveprev },
|
{ "moveprev", moveprev },
|
||||||
{ "moveitem", moveitem },
|
{ "moveitem", moveitem },
|
||||||
{ "paste", paste },
|
{ "paste", paste },
|
||||||
{ "pastesel", paste },
|
|
||||||
{ "restoresel", restoresel },
|
{ "restoresel", restoresel },
|
||||||
{ "clear", clear },
|
{ "clear", clear },
|
||||||
{ "clearins", clearins },
|
{ "clearins", clearins },
|
||||||
|
@ -391,6 +394,7 @@ static FuncList fl[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// list of modifiers that can be used in the config file
|
// list of modifiers that can be used in the config file
|
||||||
|
#if USEX
|
||||||
static ModList ml[] = {
|
static ModList ml[] = {
|
||||||
{ "Ctrl+Shift", ShiftMask|ControlMask },
|
{ "Ctrl+Shift", ShiftMask|ControlMask },
|
||||||
{ "Ctrl+Shift+Super", ShiftMask|ControlMask|Mod4Mask },
|
{ "Ctrl+Shift+Super", ShiftMask|ControlMask|Mod4Mask },
|
||||||
|
@ -409,6 +413,7 @@ static ModList ml[] = {
|
||||||
{ "None", 0 },
|
{ "None", 0 },
|
||||||
{ "0", 0 },
|
{ "0", 0 },
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
static WlModList wml[] = {
|
static WlModList wml[] = {
|
||||||
|
@ -431,6 +436,7 @@ static WlModList wml[] = {
|
||||||
|
|
||||||
// list of keys that can be used in the config file
|
// list of keys that can be used in the config file
|
||||||
// expand this array if you want more
|
// expand this array if you want more
|
||||||
|
#if USEX
|
||||||
static KeyList kl[] = {
|
static KeyList kl[] = {
|
||||||
{ "None", 0 },
|
{ "None", 0 },
|
||||||
{ "Space", XK_space },
|
{ "Space", XK_space },
|
||||||
|
@ -532,6 +538,7 @@ static KeyList kl[] = {
|
||||||
{ "Next", XK_Next },
|
{ "Next", XK_Next },
|
||||||
{ "Prior", XK_Prior },
|
{ "Prior", XK_Prior },
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
// list of keys that can be used in the config file
|
// list of keys that can be used in the config file
|
||||||
// expand this array if you want more
|
// expand this array if you want more
|
||||||
|
@ -639,23 +646,18 @@ static WlKeyList wkl[] = {
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *click;
|
char *click;
|
||||||
unsigned int button;
|
unsigned int button;
|
||||||
} ButtonType;
|
} ButtonType;
|
||||||
|
|
||||||
#if USEWAYLAND
|
|
||||||
typedef struct {
|
|
||||||
char *click;
|
|
||||||
unsigned int button;
|
|
||||||
} WlButtonType;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *tclick;
|
char *tclick;
|
||||||
unsigned int click;
|
unsigned int click;
|
||||||
} ClickType;
|
} ClickType;
|
||||||
|
|
||||||
|
#if USEX
|
||||||
static ButtonType btp[] = {
|
static ButtonType btp[] = {
|
||||||
{ "Left Click", Button1 },
|
{ "Left Click", Button1 },
|
||||||
{ "Middle Click", Button2 },
|
{ "Middle Click", Button2 },
|
||||||
|
@ -663,9 +665,10 @@ static ButtonType btp[] = {
|
||||||
{ "Scroll Up", Button4 },
|
{ "Scroll Up", Button4 },
|
||||||
{ "Scroll Down", Button5 },
|
{ "Scroll Down", Button5 },
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
static WlButtonType w_btp[] = {
|
static ButtonType w_btp[] = {
|
||||||
{ "Left Click", WL_Left },
|
{ "Left Click", WL_Left },
|
||||||
{ "Middle Click", WL_Middle },
|
{ "Middle Click", WL_Middle },
|
||||||
{ "Right Click", WL_Right },
|
{ "Right Click", WL_Right },
|
||||||
|
|
|
@ -547,12 +547,14 @@ void drawmenu_layer(void) {
|
||||||
mh = (lines + 1) * bh - bh + 2 * menumarginv;
|
mh = (lines + 1) * bh - bh + 2 * menumarginv;
|
||||||
|
|
||||||
if (!protocol) {
|
if (!protocol) {
|
||||||
|
#if USEX
|
||||||
if (!win) {
|
if (!win) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
XResizeWindow(dpy, win, mw - 2 * sp - 2 * borderwidth, mh);
|
XResizeWindow(dpy, win, mw - 2 * sp - 2 * borderwidth, mh);
|
||||||
drw_resize(drw, mw - 2 * sp - 2 * borderwidth, mh);
|
drw_resize(drw, mw - 2 * sp - 2 * borderwidth, mh);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
resizeclient();
|
resizeclient();
|
||||||
}
|
}
|
||||||
|
@ -603,5 +605,7 @@ void drawmenu_layer(void) {
|
||||||
drawcaps(mw - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w);
|
drawcaps(mw - capsWidth - 2 * sp - 2 * borderwidth - menumarginh, y, w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if USEX
|
||||||
drw_map(drw, win, 0, 0, mw, mh);
|
drw_map(drw, win, 0, 0, mw, mh);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
18
libs/img.c
18
libs/img.c
|
@ -131,6 +131,7 @@ void drawimage(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if USEX
|
||||||
void setimageopts(void) {
|
void setimageopts(void) {
|
||||||
imlib_set_cache_size(8192 * 1024);
|
imlib_set_cache_size(8192 * 1024);
|
||||||
imlib_context_set_blend(1);
|
imlib_context_set_blend(1);
|
||||||
|
@ -141,6 +142,7 @@ void setimageopts(void) {
|
||||||
imlib_context_set_colormap(cmap);
|
imlib_context_set_colormap(cmap);
|
||||||
imlib_context_set_drawable(win);
|
imlib_context_set_drawable(win);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void createifnexist(const char *dir) {
|
void createifnexist(const char *dir) {
|
||||||
// exists, so return
|
// exists, so return
|
||||||
|
@ -336,6 +338,7 @@ void jumptoindex(unsigned int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void resizetoimageheight(int imageheight) {
|
void resizetoimageheight(int imageheight) {
|
||||||
|
#if USEX
|
||||||
int omh = mh, olines = lines;
|
int omh = mh, olines = lines;
|
||||||
lines = reallines;
|
lines = reallines;
|
||||||
int wtr = 0;
|
int wtr = 0;
|
||||||
|
@ -424,7 +427,9 @@ void resizetoimageheight(int imageheight) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!win || omh == mh) {
|
if (
|
||||||
|
!win ||
|
||||||
|
omh == mh) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,5 +448,16 @@ void resizetoimageheight(int imageheight) {
|
||||||
}
|
}
|
||||||
|
|
||||||
drawmenu();
|
drawmenu();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void store_image_vars(void) {
|
||||||
|
longestedge = MAX(imagewidth, imageheight);
|
||||||
|
|
||||||
|
if (!imagew || !imageh || !imageg) {
|
||||||
|
imagew = imagewidth;
|
||||||
|
imageh = imageheight;
|
||||||
|
imageg = imagegaps;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -7,7 +7,9 @@
|
||||||
#include <openssl/md5.h>
|
#include <openssl/md5.h>
|
||||||
|
|
||||||
static void setimagesize(int width, int height);
|
static void setimagesize(int width, int height);
|
||||||
|
#if USEX
|
||||||
static void setimageopts(void);
|
static void setimageopts(void);
|
||||||
|
#endif
|
||||||
static void cleanupimage(void);
|
static void cleanupimage(void);
|
||||||
static void drawimage(void);
|
static void drawimage(void);
|
||||||
static void rotateimage(void);
|
static void rotateimage(void);
|
||||||
|
@ -15,6 +17,7 @@ static void flipimage(void);
|
||||||
static void loadimage(const char *file, int *width, int *height);
|
static void loadimage(const char *file, int *width, int *height);
|
||||||
static void loadimagecache(const char *file, int *width, int *height);
|
static void loadimagecache(const char *file, int *width, int *height);
|
||||||
static void resizetoimageheight(int imageheight);
|
static void resizetoimageheight(int imageheight);
|
||||||
|
static void store_image_vars(void);
|
||||||
|
|
||||||
static Imlib_Image image = NULL;
|
static Imlib_Image image = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -11,6 +11,18 @@
|
||||||
#include "drw.h"
|
#include "drw.h"
|
||||||
#include "../sl/main.h"
|
#include "../sl/main.h"
|
||||||
|
|
||||||
|
#ifndef X11
|
||||||
|
#define USEX 0
|
||||||
|
#else
|
||||||
|
#define USEX 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WAYLAND
|
||||||
|
#define USEWAYLAND 0
|
||||||
|
#else
|
||||||
|
#define USEWAYLAND 1
|
||||||
|
#endif
|
||||||
|
|
||||||
void cairo_set_source_hex(cairo_t* cr, const char *col, int alpha) {
|
void cairo_set_source_hex(cairo_t* cr, const char *col, int alpha) {
|
||||||
unsigned int hex;
|
unsigned int hex;
|
||||||
|
|
||||||
|
@ -23,6 +35,7 @@ void cairo_set_source_hex(cairo_t* cr, const char *col, int alpha) {
|
||||||
cairo_set_source_rgba(cr, r, g, b, alpha / 255.0);
|
cairo_set_source_rgba(cr, r, g, b, alpha / 255.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if USEX
|
||||||
Drw *drw_create_x11(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap, int protocol) {
|
Drw *drw_create_x11(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap, int protocol) {
|
||||||
Drw *drw = ecalloc(1, sizeof(Drw));
|
Drw *drw = ecalloc(1, sizeof(Drw));
|
||||||
|
|
||||||
|
@ -41,7 +54,9 @@ Drw *drw_create_x11(Display *dpy, int screen, Window root, unsigned int w, unsig
|
||||||
|
|
||||||
return drw;
|
return drw;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if USEWAYLAND
|
||||||
Drw *drw_create_wl(int protocol) {
|
Drw *drw_create_wl(int protocol) {
|
||||||
Drw *drw = ecalloc(1, sizeof(Drw));
|
Drw *drw = ecalloc(1, sizeof(Drw));
|
||||||
|
|
||||||
|
@ -57,6 +72,7 @@ void drw_create_surface_wl(Drw *drw, void *data, int32_t w, int32_t h) {
|
||||||
drw->surface = cairo_image_surface_create_for_data(drw->data, CAIRO_FORMAT_ARGB32, drw->w, drw->h, drw->w * 4);
|
drw->surface = cairo_image_surface_create_for_data(drw->data, CAIRO_FORMAT_ARGB32, drw->w, drw->h, drw->w * 4);
|
||||||
drw->d = cairo_create(drw->surface);
|
drw->d = cairo_create(drw->surface);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void drw_resize(Drw *drw, unsigned int w, unsigned int h) {
|
void drw_resize(Drw *drw, unsigned int w, unsigned int h) {
|
||||||
if (!drw)
|
if (!drw)
|
||||||
|
@ -65,18 +81,21 @@ void drw_resize(Drw *drw, unsigned int w, unsigned int h) {
|
||||||
drw->w = w;
|
drw->w = w;
|
||||||
drw->h = h;
|
drw->h = h;
|
||||||
|
|
||||||
|
#if USEX
|
||||||
if (drw->drawable)
|
if (drw->drawable)
|
||||||
XFreePixmap(drw->dpy, drw->drawable);
|
XFreePixmap(drw->dpy, drw->drawable);
|
||||||
|
|
||||||
drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth);
|
drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void drw_free(Drw *drw) {
|
void drw_free(Drw *drw) {
|
||||||
|
#if USEX
|
||||||
if (!drw->protocol) {
|
if (!drw->protocol) {
|
||||||
XFreePixmap(drw->dpy, drw->drawable);
|
XFreePixmap(drw->dpy, drw->drawable);
|
||||||
XFreeGC(drw->dpy, drw->gc);
|
XFreeGC(drw->dpy, drw->gc);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
drw_font_free(drw->font);
|
drw_font_free(drw->font);
|
||||||
free(drw);
|
free(drw);
|
||||||
|
@ -292,10 +311,12 @@ void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h)
|
||||||
if (!drw)
|
if (!drw)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#if USEX
|
||||||
if (!drw->protocol) {
|
if (!drw->protocol) {
|
||||||
XCopyArea(drw->dpy, drw->drawable, win, drw->gc, x, y, w, h, x, y);
|
XCopyArea(drw->dpy, drw->drawable, win, drw->gc, x, y, w, h, x, y);
|
||||||
XSync(drw->dpy, False);
|
XSync(drw->dpy, False);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int drw_font_getwidth(Drw *drw, const char *text, Bool markup) {
|
unsigned int drw_font_getwidth(Drw *drw, const char *text, Bool markup) {
|
||||||
|
@ -338,17 +359,21 @@ Cur * drw_cur_create(Drw *drw, int shape) {
|
||||||
if (!drw || !(cur = ecalloc(1, sizeof(Cur))))
|
if (!drw || !(cur = ecalloc(1, sizeof(Cur))))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
#if USEX
|
||||||
cur->cursor = XCreateFontCursor(drw->dpy, shape);
|
cur->cursor = XCreateFontCursor(drw->dpy, shape);
|
||||||
|
#endif
|
||||||
|
|
||||||
return cur;
|
return cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
void drw_cur_free(Drw *drw, Cur *cursor) {
|
void drw_cur_free(Drw *drw, Cur *cursor) {
|
||||||
|
#if USEX
|
||||||
if (!cursor)
|
if (!cursor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
XFreeCursor(drw->dpy, cursor->cursor);
|
XFreeCursor(drw->dpy, cursor->cursor);
|
||||||
free(cursor);
|
free(cursor);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n, Bool markup) {
|
unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n, Bool markup) {
|
||||||
|
|
|
@ -33,8 +33,15 @@ typedef struct {
|
||||||
Arg arg;
|
Arg arg;
|
||||||
} WlKey;
|
} WlKey;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned int click;
|
||||||
|
unsigned int button;
|
||||||
|
void (*func)(Arg *arg);
|
||||||
|
Arg arg;
|
||||||
|
} WlMouse;
|
||||||
|
|
||||||
static WlKey wl_ckeys[256];
|
static WlKey wl_ckeys[256];
|
||||||
static Mouse wl_cbuttons[256];
|
static WlMouse wl_cbuttons[256];
|
||||||
|
|
||||||
#define WL_CtrlShift "CtrlShift"
|
#define WL_CtrlShift "CtrlShift"
|
||||||
#define WL_CtrlShiftSuper "CtrlShiftSuper"
|
#define WL_CtrlShiftSuper "CtrlShiftSuper"
|
||||||
|
|
|
@ -10,37 +10,6 @@ void hexconv(const char *hex, unsigned short *r, unsigned short *g, unsigned sho
|
||||||
*b = col & 0xFF;
|
*b = col & 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
void store_image_vars(void) {
|
|
||||||
#if USEIMAGE
|
|
||||||
longestedge = MAX(imagewidth, imageheight);
|
|
||||||
|
|
||||||
if (!imagew || !imageh || !imageg) {
|
|
||||||
imagew = imagewidth;
|
|
||||||
imageh = imageheight;
|
|
||||||
imageg = imagegaps;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_mode(void) {
|
|
||||||
if (!type) { // no typing allowed, require normal mode
|
|
||||||
mode = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set default mode, must be done before the event loop or keybindings will not work
|
|
||||||
if (mode) {
|
|
||||||
curMode = 1;
|
|
||||||
allowkeys = 1;
|
|
||||||
|
|
||||||
strcpy(modetext, instext);
|
|
||||||
} else {
|
|
||||||
curMode = 0;
|
|
||||||
allowkeys = !curMode;
|
|
||||||
|
|
||||||
strcpy(modetext, normtext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void create_window_x11(int x, int y, int w, int h) {
|
void create_window_x11(int x, int y, int w, int h) {
|
||||||
XSetWindowAttributes swa;
|
XSetWindowAttributes swa;
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,4 @@ static void create_window_x11(int x, int y, int w, int h);
|
||||||
static void set_window_x11(void);
|
static void set_window_x11(void);
|
||||||
static void set_prop_x11(void);
|
static void set_prop_x11(void);
|
||||||
static void resizeclient_x11(void);
|
static void resizeclient_x11(void);
|
||||||
static void store_image_vars(void);
|
|
||||||
static void set_mode(void);
|
|
||||||
static void xinitvisual(void);
|
static void xinitvisual(void);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
|
||||||
|
#if USEX
|
||||||
#include "xim.c"
|
#include "xim.c"
|
||||||
#include "key.c"
|
#include "key.c"
|
||||||
#include "mouse.c"
|
#include "mouse.c"
|
||||||
|
@ -11,3 +12,4 @@
|
||||||
#include "init.c"
|
#include "init.c"
|
||||||
#include "focus.c"
|
#include "focus.c"
|
||||||
#include "clipboard.c"
|
#include "clipboard.c"
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#if USEX
|
||||||
#include "lib.h"
|
#include "lib.h"
|
||||||
|
|
||||||
#include "def.h"
|
#include "def.h"
|
||||||
|
@ -10,3 +11,4 @@
|
||||||
#include "mouse.h"
|
#include "mouse.h"
|
||||||
#include "focus.h"
|
#include "focus.h"
|
||||||
#include "clipboard.h"
|
#include "clipboard.h"
|
||||||
|
#endif
|
||||||
|
|
|
@ -22,5 +22,4 @@ static void grabkeyboard_x11(void);
|
||||||
static void getcapsstate(void);
|
static void getcapsstate(void);
|
||||||
|
|
||||||
static Key ckeys[256];
|
static Key ckeys[256];
|
||||||
static char capstext[16];
|
|
||||||
static Key hkeys[1] = { { -1, Ctrl|Alt|Shift, XK_Delete, quit, {0} } };
|
static Key hkeys[1] = { { -1, Ctrl|Alt|Shift, XK_Delete, quit, {0} } };
|
||||||
|
|
|
@ -1,19 +1,5 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
|
||||||
// clicks
|
|
||||||
enum {
|
|
||||||
ClickWindow,
|
|
||||||
ClickPrompt,
|
|
||||||
ClickInput,
|
|
||||||
ClickLArrow,
|
|
||||||
ClickItem,
|
|
||||||
ClickSelItem,
|
|
||||||
ClickRArrow,
|
|
||||||
ClickNumber,
|
|
||||||
ClickCaps,
|
|
||||||
ClickMode,
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int click;
|
unsigned int click;
|
||||||
unsigned int button;
|
unsigned int button;
|
||||||
|
|
12
meson.build
12
meson.build
|
@ -14,8 +14,6 @@ project_source_files = [
|
||||||
]
|
]
|
||||||
|
|
||||||
project_dependencies = [
|
project_dependencies = [
|
||||||
dependency('x11'),
|
|
||||||
dependency('xrender'),
|
|
||||||
dependency('cairo'),
|
dependency('cairo'),
|
||||||
dependency('pango'),
|
dependency('pango'),
|
||||||
dependency('pangocairo'),
|
dependency('pangocairo'),
|
||||||
|
@ -38,6 +36,12 @@ build_args = [
|
||||||
'-Wno-sign-compare',
|
'-Wno-sign-compare',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if get_option('x11')
|
||||||
|
project_dependencies += [ dependency('x11') ]
|
||||||
|
project_dependencies += [ dependency('xrender') ]
|
||||||
|
build_args += [ '-DX11' ]
|
||||||
|
endif
|
||||||
|
|
||||||
if get_option('wayland')
|
if get_option('wayland')
|
||||||
project_dependencies += [ dependency('wayland-client') ]
|
project_dependencies += [ dependency('wayland-client') ]
|
||||||
project_dependencies += [ dependency('wayland-scanner') ]
|
project_dependencies += [ dependency('wayland-scanner') ]
|
||||||
|
@ -53,7 +57,7 @@ if get_option('wayland')
|
||||||
run_command('scripts/make/generate-headers.sh', check : false)
|
run_command('scripts/make/generate-headers.sh', check : false)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if get_option('imlib2') and get_option('openssl')
|
if get_option('imlib2') and get_option('openssl') and get_option('x11')
|
||||||
project_dependencies += [ dependency('imlib2') ]
|
project_dependencies += [ dependency('imlib2') ]
|
||||||
project_dependencies += [ dependency('openssl') ]
|
project_dependencies += [ dependency('openssl') ]
|
||||||
build_args += [ '-DIMAGE' ]
|
build_args += [ '-DIMAGE' ]
|
||||||
|
@ -64,7 +68,7 @@ if get_option('fribidi')
|
||||||
build_args += [ '-DRTL' ]
|
build_args += [ '-DRTL' ]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if get_option('xinerama')
|
if get_option('xinerama') and get_option('x11')
|
||||||
project_dependencies += [ dependency('xinerama') ]
|
project_dependencies += [ dependency('xinerama') ]
|
||||||
build_args += [ '-DXINERAMA' ]
|
build_args += [ '-DXINERAMA' ]
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -5,6 +5,20 @@ option(
|
||||||
description : 'Enable Wayland support'
|
description : 'Enable Wayland support'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
option(
|
||||||
|
'x11',
|
||||||
|
type : 'boolean',
|
||||||
|
value : true,
|
||||||
|
description : 'Enable X11 support'
|
||||||
|
)
|
||||||
|
|
||||||
|
option(
|
||||||
|
'xinerama',
|
||||||
|
type : 'boolean',
|
||||||
|
value : true,
|
||||||
|
description : 'Enable multi-monitor support using libXinerama'
|
||||||
|
)
|
||||||
|
|
||||||
option(
|
option(
|
||||||
'imlib2',
|
'imlib2',
|
||||||
type : 'boolean',
|
type : 'boolean',
|
||||||
|
@ -39,10 +53,3 @@ option(
|
||||||
value : true,
|
value : true,
|
||||||
description : 'Enable configuration file support'
|
description : 'Enable configuration file support'
|
||||||
)
|
)
|
||||||
|
|
||||||
option(
|
|
||||||
'xinerama',
|
|
||||||
type : 'boolean',
|
|
||||||
value : true,
|
|
||||||
description : 'Enable multi-monitor support using libXinerama'
|
|
||||||
)
|
|
||||||
|
|
4
mouse.h
4
mouse.h
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Only applies to X11 */
|
/* Only applies to X11 */
|
||||||
|
#if USEX
|
||||||
static Mouse buttons[] = {
|
static Mouse buttons[] = {
|
||||||
{ ClickInput, Button1, clear, {0} },
|
{ ClickInput, Button1, clear, {0} },
|
||||||
{ ClickPrompt, Button1, clear, {0} },
|
{ ClickPrompt, Button1, clear, {0} },
|
||||||
|
@ -13,10 +14,11 @@ static Mouse buttons[] = {
|
||||||
{ ClickNumber, Button1, viewhist, {0} },
|
{ ClickNumber, Button1, viewhist, {0} },
|
||||||
{ ClickSelItem, Button1, NULL, {0} },
|
{ ClickSelItem, Button1, NULL, {0} },
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Only applies to Wayland */
|
/* Only applies to Wayland */
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
static Mouse wl_buttons[] = {
|
static WlMouse wl_buttons[] = {
|
||||||
{ ClickInput, WL_Left, clear, {0} },
|
{ ClickInput, WL_Left, clear, {0} },
|
||||||
{ ClickPrompt, WL_Left, clear, {0} },
|
{ ClickPrompt, WL_Left, clear, {0} },
|
||||||
{ ClickMode, WL_Left, switchmode, {0} },
|
{ ClickMode, WL_Left, switchmode, {0} },
|
||||||
|
|
|
@ -14,19 +14,13 @@ loadconf() {
|
||||||
[ ! -f spmenu.c ] && printf "You're probably in the wrong directory.\n" && exit 1
|
[ ! -f spmenu.c ] && printf "You're probably in the wrong directory.\n" && exit 1
|
||||||
[ -x "buildconf" ] && [ ! -x "buildconf_dev" ] && source buildconf
|
[ -x "buildconf" ] && [ ! -x "buildconf_dev" ] && source buildconf
|
||||||
[ -x "buildconf_dev" ] && source buildconf_dev
|
[ -x "buildconf_dev" ] && source buildconf_dev
|
||||||
|
|
||||||
# mandatory deps
|
|
||||||
[ "$freetype" = "false" ] && printf "Freetype not found. Install it.\n" && exit 1
|
|
||||||
[ "$openssl" = "false" ] && [ "$imlib2" = "true" ] && printf "OpenSSL not found. Install it.\n" && exit 1
|
|
||||||
[ "$xrender" = "false" ] && printf "libXrender not found. Install it.\n" && exit 1
|
|
||||||
[ "$x11" = "false" ] && printf "libX11 not found. Install it.\n" && exit 1
|
|
||||||
[ "$xft" = "false" ] && printf "libXft not found. Install it.\n" && exit 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
[ ! -f "meson.build" ] && printf "meson.build does not exist.\n" && exit 1
|
[ ! -f "meson.build" ] && printf "meson.build does not exist.\n" && exit 1
|
||||||
[ "$gen_manual" != "false" ] && [ -x "$(command -v pandoc)" ] && scripts/make/generate-docs.sh
|
[ "$gen_manual" != "false" ] && [ -x "$(command -v pandoc)" ] && scripts/make/generate-docs.sh
|
||||||
[ -z "$wayland" ] && wayland=true
|
[ -z "$wayland" ] && wayland=true
|
||||||
|
[ -z "$x11" ] && x11=true
|
||||||
|
|
||||||
cp -f meson.build meson.build.orig
|
cp -f meson.build meson.build.orig
|
||||||
|
|
||||||
|
@ -45,8 +39,9 @@ build() {
|
||||||
-Dopenssl="$openssl" \
|
-Dopenssl="$openssl" \
|
||||||
-Dlibconfig="$libconfig" \
|
-Dlibconfig="$libconfig" \
|
||||||
-Dwayland="$wayland" \
|
-Dwayland="$wayland" \
|
||||||
|
-Dx11="$x11" \
|
||||||
--prefix "$prefix" \
|
--prefix "$prefix" \
|
||||||
build
|
build || exit 1
|
||||||
else
|
else
|
||||||
meson setup \
|
meson setup \
|
||||||
-Dxresources="$xresources" $STATIC \
|
-Dxresources="$xresources" $STATIC \
|
||||||
|
@ -56,8 +51,9 @@ build() {
|
||||||
-Dopenssl="$openssl" \
|
-Dopenssl="$openssl" \
|
||||||
-Dlibconfig="$libconfig" \
|
-Dlibconfig="$libconfig" \
|
||||||
-Dwayland="$wayland" \
|
-Dwayland="$wayland" \
|
||||||
|
-Dx11="$x11" \
|
||||||
--prefix "$prefix" \
|
--prefix "$prefix" \
|
||||||
build
|
build || exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ninja -C build
|
ninja -C build
|
||||||
|
|
79
spmenu.c
79
spmenu.c
|
@ -1,15 +1,4 @@
|
||||||
/* spmenu - fancy dynamic menu
|
/* spmenu - fancy dynamic menu
|
||||||
*
|
|
||||||
* If you're looking for functions used to draw text, see 'libs/draw.c'
|
|
||||||
* If you're looking for wrapper functions used inside the draw functions, see 'libs/libdrw/drw.c'
|
|
||||||
* If you're looking for functions used to draw images, see 'libs/img.c'
|
|
||||||
* If you're looking for the .Xresources array, see 'libs/x11/xresources.h'
|
|
||||||
*
|
|
||||||
* You don't need to edit spmenu.c if you aren't making big changes to the software.
|
|
||||||
*
|
|
||||||
* After making changes, run `./build.sh` to attempt to build the software.
|
|
||||||
* `scripts/make/generate-docs.sh` will generate a man page from 'docs/docs.md', which is a Markdown document. Run this before commiting.
|
|
||||||
*
|
|
||||||
* See LICENSE file for copyright and license details.
|
* See LICENSE file for copyright and license details.
|
||||||
*/
|
*/
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -71,6 +60,13 @@
|
||||||
#define USEWAYLAND 1
|
#define USEWAYLAND 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// check if we should enable X11 support
|
||||||
|
#ifndef X11
|
||||||
|
#define USEX 0
|
||||||
|
#else
|
||||||
|
#define USEX 1
|
||||||
|
#endif
|
||||||
|
|
||||||
// include fribidi used for right to left language support
|
// include fribidi used for right to left language support
|
||||||
#if USERTL
|
#if USERTL
|
||||||
#include <fribidi.h>
|
#include <fribidi.h>
|
||||||
|
@ -109,7 +105,9 @@ static char text[BUFSIZ] = "";
|
||||||
static char numbers[NUMBERSBUFSIZE] = "";
|
static char numbers[NUMBERSBUFSIZE] = "";
|
||||||
|
|
||||||
// keybinds
|
// keybinds
|
||||||
|
#if USEX
|
||||||
static int numlockmask = 0;
|
static int numlockmask = 0;
|
||||||
|
#endif
|
||||||
static int capslockstate = 0;
|
static int capslockstate = 0;
|
||||||
|
|
||||||
static int bh, mw, mh; // height of each item, menu width, menu height
|
static int bh, mw, mh; // height of each item, menu width, menu height
|
||||||
|
@ -133,8 +131,10 @@ static unsigned int sel_size = 0;
|
||||||
static int protocol_override = 0;
|
static int protocol_override = 0;
|
||||||
static int itemn = 0; // item number
|
static int itemn = 0; // item number
|
||||||
|
|
||||||
|
#if USEX
|
||||||
static char *embed; // X11 embed
|
static char *embed; // X11 embed
|
||||||
static int screen; // screen
|
static int screen; // screen
|
||||||
|
#endif
|
||||||
|
|
||||||
// item struct
|
// item struct
|
||||||
struct item {
|
struct item {
|
||||||
|
@ -184,10 +184,12 @@ static int ignoreconfmouse = 0; // same for mouse
|
||||||
static int ignoreglobalmouse = 0; // same for mouse
|
static int ignoreglobalmouse = 0; // same for mouse
|
||||||
|
|
||||||
// colors
|
// colors
|
||||||
|
#if USEX
|
||||||
static int useargb;
|
static int useargb;
|
||||||
static int depth;
|
static int depth;
|
||||||
static Visual *visual;
|
static Visual *visual;
|
||||||
static Colormap cmap;
|
static Colormap cmap;
|
||||||
|
#endif
|
||||||
static Drw *drw;
|
static Drw *drw;
|
||||||
|
|
||||||
// declare functions
|
// declare functions
|
||||||
|
@ -197,10 +199,13 @@ static void recalculatenumbers(void);
|
||||||
static void insert(const char *str, ssize_t n);
|
static void insert(const char *str, ssize_t n);
|
||||||
static void cleanup(void);
|
static void cleanup(void);
|
||||||
static void navigatehistfile(int dir);
|
static void navigatehistfile(int dir);
|
||||||
|
#if USEX
|
||||||
static void pastesel(void);
|
static void pastesel(void);
|
||||||
|
static void grabfocus(void);
|
||||||
|
#endif
|
||||||
static void resizeclient(void);
|
static void resizeclient(void);
|
||||||
static void get_width(void);
|
static void get_width(void);
|
||||||
static void grabfocus(void);
|
static void set_mode(void);
|
||||||
static void handle(void);
|
static void handle(void);
|
||||||
static void appenditem(struct item *item, struct item **list, struct item **last);
|
static void appenditem(struct item *item, struct item **list, struct item **last);
|
||||||
static int max_textw(void);
|
static int max_textw(void);
|
||||||
|
@ -214,11 +219,26 @@ static size_t listsize;
|
||||||
static int listcount;
|
static int listcount;
|
||||||
static int listchanged = 0;
|
static int listchanged = 0;
|
||||||
|
|
||||||
|
// clicks
|
||||||
|
enum {
|
||||||
|
ClickWindow,
|
||||||
|
ClickPrompt,
|
||||||
|
ClickInput,
|
||||||
|
ClickLArrow,
|
||||||
|
ClickItem,
|
||||||
|
ClickSelItem,
|
||||||
|
ClickRArrow,
|
||||||
|
ClickNumber,
|
||||||
|
ClickCaps,
|
||||||
|
ClickMode,
|
||||||
|
};
|
||||||
|
|
||||||
// user configuration
|
// user configuration
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "keybinds.h"
|
#include "keybinds.h"
|
||||||
#include "mouse.h"
|
#include "mouse.h"
|
||||||
|
|
||||||
|
static char capstext[16];
|
||||||
static char *fonts[] = { font };
|
static char *fonts[] = { font };
|
||||||
|
|
||||||
// color array
|
// color array
|
||||||
|
@ -361,9 +381,11 @@ void cleanup(void) {
|
||||||
// free drawing and close the display
|
// free drawing and close the display
|
||||||
drw_free(drw);
|
drw_free(drw);
|
||||||
|
|
||||||
|
#if USEX
|
||||||
if (!protocol) {
|
if (!protocol) {
|
||||||
cleanup_x11(dpy);
|
cleanup_x11(dpy);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
free(sel_index);
|
free(sel_index);
|
||||||
}
|
}
|
||||||
|
@ -385,9 +407,11 @@ char * cistrstr(const char *h, const char *n) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if USEX
|
||||||
void grabfocus(void) {
|
void grabfocus(void) {
|
||||||
grabfocus_x11();
|
grabfocus_x11();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void insert(const char *str, ssize_t n) {
|
void insert(const char *str, ssize_t n) {
|
||||||
if (strlen(text) + n > sizeof text - 1)
|
if (strlen(text) + n > sizeof text - 1)
|
||||||
|
@ -423,20 +447,24 @@ size_t nextrune(int inc) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if USEX
|
||||||
void pastesel(void) {
|
void pastesel(void) {
|
||||||
if (!protocol) {
|
if (!protocol) {
|
||||||
pastesel_x11();
|
pastesel_x11();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void resizeclient(void) {
|
void resizeclient(void) {
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
if (protocol) {
|
if (protocol) {
|
||||||
resizeclient_wl(&state);
|
resizeclient_wl(&state);
|
||||||
} else {
|
} else {
|
||||||
|
#if USEX
|
||||||
resizeclient_x11();
|
resizeclient_x11();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#else
|
#elif USEX
|
||||||
resizeclient_x11();
|
resizeclient_x11();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -445,8 +473,28 @@ void get_width(void) {
|
||||||
inputw = mw / 3;
|
inputw = mw / 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_mode(void) {
|
||||||
|
if (!type) { // no typing allowed, require normal mode
|
||||||
|
mode = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set default mode, must be done before the event loop or keybindings will not work
|
||||||
|
if (mode) {
|
||||||
|
curMode = 1;
|
||||||
|
allowkeys = 1;
|
||||||
|
|
||||||
|
strcpy(modetext, instext);
|
||||||
|
} else {
|
||||||
|
curMode = 0;
|
||||||
|
allowkeys = !curMode;
|
||||||
|
|
||||||
|
strcpy(modetext, normtext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void handle(void) {
|
void handle(void) {
|
||||||
if (!protocol) {
|
if (!protocol) {
|
||||||
|
#if USEX
|
||||||
handle_x11();
|
handle_x11();
|
||||||
|
|
||||||
if (!drw_font_create(drw, fonts, LENGTH(fonts))) {
|
if (!drw_font_create(drw, fonts, LENGTH(fonts))) {
|
||||||
|
@ -454,7 +502,9 @@ void handle(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
loadhistory(); // read history entries
|
loadhistory(); // read history entries
|
||||||
|
#if USEX
|
||||||
store_image_vars();
|
store_image_vars();
|
||||||
|
#endif
|
||||||
|
|
||||||
// fast (-f) means we grab keyboard before reading standard input
|
// fast (-f) means we grab keyboard before reading standard input
|
||||||
if (fast && !isatty(0)) {
|
if (fast && !isatty(0)) {
|
||||||
|
@ -470,10 +520,13 @@ void handle(void) {
|
||||||
init_appearance(); // init colorschemes by reading arrays
|
init_appearance(); // init colorschemes by reading arrays
|
||||||
setupdisplay_x11(); // set up display and create window
|
setupdisplay_x11(); // set up display and create window
|
||||||
eventloop_x11(); // function is a loop which checks X11 events and calls other functions accordingly
|
eventloop_x11(); // function is a loop which checks X11 events and calls other functions accordingly
|
||||||
|
#endif
|
||||||
#if USEWAYLAND
|
#if USEWAYLAND
|
||||||
} else {
|
} else {
|
||||||
loadhistory();
|
loadhistory();
|
||||||
|
#if USEIMAGE
|
||||||
store_image_vars();
|
store_image_vars();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Disable some X11 only features
|
// Disable some X11 only features
|
||||||
menupaddingv = menupaddingh = 0;
|
menupaddingv = menupaddingh = 0;
|
||||||
|
|
Loading…
Reference in a new issue