mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-25 09:48:09 +02:00
Micro-optimization
This commit is contained in:
@@ -67,6 +67,7 @@ def queue_action(func, *args):
|
|||||||
|
|
||||||
is_key_pressed = defaultdict(lambda: False)
|
is_key_pressed = defaultdict(lambda: False)
|
||||||
mouse_button_pressed = defaultdict(lambda: False)
|
mouse_button_pressed = defaultdict(lambda: False)
|
||||||
|
mouse_cursor_pos = [0, 0]
|
||||||
viewport_size = ViewportSize()
|
viewport_size = ViewportSize()
|
||||||
cell_size = ViewportSize()
|
cell_size = ViewportSize()
|
||||||
terminfo_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'terminfo')
|
terminfo_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'terminfo')
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ from queue import Queue, Empty
|
|||||||
from .child import Child
|
from .child import Child
|
||||||
from .constants import (
|
from .constants import (
|
||||||
viewport_size, shell_path, appname, set_tab_manager, tab_manager, wakeup,
|
viewport_size, shell_path, appname, set_tab_manager, tab_manager, wakeup,
|
||||||
cell_size, MODIFIER_KEYS, main_thread, mouse_button_pressed
|
cell_size, MODIFIER_KEYS, main_thread, mouse_button_pressed, mouse_cursor_pos
|
||||||
)
|
)
|
||||||
from .fast_data_types import (
|
from .fast_data_types import (
|
||||||
glViewport, glBlendFunc, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GLFW_PRESS,
|
glViewport, glBlendFunc, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GLFW_PRESS,
|
||||||
@@ -350,7 +350,7 @@ class TabManager(Thread):
|
|||||||
def on_mouse_button(self, window, button, action, mods):
|
def on_mouse_button(self, window, button, action, mods):
|
||||||
mouse_button_pressed[button] = action == GLFW_PRESS
|
mouse_button_pressed[button] = action == GLFW_PRESS
|
||||||
self.show_mouse_cursor()
|
self.show_mouse_cursor()
|
||||||
w = self.window_for_pos(*window.get_cursor_pos())
|
w = self.window_for_pos(*mouse_cursor_pos)
|
||||||
if w is None:
|
if w is None:
|
||||||
return
|
return
|
||||||
focus_moved = False
|
focus_moved = False
|
||||||
@@ -367,8 +367,9 @@ class TabManager(Thread):
|
|||||||
|
|
||||||
@callback
|
@callback
|
||||||
def on_mouse_move(self, window, xpos, ypos):
|
def on_mouse_move(self, window, xpos, ypos):
|
||||||
|
mouse_cursor_pos[:2] = xpos, ypos
|
||||||
self.show_mouse_cursor()
|
self.show_mouse_cursor()
|
||||||
w = self.window_for_pos(*window.get_cursor_pos())
|
w = self.window_for_pos(xpos, ypos)
|
||||||
if w is not None:
|
if w is not None:
|
||||||
yield w
|
yield w
|
||||||
w.on_mouse_move(xpos, ypos)
|
w.on_mouse_move(xpos, ypos)
|
||||||
@@ -376,7 +377,7 @@ class TabManager(Thread):
|
|||||||
@callback
|
@callback
|
||||||
def on_mouse_scroll(self, window, x, y):
|
def on_mouse_scroll(self, window, x, y):
|
||||||
self.show_mouse_cursor()
|
self.show_mouse_cursor()
|
||||||
w = self.window_for_pos(*window.get_cursor_pos())
|
w = self.window_for_pos(*mouse_cursor_pos)
|
||||||
if w is not None:
|
if w is not None:
|
||||||
yield w
|
yield w
|
||||||
w.on_mouse_scroll(x, y)
|
w.on_mouse_scroll(x, y)
|
||||||
|
|||||||
Reference in New Issue
Block a user