Version bump: 3.3 #26

Merged
speedie merged 3 commits from 3.3 into master 2023-08-12 19:05:03 +02:00
12 changed files with 142 additions and 72 deletions
Showing only changes of commit c25009de3c - Show all commits

View file

@ -782,6 +782,12 @@ for performance reasons.
| setlines- | Decrease lines by 1 |
| setcolumns+ | Increase columns by 1 |
| setcolumns- | Decrease columns by 1 |
| setx+ | Increase X position by 1 |
| setx- | Decrease X position by 1 |
| sety+ | Increase Y position by 1 |
| sety- | Decrease Y position by 1 |
| setw+ | Increase width by 1 |
| setw- | Decrease width by 1 |
| moveup | Move up one item |
| movedown | Move down one item |
| moveleft | Move left one item |
@ -1175,6 +1181,10 @@ bind:
- Set lines to passed argument
- `setcolumns`
- Set columns to passed argument
- `setx`
- Set X position to passed argument
- `sety`
- Set Y position to passed argument
- `setlineheight`
- Set line height to passed argument
- `setprofile`

View file

@ -600,6 +600,27 @@ void setcolumns(Arg *arg) {
drawmenu();
}
void setx(Arg *arg) {
xpos += arg->i;
resizeclient();
drawmenu();
}
void sety(Arg *arg) {
ypos += arg->i;
resizeclient();
drawmenu();
}
void setw(Arg *arg) {
menuwidth += arg->i;
resizeclient();
drawmenu();
}
void spawn(Arg *arg) {
if (!system(arg->c))
die("spmenu: failed to execute command '%s'", arg->c);

View file

@ -57,6 +57,9 @@ static void screenshot(Arg *arg);
static void switchmode(Arg *arg);
static void setprofile(Arg *arg);
static void setlineheight(Arg *arg);
static void setx(Arg *arg);
static void sety(Arg *arg);
static void setw(Arg *arg);
static void quit(Arg *arg);
/* toggle */

View file

@ -377,6 +377,9 @@ static FuncList fl[] = {
{ "setlines", setlines },
{ "screenshot", screenshot },
{ "setcolumns", setcolumns },
{ "setx", setx },
{ "sety", sety },
{ "setw", setw },
{ "toggleinput", toggleinput },
{ "togglepretext", togglepretext },
{ "togglelarrow", togglelarrow },

View file

@ -29,12 +29,16 @@ void execute_fifo_cmd(void) {
* by outputting text to the FIFO.
*/
if (!strcmp(fifot, "drawmenu")) {
drawmenu();
if (!sp.isdrawing) {
drawmenu();
}
} else if (!strcmp(fifot, "match")) {
match();
} else if (!strcmp(fifot, "update")) {
match();
drawmenu();
if (!sp.isdrawing) {
match();
drawmenu();
}
} else if (!strcmp(fifot, "test")) {
fprintf(stderr, "Test print\n");
} else if (!strcmp(fifot, "die")) {
@ -109,7 +113,7 @@ void execute_fifo_cmd(void) {
setprofile(&arg);
} else if (!strcmp(fifot, "setlines+")) {
Arg arg;
arg.i = +1;
arg.i = 1;
setlines(&arg);
} else if (!strcmp(fifot, "setlines-")) {
Arg arg;
@ -123,6 +127,30 @@ void execute_fifo_cmd(void) {
Arg arg;
arg.i = -1;
setcolumns(&arg);
} else if (!strcmp(fifot, "setx+")) {
Arg arg;
arg.i = 1;
setx(&arg);
} else if (!strcmp(fifot, "setx-")) {
Arg arg;
arg.i = -1;
setx(&arg);
} else if (!strcmp(fifot, "sety+")) {
Arg arg;
arg.i = 1;
sety(&arg);
} else if (!strcmp(fifot, "sety-")) {
Arg arg;
arg.i = -1;
sety(&arg);
} else if (!strcmp(fifot, "setw+")) {
Arg arg;
arg.i = 1;
setw(&arg);
} else if (!strcmp(fifot, "setw-")) {
Arg arg;
arg.i = -1;
setw(&arg);
} else if (!strcmp(fifot, "moveup")) {
Arg arg;
moveup(&arg);

View file

@ -365,8 +365,8 @@ void resizetoimageheight_x11(int imageheight) {
x = (mo.output_width - sp.mw) / 2 + xpos;
y = (mo.output_height - sp.mh) / 2 - ypos;
} else { // top or bottom
x = 0;
y = menuposition ? 0 : mo.output_width - sp.mh - ypos;
x = xpos;
y = menuposition ? (-ypos) : (mo.output_height - sp.mh - ypos);
sp.mw = (menuwidth > 0 ? menuwidth : mo.output_width);
}

View file

@ -10,10 +10,7 @@ struct wl_buffer *create_buffer(struct state *state) {
size_t siz = stride * height;
int fd = create_shm_file(siz);
if (fd == -1) {
die("create_buffer(): fd == -1");
}
assert(fd != -1);
void *data = mmap(NULL, siz, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
@ -89,7 +86,7 @@ char *wl_clipboard(void) {
fp = popen("which wl-paste > /dev/null && wl-paste -t text/plain", "r");
if (fp == NULL) {
fprintf(stderr, "wl_clipboard(): Failed to open command\n");
fprintf(stderr, "spmenu: Failed to open command\n");
return NULL;
}
@ -247,7 +244,7 @@ void keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard, uint32_t forma
char *map_shm = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
if (map_shm == MAP_FAILED) {
close(fd);
die("keyboard_keymap(): MAP_FAILED");
die("MAP_FAILED");
return;
}
state->xkb_keymap = xkb_keymap_new_from_string(state->xkb_context, map_shm, XKB_KEYMAP_FORMAT_TEXT_V1, 0);
@ -483,11 +480,11 @@ void create_drawable(struct state *state) {
state->buffer = create_buffer(state);
if (draw == NULL) {
die("create_drawable(): A drawable was not created.");
die("spmenu: draw == NULL");
}
if (state->buffer == NULL) {
die("create_drawable(): Buffer state->buffer could not be created.");
die("state->buffer == NULL");
}
draw_create_surface_wl(draw, state->data, state->width, state->height);
@ -572,13 +569,13 @@ int await_dispatch(struct state *state) {
do {
if (wl_display_flush(state->display) == -1 && errno != EAGAIN) {
fprintf(stderr, "await_dispatch(): wl_display_flush failed: %s\n", strerror(errno));
fprintf(stderr, "spmenu: wl_display_flush failed: %s\n", strerror(errno));
break;
}
} while (errno == EAGAIN);
if (poll(fds, nfds, -1) < 0) {
fprintf(stderr, "await_dispatch(): poll failed: %s\n", strerror(errno));
fprintf(stderr, "spmenu: poll failed: %s\n", strerror(errno));
break;
}
@ -611,17 +608,13 @@ int init_disp(struct state *state) {
wl_registry_add_listener(registry, &registry_listener, state);
wl_display_roundtrip(state->display);
if (state->compositor == NULL) {
die("init_disp(): No Wayland compositor.");
}
assert(state->compositor != NULL);
if (state->layer_shell == NULL) {
die("init_disp(): Your compositor does not implement the wlr-layer-shell protocol.");
die("spmenu: Your compositor does not implement the wlr-layer-shell protocol. Run spmenu in X11 mode.");
}
if (state->shm == NULL) {
die("init_disp(): Could not create shared memory buffer.\n");
}
assert(state->shm != NULL);
wl_display_roundtrip(state->display);
@ -660,7 +653,7 @@ void resizeclient_wl(struct state *state) {
state->buffer = create_buffer(state);
if (draw == NULL) {
die("resizeclient_wl(): Draw_t is NULL.");
die("spmenu: draw == NULL");
}
if (state->buffer == NULL) {
@ -698,19 +691,12 @@ int init_keys(struct state *state) {
}
int create_layer(struct state *state, char *name) {
if (state->compositor == NULL) {
die("create_layer(): No Wayland compositor.");
}
assert(state->compositor != NULL);
state->surface = wl_compositor_create_surface(state->compositor);
if (state->surface == NULL) {
die("create_layer(): Could not create surface state->surface using state->compositor");
}
if (state->layer_shell == NULL) {
die("create_layer(): Your compositor does not implement the wlr-layer-shell protocol. Run spmenu in X11 mode.");
}
assert(state->surface != NULL);
assert(state->layer_shell != NULL);
wl_surface_add_listener(state->surface, &surface_listener, state);
state->layer_surface = zwlr_layer_shell_v1_get_layer_surface(
@ -720,18 +706,13 @@ int create_layer(struct state *state, char *name) {
ZWLR_LAYER_SHELL_V1_LAYER_TOP,
name);
if (state->layer_surface == NULL) {
die("create_layer(): Could not get layer_surface state->layer_surface");
}
assert(state->layer_surface != NULL);
return 0;
}
int anchor_layer(struct state *state, int position) {
if (state->layer_surface == NULL) {
die("anchor_layer(): Could not get layer_surface state->layer_surface");
}
assert(state->layer_surface != NULL);
zwlr_layer_surface_v1_set_anchor(
state->layer_surface,
ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
@ -744,9 +725,7 @@ int anchor_layer(struct state *state, int position) {
}
int set_layer_size(struct state *state, int32_t width, int32_t height) {
if (state->layer_surface != NULL) {
die("set_layer_size(): Could not get layer_surface state->layer_surface");
}
assert(state->layer_surface != NULL);
zwlr_layer_surface_v1_set_size(state->layer_surface, width, height);
@ -754,9 +733,7 @@ int set_layer_size(struct state *state, int32_t width, int32_t height) {
}
int set_exclusive_zone(struct state *state, unsigned int val) {
if (state->layer_surface == NULL) {
die("set_exclusive_zone(): Could not get layer_surface state->layer_surface");
}
assert(state->layer_surface != NULL);
zwlr_layer_surface_v1_set_exclusive_zone(state->layer_surface, val);
@ -764,9 +741,7 @@ int set_exclusive_zone(struct state *state, unsigned int val) {
}
int set_keyboard(struct state *state, int interactivity) {
if (state->layer_surface == NULL) {
die("set_keyboard(): Could not get layer_surface state->layer_surface");
}
assert(state->layer_surface != NULL);
zwlr_layer_surface_v1_set_keyboard_interactivity(state->layer_surface, interactivity ? true : false);
@ -774,9 +749,7 @@ int set_keyboard(struct state *state, int interactivity) {
}
int add_layer_listener(struct state *state) {
if (state->layer_surface == NULL) {
die("add_layer_listener(): Could not get layer_surface state->layer_surface");
}
assert(state->layer_surface != NULL);
zwlr_layer_surface_v1_add_listener(state->layer_surface, &layer_surface_listener, state);
@ -784,9 +757,8 @@ int add_layer_listener(struct state *state) {
}
int set_visible_layer(struct state *state) {
if (state->layer_surface == NULL) {
die("set_visible_layer(): Could not get layer_surface state->layer_surface");
}
assert(state->layer_surface != NULL);
assert(state->surface != NULL);
wl_surface_commit(state->surface);

View file

@ -8,6 +8,7 @@
#include <sys/mman.h>
#include <time.h>
#include <sys/timerfd.h>
#include <assert.h>
#include <signal.h>
#include <poll.h>
#include <wayland-client.h>

View file

@ -70,7 +70,6 @@ void set_prop_x11(void) {
}
void resizeclient_x11(void) {
int mh = sp.mh;
int x, y;
struct item *item;
int ic = 0; // item count
@ -98,14 +97,11 @@ void resizeclient_x11(void) {
x = (mo.output_width - sp.mw) / 2 + xpos;
y = (mo.output_height - sp.mh) / 2 - ypos;
} else { // top or bottom
x = 0;
y = menuposition ? 0 : mo.output_height - sp.mh - ypos;
x = xpos;
y = menuposition ? (-ypos) : (mo.output_height - sp.mh - ypos);
sp.mw = (menuwidth > 0 ? menuwidth : mo.output_width);
}
// no window/invalid window or menu height we had before is the same as the current window height
if (!win || mh == sp.mh) return;
XMoveResizeWindow(dpy, win, x + sp.sp, y + sp.vp, sp.mw - 2 * sp.sp - borderwidth * 2, sp.mh);
draw_resize(draw, sp.mw - 2 * sp.sp - borderwidth * 2, sp.mh);
}

View file

@ -71,8 +71,8 @@ void setupdisplay_x11(void) {
x = (mo.output_width - sp.mw) / 2 + xpos;
y = (mo.output_height - sp.mh) / 2 - ypos;
} else { // top or bottom
x = 0;
y = menuposition ? 0 : mo.output_height - sp.mh - ypos;
x = xpos;
y = menuposition ? (-ypos) : (mo.output_height - sp.mh - ypos);
sp.mw = (menuwidth > 0 ? menuwidth : mo.output_width);
}

View file

@ -874,12 +874,6 @@ Otherwise it will be considered invalid.
It is recommended that you sleep for 0.1 seconds after appending to the
file for performance reasons.
.PP
\f[B]NOTE: Please remove /tmp/spmenu.fifo if it exists after usage,
especially in scripts.
Otherwise the FIFO action may be carried over to the user\[cq]s next
spmenu use.
If you love your users, do not ignore this warning.\f[R]
.PP
.TS
tab(@);
lw(12.7n) lw(57.3n).
@ -1041,6 +1035,36 @@ T}@T{
Decrease columns by 1
T}
T{
setx+
T}@T{
Increase X position by 1
T}
T{
setx-
T}@T{
Decrease X position by 1
T}
T{
sety+
T}@T{
Increase Y position by 1
T}
T{
sety-
T}@T{
Decrease Y position by 1
T}
T{
setw+
T}@T{
Increase width by 1
T}
T{
setw-
T}@T{
Decrease width by 1
T}
T{
moveup
T}@T{
Move up one item
@ -2517,6 +2541,18 @@ Set lines to passed argument
Set columns to passed argument
.RE
.IP \[bu] 2
\f[V]setx\f[R]
.RS 2
.IP \[bu] 2
Set X position to passed argument
.RE
.IP \[bu] 2
\f[V]sety\f[R]
.RS 2
.IP \[bu] 2
Set Y position to passed argument
.RE
.IP \[bu] 2
\f[V]setlineheight\f[R]
.RS 2
.IP \[bu] 2

View file

@ -510,11 +510,11 @@ void get_mh(void) {
}
void set_mode(void) {
if (!type) {
if (!type) { // no typing allowed, require normal mode
sp.mode = 0;
}
// set default mode
// set default mode, must be done before the event loop or keybindings will not work
if (mode) {
sp.mode = 1;
sp.allowkeys = 1;