mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 14:18:26 +02:00
Finish calculations for other panel types in cocoa
This commit is contained in:
@@ -1932,10 +1932,10 @@ _glfwPlatformSetLayerShellConfig(_GLFWwindow* window, const GLFWLayerShellConfig
|
|||||||
#define nswindow window->ns.object
|
#define nswindow window->ns.object
|
||||||
window->resizable = false;
|
window->resizable = false;
|
||||||
if (value) config = *value;
|
if (value) config = *value;
|
||||||
const bool is_transparent = ![nswindow isOpaque];
|
const bool is_transparent = _glfwPlatformFramebufferTransparent(window);
|
||||||
int background_blur = config.related.background_blur;
|
int background_blur = config.related.background_blur;
|
||||||
if (!is_transparent || config.related.background_opacity >= 1.f) { background_blur = 0; }
|
if (!is_transparent || config.related.background_opacity >= 1.f) { background_blur = 0; }
|
||||||
[nswindow setBackgroundColor:nil];
|
[nswindow setBackgroundColor:[NSColor clearColor]];
|
||||||
_glfwPlatformSetWindowBlur(window, background_blur);
|
_glfwPlatformSetWindowBlur(window, background_blur);
|
||||||
window->ns.titlebar_hidden = true;
|
window->ns.titlebar_hidden = true;
|
||||||
window->decorated = false;
|
window->decorated = false;
|
||||||
@@ -1960,18 +1960,50 @@ _glfwPlatformSetLayerShellConfig(_GLFWwindow* window, const GLFWLayerShellConfig
|
|||||||
float xscale = (float)config.expected.xscale, yscale = (float)config.expected.yscale;
|
float xscale = (float)config.expected.xscale, yscale = (float)config.expected.yscale;
|
||||||
_glfwPlatformGetWindowContentScale(window, &xscale, &yscale);
|
_glfwPlatformGetWindowContentScale(window, &xscale, &yscale);
|
||||||
config.size_callback((GLFWwindow*)window, xscale, yscale, &cell_width, &cell_height, &left_edge_spacing, &top_edge_spacing, &right_edge_spacing, &bottom_edge_spacing);
|
config.size_callback((GLFWwindow*)window, xscale, yscale, &cell_width, &cell_height, &left_edge_spacing, &top_edge_spacing, &right_edge_spacing, &bottom_edge_spacing);
|
||||||
CGFloat x = NSMinX(screen.visibleFrame), y = NSMinY(screen.visibleFrame) + 1, width = NSWidth(screen.visibleFrame), height = NSHeight(screen.visibleFrame);
|
double spacing_x = left_edge_spacing + right_edge_spacing;
|
||||||
|
double spacing_y = top_edge_spacing + bottom_edge_spacing;
|
||||||
|
const unsigned xsz = config.x_size_in_pixels ? (unsigned)(config.x_size_in_pixels * xscale) : (cell_width * config.x_size_in_cells);
|
||||||
|
const unsigned ysz = config.y_size_in_pixels ? (unsigned)(config.y_size_in_pixels * yscale) : (cell_height * config.y_size_in_cells);
|
||||||
CGFloat dock_height = NSMinY(screen.visibleFrame) - NSMinY(screen.frame);
|
CGFloat dock_height = NSMinY(screen.visibleFrame) - NSMinY(screen.frame);
|
||||||
CGFloat menubar_height = NSHeight(screen.frame) - NSHeight(screen.visibleFrame) - dock_height;
|
CGFloat menubar_height = NSHeight(screen.frame) - NSHeight(screen.visibleFrame) - dock_height;
|
||||||
|
CGFloat x = NSMinX(screen.visibleFrame), y = NSMinY(screen.visibleFrame) - 1, width = NSWidth(screen.visibleFrame), height = NSHeight(screen.visibleFrame) + 2;
|
||||||
|
if (config.type == GLFW_LAYER_SHELL_BACKGROUND || config.edge == GLFW_EDGE_CENTER) {
|
||||||
|
x = NSMinX(screen.frame); height = NSHeight(screen.frame) - menubar_height + 1; y = NSMinY(screen.frame); width = NSWidth(screen.frame);
|
||||||
|
}
|
||||||
// Screen co-ordinate system is with origin in lower left and y increasing upwards and x increasing rightwards
|
// Screen co-ordinate system is with origin in lower left and y increasing upwards and x increasing rightwards
|
||||||
// NSLog(@"frame: %@ visibleFrame: %@\n", NSStringFromRect(screen.frame), NSStringFromRect(screen.visibleFrame));
|
// NSLog(@"frame: %@ visibleFrame: %@\n", NSStringFromRect(screen.frame), NSStringFromRect(screen.visibleFrame));
|
||||||
NSWindowLevel level = NSScreenSaverWindowLevel - 1;
|
NSWindowLevel level = NSScreenSaverWindowLevel - 1;
|
||||||
NSWindowAnimationBehavior animation_behavior = NSWindowAnimationBehaviorUtilityWindow;
|
NSWindowAnimationBehavior animation_behavior = NSWindowAnimationBehaviorUtilityWindow;
|
||||||
if (config.type == GLFW_LAYER_SHELL_BACKGROUND) {
|
switch (config.type) {
|
||||||
x = NSMinX(screen.frame); height = NSHeight(screen.frame) - menubar_height + 1; y = NSMinY(screen.frame); width = NSWidth(screen.frame);
|
case GLFW_LAYER_SHELL_BACKGROUND:
|
||||||
animation_behavior = NSWindowAnimationBehaviorNone;
|
animation_behavior = NSWindowAnimationBehaviorNone;
|
||||||
// See: https://stackoverflow.com/questions/4982584/how-do-i-draw-the-desktop-on-mac-os-x/4982619#4982619
|
// See: https://stackoverflow.com/questions/4982584/how-do-i-draw-the-desktop-on-mac-os-x/4982619#4982619
|
||||||
level = kCGDesktopWindowLevel;
|
level = kCGDesktopWindowLevel;
|
||||||
|
break;
|
||||||
|
case GLFW_LAYER_SHELL_OVERLAY: case GLFW_LAYER_SHELL_NONE: break;
|
||||||
|
case GLFW_LAYER_SHELL_PANEL: level = NSNormalWindowLevel - 1; break;
|
||||||
|
case GLFW_LAYER_SHELL_TOP: level = NSPopUpMenuWindowLevel + 1; break;
|
||||||
|
}
|
||||||
|
if (config.type != GLFW_LAYER_SHELL_BACKGROUND && config.edge != GLFW_EDGE_CENTER) {
|
||||||
|
double panel_height = spacing_y + ysz / yscale, panel_width = spacing_x + xsz / xscale;
|
||||||
|
switch (config.edge) {
|
||||||
|
case GLFW_EDGE_BOTTOM: height = panel_height; break;
|
||||||
|
case GLFW_EDGE_TOP:
|
||||||
|
y += height - panel_height + 1.;
|
||||||
|
height = panel_height;
|
||||||
|
break;
|
||||||
|
case GLFW_EDGE_LEFT: width = panel_width; break;
|
||||||
|
case GLFW_EDGE_RIGHT:
|
||||||
|
x += width - panel_width + 1.;
|
||||||
|
width = panel_width;
|
||||||
|
break;
|
||||||
|
default: // top left
|
||||||
|
y += height - panel_height + 1.;
|
||||||
|
height = panel_height; width = panel_width;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (width < 1.) width = NSWidth(screen.visibleFrame);
|
||||||
|
if (height < 1.) height = NSWidth(screen.visibleFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
x += config.requested_left_margin; width -= config.requested_left_margin + config.requested_right_margin;
|
x += config.requested_left_margin; width -= config.requested_left_margin + config.requested_right_margin;
|
||||||
@@ -3075,7 +3107,7 @@ GLFWAPI GLFWcocoarenderframefun glfwCocoaSetWindowResizeCallback(GLFWwindow *w,
|
|||||||
GLFWAPI void glfwCocoaSetWindowChrome(GLFWwindow *w, 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) { @autoreleasepool {
|
GLFWAPI void glfwCocoaSetWindowChrome(GLFWwindow *w, 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) { @autoreleasepool {
|
||||||
_GLFWwindow* window = (_GLFWwindow*)w;
|
_GLFWwindow* window = (_GLFWwindow*)w;
|
||||||
if (window->ns.layer_shell.is_active) return;
|
if (window->ns.layer_shell.is_active) return;
|
||||||
const bool is_transparent = ![window->ns.object isOpaque];
|
const bool is_transparent = _glfwPlatformFramebufferTransparent(window);
|
||||||
if (!is_transparent) { background_opacity = 1.0; background_blur = 0; }
|
if (!is_transparent) { background_opacity = 1.0; background_blur = 0; }
|
||||||
NSColor *background = nil;
|
NSColor *background = nil;
|
||||||
NSAppearance *appearance = nil;
|
NSAppearance *appearance = nil;
|
||||||
|
|||||||
Reference in New Issue
Block a user