void process_create_window_event(Compositor *compositor, XCreateWindowEvent *event)
{
- CompositedScreen *screen = find_screen_by_root(compositor, event->parent);
- if(!screen)
- return;
+ CompositedScreen *screen;
- add_window(compositor, screen, event->window);
+ if((screen = find_screen_by_root(compositor, event->parent)))
+ add_window(compositor, screen, event->window);
}
void process_destroy_window_event(Compositor *compositor, XDestroyWindowEvent *event)
CompositedScreen *screen;
CompositedWindow *window;
- screen = find_screen_by_root(compositor, event->event);
- if(!screen)
- return;
-
- window = find_window(screen, event->window);
- if(window)
- remove_window(compositor, screen, window, 1);
+ if((screen = find_screen_by_root(compositor, event->event)))
+ if((window = find_window(screen, event->window)))
+ remove_window(compositor, screen, window, 1);
}
void process_map_event(Compositor *compositor, XMapEvent *event)
return 1;
}
-void refresh_screens(Compositor *compositor)
+void refresh_screen(Compositor *compositor, CompositedScreen *screen)
{
- unsigned i, j;
+ unsigned i;
- for(i=0; i<compositor->nscreens; ++i)
+ use_gl(compositor, screen);
+
+ glClearColor(0.5f, 0.5f, 0.5f, 0.0f);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glUseProgram(screen->program);
+ glBindVertexArray(screen->vertex_array);
+ for(i=0; i<screen->nwindows; ++i)
{
- CompositedScreen *screen = &compositor->screens[i];
- if(!screen->dirty)
+ CompositedWindow *window = &screen->windows[i];
+ if(window->map_state!=IsViewable)
continue;
- use_gl(compositor, screen);
+ glBindTexture(GL_TEXTURE_2D, window->texture);
+ compositor->glXBindTexImageEXT(compositor->display, window->glx_pixmap, GLX_FRONT_LEFT_EXT, NULL);
+ glUniform4f(screen->geometry_loc,
+ (float)window->x/screen->width, (float)(screen->height-window->y-window->height)/screen->height,
+ (float)(window->width+2*window->border)/screen->width, (float)(window->height+2*window->border)/screen->height);
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+ compositor->glXReleaseTexImageEXT(compositor->display, window->glx_pixmap, GLX_FRONT_LEFT_EXT);
+ XDamageSubtract(compositor->display, window->damage, None, None);
+ }
- glClearColor(0.5f, 0.5f, 0.5f, 0.0f);
- glClear(GL_COLOR_BUFFER_BIT);
+ glXSwapBuffers(compositor->display, screen->glx_window);
- glUseProgram(screen->program);
- glBindVertexArray(screen->vertex_array);
- for(j=0; j<screen->nwindows; ++j)
- {
- CompositedWindow *window = &screen->windows[j];
- if(window->map_state==IsViewable)
- {
- glBindTexture(GL_TEXTURE_2D, window->texture);
- compositor->glXBindTexImageEXT(compositor->display, window->glx_pixmap, GLX_FRONT_LEFT_EXT, NULL);
- glUniform4f(screen->geometry_loc, (float)window->x/screen->width, (float)(screen->height-window->y-window->height)/screen->height, (float)(window->width+2*window->border)/screen->width, (float)(window->height+2*window->border)/screen->height);
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- compositor->glXReleaseTexImageEXT(compositor->display, window->glx_pixmap, GLX_FRONT_LEFT_EXT);
- XDamageSubtract(compositor->display, window->damage, None, None);
- }
- }
- glXSwapBuffers(compositor->display, screen->glx_window);
+ screen->dirty = 0;
+}
+
+void refresh_all_screens(Compositor *compositor)
+{
+ unsigned i;
- screen->dirty = 0;
+ for(i=0; i<compositor->nscreens; ++i)
+ {
+ CompositedScreen *screen = &compositor->screens[i];
+ if(screen->dirty)
+ refresh_screen(compositor, screen);
}
compositor->dirty = 0;
while(!terminate_requested)
{
if(!process_event(&compositor))
- refresh_screens(&compositor);
+ refresh_all_screens(&compositor);
}
shutdown_compositor(&compositor);