Remote control: When matching window by state:focused match the window belonging to the OS window that was last focused
Fixes #5602
This commit is contained in:
parent
f5de08d5fa
commit
935c4ded6b
@ -54,6 +54,8 @@ Detailed list of changes
|
|||||||
|
|
||||||
- Wayland: Fix high CPU usage when using some input methods (:pull:`5369`)
|
- Wayland: Fix high CPU usage when using some input methods (:pull:`5369`)
|
||||||
|
|
||||||
|
- Remote control: When matching window by `state:focused` match the window belonging to the OS window that was last focused (:iss:`5602`)
|
||||||
|
|
||||||
0.26.4 [2022-10-17]
|
0.26.4 [2022-10-17]
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|||||||
@ -786,6 +786,10 @@ def current_os_window() -> Optional[int]:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def last_focused_os_window_id() -> int:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def cocoa_set_menubar_title(title: str) -> None:
|
def cocoa_set_menubar_title(title: str) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@ -96,7 +96,7 @@ pt_to_px(double pt, id_type os_window_id) {
|
|||||||
|
|
||||||
|
|
||||||
OSWindow*
|
OSWindow*
|
||||||
current_os_window() {
|
current_os_window(void) {
|
||||||
if (global_state.callback_os_window) return global_state.callback_os_window;
|
if (global_state.callback_os_window) return global_state.callback_os_window;
|
||||||
for (size_t i = 0; i < global_state.num_os_windows; i++) {
|
for (size_t i = 0; i < global_state.num_os_windows; i++) {
|
||||||
if (global_state.os_windows[i].is_focused) return global_state.os_windows + i;
|
if (global_state.os_windows[i].is_focused) return global_state.os_windows + i;
|
||||||
@ -104,6 +104,19 @@ current_os_window() {
|
|||||||
return global_state.os_windows;
|
return global_state.os_windows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static id_type
|
||||||
|
last_focused_os_window_id(void) {
|
||||||
|
id_type ans = 0, max_fc_count = 0;
|
||||||
|
for (size_t i = 0; i < global_state.num_os_windows; i++) {
|
||||||
|
OSWindow *w = &global_state.os_windows[i];
|
||||||
|
if (w->last_focused_counter > max_fc_count) {
|
||||||
|
ans = w->id; max_fc_count = w->last_focused_counter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ans;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
OSWindow*
|
OSWindow*
|
||||||
os_window_for_kitty_window(id_type kitty_window_id) {
|
os_window_for_kitty_window(id_type kitty_window_id) {
|
||||||
for (size_t i = 0; i < global_state.num_os_windows; i++) {
|
for (size_t i = 0; i < global_state.num_os_windows; i++) {
|
||||||
@ -665,6 +678,11 @@ PYWRAP0(next_window_id) {
|
|||||||
return PyLong_FromUnsignedLongLong(global_state.window_id_counter + 1);
|
return PyLong_FromUnsignedLongLong(global_state.window_id_counter + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PYWRAP0(last_focused_os_window_id) {
|
||||||
|
return PyLong_FromUnsignedLongLong(last_focused_os_window_id());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PYWRAP1(handle_for_window_id) {
|
PYWRAP1(handle_for_window_id) {
|
||||||
id_type os_window_id;
|
id_type os_window_id;
|
||||||
PA("K", &os_window_id);
|
PA("K", &os_window_id);
|
||||||
@ -1266,6 +1284,7 @@ KK5I(add_borders_rect)
|
|||||||
static PyMethodDef module_methods[] = {
|
static PyMethodDef module_methods[] = {
|
||||||
MW(current_os_window, METH_NOARGS),
|
MW(current_os_window, METH_NOARGS),
|
||||||
MW(next_window_id, METH_NOARGS),
|
MW(next_window_id, METH_NOARGS),
|
||||||
|
MW(last_focused_os_window_id, METH_NOARGS),
|
||||||
MW(set_options, METH_VARARGS),
|
MW(set_options, METH_VARARGS),
|
||||||
MW(get_options, METH_NOARGS),
|
MW(get_options, METH_NOARGS),
|
||||||
MW(click_mouse_url, METH_VARARGS),
|
MW(click_mouse_url, METH_VARARGS),
|
||||||
|
|||||||
@ -37,7 +37,7 @@ from .fast_data_types import (
|
|||||||
STRIKETHROUGH, TINT_PROGRAM, Color, KeyEvent, Screen, add_timer, add_window,
|
STRIKETHROUGH, TINT_PROGRAM, Color, KeyEvent, Screen, add_timer, add_window,
|
||||||
cell_size_for_window, click_mouse_cmd_output, click_mouse_url, compile_program,
|
cell_size_for_window, click_mouse_cmd_output, click_mouse_url, compile_program,
|
||||||
current_os_window, encode_key_for_tty, get_boss, get_click_interval, get_options,
|
current_os_window, encode_key_for_tty, get_boss, get_click_interval, get_options,
|
||||||
init_cell_program, mark_os_window_dirty, mouse_selection,
|
init_cell_program, mark_os_window_dirty, mouse_selection, last_focused_os_window_id,
|
||||||
move_cursor_to_mouse_if_in_prompt, pt_to_px, set_titlebar_color, set_window_logo,
|
move_cursor_to_mouse_if_in_prompt, pt_to_px, set_titlebar_color, set_window_logo,
|
||||||
set_window_padding, set_window_render_data, update_ime_position_for_window,
|
set_window_padding, set_window_render_data, update_ime_position_for_window,
|
||||||
update_window_title, update_window_visibility, wakeup_main_loop,
|
update_window_title, update_window_visibility, wakeup_main_loop,
|
||||||
@ -707,7 +707,7 @@ class Window:
|
|||||||
if query == 'active':
|
if query == 'active':
|
||||||
return active_tab is not None and self is active_tab.active_window
|
return active_tab is not None and self is active_tab.active_window
|
||||||
if query == 'focused':
|
if query == 'focused':
|
||||||
return active_tab is not None and self is active_tab.active_window and current_os_window() == self.os_window_id
|
return active_tab is not None and self is active_tab.active_window and last_focused_os_window_id() == self.os_window_id
|
||||||
if query == 'needs_attention':
|
if query == 'needs_attention':
|
||||||
return self.needs_attention
|
return self.needs_attention
|
||||||
if query == 'parent_active':
|
if query == 'parent_active':
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user