macOS: Fix window not taking up full height when the title bar is hidden

When the remembered window size is the full screen height, the window
height decreases after hiding the title bar.
This commit is contained in:
pagedown 2023-02-18 19:35:01 +08:00
parent 75a4f45a23
commit b0c28148b1
No known key found for this signature in database
GPG Key ID: E921CF18AC8FF6EB

View File

@ -947,6 +947,18 @@ create_os_window(PyObject UNUSED *self, PyObject *args, PyObject *kw) {
w->fonts_data = fonts_data;
w->shown_once = true;
w->last_focused_counter = ++focus_counter;
#ifdef __APPLE__
if (OPT(hide_window_decorations) & 2) {
glfwHideCocoaTitlebar(glfw_window, true);
} else if (!(OPT(macos_show_window_title_in) & WINDOW)) {
if (glfwGetCocoaWindow) cocoa_hide_window_title(glfwGetCocoaWindow(glfw_window));
else log_error("Failed to load glfwGetCocoaWindow");
}
if (OPT(hide_window_decorations)) {
// Need to resize the window again after hiding decorations or title bar to take up screen space
glfwSetWindowSize(glfw_window, width, height);
}
#endif
os_window_update_size_increments(w);
#ifdef __APPLE__
if (OPT(macos_option_as_alt)) glfwSetCocoaTextInputFilter(glfw_window, filter_option);
@ -956,6 +968,9 @@ create_os_window(PyObject UNUSED *self, PyObject *args, PyObject *kw) {
if (logo.pixels && logo.width && logo.height) glfwSetWindowIcon(glfw_window, 1, &logo);
glfwSetCursor(glfw_window, standard_cursor);
update_os_window_viewport(w, false);
#ifdef __APPLE__
if (glfwGetCocoaWindow) cocoa_make_window_resizable(glfwGetCocoaWindow(glfw_window), OPT(macos_window_resizable));
#endif
glfwSetWindowPosCallback(glfw_window, window_pos_callback);
// missing size callback
glfwSetWindowCloseCallback(glfw_window, window_close_callback);
@ -973,16 +988,6 @@ create_os_window(PyObject UNUSED *self, PyObject *args, PyObject *kw) {
glfwSetScrollCallback(glfw_window, scroll_callback);
glfwSetKeyboardCallback(glfw_window, key_callback);
glfwSetDropCallback(glfw_window, drop_callback);
#ifdef __APPLE__
if (glfwGetCocoaWindow) {
if (OPT(hide_window_decorations) & 2) {
glfwHideCocoaTitlebar(glfw_window, true);
} else if (!(OPT(macos_show_window_title_in) & WINDOW)) {
cocoa_hide_window_title(glfwGetCocoaWindow(glfw_window));
}
cocoa_make_window_resizable(glfwGetCocoaWindow(glfw_window), OPT(macos_window_resizable));
} else log_error("Failed to load glfwGetCocoaWindow");
#endif
monotonic_t now = monotonic();
w->is_focused = true;
w->cursor_blink_zero_time = now;