mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
more bug fixes
This commit is contained in:
@@ -30,19 +30,19 @@ def border(os_window_id, tab_id, color, sz, left, top, right, bottom):
|
||||
vert(left), vert(right - sz) # left, right edges
|
||||
|
||||
|
||||
class Borders:
|
||||
def load_borders_program():
|
||||
compile_program(BORDERS_PROGRAM, *load_shaders('border'))
|
||||
init_borders_program()
|
||||
Borders.program_initialized = True
|
||||
|
||||
program_initialized = False
|
||||
|
||||
class Borders:
|
||||
|
||||
def __init__(self, os_window_id, tab_id, opts):
|
||||
self.os_window_id = os_window_id
|
||||
self.tab_id = tab_id
|
||||
self.border_width = pt_to_px(opts.window_border_width)
|
||||
self.padding_width = pt_to_px(opts.window_padding_width)
|
||||
if not Borders.program_initialized:
|
||||
compile_program(BORDERS_PROGRAM, *load_shaders('border'))
|
||||
init_borders_program()
|
||||
Borders.program_initialized = True
|
||||
self.background = color_as_int(opts.background)
|
||||
self.active_border = color_as_int(opts.active_border_color)
|
||||
self.inactive_border = color_as_int(opts.inactive_border_color)
|
||||
|
||||
@@ -20,11 +20,9 @@ from .tabs import SpecialWindow, TabManager
|
||||
from .utils import (
|
||||
get_primary_selection, open_url, safe_print, set_primary_selection
|
||||
)
|
||||
from .window import load_shader_programs
|
||||
|
||||
|
||||
def initialize_renderer():
|
||||
load_shader_programs()
|
||||
layout_sprite_map()
|
||||
prerender()
|
||||
|
||||
|
||||
@@ -170,7 +170,8 @@ static PyObject*
|
||||
create_os_window(PyObject UNUSED *self, PyObject *args) {
|
||||
int width, height;
|
||||
char *title;
|
||||
if (!PyArg_ParseTuple(args, "iis", &width, &height, &title)) return NULL;
|
||||
PyObject *load_programs = NULL;
|
||||
if (!PyArg_ParseTuple(args, "iis|O", &width, &height, &title, &load_programs)) return NULL;
|
||||
bool is_first_window = standard_cursor == NULL;
|
||||
|
||||
if (is_first_window) {
|
||||
@@ -207,6 +208,9 @@ create_os_window(PyObject UNUSED *self, PyObject *args) {
|
||||
glfwMakeContextCurrent(glfw_window);
|
||||
gl_init();
|
||||
glfwSwapInterval(0); // a value of 1 makes mouse selection laggy
|
||||
PyObject *ret = PyObject_CallFunction(load_programs, NULL);
|
||||
if (ret == NULL) return NULL;
|
||||
Py_DECREF(ret);
|
||||
}
|
||||
|
||||
OSWindow *w = add_os_window();
|
||||
|
||||
@@ -45,7 +45,8 @@ class Layout:
|
||||
name = None
|
||||
needs_window_borders = True
|
||||
|
||||
def __init__(self, opts, border_width, windows):
|
||||
def __init__(self, os_window_id, opts, border_width, windows):
|
||||
self.os_window_id = os_window_id
|
||||
self.opts = opts
|
||||
self.border_width = border_width
|
||||
self.margin_width = pt_to_px(opts.window_margin_width)
|
||||
@@ -75,9 +76,9 @@ class Layout:
|
||||
def set_active_window(self, windows, active_window_idx):
|
||||
pass
|
||||
|
||||
def __call__(self, os_window_id, windows, active_window_idx):
|
||||
def __call__(self, windows, active_window_idx):
|
||||
global viewport_width, viewport_height, cell_width, cell_height, available_height
|
||||
viewport_width, viewport_height, available_height, cell_width, cell_height = viewport_for_window(os_window_id)
|
||||
viewport_width, viewport_height, available_height, cell_width, cell_height = viewport_for_window(self.os_window_id)
|
||||
self.do_layout(windows, active_window_idx)
|
||||
|
||||
def do_layout(self, windows, active_window_idx):
|
||||
|
||||
@@ -10,6 +10,7 @@ import sys
|
||||
from contextlib import contextmanager
|
||||
from gettext import gettext as _
|
||||
|
||||
from .borders import load_borders_program
|
||||
from .boss import Boss
|
||||
from .config import (
|
||||
initial_window_size, load_cached_values, load_config, save_cached_values
|
||||
@@ -28,6 +29,7 @@ from .utils import (
|
||||
detach, end_startup_notification, get_logical_dpi,
|
||||
init_startup_notification
|
||||
)
|
||||
from .window import load_shader_programs
|
||||
|
||||
try:
|
||||
from .fast_data_types import GLFW_X11_WM_CLASS_NAME, GLFW_X11_WM_CLASS_CLASS
|
||||
@@ -35,6 +37,11 @@ except ImportError:
|
||||
GLFW_X11_WM_CLASS_NAME = GLFW_X11_WM_CLASS_CLASS = None
|
||||
|
||||
|
||||
def load_all_shaders():
|
||||
load_shader_programs()
|
||||
load_borders_program()
|
||||
|
||||
|
||||
def option_parser():
|
||||
parser = argparse.ArgumentParser(
|
||||
prog=appname,
|
||||
@@ -143,7 +150,7 @@ def run_app(opts, args):
|
||||
set_options(opts, iswayland, args.debug_gl)
|
||||
load_cached_values()
|
||||
w, h = initial_window_size(opts)
|
||||
window_id = create_os_window(w, h, args.cls)
|
||||
window_id = create_os_window(w, h, args.cls, load_all_shaders)
|
||||
startup_ctx = init_startup_notification(window_id)
|
||||
if isosx:
|
||||
from .fast_data_types import cocoa_create_global_menu, cocoa_init
|
||||
|
||||
@@ -316,10 +316,9 @@ PYWRAP1(set_options) {
|
||||
}
|
||||
|
||||
PYWRAP1(set_tab_bar_render_data) {
|
||||
#define A(name) &(d.name)
|
||||
ScreenRenderData d = {0};
|
||||
id_type os_window_id;
|
||||
PA("KffffO", &os_window_id, A(xstart), A(ystart), A(dx), A(dy), A(screen));
|
||||
PA("KffffO", &os_window_id, &d.xstart, &d.ystart, &d.dx, &d.dy, &d.screen);
|
||||
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;
|
||||
@@ -327,7 +326,6 @@ PYWRAP1(set_tab_bar_render_data) {
|
||||
Py_INCREF(os_window->tab_bar_render_data.screen);
|
||||
END_WITH_OS_WINDOW
|
||||
Py_RETURN_NONE;
|
||||
#undef A
|
||||
}
|
||||
|
||||
PYWRAP1(viewport_for_window) {
|
||||
@@ -359,7 +357,7 @@ PYWRAP1(set_window_render_data) {
|
||||
unsigned int window_idx;
|
||||
ScreenRenderData d = {0};
|
||||
WindowGeometry g = {0};
|
||||
PA("KKI ffff OIIII", &os_window_id, &tab_id, &window_idx, A(xstart), A(ystart), A(dx), A(dy), A(screen), B(left), B(top), B(right), B(bottom));
|
||||
PA("KKIffffOIIII", &os_window_id, &tab_id, &window_idx, A(xstart), A(ystart), A(dx), A(dy), A(screen), B(left), B(top), B(right), B(bottom));
|
||||
|
||||
WITH_TAB(os_window_id, tab_id);
|
||||
Py_CLEAR(tab->windows[window_idx].render_data.screen);
|
||||
|
||||
@@ -31,7 +31,7 @@ class Tab: # {{{
|
||||
def __init__(self, tab_manager, session_tab=None, special_window=None):
|
||||
self.tab_manager_ref = weakref.ref(tab_manager)
|
||||
self.os_window_id = tab_manager.os_window_id
|
||||
self.id = add_tab(self.os_window_id, self.id)
|
||||
self.id = add_tab(self.os_window_id)
|
||||
if not self.id:
|
||||
raise Exception('No OS window with id {} found, or tab counter has wrapped'.format(self.os_window_id))
|
||||
self.opts, self.args = tab_manager.opts, tab_manager.args
|
||||
@@ -45,7 +45,7 @@ class Tab: # {{{
|
||||
if session_tab is None:
|
||||
self.cwd = self.args.directory
|
||||
sl = self.enabled_layouts[0]
|
||||
self.current_layout = all_layouts[sl](self.opts, self.borders.border_width, self.windows)
|
||||
self.current_layout = all_layouts[sl](self.os_window_id, self.opts, self.borders.border_width, self.windows)
|
||||
if special_window is None:
|
||||
self.new_window()
|
||||
else:
|
||||
@@ -53,7 +53,7 @@ class Tab: # {{{
|
||||
else:
|
||||
self.cwd = session_tab.cwd or self.args.directory
|
||||
l0 = session_tab.layout
|
||||
self.current_layout = all_layouts[l0](self.opts, self.borders.border_width, self.windows)
|
||||
self.current_layout = all_layouts[l0](self.os_window_id, self.opts, self.borders.border_width, self.windows)
|
||||
self.startup(session_tab)
|
||||
|
||||
def startup(self, session_tab):
|
||||
@@ -82,7 +82,7 @@ class Tab: # {{{
|
||||
|
||||
def relayout(self):
|
||||
if self.windows:
|
||||
self.current_layout(self.os_window_id, self.windows, self.active_window_idx)
|
||||
self.current_layout(self.windows, self.active_window_idx)
|
||||
self.relayout_borders()
|
||||
|
||||
def relayout_borders(self):
|
||||
@@ -98,7 +98,7 @@ class Tab: # {{{
|
||||
except Exception:
|
||||
idx = -1
|
||||
nl = self.opts.enabled_layouts[(idx + 1) % len(self.opts.enabled_layouts)]
|
||||
self.current_layout = all_layouts[nl](self.opts, self.borders.border_width, self.windows)
|
||||
self.current_layout = all_layouts[nl](self.os_window_id, self.opts, self.borders.border_width, self.windows)
|
||||
for i, w in enumerate(self.windows):
|
||||
w.set_visible_in_layout(i, True)
|
||||
self.relayout()
|
||||
@@ -210,7 +210,8 @@ class Tab: # {{{
|
||||
|
||||
class TabBar: # {{{
|
||||
|
||||
def __init__(self, opts):
|
||||
def __init__(self, os_window_id, opts):
|
||||
self.os_window_id = os_window_id
|
||||
self.num_tabs = 1
|
||||
self.cell_width = 1
|
||||
self.data_buffer_size = 0
|
||||
@@ -295,7 +296,7 @@ class TabManager: # {{{
|
||||
self.os_window_id = os_window_id
|
||||
self.opts, self.args = opts, args
|
||||
self.tabs = []
|
||||
self.tab_bar = TabBar(opts)
|
||||
self.tab_bar = TabBar(self.os_window_id, opts)
|
||||
self.tab_bar.layout(*self.tab_bar_layout_data)
|
||||
self.active_tab_idx = 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user