Ask the window manager to mark the window as requiring attention when a bell occurs
Requires glfw 3.3. Fixes #51
This commit is contained in:
parent
2630668fa5
commit
1b336bf864
@ -394,6 +394,12 @@ class Boss(Thread):
|
|||||||
def change_mouse_cursor(self, click=False):
|
def change_mouse_cursor(self, click=False):
|
||||||
self.glfw_window.set_click_cursor(click)
|
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):
|
def start_cursor_blink(self):
|
||||||
self.cursor_blinking = True
|
self.cursor_blinking = True
|
||||||
if self.opts.cursor_stop_blinking_after > 0:
|
if self.opts.cursor_stop_blinking_after > 0:
|
||||||
|
|||||||
11
kitty/glfw.c
11
kitty/glfw.c
@ -318,6 +318,14 @@ get_window_size(Window *self) {
|
|||||||
return Py_BuildValue("ii", w, h);
|
return Py_BuildValue("ii", w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef glfwRequestWindowAttention
|
||||||
|
static PyObject*
|
||||||
|
request_window_attention(Window *self) {
|
||||||
|
glfwRequestWindowAttention(self->window);
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Boilerplate {{{
|
// Boilerplate {{{
|
||||||
#define MND(name, args) {#name, (PyCFunction)name, args, ""}
|
#define MND(name, args) {#name, (PyCFunction)name, args, ""}
|
||||||
@ -329,6 +337,9 @@ static PyMethodDef methods[] = {
|
|||||||
MND(should_close, METH_NOARGS),
|
MND(should_close, METH_NOARGS),
|
||||||
MND(get_framebuffer_size, METH_NOARGS),
|
MND(get_framebuffer_size, METH_NOARGS),
|
||||||
MND(get_window_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_should_close, METH_VARARGS),
|
||||||
MND(set_input_mode, METH_VARARGS),
|
MND(set_input_mode, METH_VARARGS),
|
||||||
MND(is_key_pressed, METH_VARARGS),
|
MND(is_key_pressed, METH_VARARGS),
|
||||||
|
|||||||
@ -118,7 +118,9 @@ class Window:
|
|||||||
pass # failure to beep is not critical
|
pass # failure to beep is not critical
|
||||||
if self.opts.visual_bell_duration > 0:
|
if self.opts.visual_bell_duration > 0:
|
||||||
self.start_visual_bell_at = monotonic()
|
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):
|
def use_utf8(self, on):
|
||||||
self.child.set_iutf8(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)
|
x, y = max(0, x - self.geometry.left), max(0, y - self.geometry.top)
|
||||||
self.last_mouse_cursor_pos = x, y
|
self.last_mouse_cursor_pos = x, y
|
||||||
tm = get_boss()
|
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:
|
if send_event:
|
||||||
x, y = self.char_grid.cell_for_pos(x, y)
|
x, y = self.char_grid.cell_for_pos(x, y)
|
||||||
if x is not None:
|
if x is not None:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user