macOS: Add an option :opt:macos_traditional_fullscreen to make full-screening of kitty windows much faster, but less pretty.

See #911
This commit is contained in:
Kovid Goyal 2018-09-12 21:27:49 +05:30
parent 4e99194022
commit 772d6597a9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
6 changed files with 38 additions and 26 deletions

View File

@ -25,10 +25,8 @@ Changelog
on macs thicker, which makes it similar to the result of
sub-pixel antialiasing (:pull:`950`)
- macOS: Make full screening of kitty much faster by using the "traditional full
screen" mode of cocoa, similar to iTerm and MacVim (:iss:`911`). Also should
hopefully workaround a bug in glfw that causes crashes when unplugging
monitors with full screen windows. (:iss:`898`)
- macOS: Add an option :opt:`macos_traditional_fullscreen` to make
full-screening of kitty windows much faster, but less pretty. (:iss:`911`)
- Fix a bug causing incorrect line ordering when viewing the scrollback buffer
if the scrollback buffer is full (:iss:`960`)

View File

@ -225,20 +225,25 @@ cocoa_focus_window(void *w) {
}
bool
cocoa_toggle_fullscreen(void *w) {
cocoa_toggle_fullscreen(void *w, bool traditional) {
NSWindow *window = (NSWindow*)w;
bool made_fullscreen = true;
NSWindowStyleMask sm = [window styleMask];
bool made_fullscreen;
if (!(sm & NSWindowStyleMaskFullScreen)) {
made_fullscreen = true;
sm |= NSWindowStyleMaskBorderless | NSWindowStyleMaskFullScreen;
[[NSApplication sharedApplication] setPresentationOptions: NSApplicationPresentationAutoHideMenuBar | NSApplicationPresentationAutoHideDock];
bool in_fullscreen = sm & NSWindowStyleMaskFullScreen;
if (traditional) {
if (!(in_fullscreen)) {
sm |= NSWindowStyleMaskBorderless | NSWindowStyleMaskFullScreen;
[[NSApplication sharedApplication] setPresentationOptions: NSApplicationPresentationAutoHideMenuBar | NSApplicationPresentationAutoHideDock];
} else {
made_fullscreen = false;
sm &= ~(NSWindowStyleMaskBorderless | NSWindowStyleMaskFullScreen);
[[NSApplication sharedApplication] setPresentationOptions: NSApplicationPresentationDefault];
}
[window setStyleMask: sm];
} else {
made_fullscreen = false;
sm &= ~(NSWindowStyleMaskBorderless | NSWindowStyleMaskFullScreen);
[[NSApplication sharedApplication] setPresentationOptions: NSApplicationPresentationDefault];
if (in_fullscreen) made_fullscreen = false;
[window toggleFullScreen: nil];
}
[window setStyleMask: sm];
return made_fullscreen;
}

View File

@ -786,6 +786,10 @@ legibility at small font sizes. For example, a value of 0.75 will
result in rendering that looks similar to sub-pixel antialiasing at
common font sizes.
'''))
o('macos_traditional_fullscreen', False, long_text=_('''
Use the traditional full-screen transition, that is faster, but less pretty.
'''))
# }}}
g('shortcuts') # {{{

View File

@ -10,7 +10,7 @@
#include "glfw-wrapper.h"
extern bool cocoa_make_window_resizable(void *w, bool);
extern void cocoa_focus_window(void *w);
extern bool cocoa_toggle_fullscreen(void *w);
extern bool cocoa_toggle_fullscreen(void *w, bool);
extern void cocoa_create_global_menu(void);
extern void cocoa_set_hide_from_tasks(void);
extern void cocoa_set_titlebar_color(void *w, color_type color);
@ -362,16 +362,20 @@ toggle_fullscreen_for_os_window(OSWindow *w) {
glfwGetWindowSize(w->handle, &width, &height);
glfwGetWindowPos(w->handle, &x, &y);
#ifdef __APPLE__
if (cocoa_toggle_fullscreen(glfwGetCocoaWindow(w->handle))) {
w->before_fullscreen.is_set = true;
w->before_fullscreen.w = width; w->before_fullscreen.h = height; w->before_fullscreen.x = x; w->before_fullscreen.y = y;
return true;
if (OPT(macos_traditional_fullscreen)) {
if (cocoa_toggle_fullscreen(glfwGetCocoaWindow(w->handle), true)) {
w->before_fullscreen.is_set = true;
w->before_fullscreen.w = width; w->before_fullscreen.h = height; w->before_fullscreen.x = x; w->before_fullscreen.y = y;
return true;
}
if (w->before_fullscreen.is_set) {
glfwSetWindowSize(w->handle, w->before_fullscreen.w, w->before_fullscreen.h);
glfwSetWindowPos(w->handle, w->before_fullscreen.x, w->before_fullscreen.y);
}
return false;
} else {
return cocoa_toggle_fullscreen(glfwGetCocoaWindow(w->handle), false);
}
if (w->before_fullscreen.is_set) {
glfwSetWindowSize(w->handle, w->before_fullscreen.w, w->before_fullscreen.h);
glfwSetWindowPos(w->handle, w->before_fullscreen.x, w->before_fullscreen.y);
}
return false;
#else
GLFWmonitor *monitor;
if ((monitor = glfwGetWindowMonitor(w->handle)) == NULL) {
@ -418,7 +422,7 @@ on_application_reopen(int has_visible_windows) {
static int
intercept_cocoa_fullscreen(GLFWwindow *w) {
if (!set_callback_window(w)) return 0;
if (!OPT(macos_traditional_fullscreen) || !set_callback_window(w)) return 0;
toggle_fullscreen_for_os_window(global_state.callback_os_window);
global_state.callback_os_window = NULL;
return 1;

View File

@ -386,6 +386,7 @@ PYWRAP1(set_options) {
S(close_on_child_death, PyObject_IsTrue);
S(window_alert_on_bell, PyObject_IsTrue);
S(macos_option_as_alt, PyObject_IsTrue);
S(macos_traditional_fullscreen, PyObject_IsTrue);
S(macos_hide_titlebar, PyObject_IsTrue);
S(macos_quit_when_last_window_closed, PyObject_IsTrue);
S(macos_window_resizable, PyObject_IsTrue);

View File

@ -23,7 +23,7 @@ typedef struct {
color_type url_color, background, active_border_color, inactive_border_color, bell_border_color;
double repaint_delay, input_delay;
bool focus_follows_mouse;
bool macos_option_as_alt, macos_hide_titlebar, macos_hide_from_tasks, x11_hide_window_decorations, macos_quit_when_last_window_closed, macos_window_resizable;
bool macos_option_as_alt, macos_hide_titlebar, macos_hide_from_tasks, x11_hide_window_decorations, macos_quit_when_last_window_closed, macos_window_resizable, macos_traditional_fullscreen;
float macos_thicken_font;
int adjust_line_height_px, adjust_column_width_px;
float adjust_line_height_frac, adjust_column_width_frac;