From: Dana Jansens Date: Tue, 27 May 2003 04:32:53 +0000 (+0000) Subject: DRAWS!! X-Git-Tag: gl2~85 X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=88c960b56b6d126c086ee6b930dfe5902c9aa9c6;p=dana%2Fopenbox.git DRAWS!! --- diff --git a/openbox/event.c b/openbox/event.c index 19beeae6..ff3a2f83 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -427,6 +427,13 @@ static void event_process(XEvent *e) Menu *menu = NULL; ObWindow *obwin = NULL; + /* expose events aren't related to any internal stuff */ + if (e->type == Expose) { + if (ob_state != State_Exiting) + RrExpose(ob_render_inst, &e->xexpose); + return; + } + window = event_get_window(e); if ((obwin = g_hash_table_lookup(window_map, &window))) { switch (obwin->type) { diff --git a/openbox/menu.c b/openbox/menu.c index 41b0d749..83546cca 100644 --- a/openbox/menu.c +++ b/openbox/menu.c @@ -8,11 +8,11 @@ GHashTable *menu_hash = NULL; -#define FRAME_EVENTMASK (ButtonPressMask |ButtonMotionMask | EnterWindowMask | \ - LeaveWindowMask) -#define TITLE_EVENTMASK (ButtonPressMask | ButtonMotionMask) +#define FRAME_EVENTMASK (ButtonPressMask |ButtonMotionMask | EnterWindowMask |\ + LeaveWindowMask | ExposureMask) +#define TITLE_EVENTMASK (ButtonPressMask | ButtonMotionMask | ExposureMask) #define ENTRY_EVENTMASK (EnterWindowMask | LeaveWindowMask | \ - ButtonPressMask | ButtonReleaseMask) + ButtonPressMask | ButtonReleaseMask | ExposureMask) void menu_control_show(Menu *self, int x, int y, Client *client); diff --git a/openbox/popup.c b/openbox/popup.c index 22b1c230..ee69a519 100644 --- a/openbox/popup.c +++ b/openbox/popup.c @@ -30,6 +30,7 @@ Popup *popup_new(gboolean hasicon) { XSetWindowAttributes attrib; Popup *self; + struct RrColor pri, sec; self = g_new(Popup, 1); self->obwin.type = Window_Internal; @@ -40,10 +41,11 @@ Popup *popup_new(gboolean hasicon) stacking_raise(INTERNAL_AS_WINDOW(self)); attrib.override_redirect = True; + attrib.event_mask = ExposureMask; self->bg = XCreateWindow(ob_display, ob_root, 0, 0, 1, 1, 0, RrInstanceDepth(ob_render_inst), InputOutput, RrInstanceVisual(ob_render_inst), - CWOverrideRedirect, &attrib); + CWEventMask|CWOverrideRedirect, &attrib); self->s_bg = RrSurfaceNew(ob_render_inst, RR_SURFACE_PLANAR, self->bg, 0); self->s_text = RrSurfaceNewChild(RR_SURFACE_PLANAR, self->s_bg, 1); self->text = RrSurfaceWindow(self->s_text); @@ -55,6 +57,18 @@ Popup *popup_new(gboolean hasicon) self->icon = None; } + RrColorSet(&pri, 1, 0, 0, 0); + RrColorSet(&pri, 0, 1, 0, 0); + RrPlanarSet(self->s_bg, RR_PLANAR_VERTICAL, &pri, &sec); + RrColorSet(&pri, 0, 0.5, 0, 1); + RrColorSet(&pri, 0.5, 0, 0.5, 1); + RrPlanarSet(self->s_text, RR_PLANAR_HORIZONTAL, &pri, &sec); + if (self->s_icon) { + RrColorSet(&pri, 0, 0, 1, 1); + RrColorSet(&pri, 0.5, 0.5, 0, 1); + RrPlanarSet(self->s_icon, RR_PLANAR_HORIZONTAL, &pri, &sec); + } + /* XXX COPY THE APPEARANCES FROM THE THEME...... LIKE THIS SORTA! self->a_text = appearance_copy(theme_app_hilite_label); */ @@ -188,12 +202,16 @@ void popup_show(Popup *self, char *text, Icon *icon) if (!RrSurfaceVisible(self->s_bg)) { RrSurfaceShow(self->s_bg); stacking_raise(INTERNAL_AS_WINDOW(self)); + } else { + /* XXX only need to paint top level surface in the future */ + RrPaint(self->s_bg); + RrPaint(self->s_text); + if (self->s_icon) + RrPaint(self->s_icon); } } void popup_hide(Popup *self) { - if (RrSurfaceVisible(self->s_bg)) { - RrSurfaceHide(self->s_bg); - } + RrSurfaceHide(self->s_bg); } diff --git a/render2/Makefile.am b/render2/Makefile.am index 36a3c081..6be6282c 100644 --- a/render2/Makefile.am +++ b/render2/Makefile.am @@ -8,7 +8,7 @@ CPPFLAGS=$(FC_CFLAGS) $(GLIB_CFLAGS) $(GL_CFLAGS) @CPPFLAGS@ \ -DTHEMEDIR=\"$(themedir)\" INCLUDES=-I.. -LIBS=$(GL_LIBS) @LIBS@ +LIBS=$(GL_LIBS) $(GLIB_LIBS) @LIBS@ noinst_PROGRAMS=rendertest rendertest_LDFLAGS=-lobrender2 -L. diff --git a/render2/instance.c b/render2/instance.c index f48593c3..b2abb3dd 100644 --- a/render2/instance.c +++ b/render2/instance.c @@ -1,4 +1,5 @@ #include "instance.h" +#include "surface.h" #include "debug.h" #include "glft/glft.h" #include @@ -96,6 +97,7 @@ struct RrInstance *RrInstanceNew(Display *display, int screen) RrVisual(inst), AllocNone); inst->glx_context = glXCreateContext(display, &vilist[best], NULL, True); + inst->surface_map = g_hash_table_new(g_int_hash, g_int_equal); assert(inst->glx_context); @@ -129,3 +131,18 @@ Visual *RrInstanceVisual(struct RrInstance *inst) { return inst->visinfo.visual; } + +void RrInstaceAddSurface(struct RrSurface *sur) +{ + g_hash_table_replace(RrSurfaceInstance(sur)->surface_map, &sur->win, sur); +} + +void RrInstaceRemoveSurface(struct RrSurface *sur) +{ + g_hash_table_remove(RrSurfaceInstance(sur)->surface_map, &sur->win); +} + +struct RrSurface *RrInstaceLookupSurface(struct RrInstance *inst, Window win) +{ + return g_hash_table_lookup(inst->surface_map, &win); +} diff --git a/render2/instance.h b/render2/instance.h index 94b194ab..c41a96af 100644 --- a/render2/instance.h +++ b/render2/instance.h @@ -5,12 +5,16 @@ #include #include +#include + struct RrInstance { Display *display; int screen; XVisualInfo visinfo; Colormap cmap; GLXContext glx_context; + + GHashTable *surface_map; }; #define RrDisplay(i) ((i)->display) @@ -24,4 +28,10 @@ struct RrInstance { #define RrColormap(i) ((i)->cmap) #define RrContext(i) ((i)->glx_context) +struct RrSurface; + +void RrInstaceAddSurface(struct RrSurface *sur); +void RrInstaceRemoveSurface(struct RrSurface *sur); +struct RrSurface *RrInstaceLookupSurface(struct RrInstance *inst, Window win); + #endif diff --git a/render2/paint.c b/render2/paint.c index acbe8930..426c136d 100644 --- a/render2/paint.c +++ b/render2/paint.c @@ -5,6 +5,17 @@ #include #include +void RrExpose(struct RrInstance *inst, XExposeEvent *e) +{ + struct RrSurface *sur; + + if ((sur = RrInstaceLookupSurface(inst, e->window))) { + RrPaintArea(sur, e->x, e->y, e->width, e->height); + } else { + RrDebug("Unable to find surface for window 0x%lx\n", e->window); + } +} + /*! Paints the surface, and all its children */ void RrPaint(struct RrSurface *sur) { diff --git a/render2/render.h b/render2/render.h index 5ced991b..719427f3 100644 --- a/render2/render.h +++ b/render2/render.h @@ -196,5 +196,6 @@ void RrPaintArea(struct RrSurface *sur, int y, int w, int h); +void RrExpose(struct RrInstance *inst, XExposeEvent *e); #endif diff --git a/render2/surface.c b/render2/surface.c index 3bad5ced..263af69a 100644 --- a/render2/surface.c +++ b/render2/surface.c @@ -28,9 +28,13 @@ static struct RrSurface *surface_new(enum RrSurfaceType type, static Window create_window(struct RrInstance *inst, Window parent) { - Window win = XCreateWindow(RrDisplay(inst), parent, 0, 0, 1, 1, 0, - RrDepth(inst), InputOutput, RrVisual(inst), - 0, NULL); + XSetWindowAttributes attrib; + Window win; + + attrib.event_mask = ExposureMask; + win = XCreateWindow(RrDisplay(inst), parent, 0, 0, 1, 1, 0, + RrDepth(inst), InputOutput, RrVisual(inst), + CWEventMask, &attrib); return win; } @@ -59,6 +63,8 @@ struct RrSurface *RrSurfaceNew(struct RrInstance *inst, sur->win = win; sur->parent = NULL; sur->visible = 0; + + RrInstaceAddSurface(sur); return sur; } @@ -77,6 +83,8 @@ struct RrSurface *RrSurfaceNewChild(enum RrSurfaceType type, sur->win = create_window(sur->inst, parent->win); sur->parent = parent; RrSurfaceShow(sur); + + RrInstaceAddSurface(sur); return sur; } @@ -115,6 +123,8 @@ struct RrSurface *RrSurfaceCopy(struct RrInstance *inst, sur->win = win; sur->parent = NULL; sur->visible = 0; + + RrInstaceAddSurface(sur); return sur; } @@ -132,6 +142,8 @@ struct RrSurface *RrSurfaceCopyChild(struct RrSurface *orig, sur->win = create_window(sur->inst, parent->win); sur->parent = parent; RrSurfaceShow(sur); + + RrInstaceAddSurface(sur); return sur; } @@ -139,6 +151,7 @@ void RrSurfaceFree(struct RrSurface *sur) { int i; if (sur) { + RrInstaceRemoveSurface(sur); for (i = 0; i < sur->ntextures; ++i) RrTextureFreeContents(&sur->texture[i]); if (sur->ntextures) @@ -198,6 +211,7 @@ void RrSurfaceMinSize(struct RrSurface *sur, int *w, int *h) break; } + minw = minh = 0; for (i = 0; i < sur->ntextures; ++i) { switch (sur->texture[i].type) { case RR_TEXTURE_NONE: