Merge remote-tracking branch 'upstream/main' into wlroots-next
This commit is contained in:
commit
fefcdbed4a
@ -29,12 +29,12 @@ static const Layout layouts[] = {
|
|||||||
|
|
||||||
/* monitors */
|
/* monitors */
|
||||||
static const MonitorRule monrules[] = {
|
static const MonitorRule monrules[] = {
|
||||||
/* name mfact nmaster scale layout rotate/reflect */
|
/* name mfact nmaster scale layout rotate/reflect x y */
|
||||||
/* example of a HiDPI laptop monitor:
|
/* example of a HiDPI laptop monitor:
|
||||||
{ "eDP-1", 0.5, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL },
|
{ "eDP-1", 0.5, 1, 2, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL -1, -1 },
|
||||||
*/
|
*/
|
||||||
/* defaults */
|
/* defaults */
|
||||||
{ NULL, 0.55, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL },
|
{ NULL, 0.55, 1, 1, &layouts[0], WL_OUTPUT_TRANSFORM_NORMAL, -1, -1 },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* keyboard */
|
/* keyboard */
|
||||||
|
83
dwl.c
83
dwl.c
@ -140,6 +140,11 @@ typedef struct {
|
|||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
struct wlr_keyboard *wlr_keyboard;
|
struct wlr_keyboard *wlr_keyboard;
|
||||||
|
|
||||||
|
int nsyms;
|
||||||
|
const xkb_keysym_t *keysyms; /* invalid if nsyms == 0 */
|
||||||
|
uint32_t mods; /* invalid if nsyms == 0 */
|
||||||
|
struct wl_event_source *key_repeat_source;
|
||||||
|
|
||||||
struct wl_listener modifiers;
|
struct wl_listener modifiers;
|
||||||
struct wl_listener key;
|
struct wl_listener key;
|
||||||
struct wl_listener destroy;
|
struct wl_listener destroy;
|
||||||
@ -196,6 +201,7 @@ typedef struct {
|
|||||||
float scale;
|
float scale;
|
||||||
const Layout *lt;
|
const Layout *lt;
|
||||||
enum wl_output_transform rr;
|
enum wl_output_transform rr;
|
||||||
|
int x, y;
|
||||||
} MonitorRule;
|
} MonitorRule;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -260,6 +266,7 @@ static void inputdevice(struct wl_listener *listener, void *data);
|
|||||||
static int keybinding(uint32_t mods, xkb_keysym_t sym);
|
static int keybinding(uint32_t mods, xkb_keysym_t sym);
|
||||||
static void keypress(struct wl_listener *listener, void *data);
|
static void keypress(struct wl_listener *listener, void *data);
|
||||||
static void keypressmod(struct wl_listener *listener, void *data);
|
static void keypressmod(struct wl_listener *listener, void *data);
|
||||||
|
static int keyrepeat(void *data);
|
||||||
static void killclient(const Arg *arg);
|
static void killclient(const Arg *arg);
|
||||||
static void locksession(struct wl_listener *listener, void *data);
|
static void locksession(struct wl_listener *listener, void *data);
|
||||||
static void maplayersurfacenotify(struct wl_listener *listener, void *data);
|
static void maplayersurfacenotify(struct wl_listener *listener, void *data);
|
||||||
@ -671,6 +678,7 @@ cleanupkeyboard(struct wl_listener *listener, void *data)
|
|||||||
{
|
{
|
||||||
Keyboard *kb = wl_container_of(listener, kb, destroy);
|
Keyboard *kb = wl_container_of(listener, kb, destroy);
|
||||||
|
|
||||||
|
wl_event_source_remove(kb->key_repeat_source);
|
||||||
wl_list_remove(&kb->link);
|
wl_list_remove(&kb->link);
|
||||||
wl_list_remove(&kb->modifiers.link);
|
wl_list_remove(&kb->modifiers.link);
|
||||||
wl_list_remove(&kb->key.link);
|
wl_list_remove(&kb->key.link);
|
||||||
@ -816,6 +824,9 @@ createkeyboard(struct wlr_keyboard *keyboard)
|
|||||||
|
|
||||||
wlr_seat_set_keyboard(seat, keyboard);
|
wlr_seat_set_keyboard(seat, keyboard);
|
||||||
|
|
||||||
|
kb->key_repeat_source = wl_event_loop_add_timer(
|
||||||
|
wl_display_get_event_loop(dpy), keyrepeat, kb);
|
||||||
|
|
||||||
/* And add the keyboard to our list of keyboards */
|
/* And add the keyboard to our list of keyboards */
|
||||||
wl_list_insert(&keyboards, &kb->link);
|
wl_list_insert(&keyboards, &kb->link);
|
||||||
}
|
}
|
||||||
@ -913,6 +924,8 @@ createmon(struct wl_listener *listener, void *data)
|
|||||||
wlr_xcursor_manager_load(cursor_mgr, r->scale);
|
wlr_xcursor_manager_load(cursor_mgr, r->scale);
|
||||||
m->lt[0] = m->lt[1] = r->lt;
|
m->lt[0] = m->lt[1] = r->lt;
|
||||||
wlr_output_set_transform(wlr_output, r->rr);
|
wlr_output_set_transform(wlr_output, r->rr);
|
||||||
|
m->m.x = r->x;
|
||||||
|
m->m.y = r->y;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -959,7 +972,10 @@ createmon(struct wl_listener *listener, void *data)
|
|||||||
* output (such as DPI, scale factor, manufacturer, etc).
|
* output (such as DPI, scale factor, manufacturer, etc).
|
||||||
*/
|
*/
|
||||||
m->scene_output = wlr_scene_output_create(scene, wlr_output);
|
m->scene_output = wlr_scene_output_create(scene, wlr_output);
|
||||||
|
if (m->m.x < 0 || m->m.y < 0)
|
||||||
wlr_output_layout_add_auto(output_layout, wlr_output);
|
wlr_output_layout_add_auto(output_layout, wlr_output);
|
||||||
|
else
|
||||||
|
wlr_output_layout_add(output_layout, wlr_output, m->m.x, m->m.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1398,6 +1414,17 @@ keypress(struct wl_listener *listener, void *data)
|
|||||||
for (i = 0; i < nsyms; i++)
|
for (i = 0; i < nsyms; i++)
|
||||||
handled = keybinding(mods, syms[i]) || handled;
|
handled = keybinding(mods, syms[i]) || handled;
|
||||||
|
|
||||||
|
if (handled && kb->wlr_keyboard->repeat_info.delay > 0) {
|
||||||
|
kb->mods = mods;
|
||||||
|
kb->keysyms = syms;
|
||||||
|
kb->nsyms = nsyms;
|
||||||
|
wl_event_source_timer_update(kb->key_repeat_source,
|
||||||
|
kb->wlr_keyboard->repeat_info.delay);
|
||||||
|
} else {
|
||||||
|
kb->nsyms = 0;
|
||||||
|
wl_event_source_timer_update(kb->key_repeat_source, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (!handled) {
|
if (!handled) {
|
||||||
/* Pass unhandled keycodes along to the client. */
|
/* Pass unhandled keycodes along to the client. */
|
||||||
wlr_seat_set_keyboard(seat, kb->wlr_keyboard);
|
wlr_seat_set_keyboard(seat, kb->wlr_keyboard);
|
||||||
@ -1424,6 +1451,22 @@ keypressmod(struct wl_listener *listener, void *data)
|
|||||||
&kb->wlr_keyboard->modifiers);
|
&kb->wlr_keyboard->modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
keyrepeat(void *data)
|
||||||
|
{
|
||||||
|
Keyboard *kb = data;
|
||||||
|
int i;
|
||||||
|
if (kb->nsyms && kb->wlr_keyboard->repeat_info.rate > 0) {
|
||||||
|
wl_event_source_timer_update(kb->key_repeat_source,
|
||||||
|
1000 / kb->wlr_keyboard->repeat_info.rate);
|
||||||
|
|
||||||
|
for (i = 0; i < kb->nsyms; i++)
|
||||||
|
keybinding(kb->mods, kb->keysyms[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
killclient(const Arg *arg)
|
killclient(const Arg *arg)
|
||||||
{
|
{
|
||||||
@ -1487,7 +1530,6 @@ mapnotify(struct wl_listener *listener, void *data)
|
|||||||
}
|
}
|
||||||
c->scene->node.data = c->scene_surface->node.data = c;
|
c->scene->node.data = c->scene_surface->node.data = c;
|
||||||
|
|
||||||
#ifdef XWAYLAND
|
|
||||||
/* Handle unmanaged clients first so we can return prior create borders */
|
/* Handle unmanaged clients first so we can return prior create borders */
|
||||||
if (client_is_unmanaged(c)) {
|
if (client_is_unmanaged(c)) {
|
||||||
client_get_geometry(c, &c->geom);
|
client_get_geometry(c, &c->geom);
|
||||||
@ -1501,7 +1543,6 @@ mapnotify(struct wl_listener *listener, void *data)
|
|||||||
}
|
}
|
||||||
goto unset_fullscreen;
|
goto unset_fullscreen;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
c->border[i] = wlr_scene_rect_create(c->scene, 0, 0, bordercolor);
|
c->border[i] = wlr_scene_rect_create(c->scene, 0, 0, bordercolor);
|
||||||
@ -1784,6 +1825,7 @@ printstatus(void)
|
|||||||
Monitor *m = NULL;
|
Monitor *m = NULL;
|
||||||
Client *c;
|
Client *c;
|
||||||
unsigned int occ, urg, sel;
|
unsigned int occ, urg, sel;
|
||||||
|
const char *appid, *title;
|
||||||
|
|
||||||
wl_list_for_each(m, &mons, link) {
|
wl_list_for_each(m, &mons, link) {
|
||||||
occ = urg = 0;
|
occ = urg = 0;
|
||||||
@ -1795,12 +1837,16 @@ printstatus(void)
|
|||||||
urg |= c->tags;
|
urg |= c->tags;
|
||||||
}
|
}
|
||||||
if ((c = focustop(m))) {
|
if ((c = focustop(m))) {
|
||||||
printf("%s title %s\n", m->wlr_output->name, client_get_title(c));
|
title = client_get_title(c);
|
||||||
|
appid = client_get_appid(c);
|
||||||
|
printf("%s title %s\n", m->wlr_output->name, title ? title : broken);
|
||||||
|
printf("%s appid %s\n", m->wlr_output->name, appid ? appid : broken);
|
||||||
printf("%s fullscreen %u\n", m->wlr_output->name, c->isfullscreen);
|
printf("%s fullscreen %u\n", m->wlr_output->name, c->isfullscreen);
|
||||||
printf("%s floating %u\n", m->wlr_output->name, c->isfloating);
|
printf("%s floating %u\n", m->wlr_output->name, c->isfloating);
|
||||||
sel = c->tags;
|
sel = c->tags;
|
||||||
} else {
|
} else {
|
||||||
printf("%s title \n", m->wlr_output->name);
|
printf("%s title \n", m->wlr_output->name);
|
||||||
|
printf("%s appid \n", m->wlr_output->name);
|
||||||
printf("%s fullscreen \n", m->wlr_output->name);
|
printf("%s fullscreen \n", m->wlr_output->name);
|
||||||
printf("%s floating \n", m->wlr_output->name);
|
printf("%s floating \n", m->wlr_output->name);
|
||||||
sel = 0;
|
sel = 0;
|
||||||
@ -1897,6 +1943,8 @@ run(char *startup_cmd)
|
|||||||
{
|
{
|
||||||
/* Add a Unix socket to the Wayland display. */
|
/* Add a Unix socket to the Wayland display. */
|
||||||
const char *socket = wl_display_add_socket_auto(dpy);
|
const char *socket = wl_display_add_socket_auto(dpy);
|
||||||
|
struct sigaction sa = {.sa_flags = SA_RESTART, .sa_handler = SIG_IGN};
|
||||||
|
sigemptyset(&sa.sa_mask);
|
||||||
if (!socket)
|
if (!socket)
|
||||||
die("startup: display_add_socket_auto");
|
die("startup: display_add_socket_auto");
|
||||||
setenv("WAYLAND_DISPLAY", socket, 1);
|
setenv("WAYLAND_DISPLAY", socket, 1);
|
||||||
@ -1925,7 +1973,7 @@ run(char *startup_cmd)
|
|||||||
close(piperw[0]);
|
close(piperw[0]);
|
||||||
}
|
}
|
||||||
/* If nobody is reading the status output, don't terminate */
|
/* If nobody is reading the status output, don't terminate */
|
||||||
signal(SIGPIPE, SIG_IGN);
|
sigaction(SIGPIPE, &sa, NULL);
|
||||||
printstatus();
|
printstatus();
|
||||||
|
|
||||||
/* At this point the outputs are initialized, choose initial selmon based on
|
/* At this point the outputs are initialized, choose initial selmon based on
|
||||||
@ -2078,18 +2126,26 @@ setsel(struct wl_listener *listener, void *data)
|
|||||||
void
|
void
|
||||||
setup(void)
|
setup(void)
|
||||||
{
|
{
|
||||||
|
struct sigaction sa_term = {.sa_flags = SA_RESTART, .sa_handler = quitsignal};
|
||||||
|
struct sigaction sa_sigchld = {
|
||||||
|
#ifdef XWAYLAND
|
||||||
|
.sa_flags = SA_RESTART,
|
||||||
|
.sa_handler = sigchld,
|
||||||
|
#else
|
||||||
|
.sa_flags = SA_NOCLDSTOP | SA_NOCLDWAIT | SA_RESTART,
|
||||||
|
.sa_handler = SIG_IGN,
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
sigemptyset(&sa_term.sa_mask);
|
||||||
|
sigemptyset(&sa_sigchld.sa_mask);
|
||||||
/* The Wayland display is managed by libwayland. It handles accepting
|
/* The Wayland display is managed by libwayland. It handles accepting
|
||||||
* clients from the Unix socket, manging Wayland globals, and so on. */
|
* clients from the Unix socket, manging Wayland globals, and so on. */
|
||||||
dpy = wl_display_create();
|
dpy = wl_display_create();
|
||||||
|
|
||||||
/* Set up signal handlers */
|
/* Set up signal handlers */
|
||||||
#ifdef XWAYLAND
|
sigaction(SIGCHLD, &sa_sigchld, NULL);
|
||||||
sigchld(0);
|
sigaction(SIGINT, &sa_term, NULL);
|
||||||
#else
|
sigaction(SIGTERM, &sa_term, NULL);
|
||||||
signal(SIGCHLD, SIG_IGN);
|
|
||||||
#endif
|
|
||||||
signal(SIGINT, quitsignal);
|
|
||||||
signal(SIGTERM, quitsignal);
|
|
||||||
|
|
||||||
/* The backend is a wlroots feature which abstracts the underlying input and
|
/* The backend is a wlroots feature which abstracts the underlying input and
|
||||||
* output hardware. The autocreate option will choose the most suitable
|
* output hardware. The autocreate option will choose the most suitable
|
||||||
@ -2712,12 +2768,11 @@ sigchld(int unused)
|
|||||||
{
|
{
|
||||||
siginfo_t in;
|
siginfo_t in;
|
||||||
/* We should be able to remove this function in favor of a simple
|
/* We should be able to remove this function in favor of a simple
|
||||||
* signal(SIGCHLD, SIG_IGN);
|
* struct sigaction sa = {.sa_handler = SIG_IGN};
|
||||||
|
* sigaction(SIGCHLD, &sa, NULL);
|
||||||
* but the Xwayland implementation in wlroots currently prevents us from
|
* but the Xwayland implementation in wlroots currently prevents us from
|
||||||
* setting our own disposition for SIGCHLD.
|
* setting our own disposition for SIGCHLD.
|
||||||
*/
|
*/
|
||||||
if (signal(SIGCHLD, sigchld) == SIG_ERR)
|
|
||||||
die("can't install SIGCHLD handler:");
|
|
||||||
/* WNOWAIT leaves the child in a waitable state, in case this is the
|
/* WNOWAIT leaves the child in a waitable state, in case this is the
|
||||||
* XWayland process
|
* XWayland process
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user