mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
wayland: refactor: remove ‘struct config’ pointer from wayland struct
The global config doesn’t necessarily reflect the correct configuration to use - we should *always* use the current terminal instance’s conf pointer. * Move selection override modifier mask to the key_binding_set struct * Always warn if XDG activation is unavailable, not just if bell.urgent is set (we no longer have access to this information) * Pass ‘bool presentation_timings’ as a parameter to wayl_init() * Remove ‘presentation_timings’ member from the ‘terminal’ struct Closes #932
This commit is contained in:
parent
7a5e5a80b9
commit
24ee3dcc10
9 changed files with 30 additions and 27 deletions
19
input.c
19
input.c
|
|
@ -489,11 +489,6 @@ keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard,
|
|||
seat->kbd.key_arrow_down = xkb_keymap_key_by_name(seat->kbd.xkb_keymap, "DOWN");
|
||||
}
|
||||
|
||||
/* Set selection-override modmask from configured mods and seat's mod indices */
|
||||
const struct config_key_modifiers* override_mods =
|
||||
&wayl->conf->mouse.selection_override_modifiers;
|
||||
seat->kbd.selection_override_modmask = conf_modifiers_to_mask(seat, override_mods);
|
||||
|
||||
munmap(map_str, size);
|
||||
close(fd);
|
||||
|
||||
|
|
@ -2237,17 +2232,19 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
|
|||
if (seat->wl_keyboard != NULL && seat->kbd.xkb_state != NULL) {
|
||||
/* Seat has keyboard - use mouse bindings *with* modifiers */
|
||||
|
||||
const struct key_binding_set *bindings = key_binding_for(
|
||||
wayl->key_binding_manager, term, seat);
|
||||
xassert(bindings != NULL);
|
||||
|
||||
xkb_mod_mask_t mods;
|
||||
get_current_modifiers(seat, &mods, NULL, 0);
|
||||
mods &= seat->kbd.bind_significant;
|
||||
|
||||
/* Ignore selection override modifiers when matching modifiers */
|
||||
mods &= ~seat->kbd.selection_override_modmask;
|
||||
/* Ignore selection override modifiers when
|
||||
* matching modifiers */
|
||||
mods &= ~bindings->selection_overrides;
|
||||
|
||||
const struct key_binding *match = NULL;
|
||||
const struct key_binding_set *bindings = key_binding_for(
|
||||
wayl->key_binding_manager, term, seat);
|
||||
xassert(bindings != NULL);
|
||||
|
||||
tll_foreach(bindings->mouse, it) {
|
||||
const struct key_binding *binding = &it->item;
|
||||
|
|
@ -2278,7 +2275,7 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
|
|||
else {
|
||||
/* Seat does NOT have a keyboard - use mouse bindings *without* modifiers */
|
||||
const struct config_key_binding *match = NULL;
|
||||
const struct config *conf = seat->wayl->conf;
|
||||
const struct config *conf = term->conf;
|
||||
|
||||
for (size_t i = 0; i < conf->bindings.mouse.count; i++) {
|
||||
const struct config_key_binding *binding =
|
||||
|
|
|
|||
|
|
@ -460,6 +460,9 @@ load_keymap(struct key_set *set)
|
|||
convert_search_bindings(set);
|
||||
convert_url_bindings(set);
|
||||
convert_mouse_bindings(set);
|
||||
|
||||
set->public.selection_overrides = conf_modifiers_to_mask(
|
||||
set->seat, &set->conf->mouse.selection_override_modifiers);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -495,6 +498,7 @@ unload_keymap(struct key_set *set)
|
|||
key_bindings_destroy(&set->public.search);
|
||||
key_bindings_destroy(&set->public.url);
|
||||
key_bindings_destroy(&set->public.mouse);
|
||||
set->public.selection_overrides = 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ struct key_binding_set {
|
|||
key_binding_list_t search;
|
||||
key_binding_list_t url;
|
||||
key_binding_list_t mouse;
|
||||
xkb_mod_mask_t selection_overrides;
|
||||
};
|
||||
|
||||
struct key_binding_manager;
|
||||
|
|
|
|||
5
main.c
5
main.c
|
|
@ -605,8 +605,11 @@ main(int argc, char *const *argv)
|
|||
if ((key_binding_manager = key_binding_manager_new()) == NULL)
|
||||
goto out;
|
||||
|
||||
if ((wayl = wayl_init(&conf, fdm, key_binding_manager)) == NULL)
|
||||
if ((wayl = wayl_init(
|
||||
fdm, key_binding_manager, conf.presentation_timings)) == NULL)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ((renderer = render_init(fdm, wayl)) == NULL)
|
||||
goto out;
|
||||
|
|
|
|||
2
render.c
2
render.c
|
|
@ -2920,7 +2920,7 @@ grid_render(struct terminal *term)
|
|||
|
||||
wl_surface_set_buffer_scale(term->window->surface, term->scale);
|
||||
|
||||
if (term->wl->presentation != NULL && term->render.presentation_timings) {
|
||||
if (term->wl->presentation != NULL && term->conf->presentation_timings) {
|
||||
struct timespec commit_time;
|
||||
clock_gettime(term->wl->presentation_clock_id, &commit_time);
|
||||
|
||||
|
|
|
|||
|
|
@ -1202,7 +1202,6 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
|
|||
.count = conf->render_worker_count,
|
||||
.queue = tll_init(),
|
||||
},
|
||||
.presentation_timings = conf->presentation_timings,
|
||||
},
|
||||
.delayed_render_timer = {
|
||||
.is_armed = false,
|
||||
|
|
|
|||
|
|
@ -591,7 +591,6 @@ struct terminal {
|
|||
|
||||
size_t search_glyph_offset;
|
||||
|
||||
bool presentation_timings;
|
||||
struct timespec input_time;
|
||||
} render;
|
||||
|
||||
|
|
|
|||
14
wayland.c
14
wayland.c
|
|
@ -1013,7 +1013,7 @@ handle_global(void *data, struct wl_registry *registry,
|
|||
}
|
||||
|
||||
else if (strcmp(interface, wp_presentation_interface.name) == 0) {
|
||||
if (wayl->conf->presentation_timings) {
|
||||
if (wayl->presentation_timings) {
|
||||
const uint32_t required = 1;
|
||||
if (!verify_iface_version(interface, version, required))
|
||||
return;
|
||||
|
|
@ -1190,8 +1190,8 @@ fdm_wayl(struct fdm *fdm, int fd, int events, void *data)
|
|||
}
|
||||
|
||||
struct wayland *
|
||||
wayl_init(const struct config *conf, struct fdm *fdm,
|
||||
struct key_binding_manager *key_binding_manager)
|
||||
wayl_init(struct fdm *fdm, struct key_binding_manager *key_binding_manager,
|
||||
bool presentation_timings)
|
||||
{
|
||||
struct wayland *wayl = calloc(1, sizeof(*wayl));
|
||||
if (unlikely(wayl == NULL)) {
|
||||
|
|
@ -1199,10 +1199,10 @@ wayl_init(const struct config *conf, struct fdm *fdm,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
wayl->conf = conf;
|
||||
wayl->fdm = fdm;
|
||||
wayl->key_binding_manager = key_binding_manager;
|
||||
wayl->fd = -1;
|
||||
wayl->presentation_timings = presentation_timings;
|
||||
|
||||
if (!fdm_hook_add(fdm, &fdm_hook, wayl, FDM_HOOK_PRIORITY_LOW)) {
|
||||
LOG_ERR("failed to add FDM hook");
|
||||
|
|
@ -1253,16 +1253,16 @@ wayl_init(const struct config *conf, struct fdm *fdm,
|
|||
LOG_WARN("no primary selection available");
|
||||
|
||||
#if defined(HAVE_XDG_ACTIVATION)
|
||||
if (wayl->xdg_activation == NULL && conf->bell.urgent) {
|
||||
if (wayl->xdg_activation == NULL) {
|
||||
#else
|
||||
if (conf->bell.urgent) {
|
||||
if (true) {
|
||||
#endif
|
||||
LOG_WARN(
|
||||
"no XDG activation support; "
|
||||
"bell.urgent will fall back to coloring the window margins red");
|
||||
}
|
||||
|
||||
if (conf->presentation_timings && wayl->presentation == NULL) {
|
||||
if (presentation_timings && wayl->presentation == NULL) {
|
||||
LOG_ERR("presentation time interface not implemented by compositor");
|
||||
goto out;
|
||||
}
|
||||
|
|
|
|||
10
wayland.h
10
wayland.h
|
|
@ -6,6 +6,7 @@
|
|||
#include <uchar.h>
|
||||
|
||||
#include <wayland-client.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
|
||||
/* Wayland protocols */
|
||||
#include <presentation-time.h>
|
||||
|
|
@ -22,7 +23,6 @@
|
|||
#include <fcft/fcft.h>
|
||||
#include <tllist.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "fdm.h"
|
||||
|
||||
/* Forward declarations */
|
||||
|
|
@ -354,10 +354,8 @@ struct wl_window {
|
|||
int resize_timeout_fd;
|
||||
};
|
||||
|
||||
struct config;
|
||||
struct terminal;
|
||||
struct wayland {
|
||||
const struct config *conf;
|
||||
struct fdm *fdm;
|
||||
struct key_binding_manager *key_binding_manager;
|
||||
|
||||
|
|
@ -381,6 +379,7 @@ struct wayland {
|
|||
struct xdg_activation_v1 *xdg_activation;
|
||||
#endif
|
||||
|
||||
bool presentation_timings;
|
||||
struct wp_presentation *presentation;
|
||||
uint32_t presentation_clock_id;
|
||||
|
||||
|
|
@ -395,8 +394,9 @@ struct wayland {
|
|||
tll(struct terminal *) terms;
|
||||
};
|
||||
|
||||
struct wayland *wayl_init(const struct config *conf, struct fdm *fdm,
|
||||
struct key_binding_manager *key_binding_manager);
|
||||
struct wayland *wayl_init(
|
||||
struct fdm *fdm, struct key_binding_manager *key_binding_manager,
|
||||
bool presentation_timings);
|
||||
void wayl_destroy(struct wayland *wayl);
|
||||
|
||||
bool wayl_reload_xcursor_theme(struct seat *seat, int new_scale);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue