mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-27 18:51:41 +02:00
Ensure window with hidden chrome is resizable on macOS
This commit is contained in:
@@ -9,6 +9,25 @@
|
|||||||
#include "data-types.h"
|
#include "data-types.h"
|
||||||
#include <Cocoa/Cocoa.h>
|
#include <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
|
#include <AvailabilityMacros.h>
|
||||||
|
|
||||||
|
#if (MAC_OS_X_VERSION_MAX_ALLOWED < 101200)
|
||||||
|
#define NSWindowStyleMaskResizable NSResizableWindowMask
|
||||||
|
#endif
|
||||||
|
|
||||||
|
PyObject*
|
||||||
|
cocoa_make_window_resizable(PyObject UNUSED *self, PyObject *window_id) {
|
||||||
|
NSWindow *window = (NSWindow*)PyLong_AsVoidPtr(window_id);
|
||||||
|
|
||||||
|
@try {
|
||||||
|
[window setStyleMask:
|
||||||
|
[window styleMask] | NSWindowStyleMaskResizable];
|
||||||
|
} @catch (NSException *e) {
|
||||||
|
return PyErr_Format(PyExc_ValueError, "Failed to set style mask: %s: %s", [[e name] UTF8String], [[e reason] UTF8String]);
|
||||||
|
}
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
PyObject*
|
PyObject*
|
||||||
cocoa_get_lang(PyObject UNUSED *self) {
|
cocoa_get_lang(PyObject UNUSED *self) {
|
||||||
NSString* locale = nil;
|
NSString* locale = nil;
|
||||||
|
|||||||
@@ -21,9 +21,12 @@ PyObject* glfw_init_hint_string(PyObject UNUSED *self, PyObject *args);
|
|||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
PyObject* cocoa_get_lang(PyObject UNUSED *self);
|
PyObject* cocoa_get_lang(PyObject UNUSED *self);
|
||||||
|
PyObject* cocoa_make_window_resizable(PyObject UNUSED *self, PyObject *window_id);
|
||||||
#define COCOA_GET_LANG {"cocoa_get_lang", (PyCFunction)cocoa_get_lang, METH_NOARGS, ""},
|
#define COCOA_GET_LANG {"cocoa_get_lang", (PyCFunction)cocoa_get_lang, METH_NOARGS, ""},
|
||||||
|
#define COCOA_MWR {"cocoa_make_window_resizable", (PyCFunction)cocoa_make_window_resizable, METH_O, ""},
|
||||||
#else
|
#else
|
||||||
#define COCOA_GET_LANG
|
#define COCOA_GET_LANG
|
||||||
|
#define COCOA_MWR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define GLFW_FUNC_WRAPPERS \
|
#define GLFW_FUNC_WRAPPERS \
|
||||||
@@ -37,5 +40,5 @@ PyObject* cocoa_get_lang(PyObject UNUSED *self);
|
|||||||
{"glfw_get_physical_dpi", (PyCFunction)glfw_get_physical_dpi, METH_NOARGS, ""}, \
|
{"glfw_get_physical_dpi", (PyCFunction)glfw_get_physical_dpi, METH_NOARGS, ""}, \
|
||||||
{"glfw_get_key_name", (PyCFunction)glfw_get_key_name, METH_VARARGS, ""}, \
|
{"glfw_get_key_name", (PyCFunction)glfw_get_key_name, METH_VARARGS, ""}, \
|
||||||
{"glfw_init_hint_string", (PyCFunction)glfw_init_hint_string, METH_VARARGS, ""}, \
|
{"glfw_init_hint_string", (PyCFunction)glfw_init_hint_string, METH_VARARGS, ""}, \
|
||||||
COCOA_GET_LANG
|
COCOA_GET_LANG \
|
||||||
|
COCOA_MWR
|
||||||
|
|||||||
@@ -212,6 +212,9 @@ def run_app(opts, args):
|
|||||||
window.make_context_current()
|
window.make_context_current()
|
||||||
if isosx:
|
if isosx:
|
||||||
check_for_extensions()
|
check_for_extensions()
|
||||||
|
if opts.macos_hide_titlebar:
|
||||||
|
from .fast_data_types import cocoa_make_window_resizable
|
||||||
|
cocoa_make_window_resizable(window.cocoa_window_id())
|
||||||
else:
|
else:
|
||||||
with open(logo_data_file, 'rb') as f:
|
with open(logo_data_file, 'rb') as f:
|
||||||
window.set_icon(f.read(), 256, 256)
|
window.set_icon(f.read(), 256, 256)
|
||||||
|
|||||||
Reference in New Issue
Block a user