Fix new window being created with different DPI not changing global DPI
This commit is contained in:
parent
5c882f3290
commit
448ffe01c3
@ -78,19 +78,26 @@ class Boss:
|
||||
startup_session = create_session(opts, args)
|
||||
self.add_os_window(startup_session, os_window_id=os_window_id)
|
||||
|
||||
def add_os_window(self, startup_session, os_window_id=None, wclass=None, wname=None, size=None, visible=True):
|
||||
def add_os_window(self, startup_session, os_window_id=None, wclass=None, wname=None, size=None, startup_id=None):
|
||||
dpi_changed = False
|
||||
if os_window_id is None:
|
||||
w, h = initial_window_size(self.opts) if size is None else size
|
||||
cls = wclass or self.args.cls or appname
|
||||
os_window_id = create_os_window(w, h, appname, wname or self.args.name or cls, cls, visible)
|
||||
os_window_id = create_os_window(w, h, appname, wname or self.args.name or cls, cls)
|
||||
if startup_id:
|
||||
ctx = init_startup_notification(os_window_id, startup_id)
|
||||
dpi_changed = show_window(os_window_id)
|
||||
if startup_id:
|
||||
end_startup_notification(ctx)
|
||||
tm = TabManager(os_window_id, self.opts, self.args, startup_session)
|
||||
self.os_window_map[os_window_id] = tm
|
||||
return os_window_id
|
||||
if dpi_changed:
|
||||
self.on_dpi_change(os_window_id)
|
||||
|
||||
def new_os_window(self, *args):
|
||||
sw = self.args_to_special_window(args) if args else None
|
||||
startup_session = create_session(self.opts, special_window=sw)
|
||||
return self.add_os_window(startup_session)
|
||||
self.add_os_window(startup_session)
|
||||
|
||||
def add_child(self, window):
|
||||
self.child_monitor.add_child(window.id, window.child.pid, window.child.child_fd, window.screen)
|
||||
@ -106,12 +113,7 @@ class Boss:
|
||||
args.args = rest
|
||||
opts = create_opts(args)
|
||||
session = create_session(opts, args)
|
||||
os_window_id = self.add_os_window(session, wclass=args.cls, wname=args.name, size=initial_window_size(opts), visible=False)
|
||||
if startup_id:
|
||||
ctx = init_startup_notification(os_window_id, startup_id)
|
||||
show_window(os_window_id)
|
||||
if startup_id:
|
||||
end_startup_notification(ctx)
|
||||
self.add_os_window(session, wclass=args.cls, wname=args.name, size=initial_window_size(opts), visible=False, startup_id=startup_id)
|
||||
else:
|
||||
safe_print('Unknown message received from peer, ignoring')
|
||||
|
||||
|
||||
14
kitty/glfw.c
14
kitty/glfw.c
@ -267,13 +267,14 @@ set_dpi_from_os_window(OSWindow *w) {
|
||||
|
||||
static PyObject*
|
||||
create_os_window(PyObject UNUSED *self, PyObject *args) {
|
||||
int width, height, visible = 1, swap_interval = 0, x = -1, y = -1;
|
||||
int width, height, swap_interval = 0, x = -1, y = -1;
|
||||
char *title, *wm_class_class, *wm_class_name;
|
||||
PyObject *load_programs = NULL;
|
||||
if (!PyArg_ParseTuple(args, "iisss|pOiii", &width, &height, &title, &wm_class_name, &wm_class_class, &visible, &load_programs, &swap_interval, &x, &y)) return NULL;
|
||||
if (!PyArg_ParseTuple(args, "iisss|Oiii", &width, &height, &title, &wm_class_name, &wm_class_class, &load_programs, &swap_interval, &x, &y)) return NULL;
|
||||
bool is_first_window = standard_cursor == NULL;
|
||||
|
||||
if (is_first_window) {
|
||||
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, OPENGL_REQUIRED_VERSION_MAJOR);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, OPENGL_REQUIRED_VERSION_MINOR);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
@ -303,7 +304,6 @@ create_os_window(PyObject UNUSED *self, PyObject *args) {
|
||||
PyErr_SetString(PyExc_ValueError, "Too many windows");
|
||||
return NULL;
|
||||
}
|
||||
glfwWindowHint(GLFW_VISIBLE, visible ? GLFW_TRUE : GLFW_FALSE);
|
||||
bool want_semi_transparent = (1.0 - OPT(background_opacity) > 0.1) ? true : false;
|
||||
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, want_semi_transparent);
|
||||
GLFWwindow *glfw_window = glfwCreateWindow(width, height, title, NULL, global_state.num_os_windows ? global_state.os_windows[0].handle : NULL);
|
||||
@ -371,16 +371,19 @@ static PyObject*
|
||||
show_window(PyObject UNUSED *self, PyObject *args) {
|
||||
id_type os_window_id;
|
||||
int yes = 1;
|
||||
bool dpi_changed = false;
|
||||
if (!PyArg_ParseTuple(args, "K|p", &os_window_id, &yes)) return NULL;
|
||||
for (size_t i = 0; i < global_state.num_os_windows; i++) {
|
||||
OSWindow *w = global_state.os_windows + i;
|
||||
set_dpi_from_os_window(w);
|
||||
if (w->id == os_window_id) {
|
||||
if (yes) {
|
||||
bool first_show = !w->shown_once;
|
||||
glfwShowWindow(w->handle);
|
||||
w->shown_once = true;
|
||||
if (first_show) {
|
||||
double before_x = global_state.logical_dpi_x, before_y = global_state.logical_dpi_y;
|
||||
set_dpi_from_os_window(w);
|
||||
dpi_changed = before_x != global_state.logical_dpi_x || before_y != global_state.logical_dpi_y;
|
||||
w->has_pending_resizes = true;
|
||||
global_state.has_pending_resizes = true;
|
||||
}
|
||||
@ -388,7 +391,8 @@ show_window(PyObject UNUSED *self, PyObject *args) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
if (dpi_changed) Py_RETURN_TRUE;
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@ -42,7 +42,7 @@ def run_app(opts, args):
|
||||
set_options(opts, is_wayland, args.debug_gl)
|
||||
load_cached_values()
|
||||
w, h = initial_window_size(opts)
|
||||
window_id = create_os_window(w, h, appname, args.name or args.cls or appname, args.cls or appname, False, load_all_shaders)
|
||||
window_id = create_os_window(w, h, appname, args.name or args.cls or appname, args.cls or appname, load_all_shaders)
|
||||
startup_ctx = init_startup_notification(window_id)
|
||||
show_window(window_id)
|
||||
if not is_wayland and not is_macos: # no window icons on wayland
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user