diff --git a/kitty/boss.py b/kitty/boss.py index 40b6caf0e..76fbe7b13 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -394,6 +394,12 @@ class Boss(Thread): def change_mouse_cursor(self, click=False): self.glfw_window.set_click_cursor(click) + def request_attention(self): + try: + self.glfw_window.request_window_attention() + except AttributeError: + pass # needs glfw 3.3 + def start_cursor_blink(self): self.cursor_blinking = True if self.opts.cursor_stop_blinking_after > 0: diff --git a/kitty/glfw.c b/kitty/glfw.c index 457a7084c..8285d5d32 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -318,6 +318,14 @@ get_window_size(Window *self) { return Py_BuildValue("ii", w, h); } +#ifdef glfwRequestWindowAttention +static PyObject* +request_window_attention(Window *self) { + glfwRequestWindowAttention(self->window); + Py_RETURN_NONE; +} +#endif + // Boilerplate {{{ #define MND(name, args) {#name, (PyCFunction)name, args, ""} @@ -329,6 +337,9 @@ static PyMethodDef methods[] = { MND(should_close, METH_NOARGS), MND(get_framebuffer_size, METH_NOARGS), MND(get_window_size, METH_NOARGS), +#ifdef glfwRequestWindowAttention + MND(request_window_attention, METH_NOARGS), +#endif MND(set_should_close, METH_VARARGS), MND(set_input_mode, METH_VARARGS), MND(is_key_pressed, METH_VARARGS), diff --git a/kitty/window.py b/kitty/window.py index 1b6f2b9a1..4b110e267 100644 --- a/kitty/window.py +++ b/kitty/window.py @@ -118,7 +118,9 @@ class Window: pass # failure to beep is not critical if self.opts.visual_bell_duration > 0: self.start_visual_bell_at = monotonic() - glfw_post_empty_event() + tm = get_boss() + tm.queue_ui_action(tm.request_attention) + glfw_post_empty_event() def use_utf8(self, on): self.child.set_iutf8(on) @@ -227,7 +229,7 @@ class Window: x, y = max(0, x - self.geometry.left), max(0, y - self.geometry.top) self.last_mouse_cursor_pos = x, y tm = get_boss() - tm.queue_ui_action(get_boss().change_mouse_cursor, self.char_grid.has_url_at(x, y)) + tm.queue_ui_action(tm.change_mouse_cursor, self.char_grid.has_url_at(x, y)) if send_event: x, y = self.char_grid.cell_for_pos(x, y) if x is not None: