diff --git a/kitty/boss.py b/kitty/boss.py index ec7494137..2fb6248a8 100644 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -220,12 +220,6 @@ class Boss: old_focus.focus_changed(False) tab.active_window.focus_changed(True) - def request_attention(self): - try: - self.glfw_window.request_window_attention() - except AttributeError: - pass # needs glfw 3.3 - def send_fake_scroll(self, window_idx, amt, upwards): tab = self.active_tab w = tab.windows[window_idx] diff --git a/kitty/data-types.h b/kitty/data-types.h index 635d3089f..3651814f1 100644 --- a/kitty/data-types.h +++ b/kitty/data-types.h @@ -320,3 +320,4 @@ void scroll_event(double, double); void set_special_key_combo(int glfw_key, int mods); void on_text_input(unsigned int codepoint, int mods); void on_key_input(int key, int scancode, int action, int mods); +void request_window_attention(); diff --git a/kitty/glfw.c b/kitty/glfw.c index b3e1183b6..9e356fffe 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -16,6 +16,10 @@ #error "glfw >= 3.2 required" #endif +#if GLFW_VERSION_MAJOR > 4 || (GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR > 2) +#define has_request_attention +#endif + #if GLFW_KEY_LAST >= MAX_KEY_COUNT #error "glfw has too many keys, you should increase MAX_KEY_COUNT" #endif @@ -401,13 +405,13 @@ current_monitor_dpi(WindowWrapper *self) { return get_physical_dpi(m); } -#ifdef glfwRequestWindowAttention -static PyObject* -request_window_attention(WindowWrapper *self) { - glfwRequestWindowAttention(self->window); - Py_RETURN_NONE; -} +void +request_window_attention() { +#ifdef has_request_attention + glfwRequestWindowAttention(the->window); #endif + glfwPostEmptyEvent(); +} #ifdef __APPLE__ static PyObject* @@ -429,9 +433,6 @@ static PyMethodDef methods[] = { MND(get_framebuffer_size, METH_NOARGS), MND(get_window_size, METH_NOARGS), MND(current_monitor_dpi, METH_NOARGS), -#ifdef glfwRequestWindowAttention - MND(request_window_attention, METH_NOARGS), -#endif #ifdef __APPLE__ MND(cocoa_window_id, METH_NOARGS), #endif diff --git a/kitty/screen.c b/kitty/screen.c index 64cfc0257..1d9c34bb0 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -951,11 +951,11 @@ screen_bell(Screen UNUSED *self) { } close(fd); } + request_window_attention(); } if (global_state.opts.visual_bell_duration > 0) { self->start_visual_bell_at = monotonic(); } - CALLBACK("bell", NULL); } static inline void diff --git a/kitty/window.py b/kitty/window.py index f1d8ef8cc..0af8eaacf 100644 --- a/kitty/window.py +++ b/kitty/window.py @@ -139,11 +139,6 @@ class Window: print('Failed to write to child %d as it does not exist' % self.id, file=sys.stderr) # screen callbacks {{{ - def bell(self): - boss = get_boss() - boss.request_attention() - glfw_post_empty_event() - def use_utf8(self, on): get_boss().child_monitor.set_iutf8(self.window_id, on)