Move unfocused ender bool into cursor render info
This commit is contained in:
parent
7e424e1848
commit
be37a283d5
8 changed files with 29 additions and 17 deletions
|
|
@ -657,7 +657,7 @@ cursor_needs_render(Window *w) {
|
|||
|
||||
static bool
|
||||
collect_cursor_info(CursorRenderInfo *ans, Window *w, monotonic_t now, OSWindow *os_window) {
|
||||
ScreenRenderData *rd = &w->render_data;
|
||||
WindowRenderData *rd = &w->render_data;
|
||||
const Cursor *cursor;
|
||||
if (screen_is_overlay_active(rd->screen)) {
|
||||
// Do not force the cursor to be visible here for the sake of some programs that prefer it hidden
|
||||
|
|
@ -746,7 +746,7 @@ prepare_to_render_os_window(OSWindow *os_window, monotonic_t now, unsigned int *
|
|||
set_os_window_title_from_window(w, os_window);
|
||||
*active_window_bg = window_bg;
|
||||
} else {
|
||||
if (WD.screen->render_unfocused_cursor) {
|
||||
if (WD.screen->cursor_render_info.render_even_when_unfocused) {
|
||||
if (collect_cursor_info(&WD.screen->cursor_render_info, w, now, os_window)) needs_render = true;
|
||||
WD.screen->cursor_render_info.is_focused = false;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@ typedef struct {
|
|||
} Cursor;
|
||||
|
||||
typedef struct {
|
||||
bool is_visible, is_focused;
|
||||
bool is_visible, is_focused, render_even_when_unfocused;
|
||||
CursorShape shape;
|
||||
unsigned int x, y;
|
||||
} CursorRenderInfo;
|
||||
|
|
|
|||
|
|
@ -1055,7 +1055,7 @@ class Screen:
|
|||
disable_ligatures: int
|
||||
cursor_key_mode: bool
|
||||
auto_repeat_enabled: bool
|
||||
render_unfocused_cursor: int
|
||||
render_unfocused_cursor: bool
|
||||
last_reported_cwd: Optional[bytes]
|
||||
|
||||
def __init__(
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ screen_reset(Screen *self) {
|
|||
update_ime_position_for_window(self->window_id, false, -1);
|
||||
}
|
||||
Py_CLEAR(self->last_reported_cwd);
|
||||
self->render_unfocused_cursor = false;
|
||||
self->cursor_render_info.render_even_when_unfocused = false;
|
||||
memset(self->main_key_encoding_flags, 0, sizeof(self->main_key_encoding_flags));
|
||||
memset(self->alt_key_encoding_flags, 0, sizeof(self->alt_key_encoding_flags));
|
||||
self->display_window_char = 0;
|
||||
|
|
@ -3676,6 +3676,19 @@ static int disable_ligatures_set(Screen *self, PyObject *val, void UNUSED *closu
|
|||
return 0;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
render_unfocused_cursor_get(Screen *self, void UNUSED *closure) {
|
||||
if (self->cursor_render_info.render_even_when_unfocused) Py_RETURN_TRUE;
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
static int
|
||||
render_unfocused_cursor_set(Screen *self, PyObject *val, void UNUSED *closure) {
|
||||
if (val == NULL) { PyErr_SetString(PyExc_TypeError, "Cannot delete attribute"); return -1; }
|
||||
self->cursor_render_info.render_even_when_unfocused = PyObject_IsTrue(val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
cursor_up(Screen *self, PyObject *args) {
|
||||
unsigned int count = 1;
|
||||
|
|
@ -4644,6 +4657,7 @@ static PyGetSetDef getsetters[] = {
|
|||
GETSET(cursor_visible)
|
||||
GETSET(cursor_key_mode)
|
||||
GETSET(disable_ligatures)
|
||||
GETSET(render_unfocused_cursor)
|
||||
{NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
|
|
@ -4671,7 +4685,6 @@ static PyMemberDef members[] = {
|
|||
{"margin_top", T_UINT, offsetof(Screen, margin_top), READONLY, "margin_top"},
|
||||
{"margin_bottom", T_UINT, offsetof(Screen, margin_bottom), READONLY, "margin_bottom"},
|
||||
{"history_line_added_count", T_UINT, offsetof(Screen, history_line_added_count), 0, "history_line_added_count"},
|
||||
{"render_unfocused_cursor", T_UINT, offsetof(Screen, render_unfocused_cursor), 0, "render_unfocused_cursor"},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,6 @@ typedef struct {
|
|||
pthread_mutex_t write_buf_lock;
|
||||
|
||||
CursorRenderInfo cursor_render_info;
|
||||
unsigned int render_unfocused_cursor;
|
||||
|
||||
DisableLigature disable_ligatures;
|
||||
PyObject *marker;
|
||||
|
|
|
|||
|
|
@ -909,7 +909,7 @@ get_visual_bell_intensity(Screen *screen) {
|
|||
}
|
||||
|
||||
void
|
||||
draw_cells(ssize_t vao_idx, const ScreenRenderData *srd, OSWindow *os_window, bool is_active_window, bool can_be_focused, Window *window) {
|
||||
draw_cells(ssize_t vao_idx, const WindowRenderData *srd, OSWindow *os_window, bool is_active_window, bool can_be_focused, Window *window) {
|
||||
float x_ratio = 1., y_ratio = 1.;
|
||||
if (os_window->live_resize.in_progress) {
|
||||
x_ratio = (float) os_window->viewport_width / (float) os_window->live_resize.width;
|
||||
|
|
|
|||
|
|
@ -751,7 +751,7 @@ PYWRAP1(set_ignore_os_keyboard_processing) {
|
|||
}
|
||||
|
||||
static void
|
||||
init_screen_render_data(OSWindow *osw, const WindowGeometry *g, ScreenRenderData *d) {
|
||||
init_window_render_data(OSWindow *osw, const WindowGeometry *g, WindowRenderData *d) {
|
||||
d->dx = gl_size(osw->fonts_data->cell_width, osw->viewport_width);
|
||||
d->dy = gl_size(osw->fonts_data->cell_height, osw->viewport_height);
|
||||
d->xstart = gl_pos_x(g->left, osw->viewport_width);
|
||||
|
|
@ -759,14 +759,14 @@ init_screen_render_data(OSWindow *osw, const WindowGeometry *g, ScreenRenderData
|
|||
}
|
||||
|
||||
PYWRAP1(set_tab_bar_render_data) {
|
||||
ScreenRenderData d = {0};
|
||||
WindowRenderData d = {0};
|
||||
WindowGeometry g = {0};
|
||||
id_type os_window_id;
|
||||
PA("KOIIII", &os_window_id, &d.screen, &g.left, &g.top, &g.right, &g.bottom);
|
||||
WITH_OS_WINDOW(os_window_id)
|
||||
Py_CLEAR(os_window->tab_bar_render_data.screen);
|
||||
d.vao_idx = os_window->tab_bar_render_data.vao_idx;
|
||||
init_screen_render_data(os_window, &g, &d);
|
||||
init_window_render_data(os_window, &g, &d);
|
||||
os_window->tab_bar_render_data = d;
|
||||
Py_INCREF(os_window->tab_bar_render_data.screen);
|
||||
END_WITH_OS_WINDOW
|
||||
|
|
@ -930,14 +930,14 @@ PYWRAP1(set_window_render_data) {
|
|||
#define A(name) &(d.name)
|
||||
#define B(name) &(g.name)
|
||||
id_type os_window_id, tab_id, window_id;
|
||||
ScreenRenderData d = {0};
|
||||
WindowRenderData d = {0};
|
||||
WindowGeometry g = {0};
|
||||
PA("KKKOIIII", &os_window_id, &tab_id, &window_id, A(screen), B(left), B(top), B(right), B(bottom));
|
||||
|
||||
WITH_WINDOW(os_window_id, tab_id, window_id);
|
||||
Py_CLEAR(window->render_data.screen);
|
||||
d.vao_idx = window->render_data.vao_idx;
|
||||
init_screen_render_data(osw, &g, &d);
|
||||
init_window_render_data(osw, &g, &d);
|
||||
window->render_data = d;
|
||||
window->geometry = g;
|
||||
Py_INCREF(window->render_data.screen);
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ typedef struct {
|
|||
ssize_t vao_idx;
|
||||
float xstart, ystart, dx, dy;
|
||||
Screen *screen;
|
||||
} ScreenRenderData;
|
||||
} WindowRenderData;
|
||||
|
||||
typedef struct {
|
||||
unsigned int left, top, right, bottom;
|
||||
|
|
@ -154,7 +154,7 @@ typedef struct {
|
|||
unsigned int last_cursor_x, last_cursor_y;
|
||||
CursorShape last_cursor_shape;
|
||||
PyObject *title;
|
||||
ScreenRenderData render_data;
|
||||
WindowRenderData render_data;
|
||||
WindowLogoRenderData window_logo;
|
||||
MousePosition mouse_pos;
|
||||
struct {
|
||||
|
|
@ -223,7 +223,7 @@ typedef struct {
|
|||
BackgroundImage *bgimage;
|
||||
unsigned int active_tab, num_tabs, capacity, last_active_tab, last_num_tabs, last_active_window_id;
|
||||
bool focused_at_last_render, needs_render;
|
||||
ScreenRenderData tab_bar_render_data;
|
||||
WindowRenderData tab_bar_render_data;
|
||||
struct {
|
||||
color_type left, right;
|
||||
} tab_bar_edge_color;
|
||||
|
|
@ -315,7 +315,7 @@ ssize_t create_cell_vao(void);
|
|||
ssize_t create_graphics_vao(void);
|
||||
ssize_t create_border_vao(void);
|
||||
bool send_cell_data_to_gpu(ssize_t, float, float, float, float, Screen *, OSWindow *);
|
||||
void draw_cells(ssize_t, const ScreenRenderData*, OSWindow *, bool, bool, Window*);
|
||||
void draw_cells(ssize_t, const WindowRenderData*, OSWindow *, bool, bool, Window*);
|
||||
void draw_centered_alpha_mask(OSWindow *w, size_t screen_width, size_t screen_height, size_t width, size_t height, uint8_t *canvas, float);
|
||||
void update_surface_size(int, int, uint32_t);
|
||||
void free_texture(uint32_t*);
|
||||
|
|
|
|||
Loading…
Reference in a new issue