Add a shortcut to toggle maximized window state
This commit is contained in:
parent
1ae32b5742
commit
2920638a3d
@ -10,6 +10,8 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
|
|||||||
- Add an option :opt:`command_on_bell` to run an arbitrary command when
|
- Add an option :opt:`command_on_bell` to run an arbitrary command when
|
||||||
a bell occurs (:iss:`1660`)
|
a bell occurs (:iss:`1660`)
|
||||||
|
|
||||||
|
- Add a shortcut to toggle maximized window state :sc:`toggle_maximized`
|
||||||
|
|
||||||
- Add support for the underscore key found in some keyboard layouts
|
- Add support for the underscore key found in some keyboard layouts
|
||||||
(:iss:`1639`)
|
(:iss:`1639`)
|
||||||
|
|
||||||
|
|||||||
@ -187,6 +187,7 @@ Increase font size :sc:`increase_font_size` (also :kbd:`⌘++`
|
|||||||
Decrease font size :sc:`decrease_font_size` (also :kbd:`⌘+-` on macOS)
|
Decrease font size :sc:`decrease_font_size` (also :kbd:`⌘+-` on macOS)
|
||||||
Restore font size :sc:`reset_font_size` (also :kbd:`⌘+0` on macOS)
|
Restore font size :sc:`reset_font_size` (also :kbd:`⌘+0` on macOS)
|
||||||
Toggle fullscreen :sc:`toggle_fullscreen` (also :kbd:`^+⌘+f` on macOS)
|
Toggle fullscreen :sc:`toggle_fullscreen` (also :kbd:`^+⌘+f` on macOS)
|
||||||
|
Toggle maximized :sc:`toggle_maximized`
|
||||||
Input unicode character :sc:`input_unicode_character`
|
Input unicode character :sc:`input_unicode_character`
|
||||||
Click URL using the keyboard :sc:`open_url`
|
Click URL using the keyboard :sc:`open_url`
|
||||||
Reset the terminal :sc:`reset_terminal`
|
Reset the terminal :sc:`reset_terminal`
|
||||||
|
|||||||
@ -24,7 +24,8 @@ from .fast_data_types import (
|
|||||||
change_os_window_state, create_os_window, current_os_window,
|
change_os_window_state, create_os_window, current_os_window,
|
||||||
destroy_global_data, get_clipboard_string, global_font_size,
|
destroy_global_data, get_clipboard_string, global_font_size,
|
||||||
mark_os_window_for_close, os_window_font_size, patch_global_colors,
|
mark_os_window_for_close, os_window_font_size, patch_global_colors,
|
||||||
set_clipboard_string, set_in_sequence_mode, toggle_fullscreen
|
set_clipboard_string, set_in_sequence_mode, toggle_fullscreen,
|
||||||
|
toggle_maximized
|
||||||
)
|
)
|
||||||
from .keys import get_shortcut, shortcut_matches
|
from .keys import get_shortcut, shortcut_matches
|
||||||
from .layout import set_draw_borders_options
|
from .layout import set_draw_borders_options
|
||||||
@ -361,6 +362,9 @@ class Boss:
|
|||||||
def toggle_fullscreen(self):
|
def toggle_fullscreen(self):
|
||||||
toggle_fullscreen()
|
toggle_fullscreen()
|
||||||
|
|
||||||
|
def toggle_maximized(self):
|
||||||
|
toggle_maximized()
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
if not getattr(self, 'io_thread_started', False):
|
if not getattr(self, 'io_thread_started', False):
|
||||||
self.child_monitor.start()
|
self.child_monitor.start()
|
||||||
|
|||||||
@ -1157,6 +1157,7 @@ Useful with git, which uses sha1 hashes to identify commits'''))
|
|||||||
|
|
||||||
g('shortcuts.misc') # {{{
|
g('shortcuts.misc') # {{{
|
||||||
k('toggle_fullscreen', 'kitty_mod+f11', 'toggle_fullscreen', _('Toggle fullscreen'))
|
k('toggle_fullscreen', 'kitty_mod+f11', 'toggle_fullscreen', _('Toggle fullscreen'))
|
||||||
|
k('toggle_maximized', 'kitty_mod+f10', 'toggle_maximized', _('Toggle maximized'))
|
||||||
k('input_unicode_character', 'kitty_mod+u', 'kitten unicode_input', _('Unicode input'))
|
k('input_unicode_character', 'kitty_mod+u', 'kitten unicode_input', _('Unicode input'))
|
||||||
k('edit_config_file', 'kitty_mod+f2', 'edit_config_file', _('Edit config file'))
|
k('edit_config_file', 'kitty_mod+f2', 'edit_config_file', _('Edit config file'))
|
||||||
k('kitty_shell', 'kitty_mod+escape', 'kitty_shell window', _('Open the kitty command shell'), long_text=_('''
|
k('kitty_shell', 'kitty_mod+escape', 'kitty_shell window', _('Open the kitty command shell'), long_text=_('''
|
||||||
|
|||||||
23
kitty/glfw.c
23
kitty/glfw.c
@ -398,6 +398,20 @@ toggle_fullscreen_for_os_window(OSWindow *w) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
toggle_maximized_for_os_window(OSWindow *w) {
|
||||||
|
bool maximized = false;
|
||||||
|
if (w && w->handle) {
|
||||||
|
if (glfwGetWindowAttrib(w->handle, GLFW_MAXIMIZED)) {
|
||||||
|
glfwRestoreWindow(w->handle);
|
||||||
|
} else {
|
||||||
|
glfwMaximizeWindow(w->handle);
|
||||||
|
maximized = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return maximized;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
static int
|
static int
|
||||||
@ -843,6 +857,14 @@ toggle_fullscreen(PYNOARG) {
|
|||||||
Py_RETURN_FALSE;
|
Py_RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject*
|
||||||
|
toggle_maximized(PYNOARG) {
|
||||||
|
OSWindow *w = current_os_window();
|
||||||
|
if (!w) Py_RETURN_NONE;
|
||||||
|
if (toggle_maximized_for_os_window(w)) { Py_RETURN_TRUE; }
|
||||||
|
Py_RETURN_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
change_os_window_state(PyObject *self UNUSED, PyObject *args) {
|
change_os_window_state(PyObject *self UNUSED, PyObject *args) {
|
||||||
char *state;
|
char *state;
|
||||||
@ -1112,6 +1134,7 @@ static PyMethodDef module_methods[] = {
|
|||||||
METHODB(ring_bell, METH_NOARGS),
|
METHODB(ring_bell, METH_NOARGS),
|
||||||
METHODB(set_clipboard_string, METH_VARARGS),
|
METHODB(set_clipboard_string, METH_VARARGS),
|
||||||
METHODB(toggle_fullscreen, METH_NOARGS),
|
METHODB(toggle_fullscreen, METH_NOARGS),
|
||||||
|
METHODB(toggle_maximized, METH_NOARGS),
|
||||||
METHODB(change_os_window_state, METH_VARARGS),
|
METHODB(change_os_window_state, METH_VARARGS),
|
||||||
METHODB(glfw_window_hint, METH_VARARGS),
|
METHODB(glfw_window_hint, METH_VARARGS),
|
||||||
METHODB(get_primary_selection, METH_NOARGS),
|
METHODB(get_primary_selection, METH_NOARGS),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user