Change from using xdg shell v5 to v6.
Also fix shell return value detection.
This commit is contained in:
parent
b27f17da65
commit
99577c8e88
8
Makefile
8
Makefile
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
include config.mk
|
include config.mk
|
||||||
|
|
||||||
SRC = st.c xdg-shell-unstable-v5-protocol.c
|
SRC = st.c xdg-shell-unstable-v6-protocol.c
|
||||||
OBJ = ${SRC:.c=.o}
|
OBJ = ${SRC:.c=.o}
|
||||||
|
|
||||||
all: options st
|
all: options st
|
||||||
@ -17,15 +17,15 @@ options:
|
|||||||
config.h:
|
config.h:
|
||||||
cp config.def.h config.h
|
cp config.def.h config.h
|
||||||
|
|
||||||
xdg-shell-unstable-v5-protocol.c:
|
xdg-shell-unstable-v6-protocol.c:
|
||||||
@echo GEN $@
|
@echo GEN $@
|
||||||
@wayland-scanner code ${XDG_SHELL_PROTO} $@
|
@wayland-scanner code ${XDG_SHELL_PROTO} $@
|
||||||
|
|
||||||
xdg-shell-unstable-v5-client-protocol.h:
|
xdg-shell-unstable-v6-client-protocol.h:
|
||||||
@echo GEN $@
|
@echo GEN $@
|
||||||
@wayland-scanner client-header ${XDG_SHELL_PROTO} $@
|
@wayland-scanner client-header ${XDG_SHELL_PROTO} $@
|
||||||
|
|
||||||
st.o: xdg-shell-unstable-v5-client-protocol.h
|
st.o: xdg-shell-unstable-v6-client-protocol.h
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
@echo CC $<
|
@echo CC $<
|
||||||
|
@ -8,7 +8,7 @@ PREFIX = /usr/local
|
|||||||
MANPREFIX = ${PREFIX}/share/man
|
MANPREFIX = ${PREFIX}/share/man
|
||||||
|
|
||||||
PKGCFG = fontconfig wayland-client wayland-cursor xkbcommon wld
|
PKGCFG = fontconfig wayland-client wayland-cursor xkbcommon wld
|
||||||
XDG_SHELL_PROTO = `pkg-config --variable=pkgdatadir wayland-protocols`/unstable/xdg-shell/xdg-shell-unstable-v5.xml
|
XDG_SHELL_PROTO = `pkg-config --variable=pkgdatadir wayland-protocols`/unstable/xdg-shell/xdg-shell-unstable-v6.xml
|
||||||
|
|
||||||
# includes and libs
|
# includes and libs
|
||||||
INCS = -I. -I/usr/include `pkg-config --cflags ${PKGCFG}`
|
INCS = -I. -I/usr/include `pkg-config --cflags ${PKGCFG}`
|
||||||
|
82
st.c
82
st.c
@ -33,7 +33,7 @@
|
|||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
#include "arg.h"
|
#include "arg.h"
|
||||||
#include "xdg-shell-unstable-v5-client-protocol.h"
|
#include "xdg-shell-unstable-v6-client-protocol.h"
|
||||||
|
|
||||||
char *argv0;
|
char *argv0;
|
||||||
|
|
||||||
@ -276,8 +276,9 @@ typedef struct {
|
|||||||
struct wl_data_offer *seloffer;
|
struct wl_data_offer *seloffer;
|
||||||
struct wl_surface *surface;
|
struct wl_surface *surface;
|
||||||
struct wl_buffer *buffer;
|
struct wl_buffer *buffer;
|
||||||
struct xdg_shell *shell;
|
struct zxdg_shell_v6 *shell;
|
||||||
struct xdg_surface *xdgsurface;
|
struct zxdg_surface_v6 *xdgsurface;
|
||||||
|
struct zxdg_toplevel_v6 *xdgtoplevel;
|
||||||
XKB xkb;
|
XKB xkb;
|
||||||
bool configured;
|
bool configured;
|
||||||
int px, py; /* pointer x and y */
|
int px, py; /* pointer x and y */
|
||||||
@ -515,10 +516,12 @@ static void ptrbutton(void *, struct wl_pointer *, uint32_t, uint32_t,
|
|||||||
uint32_t, uint32_t);
|
uint32_t, uint32_t);
|
||||||
static void ptraxis(void *, struct wl_pointer *, uint32_t, uint32_t,
|
static void ptraxis(void *, struct wl_pointer *, uint32_t, uint32_t,
|
||||||
wl_fixed_t);
|
wl_fixed_t);
|
||||||
static void xdgshellping(void *, struct xdg_shell *, uint32_t);
|
static void xdgshellping(void *, struct zxdg_shell_v6 *, uint32_t);
|
||||||
static void xdgsurfconfigure(void *, struct xdg_surface *,
|
static void xdgsurfconfigure(void *, struct zxdg_surface_v6 *,
|
||||||
int32_t, int32_t, struct wl_array *, uint32_t);
|
uint32_t);
|
||||||
static void xdgsurfclose(void *, struct xdg_surface *);
|
static void xdgtoplevelconfigure(void *, struct zxdg_toplevel_v6 *,
|
||||||
|
int32_t, int32_t, struct wl_array *);
|
||||||
|
static void xdgtoplevelclose(void *, struct zxdg_toplevel_v6 *);
|
||||||
static void datadevoffer(void *, struct wl_data_device *,
|
static void datadevoffer(void *, struct wl_data_device *,
|
||||||
struct wl_data_offer *);
|
struct wl_data_offer *);
|
||||||
static void datadeventer(void *, struct wl_data_device *, uint32_t,
|
static void datadeventer(void *, struct wl_data_device *, uint32_t,
|
||||||
@ -565,9 +568,11 @@ static struct wl_keyboard_listener kbdlistener =
|
|||||||
{ kbdkeymap, kbdenter, kbdleave, kbdkey, kbdmodifiers, kbdrepeatinfo };
|
{ kbdkeymap, kbdenter, kbdleave, kbdkey, kbdmodifiers, kbdrepeatinfo };
|
||||||
static struct wl_pointer_listener ptrlistener =
|
static struct wl_pointer_listener ptrlistener =
|
||||||
{ ptrenter, ptrleave, ptrmotion, ptrbutton, ptraxis };
|
{ ptrenter, ptrleave, ptrmotion, ptrbutton, ptraxis };
|
||||||
static struct xdg_shell_listener xdgshelllistener = { xdgshellping };
|
static struct zxdg_shell_v6_listener xdgshelllistener = { xdgshellping };
|
||||||
static struct xdg_surface_listener xdgsurflistener =
|
static struct zxdg_surface_v6_listener xdgsurflistener =
|
||||||
{ xdgsurfconfigure, xdgsurfclose };
|
{ xdgsurfconfigure };
|
||||||
|
static struct zxdg_toplevel_v6_listener xdgtoplevellistener =
|
||||||
|
{ xdgtoplevelconfigure, xdgtoplevelclose };
|
||||||
static struct wl_data_device_listener datadevlistener =
|
static struct wl_data_device_listener datadevlistener =
|
||||||
{ datadevoffer, datadeventer, datadevleave, datadevmotion, datadevdrop,
|
{ datadevoffer, datadeventer, datadevleave, datadevmotion, datadevdrop,
|
||||||
datadevselection };
|
datadevselection };
|
||||||
@ -1231,7 +1236,7 @@ sigchld(int a)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!WIFEXITED(stat) || WEXITSTATUS(stat))
|
if (!WIFEXITED(stat) || WEXITSTATUS(stat))
|
||||||
die("child finished with error '%d'\n", stat);
|
die("child finished with error '%d'\n", WEXITSTATUS(stat));
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3408,9 +3413,13 @@ wlinit(void)
|
|||||||
wl.surface = wl_compositor_create_surface(wl.cmp);
|
wl.surface = wl_compositor_create_surface(wl.cmp);
|
||||||
wl_surface_add_listener(wl.surface, &surflistener, NULL);
|
wl_surface_add_listener(wl.surface, &surflistener, NULL);
|
||||||
|
|
||||||
wl.xdgsurface = xdg_shell_get_xdg_surface(wl.shell, wl.surface);
|
wl.xdgsurface = zxdg_shell_v6_get_xdg_surface(wl.shell, wl.surface);
|
||||||
xdg_surface_add_listener(wl.xdgsurface, &xdgsurflistener, NULL);
|
zxdg_surface_v6_add_listener(wl.xdgsurface, &xdgsurflistener, NULL);
|
||||||
xdg_surface_set_app_id(wl.xdgsurface, opt_class ? opt_class : termname);
|
wl.xdgtoplevel = zxdg_surface_v6_get_toplevel(wl.xdgsurface);
|
||||||
|
zxdg_toplevel_v6_set_app_id(wl.xdgtoplevel,
|
||||||
|
opt_class ? opt_class : termname);
|
||||||
|
zxdg_toplevel_v6_add_listener(wl.xdgtoplevel, &xdgtoplevellistener,
|
||||||
|
NULL);
|
||||||
|
|
||||||
wl.xkb.ctx = xkb_context_new(0);
|
wl.xkb.ctx = xkb_context_new(0);
|
||||||
wlresettitle();
|
wlresettitle();
|
||||||
@ -3779,7 +3788,7 @@ wldrawcursor(void)
|
|||||||
void
|
void
|
||||||
wlsettitle(char *title)
|
wlsettitle(char *title)
|
||||||
{
|
{
|
||||||
xdg_surface_set_title(wl.xdgsurface, title);
|
zxdg_toplevel_v6_set_title(wl.xdgtoplevel, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -3945,12 +3954,10 @@ regglobal(void *data, struct wl_registry *registry, uint32_t name,
|
|||||||
if (strcmp(interface, "wl_compositor") == 0) {
|
if (strcmp(interface, "wl_compositor") == 0) {
|
||||||
wl.cmp = wl_registry_bind(registry, name,
|
wl.cmp = wl_registry_bind(registry, name,
|
||||||
&wl_compositor_interface, 3);
|
&wl_compositor_interface, 3);
|
||||||
} else if (strcmp(interface, "xdg_shell") == 0) {
|
} else if (strcmp(interface, "zxdg_shell_v6") == 0) {
|
||||||
wl.shell = wl_registry_bind(registry, name,
|
wl.shell = wl_registry_bind(registry, name,
|
||||||
&xdg_shell_interface, 1);
|
&zxdg_shell_v6_interface, 1);
|
||||||
xdg_shell_add_listener(wl.shell, &xdgshelllistener, NULL);
|
zxdg_shell_v6_add_listener(wl.shell, &xdgshelllistener, NULL);
|
||||||
xdg_shell_use_unstable_version(wl.shell,
|
|
||||||
XDG_SHELL_VERSION_CURRENT);
|
|
||||||
} else if (strcmp(interface, "wl_shm") == 0) {
|
} else if (strcmp(interface, "wl_shm") == 0) {
|
||||||
wl.shm = wl_registry_bind(registry, name, &wl_shm_interface, 1);
|
wl.shm = wl_registry_bind(registry, name, &wl_shm_interface, 1);
|
||||||
} else if (strcmp(interface, "wl_seat") == 0) {
|
} else if (strcmp(interface, "wl_seat") == 0) {
|
||||||
@ -4293,27 +4300,44 @@ ptraxis(void * data, struct wl_pointer * pointer, uint32_t time, uint32_t axis,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xdgshellping(void *data, struct xdg_shell *shell, uint32_t serial)
|
xdgshellping(void *data, struct zxdg_shell_v6 *shell, uint32_t serial)
|
||||||
{
|
{
|
||||||
xdg_shell_pong(shell, serial);
|
zxdg_shell_v6_pong(shell, serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xdgsurfconfigure(void *data, struct xdg_surface *surf, int32_t w, int32_t h,
|
xdgsurfconfigure(void *data, struct zxdg_surface_v6 *surf, uint32_t serial)
|
||||||
struct wl_array *states, uint32_t serial)
|
|
||||||
{
|
{
|
||||||
xdg_surface_ack_configure(surf, serial);
|
zxdg_surface_v6_ack_configure(surf, serial);
|
||||||
if (w == wl.w && h == wl.h)
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xdgtoplevelconfigure(void *data, struct zxdg_toplevel_v6 *toplevel,
|
||||||
|
int32_t w, int32_t h, struct wl_array *states)
|
||||||
|
{
|
||||||
|
|
||||||
|
enum zxdg_toplevel_v6_state *state;
|
||||||
|
bool visible = 0;
|
||||||
|
wl_array_for_each(state, states) {
|
||||||
|
if(*state == ZXDG_TOPLEVEL_V6_STATE_ACTIVATED) visible = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(visible)
|
||||||
|
wl.state |= WIN_VISIBLE;
|
||||||
|
else
|
||||||
|
wl.state &= ~WIN_VISIBLE;
|
||||||
|
|
||||||
|
if(w == wl.w && h == wl.h)
|
||||||
return;
|
return;
|
||||||
cresize(w, h);
|
cresize(w,h);
|
||||||
if (wl.configured)
|
if(wl.configured)
|
||||||
ttyresize();
|
ttyresize();
|
||||||
else
|
else
|
||||||
wl.configured = true;
|
wl.configured = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xdgsurfclose(void *data, struct xdg_surface *surf)
|
xdgtoplevelclose(void *data, struct zxdg_toplevel_v6 *toplevel)
|
||||||
{
|
{
|
||||||
/* Send SIGHUP to shell */
|
/* Send SIGHUP to shell */
|
||||||
kill(pid, SIGHUP);
|
kill(pid, SIGHUP);
|
||||||
|
Loading…
Reference in New Issue
Block a user