window.c: Handle multiple keyboard foci
Keep a count of number of wl_keyboard focus we have instead of tracking the more recent wl_keyboard.
This commit is contained in:
+3
-4
@@ -404,7 +404,6 @@ struct terminal {
|
|||||||
struct utf8_state_machine state_machine;
|
struct utf8_state_machine state_machine;
|
||||||
int margin;
|
int margin;
|
||||||
int fullscreen;
|
int fullscreen;
|
||||||
int focused;
|
|
||||||
struct color_scheme *color_scheme;
|
struct color_scheme *color_scheme;
|
||||||
struct terminal_color color_table[256];
|
struct terminal_color color_table[256];
|
||||||
cairo_font_extents_t extents;
|
cairo_font_extents_t extents;
|
||||||
@@ -537,7 +536,7 @@ terminal_decode_attr(struct terminal *terminal, int row, int col,
|
|||||||
if ((attr.a & ATTRMASK_INVERSE) ||
|
if ((attr.a & ATTRMASK_INVERSE) ||
|
||||||
decoded->attr.s ||
|
decoded->attr.s ||
|
||||||
((terminal->mode & MODE_SHOW_CURSOR) &&
|
((terminal->mode & MODE_SHOW_CURSOR) &&
|
||||||
terminal->focused && terminal->row == row &&
|
window_has_focus(terminal->window) && terminal->row == row &&
|
||||||
terminal->column == col)) {
|
terminal->column == col)) {
|
||||||
foreground = attr.bg;
|
foreground = attr.bg;
|
||||||
background = attr.fg;
|
background = attr.fg;
|
||||||
@@ -999,7 +998,8 @@ redraw_handler(struct widget *widget, void *data)
|
|||||||
attr.key = ~0;
|
attr.key = ~0;
|
||||||
glyph_run_flush(&run, attr);
|
glyph_run_flush(&run, attr);
|
||||||
|
|
||||||
if ((terminal->mode & MODE_SHOW_CURSOR) && !terminal->focused) {
|
if ((terminal->mode & MODE_SHOW_CURSOR) &&
|
||||||
|
!window_has_focus(terminal->window)) {
|
||||||
d = 0.5;
|
d = 0.5;
|
||||||
|
|
||||||
cairo_set_line_width(cr, 1);
|
cairo_set_line_width(cr, 1);
|
||||||
@@ -2260,7 +2260,6 @@ keyboard_focus_handler(struct window *window,
|
|||||||
{
|
{
|
||||||
struct terminal *terminal = data;
|
struct terminal *terminal = data;
|
||||||
|
|
||||||
terminal->focused = (device != NULL);
|
|
||||||
window_schedule_redraw(terminal->window);
|
window_schedule_redraw(terminal->window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-7
@@ -145,7 +145,8 @@ struct window {
|
|||||||
int resize_needed;
|
int resize_needed;
|
||||||
int type;
|
int type;
|
||||||
int transparent;
|
int transparent;
|
||||||
struct input *keyboard_device;
|
int focus_count;
|
||||||
|
|
||||||
enum window_buffer_type buffer_type;
|
enum window_buffer_type buffer_type;
|
||||||
|
|
||||||
cairo_surface_t *cairo_surface;
|
cairo_surface_t *cairo_surface;
|
||||||
@@ -769,6 +770,12 @@ window_attach_surface(struct window *window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
window_has_focus(struct window *window)
|
||||||
|
{
|
||||||
|
return window->focus_count > 0;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
window_flush(struct window *window)
|
window_flush(struct window *window)
|
||||||
{
|
{
|
||||||
@@ -1514,7 +1521,7 @@ frame_redraw_handler(struct widget *widget, void *data)
|
|||||||
|
|
||||||
cr = cairo_create(window->cairo_surface);
|
cr = cairo_create(window->cairo_surface);
|
||||||
|
|
||||||
if (window->keyboard_device)
|
if (window->focus_count)
|
||||||
flags |= THEME_FRAME_ACTIVE;
|
flags |= THEME_FRAME_ACTIVE;
|
||||||
theme_render_frame(t, cr, widget->allocation.width,
|
theme_render_frame(t, cr, widget->allocation.width,
|
||||||
widget->allocation.height, window->title, flags);
|
widget->allocation.height, window->title, flags);
|
||||||
@@ -1938,7 +1945,7 @@ input_remove_keyboard_focus(struct input *input)
|
|||||||
if (!window)
|
if (!window)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
window->keyboard_device = NULL;
|
window->focus_count--;
|
||||||
if (window->keyboard_focus_handler)
|
if (window->keyboard_focus_handler)
|
||||||
(*window->keyboard_focus_handler)(window, NULL,
|
(*window->keyboard_focus_handler)(window, NULL,
|
||||||
window->user_data);
|
window->user_data);
|
||||||
@@ -2031,11 +2038,10 @@ keyboard_handle_enter(void *data, struct wl_keyboard *keyboard,
|
|||||||
input->keyboard_focus = wl_surface_get_user_data(surface);
|
input->keyboard_focus = wl_surface_get_user_data(surface);
|
||||||
|
|
||||||
window = input->keyboard_focus;
|
window = input->keyboard_focus;
|
||||||
window->keyboard_device = input;
|
window->focus_count++;
|
||||||
if (window->keyboard_focus_handler)
|
if (window->keyboard_focus_handler)
|
||||||
(*window->keyboard_focus_handler)(window,
|
(*window->keyboard_focus_handler)(window,
|
||||||
window->keyboard_device,
|
input, window->user_data);
|
||||||
window->user_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -2064,7 +2070,7 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
|
|||||||
|
|
||||||
input->display->serial = serial;
|
input->display->serial = serial;
|
||||||
code = key + 8;
|
code = key + 8;
|
||||||
if (!window || window->keyboard_device != input || !input->xkb.state)
|
if (!window || !input->xkb.state)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
num_syms = xkb_key_get_syms(input->xkb.state, code, &syms);
|
num_syms = xkb_key_get_syms(input->xkb.state, code, &syms);
|
||||||
|
|||||||
@@ -205,6 +205,9 @@ window_create_transient(struct display *display, struct window *parent,
|
|||||||
struct window *
|
struct window *
|
||||||
window_create_custom(struct display *display);
|
window_create_custom(struct display *display);
|
||||||
|
|
||||||
|
int
|
||||||
|
window_has_focus(struct window *window);
|
||||||
|
|
||||||
typedef void (*menu_func_t)(struct window *window, int index, void *data);
|
typedef void (*menu_func_t)(struct window *window, int index, void *data);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user