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)
|
startup_session = create_session(opts, args)
|
||||||
self.add_os_window(startup_session, os_window_id=os_window_id)
|
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:
|
if os_window_id is None:
|
||||||
w, h = initial_window_size(self.opts) if size is None else size
|
w, h = initial_window_size(self.opts) if size is None else size
|
||||||
cls = wclass or self.args.cls or appname
|
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)
|
tm = TabManager(os_window_id, self.opts, self.args, startup_session)
|
||||||
self.os_window_map[os_window_id] = tm
|
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):
|
def new_os_window(self, *args):
|
||||||
sw = self.args_to_special_window(args) if args else None
|
sw = self.args_to_special_window(args) if args else None
|
||||||
startup_session = create_session(self.opts, special_window=sw)
|
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):
|
def add_child(self, window):
|
||||||
self.child_monitor.add_child(window.id, window.child.pid, window.child.child_fd, window.screen)
|
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
|
args.args = rest
|
||||||
opts = create_opts(args)
|
opts = create_opts(args)
|
||||||
session = create_session(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)
|
self.add_os_window(session, wclass=args.cls, wname=args.name, size=initial_window_size(opts), visible=False, startup_id=startup_id)
|
||||||
if startup_id:
|
|
||||||
ctx = init_startup_notification(os_window_id, startup_id)
|
|
||||||
show_window(os_window_id)
|
|
||||||
if startup_id:
|
|
||||||
end_startup_notification(ctx)
|
|
||||||
else:
|
else:
|
||||||
safe_print('Unknown message received from peer, ignoring')
|
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*
|
static PyObject*
|
||||||
create_os_window(PyObject UNUSED *self, PyObject *args) {
|
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;
|
char *title, *wm_class_class, *wm_class_name;
|
||||||
PyObject *load_programs = NULL;
|
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;
|
bool is_first_window = standard_cursor == NULL;
|
||||||
|
|
||||||
if (is_first_window) {
|
if (is_first_window) {
|
||||||
|
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, OPENGL_REQUIRED_VERSION_MAJOR);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, OPENGL_REQUIRED_VERSION_MAJOR);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, OPENGL_REQUIRED_VERSION_MINOR);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, OPENGL_REQUIRED_VERSION_MINOR);
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
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");
|
PyErr_SetString(PyExc_ValueError, "Too many windows");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
glfwWindowHint(GLFW_VISIBLE, visible ? GLFW_TRUE : GLFW_FALSE);
|
|
||||||
bool want_semi_transparent = (1.0 - OPT(background_opacity) > 0.1) ? true : false;
|
bool want_semi_transparent = (1.0 - OPT(background_opacity) > 0.1) ? true : false;
|
||||||
glfwWindowHint(GLFW_TRANSPARENT_FRAMEBUFFER, want_semi_transparent);
|
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);
|
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) {
|
show_window(PyObject UNUSED *self, PyObject *args) {
|
||||||
id_type os_window_id;
|
id_type os_window_id;
|
||||||
int yes = 1;
|
int yes = 1;
|
||||||
|
bool dpi_changed = false;
|
||||||
if (!PyArg_ParseTuple(args, "K|p", &os_window_id, &yes)) return NULL;
|
if (!PyArg_ParseTuple(args, "K|p", &os_window_id, &yes)) return NULL;
|
||||||
for (size_t i = 0; i < global_state.num_os_windows; i++) {
|
for (size_t i = 0; i < global_state.num_os_windows; i++) {
|
||||||
OSWindow *w = global_state.os_windows + i;
|
OSWindow *w = global_state.os_windows + i;
|
||||||
set_dpi_from_os_window(w);
|
|
||||||
if (w->id == os_window_id) {
|
if (w->id == os_window_id) {
|
||||||
if (yes) {
|
if (yes) {
|
||||||
bool first_show = !w->shown_once;
|
bool first_show = !w->shown_once;
|
||||||
glfwShowWindow(w->handle);
|
glfwShowWindow(w->handle);
|
||||||
w->shown_once = true;
|
w->shown_once = true;
|
||||||
if (first_show) {
|
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;
|
w->has_pending_resizes = true;
|
||||||
global_state.has_pending_resizes = true;
|
global_state.has_pending_resizes = true;
|
||||||
}
|
}
|
||||||
@ -388,7 +391,8 @@ show_window(PyObject UNUSED *self, PyObject *args) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Py_RETURN_NONE;
|
if (dpi_changed) Py_RETURN_TRUE;
|
||||||
|
Py_RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@ -42,7 +42,7 @@ def run_app(opts, args):
|
|||||||
set_options(opts, is_wayland, args.debug_gl)
|
set_options(opts, is_wayland, args.debug_gl)
|
||||||
load_cached_values()
|
load_cached_values()
|
||||||
w, h = initial_window_size(opts)
|
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)
|
startup_ctx = init_startup_notification(window_id)
|
||||||
show_window(window_id)
|
show_window(window_id)
|
||||||
if not is_wayland and not is_macos: # no window icons on wayland
|
if not is_wayland and not is_macos: # no window icons on wayland
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user