Add a new kitty --start-as command line flag to start kitty fullscreen/maximized/minimized.

This obsoletes the --start-in-fullscreen flag introduced in the previous release
which has been removed since it has only existed for a few days.

Fixes #935
This commit is contained in:
Kovid Goyal 2018-09-09 10:23:48 +05:30
parent ab65b9b2fb
commit e1f993938a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 34 additions and 11 deletions

View File

@ -13,6 +13,10 @@ Changelog
neighboring windows in the current layout, and move them around, similar to
window movement in vim (:iss:`916`)
- Add a new :option:`kitty --start-as` command line flag to start kitty
fullscreen/maximized/minimized. This obsoletes the ``--start-in-fullscreen``
flag introduced in the previous release (:iss:`935`)
- Linux: Ensure that the python embedded in the kitty binary build uses
UTF-8 mode to process command-line arguments (:iss:`924`)
@ -23,7 +27,7 @@ Changelog
0.12.1 [2018-09-08]
------------------------------
- Add a new :option:`kitty --start-in-fullscreen` command line flag to start
- Add a new ``--start-in-fullscreen`` command line flag to start
kitty in full screen mode (:iss:`856`)
- macOS: Fix a character that cannot be rendered in any font causing

View File

@ -19,10 +19,11 @@ from .constants import (
)
from .fast_data_types import (
ChildMonitor, background_opacity_of, change_background_opacity,
create_os_window, current_os_window, destroy_global_data,
get_clipboard_string, glfw_post_empty_event, global_font_size,
mark_os_window_for_close, os_window_font_size, patch_global_colors,
set_clipboard_string, set_in_sequence_mode, toggle_fullscreen
change_os_window_state, create_os_window, current_os_window,
destroy_global_data, get_clipboard_string, glfw_post_empty_event,
global_font_size, mark_os_window_for_close, os_window_font_size,
patch_global_colors, set_clipboard_string, set_in_sequence_mode,
toggle_fullscreen
)
from .keys import get_shortcut, shortcut_matches
from .layout import set_draw_minimal_borders
@ -103,8 +104,11 @@ class Boss:
if new_os_window_trigger is not None:
self.keymap.pop(new_os_window_trigger, None)
self.add_os_window(startup_session, os_window_id=os_window_id)
if args.start_in_fullscreen:
self.toggle_fullscreen()
if args.start_as != 'normal':
if args.start_as == 'fullscreen':
self.toggle_fullscreen()
else:
change_os_window_state(args.start_as)
def add_os_window(self, startup_session, os_window_id=None, wclass=None, wname=None, opts_for_size=None, startup_id=None):
if os_window_id is None:

View File

@ -546,9 +546,11 @@ specify this address. This option will be ignored, unless you set
option as it is read automatically from the environment.
--start-in-fullscreen
type=bool-set
Make the initial kitty window fullscreen on startup
--start-as
type=choices
default=normal
choices=normal,fullscreen,maximized,minimized
Control how the initial kitty window is created.
# Debugging options

View File

@ -693,7 +693,7 @@ static PyObject*
toggle_fullscreen(PYNOARG) {
GLFWmonitor *monitor;
OSWindow *w = current_os_window();
if (!w) Py_RETURN_NONE;
if (!w || !w->handle) Py_RETURN_NONE;
if ((monitor = glfwGetWindowMonitor(w->handle)) == NULL) {
// make fullscreen
monitor = current_monitor(w->handle);
@ -716,6 +716,18 @@ toggle_fullscreen(PYNOARG) {
}
}
static PyObject*
change_os_window_state(PyObject *self UNUSED, PyObject *args) {
char *state;
if (!PyArg_ParseTuple(args, "s", &state)) return NULL;
OSWindow *w = current_os_window();
if (!w || !w->handle) Py_RETURN_NONE;
if (strcmp(state, "maximized") == 0) glfwMaximizeWindow(w->handle);
else if (strcmp(state, "minimized") == 0) glfwIconifyWindow(w->handle);
else { PyErr_SetString(PyExc_ValueError, "Unknown window state"); return NULL; }
Py_RETURN_NONE;
}
void
ring_audio_bell(OSWindow *w) {
static double last_bell_at = -1;
@ -924,6 +936,7 @@ static PyMethodDef module_methods[] = {
METHODB(get_content_scale_for_window, METH_NOARGS),
METHODB(set_clipboard_string, METH_VARARGS),
METHODB(toggle_fullscreen, METH_NOARGS),
METHODB(change_os_window_state, METH_VARARGS),
METHODB(glfw_window_hint, METH_VARARGS),
METHODB(os_window_should_close, METH_VARARGS),
METHODB(os_window_swap_buffers, METH_VARARGS),