Add a akeyboard shortcut to toggle full-screen mode
This commit is contained in:
parent
505ae90fd7
commit
ff528604dd
@ -12,6 +12,8 @@ version 0.5.0 [future]
|
|||||||
|
|
||||||
- Add an option to have window focus follow mouse
|
- Add an option to have window focus follow mouse
|
||||||
|
|
||||||
|
- Add a keyboard shortcut (ctrl+shift+f11) to toggle fullscreen mode
|
||||||
|
|
||||||
- macOS: Fix handling of option key. It now behaves just like the alt key on
|
- macOS: Fix handling of option key. It now behaves just like the alt key on
|
||||||
Linux. There is an option to make it type unicode characters instead.
|
Linux. There is an option to make it type unicode characters instead.
|
||||||
|
|
||||||
|
|||||||
@ -109,6 +109,9 @@ class Boss:
|
|||||||
for window in tab:
|
for window in tab:
|
||||||
self.close_window(window)
|
self.close_window(window)
|
||||||
|
|
||||||
|
def toggle_fullscreen(self):
|
||||||
|
self.glfw_window.toggle_fullscreen()
|
||||||
|
|
||||||
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()
|
||||||
|
|||||||
29
kitty/glfw.c
29
kitty/glfw.c
@ -36,12 +36,18 @@
|
|||||||
#define WINDOW_CALLBACK(name, fmt, ...) \
|
#define WINDOW_CALLBACK(name, fmt, ...) \
|
||||||
CALLBACK(the_window->name, "O" fmt, the_window, __VA_ARGS__);
|
CALLBACK(the_window->name, "O" fmt, the_window, __VA_ARGS__);
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int x, y, w, h;
|
||||||
|
bool is_set;
|
||||||
|
} GLFWWindowGeometry;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
|
|
||||||
GLFWwindow *window;
|
GLFWwindow *window;
|
||||||
PyObject *framebuffer_size_callback, *window_focus_callback;
|
PyObject *framebuffer_size_callback, *window_focus_callback;
|
||||||
GLFWcursor *standard_cursor, *click_cursor, *arrow_cursor;
|
GLFWcursor *standard_cursor, *click_cursor, *arrow_cursor;
|
||||||
|
GLFWWindowGeometry before_fullscreen;
|
||||||
} WindowWrapper;
|
} WindowWrapper;
|
||||||
|
|
||||||
static void update_viewport(GLFWwindow *window) {
|
static void update_viewport(GLFWwindow *window) {
|
||||||
@ -429,6 +435,28 @@ current_monitor_dpi(WindowWrapper *self) {
|
|||||||
return get_physical_dpi(m);
|
return get_physical_dpi(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PyObject*
|
||||||
|
toggle_fullscreen(WindowWrapper *self) {
|
||||||
|
GLFWmonitor *monitor;
|
||||||
|
if ((monitor = glfwGetWindowMonitor(self->window)) == NULL) {
|
||||||
|
// make fullscreen
|
||||||
|
monitor = current_monitor(self->window);
|
||||||
|
if (monitor == NULL) return NULL;
|
||||||
|
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
|
||||||
|
self->before_fullscreen.is_set = true;
|
||||||
|
glfwGetWindowSize(self->window, &self->before_fullscreen.w, &self->before_fullscreen.h);
|
||||||
|
glfwGetWindowPos(self->window, &self->before_fullscreen.x, &self->before_fullscreen.y);
|
||||||
|
glfwSetWindowMonitor(self->window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate);
|
||||||
|
Py_RETURN_TRUE;
|
||||||
|
} else {
|
||||||
|
// make windowed
|
||||||
|
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
|
||||||
|
if (self->before_fullscreen.is_set) glfwSetWindowMonitor(self->window, NULL, self->before_fullscreen.x, self->before_fullscreen.y, self->before_fullscreen.w, self->before_fullscreen.h, mode->refreshRate);
|
||||||
|
else glfwSetWindowMonitor(self->window, NULL, 0, 0, 600, 400, mode->refreshRate);
|
||||||
|
Py_RETURN_FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
request_window_attention() {
|
request_window_attention() {
|
||||||
#ifdef has_request_attention
|
#ifdef has_request_attention
|
||||||
@ -477,6 +505,7 @@ static PyMethodDef methods[] = {
|
|||||||
MND(should_close, METH_NOARGS),
|
MND(should_close, METH_NOARGS),
|
||||||
MND(get_framebuffer_size, METH_NOARGS),
|
MND(get_framebuffer_size, METH_NOARGS),
|
||||||
MND(get_window_size, METH_NOARGS),
|
MND(get_window_size, METH_NOARGS),
|
||||||
|
MND(toggle_fullscreen, METH_NOARGS),
|
||||||
MND(current_monitor_dpi, METH_NOARGS),
|
MND(current_monitor_dpi, METH_NOARGS),
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
MND(cocoa_window_id, METH_NOARGS),
|
MND(cocoa_window_id, METH_NOARGS),
|
||||||
|
|||||||
@ -282,6 +282,7 @@ map ctrl+shift+, move_tab_backward
|
|||||||
map ctrl+shift+equal increase_font_size
|
map ctrl+shift+equal increase_font_size
|
||||||
map ctrl+shift+minus decrease_font_size
|
map ctrl+shift+minus decrease_font_size
|
||||||
map ctrl+shift+backspace restore_font_size
|
map ctrl+shift+backspace restore_font_size
|
||||||
|
map ctrl+shift+f11 toggle_fullscreen
|
||||||
|
|
||||||
# Sending arbitrary text on shortcut key presses
|
# Sending arbitrary text on shortcut key presses
|
||||||
# You can tell kitty to send arbitrary (UTF-8) encoded text to
|
# You can tell kitty to send arbitrary (UTF-8) encoded text to
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user