mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-27 01:40:16 -05:00
wayland: rename focused/moused to kbd_focus/mouse_focus
This commit is contained in:
parent
6c75c16d2c
commit
4ecb0ecf4d
5 changed files with 34 additions and 34 deletions
34
input.c
34
input.c
|
|
@ -87,11 +87,11 @@ keyboard_enter(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
|
||||||
|
|
||||||
struct wayland *wayl = data;
|
struct wayland *wayl = data;
|
||||||
wayl->input_serial = serial;
|
wayl->input_serial = serial;
|
||||||
wayl->focused = wayl_terminal_from_surface(wayl, surface);
|
wayl->kbd_focus = wayl_terminal_from_surface(wayl, surface);
|
||||||
assert(wayl->focused != NULL);
|
assert(wayl->kbd_focus != NULL);
|
||||||
|
|
||||||
term_focus_in(wayl->focused);
|
term_focus_in(wayl->kbd_focus);
|
||||||
term_xcursor_update(wayl->focused);
|
term_xcursor_update(wayl->kbd_focus);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|
@ -143,12 +143,12 @@ keyboard_leave(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
|
||||||
struct wayland *wayl = data;
|
struct wayland *wayl = data;
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
wayl->focused == NULL ||
|
wayl->kbd_focus == NULL ||
|
||||||
surface == NULL || /* Seen on Sway 1.2 */
|
surface == NULL || /* Seen on Sway 1.2 */
|
||||||
wayl_terminal_from_surface(wayl, surface) == wayl->focused);
|
wayl_terminal_from_surface(wayl, surface) == wayl->kbd_focus);
|
||||||
|
|
||||||
struct terminal *old_focused = wayl->focused;
|
struct terminal *old_focused = wayl->kbd_focus;
|
||||||
wayl->focused = NULL;
|
wayl->kbd_focus = NULL;
|
||||||
|
|
||||||
stop_repeater(wayl, -1);
|
stop_repeater(wayl, -1);
|
||||||
if (old_focused != NULL) {
|
if (old_focused != NULL) {
|
||||||
|
|
@ -171,7 +171,7 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
|
||||||
uint32_t time, uint32_t key, uint32_t state)
|
uint32_t time, uint32_t key, uint32_t state)
|
||||||
{
|
{
|
||||||
struct wayland *wayl = data;
|
struct wayland *wayl = data;
|
||||||
struct terminal *term = wayl->focused;
|
struct terminal *term = wayl->kbd_focus;
|
||||||
|
|
||||||
/* Workaround buggy Sway 1.2 */
|
/* Workaround buggy Sway 1.2 */
|
||||||
if (term == NULL) {
|
if (term == NULL) {
|
||||||
|
|
@ -409,8 +409,8 @@ keyboard_modifiers(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
|
||||||
wayl->kbd.meta = xkb_state_mod_index_is_active(
|
wayl->kbd.meta = xkb_state_mod_index_is_active(
|
||||||
wayl->kbd.xkb_state, wayl->kbd.mod_meta, XKB_STATE_MODS_DEPRESSED);
|
wayl->kbd.xkb_state, wayl->kbd.mod_meta, XKB_STATE_MODS_DEPRESSED);
|
||||||
|
|
||||||
if (wayl->focused)
|
if (wayl->kbd_focus)
|
||||||
term_xcursor_update(wayl->focused);
|
term_xcursor_update(wayl->kbd_focus);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -450,7 +450,7 @@ wl_pointer_enter(void *data, struct wl_pointer *wl_pointer,
|
||||||
|
|
||||||
LOG_DBG("pointer-enter: surface = %p, new-moused = %p", surface, term);
|
LOG_DBG("pointer-enter: surface = %p, new-moused = %p", surface, term);
|
||||||
|
|
||||||
wayl->moused = term;
|
wayl->mouse_focus = term;
|
||||||
|
|
||||||
int x = wl_fixed_to_int(surface_x) * term->scale;
|
int x = wl_fixed_to_int(surface_x) * term->scale;
|
||||||
int y = wl_fixed_to_int(surface_y) * term->scale;
|
int y = wl_fixed_to_int(surface_y) * term->scale;
|
||||||
|
|
@ -466,11 +466,11 @@ wl_pointer_leave(void *data, struct wl_pointer *wl_pointer,
|
||||||
uint32_t serial, struct wl_surface *surface)
|
uint32_t serial, struct wl_surface *surface)
|
||||||
{
|
{
|
||||||
struct wayland *wayl = data;
|
struct wayland *wayl = data;
|
||||||
struct terminal *old_moused = wayl->moused;
|
struct terminal *old_moused = wayl->mouse_focus;
|
||||||
|
|
||||||
LOG_DBG("pointer-leave: surface = %p, old-moused = %p", surface, old_moused);
|
LOG_DBG("pointer-leave: surface = %p, old-moused = %p", surface, old_moused);
|
||||||
|
|
||||||
wayl->moused = NULL;
|
wayl->mouse_focus = NULL;
|
||||||
if (old_moused == NULL) {
|
if (old_moused == NULL) {
|
||||||
LOG_WARN(
|
LOG_WARN(
|
||||||
"compositor sent pointer_leave event without a pointer_enter "
|
"compositor sent pointer_leave event without a pointer_enter "
|
||||||
|
|
@ -484,7 +484,7 @@ wl_pointer_motion(void *data, struct wl_pointer *wl_pointer,
|
||||||
uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y)
|
uint32_t time, wl_fixed_t surface_x, wl_fixed_t surface_y)
|
||||||
{
|
{
|
||||||
struct wayland *wayl = data;
|
struct wayland *wayl = data;
|
||||||
struct terminal *term = wayl->moused;
|
struct terminal *term = wayl->mouse_focus;
|
||||||
|
|
||||||
/* Workaround buggy Sway 1.2 */
|
/* Workaround buggy Sway 1.2 */
|
||||||
if (term == NULL) {
|
if (term == NULL) {
|
||||||
|
|
@ -540,7 +540,7 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
|
||||||
LOG_DBG("BUTTON: button=%x, state=%u", button, state);
|
LOG_DBG("BUTTON: button=%x, state=%u", button, state);
|
||||||
|
|
||||||
struct wayland *wayl = data;
|
struct wayland *wayl = data;
|
||||||
struct terminal *term = wayl->moused;
|
struct terminal *term = wayl->mouse_focus;
|
||||||
|
|
||||||
/* Workaround buggy Sway 1.2 */
|
/* Workaround buggy Sway 1.2 */
|
||||||
if (term == NULL) {
|
if (term == NULL) {
|
||||||
|
|
@ -621,7 +621,7 @@ wl_pointer_button(void *data, struct wl_pointer *wl_pointer,
|
||||||
static void
|
static void
|
||||||
mouse_scroll(struct wayland *wayl, int amount)
|
mouse_scroll(struct wayland *wayl, int amount)
|
||||||
{
|
{
|
||||||
struct terminal *term = wayl->moused;
|
struct terminal *term = wayl->mouse_focus;
|
||||||
assert(term != NULL);
|
assert(term != NULL);
|
||||||
|
|
||||||
int button = amount < 0 ? BTN_BACK : BTN_FORWARD;
|
int button = amount < 0 ? BTN_BACK : BTN_FORWARD;
|
||||||
|
|
|
||||||
2
render.c
2
render.c
|
|
@ -279,7 +279,7 @@ draw_cursor(const struct terminal *term, const struct cell *cell,
|
||||||
pixman_image_t *pix, pixman_color_t *fg, const pixman_color_t *bg,
|
pixman_image_t *pix, pixman_color_t *fg, const pixman_color_t *bg,
|
||||||
int x, int y, int cols)
|
int x, int y, int cols)
|
||||||
{
|
{
|
||||||
bool have_focus = term->wl->focused == term;
|
bool have_focus = term->wl->kbd_focus == term;
|
||||||
|
|
||||||
pixman_color_t cursor_color;
|
pixman_color_t cursor_color;
|
||||||
pixman_color_t text_color;
|
pixman_color_t text_color;
|
||||||
|
|
|
||||||
24
terminal.c
24
terminal.c
|
|
@ -716,13 +716,13 @@ fdm_shutdown(struct fdm *fdm, int fd, int events, void *data)
|
||||||
* are deferred (for example, when a screen locker is active), and
|
* are deferred (for example, when a screen locker is active), and
|
||||||
* thus we can get here without having been unmapped.
|
* thus we can get here without having been unmapped.
|
||||||
*/
|
*/
|
||||||
if (wayl->focused == term)
|
if (wayl->kbd_focus == term)
|
||||||
wayl->focused = NULL;
|
wayl->kbd_focus = NULL;
|
||||||
if (wayl->moused == term)
|
if (wayl->mouse_focus == term)
|
||||||
wayl->moused = NULL;
|
wayl->mouse_focus = NULL;
|
||||||
|
|
||||||
assert(wayl->focused != term);
|
assert(wayl->kbd_focus != term);
|
||||||
assert(wayl->moused != term);
|
assert(wayl->mouse_focus != term);
|
||||||
|
|
||||||
void (*cb)(void *, int) = term->shutdown_cb;
|
void (*cb)(void *, int) = term->shutdown_cb;
|
||||||
void *cb_data = term->shutdown_data;
|
void *cb_data = term->shutdown_data;
|
||||||
|
|
@ -1234,7 +1234,7 @@ void
|
||||||
term_cursor_blink_enable(struct terminal *term)
|
term_cursor_blink_enable(struct terminal *term)
|
||||||
{
|
{
|
||||||
term->cursor_blink.state = CURSOR_BLINK_ON;
|
term->cursor_blink.state = CURSOR_BLINK_ON;
|
||||||
term->cursor_blink.active = term->wl->focused == term
|
term->cursor_blink.active = term->wl->kbd_focus == term
|
||||||
? cursor_blink_start_timer(term) : true;
|
? cursor_blink_start_timer(term) : true;
|
||||||
cursor_refresh(term);
|
cursor_refresh(term);
|
||||||
}
|
}
|
||||||
|
|
@ -1253,7 +1253,7 @@ term_cursor_blink_restart(struct terminal *term)
|
||||||
{
|
{
|
||||||
if (term->cursor_blink.active) {
|
if (term->cursor_blink.active) {
|
||||||
term->cursor_blink.state = CURSOR_BLINK_ON;
|
term->cursor_blink.state = CURSOR_BLINK_ON;
|
||||||
term->cursor_blink.active = term->wl->focused == term
|
term->cursor_blink.active = term->wl->kbd_focus == term
|
||||||
? cursor_blink_start_timer(term) : true;
|
? cursor_blink_start_timer(term) : true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1508,7 +1508,7 @@ term_mouse_grabbed(const struct terminal *term)
|
||||||
* Mouse is grabbed by us, regardless of whether mouse tracking has been enabled or not.
|
* Mouse is grabbed by us, regardless of whether mouse tracking has been enabled or not.
|
||||||
*/
|
*/
|
||||||
return
|
return
|
||||||
term->wl->focused == term &&
|
term->wl->kbd_focus == term &&
|
||||||
term->wl->kbd.shift &&
|
term->wl->kbd.shift &&
|
||||||
!term->wl->kbd.alt && !term->wl->kbd.ctrl && !term->wl->kbd.meta;
|
!term->wl->kbd.alt && !term->wl->kbd.ctrl && !term->wl->kbd.meta;
|
||||||
}
|
}
|
||||||
|
|
@ -1529,7 +1529,7 @@ term_mouse_down(struct terminal *term, int button, int row, int col)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
bool has_focus = term->wl->focused == term;
|
bool has_focus = term->wl->kbd_focus == term;
|
||||||
bool shift = has_focus ? term->wl->kbd.shift : false;
|
bool shift = has_focus ? term->wl->kbd.shift : false;
|
||||||
bool alt = has_focus ? term->wl->kbd.alt : false;
|
bool alt = has_focus ? term->wl->kbd.alt : false;
|
||||||
bool ctrl = has_focus ? term->wl->kbd.ctrl : false;
|
bool ctrl = has_focus ? term->wl->kbd.ctrl : false;
|
||||||
|
|
@ -1573,7 +1573,7 @@ term_mouse_up(struct terminal *term, int button, int row, int col)
|
||||||
if (encoded == -1)
|
if (encoded == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool has_focus = term->wl->focused == term;
|
bool has_focus = term->wl->kbd_focus == term;
|
||||||
bool shift = has_focus ? term->wl->kbd.shift : false;
|
bool shift = has_focus ? term->wl->kbd.shift : false;
|
||||||
bool alt = has_focus ? term->wl->kbd.alt : false;
|
bool alt = has_focus ? term->wl->kbd.alt : false;
|
||||||
bool ctrl = has_focus ? term->wl->kbd.ctrl : false;
|
bool ctrl = has_focus ? term->wl->kbd.ctrl : false;
|
||||||
|
|
@ -1617,7 +1617,7 @@ term_mouse_motion(struct terminal *term, int button, int row, int col)
|
||||||
} else
|
} else
|
||||||
encoded = 3; /* "released" */
|
encoded = 3; /* "released" */
|
||||||
|
|
||||||
bool has_focus = term->wl->focused == term;
|
bool has_focus = term->wl->kbd_focus == term;
|
||||||
bool shift = has_focus ? term->wl->kbd.shift : false;
|
bool shift = has_focus ? term->wl->kbd.shift : false;
|
||||||
bool alt = has_focus ? term->wl->kbd.alt : false;
|
bool alt = has_focus ? term->wl->kbd.alt : false;
|
||||||
bool ctrl = has_focus ? term->wl->kbd.ctrl : false;
|
bool ctrl = has_focus ? term->wl->kbd.ctrl : false;
|
||||||
|
|
|
||||||
|
|
@ -849,12 +849,12 @@ wayl_cursor_set(struct wayland *wayl, const struct terminal *term)
|
||||||
if (wayl->pointer.theme == NULL)
|
if (wayl->pointer.theme == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (wayl->moused == NULL) {
|
if (wayl->mouse_focus == NULL) {
|
||||||
wayl->pointer.xcursor = NULL;
|
wayl->pointer.xcursor = NULL;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wayl->moused != term) {
|
if (wayl->mouse_focus != term) {
|
||||||
/* This terminal doesn't have mouse focus */
|
/* This terminal doesn't have mouse focus */
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -164,8 +164,8 @@ struct wayland {
|
||||||
tll(struct monitor) monitors; /* All available outputs */
|
tll(struct monitor) monitors; /* All available outputs */
|
||||||
|
|
||||||
tll(struct terminal *) terms;
|
tll(struct terminal *) terms;
|
||||||
struct terminal *focused;
|
struct terminal *kbd_focus;
|
||||||
struct terminal *moused;
|
struct terminal *mouse_focus;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wayland *wayl_init(const struct config *conf, struct fdm *fdm);
|
struct wayland *wayl_init(const struct config *conf, struct fdm *fdm);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue