mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-23 16:58:09 +02:00
Move the code to cycle through OS Windows into glfw
This commit is contained in:
@@ -3480,6 +3480,36 @@ glfwGetCocoaKeyEquivalent(uint32_t glfw_key, int glfw_mods, int *cocoa_mods) {
|
||||
|
||||
GLFWAPI bool glfwIsLayerShellSupported(void) { return true; }
|
||||
|
||||
GLFWAPI void
|
||||
glfwCocoaCycleThroughOSWindows(bool backwards) {
|
||||
NSArray *allWindows = [NSApp windows];
|
||||
if (allWindows.count < 2) return;
|
||||
NSMutableArray<NSWindow *> *filteredWindows = [NSMutableArray array];
|
||||
for (NSWindow *window in allWindows) {
|
||||
NSRect windowFrame = [window frame];
|
||||
// Exclude zero size windows which are likely zombie windows from the Tahoe bug
|
||||
// if ([obj isMemberOfClass:[MyClass class]]) {
|
||||
if (
|
||||
windowFrame.size.width > 0 && windowFrame.size.height > 0 && \
|
||||
!window.isMiniaturized && window.isVisible && \
|
||||
[window isMemberOfClass:[GLFWWindow class]]
|
||||
) [filteredWindows addObject:window];
|
||||
}
|
||||
if (filteredWindows.count < 2) return;
|
||||
NSWindow *keyWindow = [NSApp keyWindow];
|
||||
NSUInteger index = [filteredWindows indexOfObject:keyWindow];
|
||||
NSUInteger nextIndex = 0;
|
||||
if (index != NSNotFound) {
|
||||
if (backwards) {
|
||||
nextIndex = (index == 0) ? [filteredWindows count] - 1 : index - 1;
|
||||
} else nextIndex = (index + 1) % filteredWindows.count;
|
||||
}
|
||||
NSWindow *nextWindow = filteredWindows[nextIndex];
|
||||
[nextWindow makeKeyAndOrderFront:nil];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -313,6 +313,7 @@ def generate_wrappers(glfw_header: str) -> None:
|
||||
void* glfwGetX11Display(void)
|
||||
unsigned long glfwGetX11Window(GLFWwindow* window)
|
||||
void glfwSetPrimarySelectionString(GLFWwindow* window, const char* string)
|
||||
void glfwCocoaCycleThroughOSWindows(bool backwards)
|
||||
void glfwCocoaSetWindowChrome(GLFWwindow* window, unsigned int color, bool use_system_color, unsigned int system_color,\
|
||||
int background_blur, unsigned int hide_window_decorations, bool show_text_in_titlebar, int color_space, float background_opacity, bool resizable)
|
||||
const char* glfwGetPrimarySelectionString(GLFWwindow* window, void)
|
||||
|
||||
Reference in New Issue
Block a user