Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions kitty/cocoa_window.m
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,26 @@ - (void)openFilesFromPasteboard:(NSPasteboard *)pasteboard type:(int)type {
} // autoreleasepool
}

void
cocoa_hide_titlebar(void *w)
{
@autoreleasepool {

cocoa_hide_window_title(w);

NSWindow *window = (NSWindow*)w;

[window standardWindowButton: NSWindowCloseButton].hidden = true;
[window standardWindowButton: NSWindowMiniaturizeButton].hidden = true;
[window standardWindowButton: NSWindowZoomButton].hidden = true;

[window setTitlebarAppearsTransparent:YES];
[window setStyleMask:
[window styleMask] | NSWindowStyleMaskFullSizeContentView];

} // autoreleasepool
}

static PyMethodDef module_methods[] = {
{"cocoa_get_lang", (PyCFunction)cocoa_get_lang, METH_NOARGS, ""},
{"cocoa_set_new_window_trigger", (PyCFunction)cocoa_set_new_window_trigger, METH_VARARGS, ""},
Expand Down
14 changes: 12 additions & 2 deletions kitty/config_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,8 +662,18 @@ def to_layout_names(raw):
zero and one, with zero being fully faded).
'''))

o('hide_window_decorations', False, long_text=_('''
Hide the window decorations (title-bar and window borders).

def hide_window_decorations(x):
if x == 'titlebar-only':
return 0b10
elif to_bool(x):
return 0b01
return 0b00


o('hide_window_decorations', 'no', option_type=hide_window_decorations, long_text=_('''
Hide the window decorations (title-bar and window borders) with :code:`yes`.
On macOS, :code:`titlebar-only` can be used to only hide the titlebar.
Whether this works and exactly what effect it has depends on the
window manager/operating system.
'''))
Expand Down
7 changes: 5 additions & 2 deletions kitty/glfw.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extern bool cocoa_make_window_resizable(void *w, bool);
extern void cocoa_focus_window(void *w);
extern void cocoa_create_global_menu(void);
extern void cocoa_hide_window_title(void *w);
extern void cocoa_hide_titlebar(void *w);
extern void cocoa_set_activation_policy(bool);
extern void cocoa_set_titlebar_color(void *w, color_type color);
extern bool cocoa_alt_option_key_pressed(unsigned long);
Expand Down Expand Up @@ -513,7 +514,7 @@ create_os_window(PyObject UNUSED *self, PyObject *args) {
// We don't use depth and stencil buffers
glfwWindowHint(GLFW_DEPTH_BITS, 0);
glfwWindowHint(GLFW_STENCIL_BITS, 0);
if (OPT(hide_window_decorations)) glfwWindowHint(GLFW_DECORATED, false);
if (OPT(hide_window_decorations) & 1) glfwWindowHint(GLFW_DECORATED, false);
#ifdef __APPLE__
cocoa_set_activation_policy(OPT(macos_hide_from_tasks));
glfwWindowHint(GLFW_COCOA_GRAPHICS_SWITCHING, true);
Expand Down Expand Up @@ -652,7 +653,9 @@ create_os_window(PyObject UNUSED *self, PyObject *args) {
glfwSetDropCallback(glfw_window, drop_callback);
#ifdef __APPLE__
if (glfwGetCocoaWindow) {
if (!(OPT(macos_show_window_title_in) & WINDOW)) {
if (OPT(hide_window_decorations) & 2) {
cocoa_hide_titlebar(glfwGetCocoaWindow(glfw_window));
} 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));
Expand Down
2 changes: 1 addition & 1 deletion kitty/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ PYWRAP1(set_options) {
#define SS(name, dest, convert) { GA(name); dest = convert(ret); Py_DECREF(ret); if (PyErr_Occurred()) return NULL; }
#define S(name, convert) SS(name, OPT(name), convert)
SS(kitty_mod, kitty_mod, PyLong_AsLong);
S(hide_window_decorations, PyObject_IsTrue);
S(hide_window_decorations, PyLong_AsUnsignedLong);
S(visual_bell_duration, parse_s_double_to_monotonic_t);
S(enable_audio_bell, PyObject_IsTrue);
S(focus_follows_mouse, PyObject_IsTrue);
Expand Down
3 changes: 2 additions & 1 deletion kitty/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ typedef struct {
color_type url_color, background, foreground, active_border_color, inactive_border_color, bell_border_color;
color_type mark1_foreground, mark1_background, mark2_foreground, mark2_background, mark3_foreground, mark3_background;
monotonic_t repaint_delay, input_delay;
bool focus_follows_mouse, hide_window_decorations;
bool focus_follows_mouse;
unsigned int hide_window_decorations;
bool macos_hide_from_tasks, macos_quit_when_last_window_closed, macos_window_resizable, macos_traditional_fullscreen;
unsigned int macos_option_as_alt;
float macos_thicken_font;
Expand Down