A new remote control command to resize OS Windows

This commit is contained in:
Kovid Goyal
2021-07-25 22:57:00 +05:30
parent aa339a8a9f
commit 419cf78984
7 changed files with 183 additions and 13 deletions

View File

@@ -12,6 +12,34 @@ is_macos = 'darwin' in _plat
class TestGLFW(BaseTest):
def test_os_window_size_calculation(self):
from kitty.utils import get_new_os_window_size
def t(w, h, width=0, height=0, unit='cells', incremental=False):
self.ae((w, h), get_new_os_window_size(metrics, width, height, unit, incremental, has_window_scaling))
with self.subTest(has_window_scaling=False):
has_window_scaling = False
metrics = {
'width': 200, 'height': 100,
'framebuffer_width': 200, 'framebuffer_height': 100,
'xscale': 2.0, 'yscale': 2.0, 'xdpi': 192.0, 'ydpi': 192.0,
'cell_width': 8, 'cell_height': 16
}
t(80 * metrics['cell_width'], 100, 80)
t(80 * metrics['cell_width'] + metrics['width'], 100, 80, incremental=True)
t(1217, 100, 1217, unit='pixels')
t(1217 + metrics['width'], 100, 1217, unit='pixels', incremental=True)
with self.subTest(has_window_scaling=True):
has_window_scaling = True
metrics['framebuffer_width'] = metrics['width'] * 2
metrics['framebuffer_height'] = metrics['height'] * 2
t(80 * metrics['cell_width'] / metrics['xscale'], 100, 80)
t(80 * metrics['cell_width'] / metrics['xscale'] + metrics['width'], 100, 80, incremental=True)
t(1217, 100, 1217, unit='pixels')
t(1217 + metrics['width'], 100, 1217, unit='pixels', incremental=True)
@unittest.skipIf(is_macos, 'Skipping test on macOS because glfw-cocoa.so is not built with backend_utils')
def test_utf_8_strndup(self):
import ctypes