From 5890ca497307b7eb2670b79036dde2b13510638f Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Fri, 1 Feb 2008 00:41:11 -0500 Subject: [PATCH] compositing pre-pre-pre alpha crap --- loco/loco.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++- loco/loco.h | 2 +- openbox/openbox.c | 2 +- 3 files changed, 62 insertions(+), 3 deletions(-) diff --git a/loco/loco.c b/loco/loco.c index baed45fc..f214cb1b 100644 --- a/loco/loco.c +++ b/loco/loco.c @@ -17,11 +17,70 @@ See the COPYING file for a copy of the GNU General Public License. */ +#include +#include "obt/mainloop.h" +#include "obt/display.h" #include "obt/mainloop.h" #include +#include +#include +#include +#include +/* + you want CreateNotify, DestroyNotify, MapNotify, UnmapNotify, and + ConfigureNotify + and then xdamage or whatever + +*/ + +void composite_setup_window(Window win) +{ + XCompositeRedirectWindow(obt_display, win, CompositeRedirectAutomatic); + /*something useful = */XDamageCreate(obt_display, win, XDamageReportRawRectangles); +} -void loco_set_mainloop(ObtMainLoop *loop) +void COMPOSTER_RAWR(const XEvent *e, gpointer data) { + Window window; + if (e->type == CreateNotify) { + window = e->xmap.window; + printf("Do first time stuff\n"); + composite_setup_window(window); + } + if (e->type == obt_display_extension_damage_basep + XDamageNotify) { + } + if (e->type == ConfigureNotify) { + printf("Window moved or something\n"); + } +} + +void loco_set_mainloop(gint ob_screen, ObtMainLoop *loop) +{ + int w, h; + XVisualInfo *vi; + GLXContext cont; + int config[] = + { GLX_DEPTH_SIZE, 1, GLX_DOUBLEBUFFER, GLX_RGBA, None }; + + vi = glXChooseVisual(obt_display, DefaultScreen(obt_display), config); + cont = glXCreateContext(obt_display, vi, NULL, GL_TRUE); + if (cont == NULL) + printf("context creation failed\n"); + glXMakeCurrent(obt_display, RootWindow(obt_display, ob_screen), cont); + + w = WidthOfScreen(ScreenOfDisplay(obt_display, ob_screen)); + h = HeightOfScreen(ScreenOfDisplay(obt_display, ob_screen)); + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); +printf("Setting up an orthographic projection of %dx%d\n", w, h); + glOrtho(0, w, h, 0.0, -1.0, 100.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glClear(GL_COLOR_BUFFER_BIT); + glEnable(GL_TEXTURE_RECTANGLE_ARB); + glXSwapBuffers(obt_display, RootWindow(obt_display, ob_screen)); + obt_main_loop_x_add(loop, COMPOSTER_RAWR, NULL, NULL); } void loco_shutdown(void) diff --git a/loco/loco.h b/loco/loco.h index 5136f26a..8d645293 100644 --- a/loco/loco.h +++ b/loco/loco.h @@ -22,7 +22,7 @@ struct _ObtMainLoop; -void loco_set_mainloop(struct _ObtMainLoop *loop); +void loco_set_mainloop(gint ob_screen, struct _ObtMainLoop *loop); void loco_shutdown(void); diff --git a/openbox/openbox.c b/openbox/openbox.c index 3b53c246..041ef853 100644 --- a/openbox/openbox.c +++ b/openbox/openbox.c @@ -200,7 +200,7 @@ gint main(gint argc, gchar **argv) XC_top_left_corner); if (screen_annex()) { /* it will be ours! */ - loco_set_mainloop(ob_main_loop); + loco_set_mainloop(ob_screen, ob_main_loop); do { if (reconfigure) obt_keyboard_reload(); -- 2.34.1