Redraw windows when the window manager tells us they have been damaged

Needed on systems with non-compositing window managers. Fix #317
This commit is contained in:
Kovid Goyal 2018-02-10 06:49:40 +05:30
parent e119ed0daa
commit b1b76ca250
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 11 additions and 1 deletions

View File

@ -623,6 +623,7 @@ render_os_window(OSWindow *os_window, double now, unsigned int active_window_id)
br->is_dirty = false;
os_window->last_active_tab = os_window->active_tab; os_window->last_num_tabs = os_window->num_tabs; os_window->last_active_window_id = active_window_id;
os_window->focused_at_last_render = os_window->is_focused;
os_window->is_damaged = false;
#undef WD
#undef TD
}
@ -638,7 +639,7 @@ render(double now) {
for (size_t i = 0; i < global_state.num_os_windows; i++) {
OSWindow *w = global_state.os_windows + i;
if (!w->num_tabs || !should_os_window_be_rendered(w)) continue;
bool needs_render = w->is_focused;
bool needs_render = w->is_focused || w->is_damaged;
make_os_window_context_current(w);
if (w->viewport_size_dirty) {
w->clear_count = 0;

View File

@ -85,6 +85,13 @@ framebuffer_size_callback(GLFWwindow *w, int width, int height) {
global_state.callback_os_window = NULL;
}
static void
refresh_callback(GLFWwindow *w) {
if (!set_callback_window(w)) return;
global_state.callback_os_window->is_damaged = true;
global_state.callback_os_window = NULL;
}
static void
char_mods_callback(GLFWwindow *w, unsigned int codepoint, int mods) {
if (!set_callback_window(w)) return;
@ -363,6 +370,7 @@ create_os_window(PyObject UNUSED *self, PyObject *args) {
glfwSetCursor(glfw_window, standard_cursor);
update_os_window_viewport(w, false);
glfwSetFramebufferSizeCallback(glfw_window, framebuffer_size_callback);
glfwSetWindowRefreshCallback(glfw_window, refresh_callback);
glfwSetCharModsCallback(glfw_window, char_mods_callback);
glfwSetMouseButtonCallback(glfw_window, mouse_button_callback);
glfwSetScrollCallback(glfw_window, scroll_callback);

View File

@ -111,6 +111,7 @@ typedef struct {
bool has_pending_resizes;
bool is_semi_transparent;
bool shown_once;
bool is_damaged;
uint32_t offscreen_texture_id;
unsigned int clear_count;
} OSWindow;