mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-28 03:01:57 +02:00
macOS: When closing a top-level window only switch focus to the previous kitty window if it is on the same workspace
Fixes #1379 Fixes #1383
This commit is contained in:
@@ -53,6 +53,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
|
|||||||
- Fix scrollback pager history not being cleared when clearing the
|
- Fix scrollback pager history not being cleared when clearing the
|
||||||
main scrollback buffer (:iss:`1387`)
|
main scrollback buffer (:iss:`1387`)
|
||||||
|
|
||||||
|
- macOS: When closing a top-level window only switch focus to the previous kitty
|
||||||
|
window if it is on the same workspace (:iss:`1379`)
|
||||||
|
|
||||||
0.13.3 [2019-01-19]
|
0.13.3 [2019-01-19]
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -372,8 +372,8 @@ cocoa_focus_window(void *w) {
|
|||||||
int
|
int
|
||||||
cocoa_get_workspace_id(void *w) {
|
cocoa_get_workspace_id(void *w) {
|
||||||
NSWindow *window = (NSWindow*)w;
|
NSWindow *window = (NSWindow*)w;
|
||||||
int ans = 0;
|
int ans = -1;
|
||||||
CGSGetWindowWorkspace(_CGSDefaultConnection(), [window windowNumber], &ans);
|
if (window) CGSGetWindowWorkspace(_CGSDefaultConnection(), [window windowNumber], &ans);
|
||||||
return ans;
|
return ans;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
15
kitty/glfw.c
15
kitty/glfw.c
@@ -15,6 +15,7 @@ extern void cocoa_create_global_menu(void);
|
|||||||
extern void cocoa_set_hide_from_tasks(void);
|
extern void cocoa_set_hide_from_tasks(void);
|
||||||
extern void cocoa_set_titlebar_color(void *w, color_type color);
|
extern void cocoa_set_titlebar_color(void *w, color_type color);
|
||||||
extern bool cocoa_alt_option_key_pressed(unsigned long);
|
extern bool cocoa_alt_option_key_pressed(unsigned long);
|
||||||
|
extern int cocoa_get_workspace_id(void *w);
|
||||||
|
|
||||||
|
|
||||||
#if GLFW_KEY_LAST >= MAX_KEY_COUNT
|
#if GLFW_KEY_LAST >= MAX_KEY_COUNT
|
||||||
@@ -594,7 +595,13 @@ create_os_window(PyObject UNUSED *self, PyObject *args) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
destroy_os_window(OSWindow *w) {
|
destroy_os_window(OSWindow *w) {
|
||||||
|
#ifdef __APPLE__
|
||||||
|
int workspace_id = -1;
|
||||||
|
#endif
|
||||||
if (w->handle) {
|
if (w->handle) {
|
||||||
|
#ifdef __APPLE__
|
||||||
|
workspace_id = cocoa_get_workspace_id(glfwGetCocoaWindow(w->handle));
|
||||||
|
#endif
|
||||||
// Ensure mouse cursor is visible and reset to default shape, needed on macOS
|
// Ensure mouse cursor is visible and reset to default shape, needed on macOS
|
||||||
show_mouse_cursor(w->handle);
|
show_mouse_cursor(w->handle);
|
||||||
glfwSetCursor(w->handle, NULL);
|
glfwSetCursor(w->handle, NULL);
|
||||||
@@ -608,13 +615,17 @@ destroy_os_window(OSWindow *w) {
|
|||||||
OSWindow *window_to_focus = NULL;
|
OSWindow *window_to_focus = NULL;
|
||||||
for (size_t i = 0; i < global_state.num_os_windows; i++) {
|
for (size_t i = 0; i < global_state.num_os_windows; i++) {
|
||||||
OSWindow *c = global_state.os_windows + i;
|
OSWindow *c = global_state.os_windows + i;
|
||||||
if (c->id != w->id && c->handle && c->shown_once && (c->last_focused_counter >= highest_focus_number)) {
|
if (
|
||||||
|
c->id != w->id && c->handle && c->shown_once &&
|
||||||
|
c->last_focused_counter >= highest_focus_number &&
|
||||||
|
(workspace_id == -1 || cocoa_get_workspace_id(glfwGetCocoaWindow(c->handle)) == workspace_id)
|
||||||
|
) {
|
||||||
highest_focus_number = c->last_focused_counter;
|
highest_focus_number = c->last_focused_counter;
|
||||||
window_to_focus = c;
|
window_to_focus = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (window_to_focus) {
|
if (window_to_focus) {
|
||||||
glfwFocusWindow(w->handle);
|
glfwFocusWindow(window_to_focus->handle);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user